omit feeds + valueIn in coinbase TXs

This commit is contained in:
Matias Alejo Garcia 2014-01-09 18:35:14 -03:00
parent 50485ce18e
commit 4de5c5dd00
2 changed files with 8 additions and 2 deletions

View File

@ -187,9 +187,12 @@ TransactionSchema.methods.queryInfo = function (next) {
valueOut = valueOut.add(n); valueOut = valueOut.add(n);
}); });
that.info.valueIn = valueIn / util.COIN;
that.info.valueOut = valueOut / util.COIN; that.info.valueOut = valueOut / util.COIN;
if ( !tx.isCoinBase() ) {
that.info.valueIn = valueIn / util.COIN;
that.info.feeds = (valueIn - valueOut) / util.COIN; that.info.feeds = (valueIn - valueOut) / util.COIN;
}
that.info.size = b.length; that.info.size = b.length;

View File

@ -30,6 +30,7 @@ describe('Transaction fromIdWithInfo', function(){
Transaction.fromIdWithInfo(test_txid, function(err, tx) { Transaction.fromIdWithInfo(test_txid, function(err, tx) {
if (err) done(err); if (err) done(err);
assert.equal(tx.txid, test_txid); assert.equal(tx.txid, test_txid);
assert(!tx.info.isCoinBase);
done(); done();
}); });
}); });
@ -43,6 +44,7 @@ describe('Transaction fromIdWithInfo', function(){
assert.equal(tx.info.valueOut, 1.66174); assert.equal(tx.info.valueOut, 1.66174);
assert.equal(tx.info.feeds, 0.0005 ); assert.equal(tx.info.feeds, 0.0005 );
assert.equal(tx.info.size, 226 ); assert.equal(tx.info.size, 226 );
assert(!tx.info.isCoinBase);
done(); done();
}); });
}); });
@ -53,6 +55,7 @@ describe('Transaction fromIdWithInfo', function(){
if (err) done(err); if (err) done(err);
assert(tx.info.isCoinBase); assert(tx.info.isCoinBase);
assert.equal(tx.info.txid, test_txid2); assert.equal(tx.info.txid, test_txid2);
assert(!tx.info.feeds);
done(); done();
}); });
}); });