payments/p2wpkh: fix exception messages

This commit is contained in:
Daniel Cousens 2018-07-14 20:13:50 +10:00
parent 35e0956ed9
commit 0d9619aeed
2 changed files with 11 additions and 5 deletions

View file

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

View file

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