Skip to content

Commit

Permalink
#noticket Added getBasicTransaction endpoint to BTC-based endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasov-menasoft committed May 11, 2021
1 parent 5ed4fa4 commit 0c9eb8a
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2021-05-11, Version 4.7.0

#### Added:
* Added `getBasicTransaction` endpoint to BTC-based endpoints
* caClient.BC.XXX.transaction.getBasicTransaction

## 2020-08-26, Version 4.6.1

#### Bugfixes:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ NOTES:

#### Transaction methods
* caClient.BC.XXX.transaction.getTransaction(txID) ([docs](https://docs.cryptoapis.io/rest-apis/blockchain-as-a-service-apis/btc/index#btc-transactions-transaction-txid-endpoint))
* caClient.BC.XXX.transaction.getBasicTransaction(txID) ([docs](https://docs.cryptoapis.io/rest-apis/blockchain-as-a-service-apis/btc/index#btc-basic-transaction-txid-endpoint))
* caClient.BC.XXX.transaction.getTransactionIndexByBlock(block, ?{?index, ?limit} = {index: 0, limit: 1}) ([docs](https://docs.cryptoapis.io/rest-apis/blockchain-as-a-service-apis/btc/index#btc-transactions-transaction-by-block-endpoint))
* caClient.BC.XXX.transaction.getUnconfirmedTransactions(?{?index, ?limit} = {index: 0, limit: 100}) ([docs](https://docs.cryptoapis.io/rest-apis/blockchain-as-a-service-apis/btc/index#btc-transactions-unconfirmed-transactions-endpoint))
* caClient.BC.XXX.transaction.decodeRawTransaction(hex) ([docs](https://docs.cryptoapis.io/rest-apis/blockchain-as-a-service-apis/btc/index#btc-transactions-decode-raw-transaction-endpoint))
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.6.1",
"version": "4.7.0",
"description": "Crypto APIs SDK",
"main": "src/index.js",
"scripts": {
Expand Down
15 changes: 15 additions & 0 deletions src/common/blockchain/base-transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ class BaseTransaction extends BaseChainComponent {
return this.request.get(this.basePath + this.getSelectedNetwork() + '/txs/txid/' + txID, queryParams);
}

/**
* Basic Transaction Details By Transaction ID
*
* @async
* @desc The Basic Transaction By Txid Endpoint returns basic information about a given transaction based on its id.
*
* @param {string} txID - Id of the transaction in blockchain.
* @param {object} [queryParams] - Additional query parameters.
*
* @returns {*|Promise<any | never>}
*/
getBasicTransaction(txID, queryParams = {}) {
return this.request.get(this.basePath + this.getSelectedNetwork() + '/txs/basic/txid/' + txID, queryParams);
}

/**
* Transactions Block Endpoint
*
Expand Down
1 change: 1 addition & 0 deletions tests/rest-apis/blockchains/BCH/transaction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ async function Transaction(caClient) {

if (transactions && transactions.length) {
const txId = transactions[0].txid;
await caClient.BC.BCH.transaction.getBasicTransaction(txId).then(response => response ? response.payload : null);
await caClient.BC.BCH.transaction.getTransaction(txId);
}

Expand Down
1 change: 1 addition & 0 deletions tests/rest-apis/blockchains/BTC/transaction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ async function Transaction(caClient) {

if (transactions && transactions.length) {
const txId = transactions[0].txid;
await caClient.BC.BTC.transaction.getBasicTransaction(txId).then(response => response ? response.payload : null);
await caClient.BC.BTC.transaction.getTransaction(txId);
}

Expand Down
1 change: 1 addition & 0 deletions tests/rest-apis/blockchains/DASH/transaction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ async function Transaction(caClient) {

if (transactions && transactions.length) {
const txId = transactions[0].txid;
await caClient.BC.DASH.transaction.getBasicTransaction(txId).then(response => response ? response.payload : null);
await caClient.BC.DASH.transaction.getTransaction(txId);
}

Expand Down
1 change: 1 addition & 0 deletions tests/rest-apis/blockchains/DOGE/transaction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ async function Transaction(caClient) {

if (transactions && transactions.length) {
const txId = transactions[0].txid;
await caClient.BC.DOGE.transaction.getBasicTransaction(txId).then(response => response ? response.payload : null);
await caClient.BC.DOGE.transaction.getTransaction(txId);
}

Expand Down
1 change: 1 addition & 0 deletions tests/rest-apis/blockchains/LTC/transaction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ async function Transaction(caClient) {

if (transactions && transactions.length) {
const txId = transactions[0].txid;
await caClient.BC.LTC.transaction.getBasicTransaction(txId).then(response => response ? response.payload : null);
await caClient.BC.LTC.transaction.getTransaction(txId);
}

Expand Down

0 comments on commit 0c9eb8a

Please sign in to comment.