add getTransactionWithBlock.
This commit is contained in:
parent
f6758c0e6f
commit
7ce053ab05
@ -435,6 +435,50 @@ Bitcoin.prototype.getTx = function(txid, blockhash, callback) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Bitcoin.prototype.getTransactionWithBlock = function(txid, blockhash, callback) {
|
||||||
|
var slow = true;
|
||||||
|
|
||||||
|
if (typeof txid === 'object' && txid) {
|
||||||
|
var options = txid;
|
||||||
|
callback = blockhash;
|
||||||
|
txid = options.txid || options.tx || options.txhash || options.id || options.hash;
|
||||||
|
blockhash = options.blockhash || options.block;
|
||||||
|
slow = options.slow !== false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof blockhash === 'function') {
|
||||||
|
callback = blockhash;
|
||||||
|
blockhash = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof blockhash !== 'string') {
|
||||||
|
if (blockhash) {
|
||||||
|
blockhash = blockhash.hash
|
||||||
|
|| blockhash.blockhash
|
||||||
|
|| (blockhash.getHash && blockhash.getHash())
|
||||||
|
|| '';
|
||||||
|
} else {
|
||||||
|
blockhash = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return bitcoindjs.getTransaction(txid, blockhash, function(err, tx) {
|
||||||
|
if (err) return callback(err);
|
||||||
|
|
||||||
|
if (slow && !tx.blockhash) {
|
||||||
|
return bitcoindjs.getBlockByTx(txid, function(err, block) {
|
||||||
|
if (err) return callback(err);
|
||||||
|
return callback(null, bitcoin.tx(tx), bitcoin.block(block));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return bitcoindjs.getBlock(tx.blockhash, function(err, block) {
|
||||||
|
if (err) return callback(err);
|
||||||
|
return callback(null, bitcoin.tx(tx), bitcoin.block(block));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
Bitcoin.prototype.getInfo = function() {
|
Bitcoin.prototype.getInfo = function() {
|
||||||
return bitcoindjs.getInfo();
|
return bitcoindjs.getInfo();
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user