diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ba3576..3c41d73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: diff --git a/README.md b/README.md index b4b66e2..b7cfaf7 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/package-lock.json b/package-lock.json index c21440e..56ffcdf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { "name": "cryptoapis.io", - "version": "4.2.0", + "version": "4.2.1", "lockfileVersion": 1 } diff --git a/package.json b/package.json index 5961a1e..3a0a309 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cryptoapis.io", - "version": "4.2.0", + "version": "4.2.1", "description": "Crypto APIs SDK", "main": "src/index.js", "scripts": { diff --git a/src/common/blockchain/base-transaction.js b/src/common/blockchain/base-transaction.js index 72955ba..bd2178b 100644 --- a/src/common/blockchain/base-transaction.js +++ b/src/common/blockchain/base-transaction.js @@ -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. * @@ -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. @@ -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. * @@ -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} + */ + 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 *