diff --git a/src/payments/p2pk.js b/src/payments/p2pk.js index 9e12749..5f65030 100644 --- a/src/payments/p2pk.js +++ b/src/payments/p2pk.js @@ -58,13 +58,10 @@ function p2pk (a, opts) { // extended validation if (opts.validate) { - if (a.pubkey && a.output) { - if (!a.pubkey.equals(o.pubkey)) throw new TypeError('Pubkey mismatch') - } - if (a.output) { if (a.output[a.output.length - 1] !== OPS.OP_CHECKSIG) throw new TypeError('Output is invalid') if (!ecc.isPoint(o.pubkey)) throw new TypeError('Output pubkey is invalid') + if (a.pubkey && !a.pubkey.equals(o.pubkey)) throw new TypeError('Pubkey mismatch') } if (a.signature) { @@ -73,7 +70,7 @@ function p2pk (a, opts) { if (a.input) { if (_chunks().length !== 1) throw new TypeError('Input is invalid') - if (!bscript.isCanonicalScriptSignature(_chunks()[0])) throw new TypeError('Input has invalid signature') + if (!bscript.isCanonicalScriptSignature(o.signature)) throw new TypeError('Input has invalid signature') } } diff --git a/src/payments/p2wpkh.js b/src/payments/p2wpkh.js index ba42ba1..c47c354 100644 --- a/src/payments/p2wpkh.js +++ b/src/payments/p2wpkh.js @@ -93,7 +93,6 @@ function p2wpkh (a, opts) { if (network && network.bech32 !== _address().prefix) throw new TypeError('Invalid prefix or Network mismatch') if (_address().version !== 0x00) throw new TypeError('Invalid address version') if (_address().data.length !== 20) throw new TypeError('Invalid address data') - // if (hash && !hash.equals(_address().data)) throw new TypeError('Hash mismatch') hash = _address().data } diff --git a/src/payments/p2wsh.js b/src/payments/p2wsh.js index c84d822..8c45022 100644 --- a/src/payments/p2wsh.js +++ b/src/payments/p2wsh.js @@ -122,7 +122,7 @@ function p2wsh (a, opts) { if (_address().prefix !== network.bech32) throw new TypeError('Invalid prefix or Network mismatch') if (_address().version !== 0x00) throw new TypeError('Invalid address version') if (_address().data.length !== 32) throw new TypeError('Invalid address data') - else hash = _address().data + hash = _address().data } if (a.hash) {