Merge pull request #1307 from bitcoinjs/bugFixes

Fix some small bugs
This commit is contained in:
Jonathan Underwood 2018-12-29 21:42:12 +09:00 committed by GitHub
commit 46c1991efa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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": {