diff --git a/lib/primitives/mtx.js b/lib/primitives/mtx.js index 676bfca3..d6d19c5b 100644 --- a/lib/primitives/mtx.js +++ b/lib/primitives/mtx.js @@ -1497,6 +1497,30 @@ MTX.prototype.setLocktime = function setLocktime(locktime) { this.locktime = locktime; }; +/** + * Set sequence locktime. + * @param {Number} index - Input index. + * @param {Number} locktime + * @param {Boolean?} seconds + */ + +MTX.prototype.setSequence = function setSequence(index, locktime, seconds) { + var input = this.inputs[index]; + + assert(input, 'Input does not exist.'); + + this.version = 2; + + if (seconds) { + locktime >>>= constants.sequence.GRANULARITY; + locktime = constants.sequence.TYPE_FLAG | locktime; + } else { + locktime = constants.sequence.MASK & locktime; + } + + input.sequence = locktime; +}; + /** * Mark inputs and outputs as mutable. * @private