Skip to content

Commit

Permalink
update to v0.1.6 (#22)
Browse files Browse the repository at this point in the history
Co-authored-by: k-matsuzawa <[email protected]>
  • Loading branch information
ko-matsu and k-matsuzawa authored Sep 3, 2020
1 parent f938131 commit 7b1ab85
Show file tree
Hide file tree
Showing 21 changed files with 431 additions and 280 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/check_pre-merge_sprint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: ctest
run: |
cd build
ctest -C Release --output-on-failure
ctest -C Release --output-on-failure -R cfd
cmake-mac:
name: cmake build-mac
Expand All @@ -52,7 +52,7 @@ jobs:
- name: ctest
run: |
cd build
ctest -C Release --output-on-failure
ctest -C Release --output-on-failure -R cfd_test
cmake-ubuntu-coverage:
name: cmake build-ubuntu
Expand Down Expand Up @@ -119,7 +119,7 @@ jobs:
- name: test
run: |
cd build
ctest -C Debug --output-on-failure
ctest -C Debug --output-on-failure -R cfd
cd ..
- name: collect coverage
run: |
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/create_release-and-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ jobs:
mkdir build
cd build
cmake .. -DENABLE_SHARED=${{ matrix.shared }} -DENABLE_TESTS=off -DENABLE_JS_WRAPPER=off -DCMAKE_BUILD_TYPE=Release -DTARGET_RPATH="/usr/local/lib"
make
cd ..
cmake --build build --parallel 2 --config Release
cd build
sudo make install DESTDIR=../dist
cd ..
timeout-minutes: 20
Expand Down Expand Up @@ -315,10 +317,12 @@ jobs:
mkdir build
cd build
cmake .. -DENABLE_SHARED=${{ matrix.shared }} -DENABLE_TESTS=off -DENABLE_JS_WRAPPER=off -DCMAKE_BUILD_TYPE=Release -DTARGET_RPATH="/usr/local/lib;@executable_path;./build/Release"
make
cd ..
cmake --build build --parallel 2 --config Release
cd build
sudo make install DESTDIR=../dist
cd ..
timeout-minutes: 20
timeout-minutes: 30
- name: create archive file
run: |
cd dist
Expand Down
6 changes: 4 additions & 2 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ project(external_download NONE)
include(../cmake/EnableCcache.cmake)
include(../cmake/ConvertSrclistFunction.cmake)

find_package(cfdcore QUIET CONFIG)
find_package(univalue QUIET CONFIG)
find_package(wally QUIET CONFIG)
find_package(cfdcore CONFIG)

# env check
if($ENV{CFD_CMAKE_GIT_SSH})
Expand Down Expand Up @@ -48,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.1.5)
set(CFDCORE_TARGET_TAG v0.1.6)
endif()
if(CFDCORE_TARGET_URL)
set(CFDCORE_TARGET_REP ${CFDCORE_TARGET_URL})
Expand Down
8 changes: 4 additions & 4 deletions include/cfd/cfdapi_elements_transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ class CFD_EXPORT ElementsTransactionApi {
* @param[in] tx_hex tx hex string
* @param[in] utxos using utxo data
* @param[in] fee_asset using fee asset
* @param[in] tx_fee tx fee amount (ignore utxo)
* @param[in] txout_fee tx fee amount (ignore utxo)
* @param[in] utxo_fee utxo fee amount
* @param[in] is_blind using tx blinding
* @param[in] effective_fee_rate effective fee rate (minimum)
Expand All @@ -524,7 +524,7 @@ class CFD_EXPORT ElementsTransactionApi {
Amount EstimateFee(
const std::string& tx_hex,
const std::vector<ElementsUtxoAndOption>& utxos,
const ConfidentialAssetId& fee_asset, Amount* tx_fee = nullptr,
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;
Expand All @@ -534,7 +534,7 @@ class CFD_EXPORT ElementsTransactionApi {
* @param[in] tx_hex tx hex string
* @param[in] utxos using utxo data
* @param[in] fee_asset using fee asset
* @param[in] tx_fee tx fee amount (ignore utxo)
* @param[in] txout_fee tx fee amount (ignore utxo)
* @param[in] utxo_fee utxo fee amount
* @param[in] is_blind using tx blinding
* @param[in] effective_fee_rate effective fee rate (minimum)
Expand All @@ -547,7 +547,7 @@ class CFD_EXPORT ElementsTransactionApi {
Amount EstimateFee(
const std::string& tx_hex,
const std::vector<ElementsUtxoAndOption>& utxos,
const ConfidentialAssetId& fee_asset, Amount* tx_fee = nullptr,
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;
Expand Down
4 changes: 2 additions & 2 deletions include/cfd/cfdapi_transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,14 @@ class CFD_EXPORT TransactionApi {
* @brief estimate a fee amount from transaction.
* @param[in] tx_hex tx hex string
* @param[in] utxos using utxo data
* @param[in] tx_fee tx fee amount (ignore utxo)
* @param[in] txout_fee tx fee amount (ignore utxo)
* @param[in] utxo_fee utxo fee amount
* @param[in] effective_fee_rate effective fee rate (minimum)
* @return tx fee (contains utxo)
*/
Amount EstimateFee(
const std::string& tx_hex, const std::vector<UtxoData>& utxos,
Amount* tx_fee = nullptr, Amount* utxo_fee = nullptr,
Amount* txout_fee = nullptr, Amount* utxo_fee = nullptr,
double effective_fee_rate = 1) const;

/**
Expand Down
6 changes: 3 additions & 3 deletions include/cfdc/cfdcapi_coin.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,17 @@ CFDC_API int CfdSetOptionEstimateFee(
* @param[in] fee_handle handle for fee estimation apis.
* @param[in] tx_hex transaction hex.
* @param[in] fee_asset asset id used as fee.
* @param[out] tx_fee estimated fee by transaction base.
* @param[out] txout_fee estimated fee by transaction base & output.
* (not contain utxo_fee.)
* @param[out] utxo_fee estimated fee by input utxos.
* (not contain tx_fee.)
* (not contain txout_fee.)
* @param[in] is_blind need blind later.
* @param[in] effective_fee_rate effective fee rate for estimation.
* @return CfdErrorCode
*/
CFDC_API int CfdFinalizeEstimateFee(
void* handle, void* fee_handle, const char* tx_hex, const char* fee_asset,
int64_t* tx_fee, int64_t* utxo_fee, bool is_blind,
int64_t* txout_fee, int64_t* utxo_fee, bool is_blind,
double effective_fee_rate);

/**
Expand Down
26 changes: 22 additions & 4 deletions include/cfdc/cfdcapi_elements_transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ CFDC_API int CfdSetBlindTxOption(
* @param[in] vout txin vout.
* @param[in] asset_string asset.(utxo value)
* @param[in] asset_blind_factor asset blind factor.(utxo value)
* @param[in] value_blind_vactor value blind factor.(utxo value)
* @param[in] value_blind_factor value blind factor.(utxo value)
* @param[in] value_satoshi satoshi value.(utxo value)
* @param[in] asset_key asset blinding key(privkey).
* (blind issuance only)
Expand All @@ -526,7 +526,7 @@ CFDC_API int CfdSetBlindTxOption(
CFDC_API int CfdAddBlindTxInData(
void* handle, void* blind_handle, const char* txid, uint32_t vout,
const char* asset_string, const char* asset_blind_factor,
const char* value_blind_vactor, int64_t value_satoshi,
const char* value_blind_factor, int64_t value_satoshi,
const char* asset_key, const char* token_key);

/**
Expand Down Expand Up @@ -815,15 +815,33 @@ CFDC_API int CfdGetAssetCommitment(
* @param[in] handle cfd handle.
* @param[in] value_satoshi satoshi value.
* @param[in] asset_commitment asset commitment.
* @param[in] value_blind_vactor value blind factor.
* @param[in] value_blind_factor value blind factor.
* @param[out] value_commitment value commitment
* If 'CfdFreeStringBuffer' is implemented,
* Call 'CfdFreeStringBuffer' after you are finished using it.
* @return CfdErrorCode
*/
CFDC_API int CfdGetValueCommitment(
void* handle, int64_t value_satoshi, const char* asset_commitment,
const char* value_blind_vactor, char** value_commitment);
const char* value_blind_factor, char** value_commitment);

/**
* @brief add transaction output.
* @param[in] handle cfd handle.
* @param[in] create_handle create transaction handle.
* @param[in] value_satoshi satoshi value. (Specify 0 if disabled)
* @param[in] address destination address.(Specify null if disabled)
* @param[in] direct_locking_script locking script for direct.
* (Specify null if disabled.)
* @param[in] asset_string value asset.(Specify null if disabled)
* @param[in] nonce nonce.(Specify null if disabled)
* @return CfdErrorCode
* @see CfdInitializeTransaction
*/
CFDC_API int CfdAddConfidentialTxOutput(
void* handle, void* create_handle, int64_t value_satoshi,
const char* address, const char* direct_locking_script,
const char* asset_string, const char* nonce);

/*
CFDC_API int CfdAddConfidentialTxPeginInput(
Expand Down
18 changes: 17 additions & 1 deletion include/cfdc/cfdcapi_transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ enum CfdFundTxOption {
};

/**
* @brief create initialized elements transaction.
* @brief create initialized transaction.
* @param[in] handle cfd handle.
* @param[in] net_type network type.
* @param[in] version transaction version.
Expand All @@ -72,6 +72,7 @@ CFDC_API int CfdInitializeTransaction(
* @param[in] vout utxo vout.
* @param[in] sequence sequence number.
* @return CfdErrorCode
* @see CfdInitializeTransaction
*/
CFDC_API int CfdAddTransactionInput(
void* handle, void* create_handle, const char* txid, uint32_t vout,
Expand All @@ -87,6 +88,7 @@ CFDC_API int CfdAddTransactionInput(
* (Specify null if disabled.)
* @param[in] asset_string value asset.(Specify null if disabled)
* @return CfdErrorCode
* @see CfdInitializeTransaction
*/
CFDC_API int CfdAddTransactionOutput(
void* handle, void* create_handle, int64_t value_satoshi,
Expand All @@ -101,6 +103,7 @@ CFDC_API int CfdAddTransactionOutput(
* If 'CfdFreeStringBuffer' is implemented,
* Call 'CfdFreeStringBuffer' after you are finished using it.
* @return CfdErrorCode
* @see CfdInitializeTransaction
*/
CFDC_API int CfdFinalizeTransaction(
void* handle, void* create_handle, char** tx_hex_string);
Expand All @@ -110,6 +113,7 @@ CFDC_API int CfdFinalizeTransaction(
* @param[in] handle handle pointer.
* @param[in] create_handle create transaction handle.
* @return CfdErrorCode
* @see CfdInitializeTransaction
*/
CFDC_API int CfdFreeTransactionHandle(void* handle, void* create_handle);

Expand Down Expand Up @@ -509,6 +513,18 @@ CFDC_API int CfdInitializeTxDataHandle(
*/
CFDC_API int CfdFreeTxDataHandle(void* handle, void* tx_data_handle);

/**
* @brief free transaction data handle.
* @param[in] handle handle pointer.
* @param[in] tx_data_handle transaction data handle.
* @param[out] tx_hex_string transaction hex.
* If 'CfdFreeStringBuffer' is implemented,
* Call 'CfdFreeStringBuffer' after you are finished using it.
* @return CfdErrorCode
*/
CFDC_API int CfdGetModifiedTxByHandle(
void* handle, void* tx_data_handle, char** tx_hex_string);

/**
* @brief get transaction information.
* @param[in] handle cfd handle.
Expand Down
4 changes: 3 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ else()
set(CFD_CORE_SHARED_OPT "")
endif()

find_package(cfdcore QUIET)
find_package(univalue QUIET CONFIG)
find_package(wally QUIET CONFIG)
find_package(cfdcore QUIET CONFIG)
if((NOT cfdcore_FOUND) OR (NOT ${cfdcore_FOUND}))
set(CFDCORE_LIBRARY cfdcore)
set(LIBWALLY_LIBRARY wally)
Expand Down
36 changes: 0 additions & 36 deletions src/capi/cfdc_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,42 +88,6 @@ struct CfdCapiMultisigSignData {
uint32_t current_index; //!< current index
};

//! prefix: CreateTx
constexpr const char* const kPrefixCreateTxData = "CreateTx";

/**
* @brief cfd-capi transaction input data
*/
struct CfdCapiTxInputData {
Txid txid; //!< txid
uint32_t vout; //!< vout
uint32_t sequence; //!< sequence
};

/**
* @brief cfd-capi transaction output data
*/
struct CfdCapiTxOutputData {
int64_t amount; //!< amount
ByteData locking_script; //!< locking script (under 520)
#ifndef CFD_DISABLE_ELEMENTS
ConfidentialValue value; //!< value
ConfidentialAssetId asset; //!< asset
ConfidentialNonce nonce; //!< nonce
#endif // CFD_DISABLE_ELEMENTS
};

/**
* @brief cfd-capi CreateTransaction構造体.
*/
struct CfdCapiCreateTransactionData {
char prefix[kPrefixLength]; //!< buffer prefix
int net_type; //!< network type
char* base_tx_hex; //!< base tx hex
std::vector<CfdCapiTxInputData>* txin_list; //!< txin list
std::vector<CfdCapiTxOutputData>* txout_list; //!< txout list
};

//! prefix: TxData
constexpr const char* const kPrefixTransactionData = "TransactionData";

Expand Down
10 changes: 5 additions & 5 deletions src/capi/cfdcapi_coin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,18 +755,18 @@ int CfdSetOptionEstimateFee(

int CfdFinalizeEstimateFee(
void* handle, void* fee_handle, const char* tx_hex, const char* fee_asset,
int64_t* tx_fee, int64_t* utxo_fee, bool is_blind,
int64_t* txout_fee, int64_t* utxo_fee, bool is_blind,
double effective_fee_rate) {
try {
cfd::Initialize();
CheckBuffer(fee_handle, kPrefixEstimateFeeData);
CfdCapiEstimateFeeData* buffer =
static_cast<CfdCapiEstimateFeeData*>(fee_handle);
if (tx_fee == nullptr) {
warn(CFD_LOG_SOURCE, "tx fee is null.");
if (txout_fee == nullptr) {
warn(CFD_LOG_SOURCE, "txout fee is null.");
throw CfdException(
CfdError::kCfdIllegalArgumentError,
"Failed to parameter. tx fee is null.");
"Failed to parameter. txout fee is null.");
}
if (utxo_fee == nullptr) {
warn(CFD_LOG_SOURCE, "utxo fee is null.");
Expand Down Expand Up @@ -800,7 +800,7 @@ int CfdFinalizeEstimateFee(
std::string(tx_hex), *(buffer->input_utxos), &tx_fee_amt,
&utxo_fee_amt, effective_fee_rate);
}
*tx_fee = tx_fee_amt.GetSatoshiValue();
*txout_fee = tx_fee_amt.GetSatoshiValue();
*utxo_fee = utxo_fee_amt.GetSatoshiValue();

return CfdErrorCode::kCfdSuccess;
Expand Down
Loading

0 comments on commit 7b1ab85

Please sign in to comment.