Skip to content

Commit

Permalink
Stringify arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Cardona committed Aug 21, 2018
1 parent 192e1fd commit 342d671
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let clone = require('git-clone');
let cmd = require('node-cmd');

program
.version('1.5.11');
.version('1.5.12');

program
.command('new <name>')
Expand Down
15 changes: 15 additions & 0 deletions lib/Blockchain.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ var Blockchain = function () {
//
// Result:
// "hash" (string) The block hash
if (typeof height !== 'string') {
height = JSON.stringify(height);
}
return _axios2.default.get(this.restURL + 'blockchain/getBlockHash/' + height).then(function (response) {
return response.data;
}).catch(function (error) {
Expand Down Expand Up @@ -152,6 +155,9 @@ var Blockchain = function () {
//
// Result (for verbose=false):
// "data" (string) A string that is serialized, hex-encoded data for block 'hash'.
if (typeof hash !== 'string') {
hash = JSON.stringify(hash);
}
return _axios2.default.get(this.restURL + 'blockchain/getBlockHeader/' + hash + '?verbose=' + verbose).then(function (response) {
return response.data;
}).catch(function (error) {
Expand Down Expand Up @@ -244,6 +250,9 @@ var Blockchain = function () {
// ... ]
// }, ...
// }
if (typeof txid !== 'string') {
txid = JSON.stringify(txid);
}
return _axios2.default.get(this.restURL + 'blockchain/getMempoolAncestors/' + txid + '?verbose=' + verbose).then(function (response) {
return response.data;
}).catch(function (error) {
Expand Down Expand Up @@ -288,6 +297,9 @@ var Blockchain = function () {
// ... ]
// }, ...
// }
if (typeof txid !== 'string') {
txid = JSON.stringify(txid);
}

return _axios2.default.get(this.restURL + 'blockchain/getMempoolDescendants/' + txid + '?verbose=' + verbose).then(function (response) {
return response.data;
Expand Down Expand Up @@ -322,6 +334,9 @@ var Blockchain = function () {
// "transactionid", (string) parent transaction id
// ... ]
// }
if (typeof txid !== 'string') {
txid = JSON.stringify(txid);
}

return _axios2.default.get(this.restURL + 'blockchain/getMempoolEntry/' + txid).then(function (response) {
return response.data;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bitbox-cli",
"version": "1.5.11",
"version": "1.5.12",
"description": "BITBOX javascript sdk for Bitcoin Cash",
"author": "Gabriel Cardona @ Bitcoin.com",
"main": "index.js",
Expand Down
15 changes: 15 additions & 0 deletions src/Blockchain.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ class Blockchain {
//
// Result:
// "hash" (string) The block hash
if(typeof height !== 'string') {
height = JSON.stringify(height);
}
return axios.get(`${this.restURL}blockchain/getBlockHash/${height}`)
.then((response) => {
return response.data;
Expand Down Expand Up @@ -132,6 +135,9 @@ class Blockchain {
//
// Result (for verbose=false):
// "data" (string) A string that is serialized, hex-encoded data for block 'hash'.
if(typeof hash !== 'string') {
hash = JSON.stringify(hash);
}
return axios.get(`${this.restURL}blockchain/getBlockHeader/${hash}?verbose=${verbose}`)
.then((response) => {
return response.data;
Expand Down Expand Up @@ -225,6 +231,9 @@ class Blockchain {
// ... ]
// }, ...
// }
if(typeof txid !== 'string') {
txid = JSON.stringify(txid);
}
return axios.get(`${this.restURL}blockchain/getMempoolAncestors/${txid}?verbose=${verbose}`)
.then((response) => {
return response.data;
Expand Down Expand Up @@ -268,6 +277,9 @@ class Blockchain {
// ... ]
// }, ...
// }
if(typeof txid !== 'string') {
txid = JSON.stringify(txid);
}

return axios.get(`${this.restURL}blockchain/getMempoolDescendants/${txid}?verbose=${verbose}`)
.then((response) => {
Expand Down Expand Up @@ -303,6 +315,9 @@ class Blockchain {
// "transactionid", (string) parent transaction id
// ... ]
// }
if(typeof txid !== 'string') {
txid = JSON.stringify(txid);
}

return axios.get(`${this.restURL}blockchain/getMempoolEntry/${txid}`)
.then((response) => {
Expand Down

0 comments on commit 342d671

Please sign in to comment.