Merge pull request #18 from matiu/bug/TX-ID-64496d005faee77ac5a18866f50af6b8dd1f60107d6795df34c402747af98608
fix issue with strange TX -- good!
This commit is contained in:
commit
a5b9df2aff
|
@ -66,7 +66,7 @@ module.exports = function(grunt) {
|
||||||
options: {
|
options: {
|
||||||
file: 'server.js',
|
file: 'server.js',
|
||||||
args: [],
|
args: [],
|
||||||
ignoredFiles: ['public/**', 'test/**'],
|
ignoredFiles: ['public/**', 'test/**','util/**'],
|
||||||
watchedExtensions: ['js'],
|
watchedExtensions: ['js'],
|
||||||
// nodeArgs: ['--debug'],
|
// nodeArgs: ['--debug'],
|
||||||
delayTime: 1,
|
delayTime: 1,
|
||||||
|
|
|
@ -171,11 +171,14 @@ TransactionSchema.methods.queryInfo = function (next) {
|
||||||
|
|
||||||
var scriptSig = i.getScript();
|
var scriptSig = i.getScript();
|
||||||
var pubKey = scriptSig.simpleInPubKey();
|
var pubKey = scriptSig.simpleInPubKey();
|
||||||
var pubKeyHash = util.sha256ripe160(pubKey);
|
|
||||||
var addr = new Address(network.addressPubkey, pubKeyHash);
|
|
||||||
var addrStr = addr.toString();
|
|
||||||
|
|
||||||
that.info.vin[c].addr = addrStr;
|
// We check for pubKey in case a broken / strange TX.
|
||||||
|
if (pubKey) {
|
||||||
|
var pubKeyHash = util.sha256ripe160(pubKey);
|
||||||
|
var addr = new Address(network.addressPubkey, pubKeyHash);
|
||||||
|
var addrStr = addr.toString();
|
||||||
|
that.info.vin[c].addr = addrStr;
|
||||||
|
}
|
||||||
|
|
||||||
c++;
|
c++;
|
||||||
});
|
});
|
||||||
|
|
|
@ -49,7 +49,7 @@ describe('Transaction fromIdWithInfo', function(){
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('test a coinbase TX', function(done) {
|
it('test a coinbase TX 2a104bab1782e9b6445583296d4a0ecc8af304e4769ceb64b890e8219c562399', function(done) {
|
||||||
var test_txid2 = '2a104bab1782e9b6445583296d4a0ecc8af304e4769ceb64b890e8219c562399';
|
var test_txid2 = '2a104bab1782e9b6445583296d4a0ecc8af304e4769ceb64b890e8219c562399';
|
||||||
Transaction.fromIdWithInfo(test_txid2, function(err, tx) {
|
Transaction.fromIdWithInfo(test_txid2, function(err, tx) {
|
||||||
if (err) done(err);
|
if (err) done(err);
|
||||||
|
@ -60,5 +60,17 @@ describe('Transaction fromIdWithInfo', function(){
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it('test a broken TX 64496d005faee77ac5a18866f50af6b8dd1f60107d6795df34c402747af98608', function(done) {
|
||||||
|
var test_txid2 = '64496d005faee77ac5a18866f50af6b8dd1f60107d6795df34c402747af98608';
|
||||||
|
Transaction.fromIdWithInfo(test_txid2, function(err, tx) {
|
||||||
|
if (err) done(err);
|
||||||
|
assert.equal(tx.info.txid, test_txid2);
|
||||||
|
assert.equal(tx.info.vin[0].addr, null);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue