TxBuilder: fix undefined scriptSig
Fixed and typeForce used to enforce this wont happen again in future.
This commit is contained in:
parent
3a371fccec
commit
a788214921
2 changed files with 11 additions and 5 deletions
|
@ -308,6 +308,9 @@ Transaction.prototype.toHex = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Transaction.prototype.setInputScript = function(index, script) {
|
Transaction.prototype.setInputScript = function(index, script) {
|
||||||
|
typeForce('Number', index)
|
||||||
|
typeForce('Script', script)
|
||||||
|
|
||||||
this.ins[index].script = script
|
this.ins[index].script = script
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -249,12 +249,15 @@ TransactionBuilder.prototype.__build = function(allowIncomplete) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we built a scriptSig, wrap as scriptHash if necessary
|
// did we build a scriptSig?
|
||||||
if (scriptSig && input.prevOutType === 'scripthash') {
|
if (scriptSig) {
|
||||||
|
// wrap as scriptHash if necessary
|
||||||
|
if (input.prevOutType === 'scripthash') {
|
||||||
scriptSig = scripts.scriptHashInput(scriptSig, input.redeemScript)
|
scriptSig = scripts.scriptHashInput(scriptSig, input.redeemScript)
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.setInputScript(index, scriptSig)
|
tx.setInputScript(index, scriptSig)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return tx
|
return tx
|
||||||
|
|
Loading…
Reference in a new issue