mtx: add setSequence.

This commit is contained in:
Christopher Jeffrey 2016-08-29 15:01:19 -07:00
parent 17487bfcf6
commit 5a41c04bfd
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -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