Skip to content
This repository was archived by the owner on Feb 20, 2021. It is now read-only.

Commit 590eaf7

Browse files
Merge pull request #11 from sogoiii/master
fix: Adding unit test cases for sanity.
2 parents 8e1251c + f87d34a commit 590eaf7

45 files changed

Lines changed: 4482 additions & 24 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
*.swp
22
node_modules
3+
coverage

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Examples
1515
```javascript
1616
bcypher = require('blockcypher');
1717

18-
var bcapi = new bcypher('btc','main','YOURTOKEN');
18+
var bcapi = new bcypher('btc','main',process.env.TOKEN);
1919

2020
function printResponse(err, data) {
2121
if (err !== null) {

lib/bcypher.js

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,14 @@ Blockcy.prototype.getAddrFull = function (addr, params, cb) {
192192
/**
193193
* <b>Gen Addr</b>
194194
* Generates a new address and associate private/public keys.
195-
* @param {Object} data Optional JSON data, which could be used for generating multisig addresses, for exampl.JSON data, which could be used for generating multisig addresses, for example.
195+
* @param {Object} data Optional JSON data, which could be used for generating multisig addresses, for exampl.JSON data, which could be used for generating multisig addresses, for example.
196+
* @param {Array[Strings]} data.pubKeys Optional pubKeys for multi sig address
197+
* @param {String} data.script_type Optional script type for multi sig address
196198
* @callback cb
197199
* @memberof Blockcy
198200
* @method genAddr
199201
*/
200-
Blockcy.prototype.genAddr = function (data, cb) {
202+
Blockcy.prototype.genAddr = function (data, cb) { //TODO Allow function signature genAddr(cb) as well
201203
this._post('/addrs', {}, data, function (error, body) {
202204
cb(error, body);
203205
});
@@ -212,7 +214,7 @@ Blockcy.prototype.genAddr = function (data, cb) {
212214
* @memberof Blockcy
213215
* @method faucet
214216
*/
215-
Blockcy.prototype.faucet = function (addr, value, cb) {
217+
Blockcy.prototype.faucet = function (addr, value, cb) { //TODO set default value if value is undefined/null. Maybe allow faucet(addr, cb).
216218
this._post('/faucet', {}, { address: addr, amount: value }, function (error, body) {
217219
cb(error, body);
218220
});
@@ -221,12 +223,14 @@ Blockcy.prototype.faucet = function (addr, value, cb) {
221223
/**
222224
* <b>Create Wallet</b>
223225
* Creates a new wallet.
224-
* @param {Object} data JSON Data used to create wallet.
226+
* @param {Object} data JSON Data used to create wallet.
227+
* @param {String} data.name Name of wallet
228+
* @param {Array[String]} data.addresses Array of addresses
225229
* @callback cb
226230
* @memberof Blockcy
227231
* @method createWallet
228232
*/
229-
Blockcy.prototype.createWallet = function (data, cb) {
233+
Blockcy.prototype.createWallet = function (data, cb) { //TODO check if they have name and address before making request
230234
this._post('/wallets', {}, data, function (error, body) {
231235
cb(error, body);
232236
});
@@ -235,12 +239,15 @@ Blockcy.prototype.createWallet = function (data, cb) {
235239
/**
236240
* <b>Create HD Wallet</b>
237241
* Creates a new HD wallet.
238-
* @param {Object} data JSON Data used to create HD wallet.
242+
* @param {Object} data JSON Data used to create HD wallet.
243+
* @param {String} data.name Name of wallet
244+
* @param {String} data.extended_public_key extended public key
245+
* @param {Array[int]} data.subchain_indexes subchain indexes
239246
* @callback cb
240247
* @memberof Blockcy
241248
* @method createHDWallet
242249
*/
243-
Blockcy.prototype.createHDWallet = function (data, cb) {
250+
Blockcy.prototype.createHDWallet = function (data, cb) { //TODO error validation on name and extended_public_key
244251
this._post('/wallets/hd', {}, data, function (error, body) {
245252
cb(error, body);
246253
});
@@ -428,7 +435,7 @@ Blockcy.prototype.delHDWallet = function (name, cb) {
428435
* @memberof Blockcy
429436
* @method getTX
430437
*/
431-
Blockcy.prototype.getTX = function (hash, params, cb) {
438+
Blockcy.prototype.getTX = function (hash, params, cb) { //TODO allow params to be optional getTX(hash, cb) should work
432439
this._get('/txs/' + hash, params, function (error, body) {
433440
cb(error, body);
434441
});
@@ -451,7 +458,7 @@ Blockcy.prototype.getUnTXs = function (cb) {
451458
* <b>New Transaction</b>
452459
* Creates a new transaction skeleton, which returns the transaction along with data that needs to be signed. You can see more information on how this process works here: <a href="http://dev.blockcypher.com/?javascript#creating-transactions">http://dev.blockcypher.com/?javascript#creating-transactions</a>
453460
* @callback cb
454-
* @param {Object} tx Transaction base you're using to build a TX.
461+
* @param {Object} tx Transaction base you're using to build a TX. https://www.blockcypher.com/dev/bitcoin/#tx
455462
* @memberof Blockcy
456463
* @method newTX
457464
*/
@@ -465,7 +472,7 @@ Blockcy.prototype.newTX = function (tx, cb) {
465472
* <b>Send Transaction</b>
466473
* Sends a signed transaction skeleton, which returns the completed transaction. You can read more information on how this process works here: <a href="http://dev.blockcypher.com/?javascript#creating-transactions">http://dev.blockcypher.com/?javascript#creating-transactions</a>
467474
* @callback cb
468-
* @param {Object} txskel Signed transaction skeleton you're sending.
475+
* @param {Object} txskel Signed transaction skeleton you're sending. https://www.blockcypher.com/dev/bitcoin/#txskeleton
469476
* @memberof Blockcy
470477
* @method sendTX
471478
*/
@@ -548,7 +555,9 @@ Blockcy.prototype.getTXConf = function (hash, cb) {
548555
/**
549556
* <b>Create Payment Forward</b>
550557
* Creates a new payment forward.
551-
* @param {Object} data JSON Data used to create payment forward.
558+
* @param {Object} data JSON Data used to create payment forward.
559+
* @param {String} data.destination Destination address
560+
* @param {String} data.callback_url callback url
552561
* @callback cb
553562
* @memberof Blockcy
554563
* @method createPayFwd
@@ -589,7 +598,10 @@ Blockcy.prototype.delPayFwd = function (id, cb) {
589598
/**
590599
* <b>Create WebHook</b>
591600
* Creates a new webhook.
592-
* @param {Object} data JSON Data used to create webhook.
601+
* @param {Object} data JSON Data used to create webhook.
602+
* @param {String} data.event Event name
603+
* @param {String} data.address address
604+
* @param {String} data.url url
593605
* @callback cb
594606
* @memberof Blockcy
595607
* @method createHook

0 commit comments

Comments
 (0)