Browse Source

payments: cleanup

addLowRGrinding
Daniel Cousens 6 years ago
parent
commit
3ed77c4820
  1. 7
      src/payments/p2pk.js
  2. 1
      src/payments/p2wpkh.js
  3. 2
      src/payments/p2wsh.js

7
src/payments/p2pk.js

@ -58,13 +58,10 @@ function p2pk (a, opts) {
// extended validation // extended validation
if (opts.validate) { 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) {
if (a.output[a.output.length - 1] !== OPS.OP_CHECKSIG) throw new TypeError('Output is invalid') 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 (!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) { if (a.signature) {
@ -73,7 +70,7 @@ function p2pk (a, opts) {
if (a.input) { if (a.input) {
if (_chunks().length !== 1) throw new TypeError('Input is invalid') 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')
} }
} }

1
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 (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().version !== 0x00) throw new TypeError('Invalid address version')
if (_address().data.length !== 20) throw new TypeError('Invalid address data') 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 hash = _address().data
} }

2
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().prefix !== network.bech32) throw new TypeError('Invalid prefix or Network mismatch')
if (_address().version !== 0x00) throw new TypeError('Invalid address version') if (_address().version !== 0x00) throw new TypeError('Invalid address version')
if (_address().data.length !== 32) throw new TypeError('Invalid address data') if (_address().data.length !== 32) throw new TypeError('Invalid address data')
else hash = _address().data hash = _address().data
} }
if (a.hash) { if (a.hash) {

Loading…
Cancel
Save