diff --git a/lib/bcoin/tx.js b/lib/bcoin/tx.js index 0ec82892..07721581 100644 --- a/lib/bcoin/tx.js +++ b/lib/bcoin/tx.js @@ -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) {