Browse Source

Merge pull request #578 from bitcoinjs/coinbase

Add isCoinbase
hk-custom-address
Daniel Cousens 9 years ago
parent
commit
a3ec53e2d8
  1. 4
      src/transaction.js
  2. 15
      test/fixtures/transaction.json
  3. 10
      test/transaction.js

4
src/transaction.js

@ -87,6 +87,10 @@ Transaction.isCoinbaseHash = function (buffer) {
}) })
} }
Transaction.prototype.isCoinbase = function () {
return this.ins.length === 1 && Transaction.isCoinbaseHash(this.ins[0].hash)
}
var EMPTY_SCRIPT = new Buffer(0) var EMPTY_SCRIPT = new Buffer(0)
Transaction.prototype.addInput = function (hash, index, sequence, scriptSig) { Transaction.prototype.addInput = function (hash, index, sequence, scriptSig) {

15
test/fixtures/transaction.json

File diff suppressed because one or more lines are too long

10
test/transaction.js

@ -162,6 +162,16 @@ describe('Transaction', function () {
}) })
}) })
describe('isCoinbase', function () {
fixtures.valid.forEach(function (f) {
it('should return ' + f.coinbase + ' for ' + f.id, function () {
var tx = Transaction.fromHex(f.hex)
assert.strictEqual(tx.isCoinbase(), f.coinbase)
})
})
})
// TODO: // TODO:
// hashForSignature: [Function], // hashForSignature: [Function],
}) })

Loading…
Cancel
Save