Skip to content

Commit

Permalink
#noticket getTransactionSize method
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasov-menasoft committed Dec 20, 2019
1 parent 3427f39 commit fe6d990
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2019-12-20, Version 4.2.1

#### Notable changes:
* Added `getTransactionSize` method for BTC based

## 2019-12-20, Version 4.2.0

#### Notable changes:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ NOTES:
* caClient.BC.XXX.transaction.newTransaction ([docs](https://docs.cryptoapis.io/rest-apis/blockchain-as-a-service-apis/btc/index#btc-transactions-new-transactions))
* caClient.BC.XXX.transaction.createHDWalletTransaction ([docs](https://docs.cryptoapis.io/rest-apis/blockchain-as-a-service-apis/btc/index#btc-transactions-hdwallet-transactions))
* caClient.BC.XXX.transaction.getTransactionsFee ([docs](https://docs.cryptoapis.io/rest-apis/blockchain-as-a-service-apis/btc/index#btc-transactions-fee-endpoint))
* caClient.BC.XXX.transaction.getTransactionSize ([docs](https://docs.cryptoapis.io/rest-apis/blockchain-as-a-service-apis/btc/index#btc-transactions-size))
* caClient.BC.XXX.transaction.refund ([docs](https://docs.cryptoapis.io/rest-apis/blockchain-as-a-service-apis/btc/index#btc-refund-transaction))

#### Payment Forwarding methods
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cryptoapis.io",
"version": "4.2.0",
"version": "4.2.1",
"description": "Crypto APIs SDK",
"main": "src/index.js",
"scripts": {
Expand Down
31 changes: 28 additions & 3 deletions src/common/blockchain/base-transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class BaseTransaction extends BaseChainComponent {
*
* @param {Array} inputs
* @param {Array} outputs
* @param {Object<{number} value>} fee
* @param {object<{number} value>} fee
* @param {object} [optData] - Optional data.
* @param {object} [queryParams] - Additional query parameters.
*
Expand Down Expand Up @@ -167,7 +167,7 @@ class BaseTransaction extends BaseChainComponent {
*
* @param {Array} inputs
* @param {Array} outputs
* @param {Object<{number} value>} fee
* @param {object<{number} value>} fee
* @param {Array} wifs
* @param {object} [optData] - Optional data.
* @param {object} [queryParams] - Additional query parameters.
Expand Down Expand Up @@ -203,7 +203,7 @@ class BaseTransaction extends BaseChainComponent {
* @param {string} walletName - Wallet name.
* @param {string} password - Wallet password.
* @param {Array} outputs
* @param {Object<{number} value, {string} [address]>} fee
* @param {object<{number} value, {string} [address]>} fee
* @param {object} [optData] - Optional data.
* @param {object} [queryParams] - Additional query parameters.
*
Expand Down Expand Up @@ -248,6 +248,31 @@ class BaseTransaction extends BaseChainComponent {
return this.request.get(this.basePath + this.getSelectedNetwork() + '/txs/fee', queryParams);
}

/**
* Transaction Size Endpoint
*
* @async
* @desc Using Crypto APIs, you can calculate the approximate size of a standard transaction.
*
* @param {array} inputs
* @param {array} outputs
* @param {object} fee
* @param {object} [optData] - Optional data.
* @param {object} [queryParams] - Additional query parameters.
*
* @returns {*|Promise|Promise<any>}
*/
getTransactionSize(inputs, outputs, fee, optData = {}, queryParams = {}) {
const data = {
...optData,
inputs,
outputs,
fee,
};

return this.request.post(this.basePath + this.getSelectedNetwork() + '/txs/size', data, queryParams);
}

/**
* Refund Transaction Endpoint
*
Expand Down

0 comments on commit fe6d990

Please sign in to comment.