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