Fix some small bugs
This commit is contained in:
parent
293116b20f
commit
912d6d41be
3 changed files with 17 additions and 3 deletions
|
@ -129,7 +129,7 @@ function p2ms (a, opts) {
|
||||||
if (a.input[0] !== OPS.OP_0) throw new TypeError('Input is invalid')
|
if (a.input[0] !== OPS.OP_0) throw new TypeError('Input is invalid')
|
||||||
if (o.signatures.length === 0 || !o.signatures.every(isAcceptableSignature)) throw new TypeError('Input has invalid signature(s)')
|
if (o.signatures.length === 0 || !o.signatures.every(isAcceptableSignature)) throw new TypeError('Input has invalid signature(s)')
|
||||||
|
|
||||||
if (a.signatures && !stacksEqual(a.signatures.equals(o.signatures))) throw new TypeError('Signature mismatch')
|
if (a.signatures && !stacksEqual(a.signatures, o.signatures)) throw new TypeError('Signature mismatch')
|
||||||
if (a.m !== undefined && a.m !== a.signatures.length) throw new TypeError('Signature count mismatch')
|
if (a.m !== undefined && a.m !== a.signatures.length) throw new TypeError('Signature count mismatch')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,7 +217,7 @@ function expandOutput (script, ourPubKey) {
|
||||||
return { type }
|
return { type }
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareInput (input, ourPubKey, redeemScript, witnessValue, witnessScript) {
|
function prepareInput (input, ourPubKey, redeemScript, witnessScript) {
|
||||||
if (redeemScript && witnessScript) {
|
if (redeemScript && witnessScript) {
|
||||||
const p2wsh = payments.p2wsh({ redeem: { output: witnessScript } })
|
const p2wsh = payments.p2wsh({ redeem: { output: witnessScript } })
|
||||||
const p2wshAlt = payments.p2wsh({ output: redeemScript })
|
const p2wshAlt = payments.p2wsh({ output: redeemScript })
|
||||||
|
@ -665,7 +665,7 @@ TransactionBuilder.prototype.sign = function (vin, keyPair, redeemScript, hashTy
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!canSign(input)) {
|
if (!canSign(input)) {
|
||||||
const prepared = prepareInput(input, ourPubKey, redeemScript, witnessValue, witnessScript)
|
const prepared = prepareInput(input, ourPubKey, redeemScript, witnessScript)
|
||||||
|
|
||||||
// updates inline
|
// updates inline
|
||||||
Object.assign(input, prepared)
|
Object.assign(input, prepared)
|
||||||
|
|
14
test/fixtures/p2ms.json
vendored
14
test/fixtures/p2ms.json
vendored
|
@ -310,6 +310,20 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"exception": "Signature mismatch",
|
||||||
|
"arguments": {
|
||||||
|
"m": 1,
|
||||||
|
"pubkeys": [
|
||||||
|
"030000000000000000000000000000000000000000000000000000000000000001",
|
||||||
|
"030000000000000000000000000000000000000000000000000000000000000001"
|
||||||
|
],
|
||||||
|
"signatures": [
|
||||||
|
"300602010002010001"
|
||||||
|
],
|
||||||
|
"input": "OP_0 300602010002010101"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"exception": "Too many signatures provided",
|
"exception": "Too many signatures provided",
|
||||||
"arguments": {
|
"arguments": {
|
||||||
|
|
Loading…
Reference in a new issue