cleanup. allow no block hash.
This commit is contained in:
parent
0fd0b7c7b6
commit
be2bba94bd
@ -15,7 +15,8 @@ bitcoind.start(function(err) {
|
||||
bitcoind.on('open', function(status) {
|
||||
console.log('bitcoind: status="%s"', status);
|
||||
return setTimeout(function() {
|
||||
return bitcoind.getTx(genesisTx, genesisBlock, function(err, tx) {
|
||||
// return bitcoind.getTx(genesisTx, genesisBlock, function(err, tx) {
|
||||
return bitcoind.getTx(genesisTx, function(err, tx) {
|
||||
if (err) throw err;
|
||||
return print(tx);
|
||||
});
|
||||
|
||||
@ -140,16 +140,25 @@ Bitcoin.prototype.start = function(callback) {
|
||||
}
|
||||
};
|
||||
|
||||
Bitcoin.prototype.getBlock = function(hash, callback) {
|
||||
return bitcoindjs.getBlock(hash, callback);
|
||||
Bitcoin.prototype.getBlock = function(blockHash, callback) {
|
||||
return bitcoindjs.getBlock(blockHash, callback);
|
||||
};
|
||||
|
||||
Bitcoin.prototype.getTx = function(hash, blockHash, callback) {
|
||||
if (hash[1] === 'x') hash = hash.slice(2);
|
||||
if (blockHash[1] === 'x') blockHash = blockHash.slice(2);
|
||||
// hash = utils.revHex(hash);
|
||||
// blockHash = utils.revHex(blockHash);
|
||||
return bitcoindjs.getTx(hash, blockHash, callback);
|
||||
Bitcoin.prototype.getTx = function(txHash, blockHash, callback) {
|
||||
if (!callback) {
|
||||
callback = blockHash;
|
||||
blockHash = '';
|
||||
}
|
||||
|
||||
// if (txHash[1] === 'x') txHash = txHash.slice(2);
|
||||
// txHash = utils.revHex(txHash);
|
||||
|
||||
// if (blockHash) {
|
||||
// if (blockHash[1] === 'x') blockHash = blockHash.slice(2);
|
||||
// blockHash = utils.revHex(blockHash);
|
||||
// }
|
||||
|
||||
return bitcoindjs.getTx(txHash, blockHash, callback);
|
||||
};
|
||||
|
||||
Bitcoin.prototype.log =
|
||||
|
||||
@ -896,6 +896,12 @@ NAN_METHOD(GetTx) {
|
||||
std::string txHash = std::string(*txHash_);
|
||||
std::string blockHash = std::string(*blockHash_);
|
||||
|
||||
bool noBlockHash = false;
|
||||
if (blockHash.empty()) {
|
||||
blockHash = std::string("0x0000000000000000000000000000000000000000000000000000000000000000");
|
||||
noBlockHash = true;
|
||||
}
|
||||
|
||||
if (txHash[1] != 'x') {
|
||||
txHash = "0x" + txHash;
|
||||
}
|
||||
@ -910,9 +916,10 @@ NAN_METHOD(GetTx) {
|
||||
uint256 hash(txHash);
|
||||
uint256 hashBlock(blockHash);
|
||||
// uint256 hashBlock = 0;
|
||||
// if (noBlockHash) hashBlock = 0;
|
||||
CTransaction tx;
|
||||
|
||||
if (!GetTransaction(hash, tx, hashBlock, true)) {
|
||||
if (!GetTransaction(hash, tx, hashBlock, noBlockHash ? true : false)) {
|
||||
Local<Value> err = Exception::Error(String::New("Bad Transaction."));
|
||||
const unsigned argc = 1;
|
||||
Local<Value> argv[argc] = { err };
|
||||
|
||||
Loading…
Reference in New Issue
Block a user