Skip to content

Commit

Permalink
Update to v0.3.2 (#29)
Browse files Browse the repository at this point in the history
* upgrade: update from cryptogarageinc/v0.3.26

* fix: header
  • Loading branch information
ko-matsu authored Sep 26, 2021
1 parent 94246ef commit e2a82a8
Show file tree
Hide file tree
Showing 51 changed files with 3,704 additions and 263 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/check_pre-merge_develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,12 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-18.04, ubuntu-16.04]
os: [ubuntu-20.04, ubuntu-18.04]
shared: [on, off]
elements: [on, off]
exclude:
- os: ubuntu-18.04
elements: off
- os: ubuntu-16.04
elements: off

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/check_pre-merge_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,12 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-18.04, ubuntu-16.04]
os: [ubuntu-20.04, ubuntu-18.04]
shared: [on, off]
elements: [on, off]
exclude:
- os: ubuntu-18.04
elements: off
- os: ubuntu-16.04
elements: off

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_pre-merge_sprint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-18.04, ubuntu-16.04]
os: [ubuntu-20.04, ubuntu-18.04]
shared: [on]
elements: [on]

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/create_release-and-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ jobs:
strategy:
fail-fast: false
matrix:
# os: [ubuntu-20.04, ubuntu-18.04, ubuntu-16.04]
os_ver: [20, 18, 16]
# os: [ubuntu-20.04, ubuntu-18.04]
os_ver: [20, 18]
bin: [gcc, gcc-static]
include:
- bin: gcc
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,14 @@ cmake version is 3.15 or higher: `cmake --install build`
sudo ./tools/cleanup_install_files.sh

(download)
wget https://github.com/p2pderivatives/cfd/releases/download/v0.3.0/cfd-v0.3.0-ubuntu2004-gcc-x86_64.zip
wget https://github.com/p2pderivatives/cfd/releases/download/v0.3.2/cfd-v0.3.2-ubuntu2004-gcc-x86_64.zip

