enforce checklocktimeverify for nLockTime when adding input. tx.prevOut method.
This commit is contained in:
parent
aac4911b4e
commit
7f70b573c1
@ -97,6 +97,20 @@ TX.prototype._input = function _input(i, index) {
|
|||||||
seq: i.seq === undefined ? 0xffffffff : i.seq
|
seq: i.seq === undefined ? 0xffffffff : i.seq
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (input.out.tx) {
|
||||||
|
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 (!bcoin.script.spendable(this, this.lock))
|
||||||
|
// throw new Error('Cannot spend ' + utils.revHex(input.out.hash));
|
||||||
|
if (input.seq === 0xffffffff)
|
||||||
|
input.seq = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Try modifying existing input first
|
// Try modifying existing input first
|
||||||
var index = this._inputIndex(hash, index);
|
var index = this._inputIndex(hash, index);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
@ -125,6 +139,18 @@ TX.prototype._inputIndex = function _inputIndex(hash, index) {
|
|||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TX.prototype.prevOut = function prevOut(i, def) {
|
||||||
|
if (typeof i === 'object')
|
||||||
|
i = this.inputs.indexOf(i);
|
||||||
|
|
||||||
|
var input = this.inputs[i];
|
||||||
|
|
||||||
|
if (!input || !input.out.tx || input.out.index == null)
|
||||||
|
return def;
|
||||||
|
|
||||||
|
return input.out.tx.outputs[input.out.index] || def;
|
||||||
|
};
|
||||||
|
|
||||||
TX.prototype.signatureHash = function signatureHash(i, type) {
|
TX.prototype.signatureHash = function signatureHash(i, type) {
|
||||||
if (typeof i === 'object')
|
if (typeof i === 'object')
|
||||||
i = this.inputs.indexOf(i);
|
i = this.inputs.indexOf(i);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user