always set nSequence to zero when nLockTime is present.

This commit is contained in:
Christopher Jeffrey 2015-12-17 18:33:02 -08:00
parent 1e0a153b59
commit 135208910d

View File

@ -23,6 +23,7 @@ function TX(data, block) {
this._hash = null;
this._raw = data._raw || null;
this._network = data._network || false;
this._lock = this.lock;
if (data.inputs) {
data.inputs.forEach(function(input) {
@ -101,16 +102,18 @@ TX.prototype._input = function _input(i, index) {
var prev = input.out.tx.outputs[input.out.index].script;
var lock = bcoin.script.lockTime(prev);
if (lock) {
// this.lock = Math.max(lock.toNumber(), this.lock);
if (this.lock === 0)
this.lock = lock.toNumber();
if (this._lock === 0)
this.lock = Math.max(lock.toNumber(), this.lock);
if (!bcoin.script.spendable(this, this.lock))
throw new Error('Cannot spend ' + utils.revHex(input.out.hash));
if (input.seq === 0xffffffff)
input.seq = 0;
}
}
if (this.lock !== 0) {
if (i.seq === undefined)
input.seq = 0;
}
// Try modifying existing input first
var index = this._inputIndex(hash, index);
if (index !== -1) {