(unzip)
sudo unzip -q cfd-v0.3.0-ubuntu2004-gcc-x86_64.zip -d /
sudo unzip -q cfd-v0.3.2-ubuntu2004-gcc-x86_64.zip -d /
```

- Windows
1. get releases asset. (ex. https://github.com/p2pderivatives/cfd/releases/download/v0.3.0/cfd-v0.3.0-win-vs2019-x86_64.zip )
1. get releases asset. (ex. https://github.com/p2pderivatives/cfd/releases/download/v0.3.2/cfd-v0.3.2-win-vs2019-x86_64.zip )
2. Expand to PATH

### uninstall
Expand Down
6 changes: 6 additions & 0 deletions cmake/Cpp11Setting.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -ggdb")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -ggdb")
endif()
else()
if(MSVC)
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os")
endif()
endif()

if(${USE_EMSCRIPTEN})
Expand Down
2 changes: 1 addition & 1 deletion external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ if(CFDCORE_TARGET_VERSION)
set(CFDCORE_TARGET_TAG ${CFDCORE_TARGET_VERSION})
message(STATUS "[external project local] cfd-core target=${CFDCORE_TARGET_VERSION}")
else()
set(CFDCORE_TARGET_TAG v0.3.1)
set(CFDCORE_TARGET_TAG v0.3.2)
endif()
if(CFDCORE_TARGET_URL)
set(CFDCORE_TARGET_REP ${CFDCORE_TARGET_URL})
Expand Down
2 changes: 2 additions & 0 deletions include/cfd/cfd_address.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ using cfd::core::NetType;
using cfd::core::Pubkey;
using cfd::core::SchnorrPubkey;
using cfd::core::Script;
using cfd::core::TapBranch;
using cfd::core::TaprootScriptTree;
using cfd::core::WitnessVersion;

Expand All @@ -50,6 +51,7 @@ struct DescriptorScriptData {
DescriptorKeyType key_type; //!< key type
std::string key; //!< key string
uint32_t multisig_req_sig_num; //!< multisig num of require signatures
TapBranch branch; //!< taproot tapbranch
TaprootScriptTree tree; //!< taproot script tree
};

Expand Down
17 changes: 17 additions & 0 deletions include/cfd/cfd_elements_address.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "cfd/cfd_address.h"
#include "cfd/cfd_common.h"
#include "cfdcore/cfdcore_address.h"
#include "cfdcore/cfdcore_descriptor.h"
#include "cfdcore/cfdcore_elements_address.h"
#include "cfdcore/cfdcore_key.h"
#include "cfdcore/cfdcore_script.h"
Expand All @@ -24,6 +25,7 @@ using cfd::core::Address;
using cfd::core::AddressFormatData;
using cfd::core::AddressType;
using cfd::core::ConfidentialKey;
using cfd::core::Descriptor;
using cfd::core::ElementsConfidentialAddress;
using cfd::core::ElementsNetType;
using cfd::core::NetType;
Expand Down Expand Up @@ -160,6 +162,21 @@ class CFD_EXPORT ElementsAddressFactory : public AddressFactory {
NetType mainchain_net_type, AddressType address_type,
const Script& tweak_fedpegscript);

/**
* @brief get pegout address.
* @param[in] mainchain_network mainchain network.
* @param[in] elements_network elements network.
* @param[in] descriptor_or_xpub descriptor or xpub.
* @param[in] bip32_counter bip32 counter.
* @param[in] address_type address type. (use if descriptor is xpub.)
* @param[out] base_descriptor pegout base descriptor.
* @return mainchain address
*/
static Address CreatePegOutAddress(
NetType mainchain_network, NetType elements_network,
const std::string& descriptor_or_xpub, uint32_t bip32_counter,
AddressType address_type, Descriptor* base_descriptor);

/**
* @brief check confidential address's network type is valid.
* @param[in] conf_addr confidential address which is checked network type
Expand Down
14 changes: 14 additions & 0 deletions include/cfd/cfd_elements_transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,20 @@ class CFD_EXPORT ConfidentialTransactionContext
Address GetTxOutAddress(
uint32_t index, NetType net_type = NetType::kLiquidV1,
bool ignore_error = false) const;
/**
* @brief Has pegout txout.
* @param[in] index txout index.
* @retval true
*/
bool HasPegoutTxOut(uint32_t index) const;
/**
* @brief Get txout mainchain address.
* @param[in] index txout index.
* @param[in] mainchain_network mainchain network type.
* @return address
*/
Address GetTxOutPegoutAddress(
uint32_t index, NetType mainchain_network = NetType::kMainnet) const;

/**
* @brief Get if it is blind.
Expand Down
16 changes: 15 additions & 1 deletion include/cfd/cfd_utxo.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ class CFD_EXPORT CoinSelectionOption {
* @return dust fee satoshi
*/
Amount GetDustFeeAmount(const Address& address) const;
/**
* @brief Get the ignore fee asset flag.
* @return ignore fee asset flag.
*/
bool HasIgnoreFeeAsset() const;

/**
* @brief Set the BnB using flag.
Expand Down Expand Up @@ -156,6 +161,11 @@ class CFD_EXPORT CoinSelectionOption {
* @param[in] baserate fee baserate (for BTC/byte)
*/
void SetDustFeeRate(double baserate);
/**
* @brief Set the ignore fee asset.
* @param[in] has_ignore_fee_asset ignore fee asset
*/
void SetIgnoreFeeAsset(bool has_ignore_fee_asset);

/**
* @brief Initializes size related information equivalent to bitcoin.
Expand Down Expand Up @@ -212,6 +222,7 @@ class CFD_EXPORT CoinSelectionOption {
uint64_t long_term_fee_baserate_; //!< longterm fee baserate
int64_t knapsack_minimum_change_; //!< knapsack min change
int64_t dust_fee_rate_; //!< dust fee rate
bool has_ignore_fee_asset_; //!< ignore fee asset
#ifndef CFD_DISABLE_ELEMENTS
ConfidentialAssetId fee_asset_; //!< asset to be used as a fee
int exponent_ = 0; //!< rangeproof exponent value
Expand Down Expand Up @@ -271,14 +282,17 @@ class CFD_EXPORT CoinSelection {
* @param[out] utxo_fee_value the fee amount for utxo
* @param[out] map_searched_bnb Flag of whether you searched with BnB.
* The result is stored for each Asset specified by map_target_value.
* @param[out] map_utxo_fee_value Fee utxo amount map.
* The collection amount for each Asset specified by map_target_value is stored.
* @return UTXO list. If it is empty, the error ends.
*/
std::vector<Utxo> SelectCoins(
const AmountMap& map_target_value, const std::vector<Utxo>& utxos,
const UtxoFilter& filter, const CoinSelectionOption& option_params,
const Amount& tx_fee_value, AmountMap* map_select_value,
Amount* utxo_fee_value = nullptr,
std::map<std::string, bool>* map_searched_bnb = nullptr);
std::map<std::string, bool>* map_searched_bnb = nullptr,
AmountMap* map_utxo_fee_value = nullptr);
#endif // CFD_DISABLE_ELEMENTS

/**
Expand Down
25 changes: 16 additions & 9 deletions include/cfd/cfdapi_elements_transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,13 @@ struct IssuanceOutput {
* @brief Using utxo and option data in elements
*/
struct ElementsUtxoAndOption {
UtxoData utxo; //!< utxo
bool is_issuance = false; //!< use issuance/reissuance
bool is_blind_issuance = false; //!< use blind issuance/reissuance
bool is_pegin = false; //!< use pegin
uint32_t pegin_btc_tx_size = 0; //!< btc pegin tx size
Script fedpeg_script; //!< fedpeg script for pegin
UtxoData utxo; //!< utxo
bool is_issuance = false; //!< use issuance/reissuance
bool is_blind_issuance = false; //!< use blind issuance/reissuance
bool is_pegin = false; //!< use pegin
uint32_t pegin_btc_tx_size = 0; //!< btc pegin tx size
Script claim_script; //!< claim script for pegin
uint32_t pegin_txoutproof_size = 0; //!< btc pegin txoutproof size
};

/**
Expand Down Expand Up @@ -519,6 +520,7 @@ class CFD_EXPORT ElementsTransactionApi {
* -1 to 18. -1 is public value. 0 is most private.
* @param[in] minimum_bits rangeproof blinding bits.
* 0 to 64. Number of bits of the value to keep private. 0 is auto.
* @param[in] append_asset_count append asset count.
* @return tx fee (contains utxo)
*/
Amount EstimateFee(
Expand All @@ -527,7 +529,8 @@ class CFD_EXPORT ElementsTransactionApi {
const ConfidentialAssetId& fee_asset, Amount* txout_fee = nullptr,
Amount* utxo_fee = nullptr, bool is_blind = true,
double effective_fee_rate = 1, int exponent = 0,
int minimum_bits = cfd::core::kDefaultBlindMinimumBits) const;
int minimum_bits = cfd::core::kDefaultBlindMinimumBits,
uint32_t* append_asset_count = nullptr) const;

/**
* @brief estimate a fee amount from transaction.
Expand All @@ -542,6 +545,7 @@ class CFD_EXPORT ElementsTransactionApi {
* -1 to 18. -1 is public value. 0 is most private.
* @param[in] minimum_bits rangeproof blinding bits.
* 0 to 64. Number of bits of the value to keep private. 0 is auto.
* @param[in] append_asset_count append asset count.
* @return tx fee (contains utxo)
*/
Amount EstimateFee(
Expand All @@ -550,7 +554,8 @@ class CFD_EXPORT ElementsTransactionApi {
const ConfidentialAssetId& fee_asset, Amount* txout_fee = nullptr,
Amount* utxo_fee = nullptr, bool is_blind = true,
uint64_t effective_fee_rate = 1000, int exponent = 0,
int minimum_bits = cfd::core::kDefaultBlindMinimumBits) const;
int minimum_bits = cfd::core::kDefaultBlindMinimumBits,
uint32_t* append_asset_count = nullptr) const;

/**
* @brief calculate fund transaction.
Expand All @@ -571,6 +576,7 @@ class CFD_EXPORT ElementsTransactionApi {
* @param[out] append_txout_addresses used txout additional address
* @param[in] net_type network type
* @param[in] prefix_list address prefix list
* @param[out] calculate_fee calculate fee (before add dust amount)
* @return tx controller
*/
ConfidentialTransactionController FundRawTransaction(
Expand All @@ -584,7 +590,8 @@ class CFD_EXPORT ElementsTransactionApi {
const CoinSelectionOption* option_params = nullptr,
std::vector<std::string>* append_txout_addresses = nullptr,
NetType net_type = NetType::kLiquidV1,
const std::vector<AddressFormatData>* prefix_list = nullptr) const;
const std::vector<AddressFormatData>* prefix_list = nullptr,
Amount* calculate_fee = nullptr) const;

// CreateDestroyAmountTransaction
// see CreateRawTransaction and ConfidentialTxOut::CreateDestroyAmountTxOut
Expand Down
4 changes: 3 additions & 1 deletion include/cfd/cfdapi_transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ class CFD_EXPORT TransactionApi {
* @param[out] append_txout_addresses used txout additional address
* @param[in] net_type network type
* @param[in] prefix_list address prefix list
* @param[out] calculate_fee calculate fee (before add dust amount)
* @return tx controller
*/
TransactionController FundRawTransaction(
Expand All @@ -258,7 +259,8 @@ class CFD_EXPORT TransactionApi {
const CoinSelectionOption* option_params = nullptr,
std::vector<std::string>* append_txout_addresses = nullptr,
NetType net_type = NetType::kMainnet,
const std::vector<AddressFormatData>* prefix_list = nullptr) const;
const std::vector<AddressFormatData>* prefix_list = nullptr,
Amount* calculate_fee = nullptr) const;

/**
* @brief Create multisig scriptsig (unlocking script).
Expand Down
1 change: 1 addition & 0 deletions include/cfdc/Makefile.srclist
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
CFDC_PKGINCLUDE_FILES = \
cfdcapi_common.h \
cfdcapi_address.h \
cfdcapi_block.h \
cfdcapi_script.h \
cfdcapi_transaction.h \
cfdcapi_key.h \
Expand Down
Loading

0 comments on commit e2a82a8

Please sign in to comment.