Browse Source

payments/p2wpkh: fix exception messages

addLowRGrinding
Daniel Cousens 7 years ago
parent
commit
0d9619aeed
  1. 6
      src/payments/p2wpkh.js
  2. 10
      test/fixtures/p2wpkh.json

6
src/payments/p2wpkh.js

@ -118,9 +118,9 @@ function p2wpkh (a, opts) {
}
if (a.witness) {
if (a.witness.length !== 2) throw new TypeError('Input is invalid')
if (!bscript.isCanonicalScriptSignature(a.witness[0])) throw new TypeError('Input has invalid signature')
if (!ecc.isPoint(a.witness[1])) throw new TypeError('Input has invalid pubkey')
if (a.witness.length !== 2) throw new TypeError('Witness is invalid')
if (!bscript.isCanonicalScriptSignature(a.witness[0])) throw new TypeError('Witness has invalid signature')
if (!ecc.isPoint(a.witness[1])) throw new TypeError('Witness has invalid pubkey')
if (a.signature && !a.signature.equals(a.witness[0])) throw new TypeError('Signature mismatch')
if (a.pubkey && !a.pubkey.equals(a.witness[1])) throw new TypeError('Pubkey mismatch')

10
test/fixtures/p2wpkh.json

@ -148,7 +148,13 @@
}
},
{
"exception": "Input has invalid signature",
"exception": "Witness is invalid",
"arguments": {
"witness": []
}
},
{
"exception": "Witness has invalid signature",
"arguments": {
"witness": [
"ffffffffffffffffff",
@ -157,7 +163,7 @@
}
},
{
"exception": "Input has invalid pubkey",
"exception": "Witness has invalid pubkey",
"arguments": {
"witness": [
"300602010002010001",

Loading…
Cancel
Save