diff --git a/lib/bitcoind.js b/lib/bitcoind.js index 7560464c..4b48e2a7 100644 --- a/lib/bitcoind.js +++ b/lib/bitcoind.js @@ -342,6 +342,15 @@ function Transaction(data) { } }); + if (this.isCoinbase()) { + this.vin[0].txid = Array(64 + 1).join('0'); + this.vin[0].vout = 0; + this.vin[0].scriptSig = { + asm: null, + hex: this.vin[0].coinbase + }; + } + this.toHex(); } @@ -378,7 +387,7 @@ Transaction.prototype.computePriority = function() { }; Transaction.prototype.isCoinbase = function() { - ; + return this.vin.length === 1 && this.vin[0].coinbase; }; Transaction.prototype.equal = function() { @@ -422,9 +431,6 @@ Transaction.toBinary = function(tx) { off += utils.copy(s, p, off, true); off += utils.writeU32(p, input.sequence, off); - - // off += utils.copy(new bn(input.coinbase, 'hex').toArray(), p, off, true); - // off += utils.writeU32(p, input.sequence, off); } else { off += utils.copy(new bn(input.txid, 'hex').toArray(), p, off, true); off += utils.writeU32(p, input.vout, off);