Fix some small bugs

This commit is contained in:
junderw 2018-12-29 17:02:32 +09:00
parent 293116b20f
commit 912d6d41be
No known key found for this signature in database
GPG key ID: B256185D3A971908
3 changed files with 17 additions and 3 deletions

View file

@ -129,7 +129,7 @@ function p2ms (a, opts) {
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 (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')
}
}

View file

@ -217,7 +217,7 @@ function expandOutput (script, ourPubKey) {
return { type }
}
function prepareInput (input, ourPubKey, redeemScript, witnessValue, witnessScript) {
function prepareInput (input, ourPubKey, redeemScript, witnessScript) {
if (redeemScript && witnessScript) {
const p2wsh = payments.p2wsh({ redeem: { output: witnessScript } })
const p2wshAlt = payments.p2wsh({ output: redeemScript })
@ -665,7 +665,7 @@ TransactionBuilder.prototype.sign = function (vin, keyPair, redeemScript, hashTy
}
if (!canSign(input)) {
const prepared = prepareInput(input, ourPubKey, redeemScript, witnessValue, witnessScript)
const prepared = prepareInput(input, ourPubKey, redeemScript, witnessScript)
// updates inline
Object.assign(input, prepared)

View file

@ -310,6 +310,20 @@
]
}
},
{
"exception": "Signature mismatch",
"arguments": {
"m": 1,
"pubkeys": [
"030000000000000000000000000000000000000000000000000000000000000001",
"030000000000000000000000000000000000000000000000000000000000000001"
],
"signatures": [
"300602010002010001"
],
"input": "OP_0 300602010002010101"
}
},
{
"exception": "Too many signatures provided",
"arguments": {