txb: add fixes for P2SH(P2WSH(...)) and P2WSH(...) in BIP143 compliance
This commit is contained in:
parent
39a681d2d3
commit
7be698b5a1
1 changed files with 6 additions and 2 deletions
|
@ -708,8 +708,12 @@ TransactionBuilder.prototype.sign = function (vin, keyPair, redeemScript, hashTy
|
|||
var signed = input.pubKeys.some(function (pubKey, i) {
|
||||
if (!kpPubKey.equals(pubKey)) return false
|
||||
if (input.signatures[i]) throw new Error('Signature already exists')
|
||||
if (kpPubKey.length !== 33 &&
|
||||
input.signType === scriptTypes.P2WPKH) throw new Error('BIP143 rejects uncompressed public keys in P2WPKH or P2WSH')
|
||||
|
||||
if (kpPubKey.length !== 33 && (
|
||||
input.signType === scriptTypes.P2WPKH ||
|
||||
input.redeemScriptType === scriptTypes.P2WSH ||
|
||||
input.prevOutType === scriptTypes.P2WSH
|
||||
)) throw new Error('BIP143 rejects uncompressed public keys in P2WPKH or P2WSH')
|
||||
|
||||
var signature = keyPair.sign(signatureHash)
|
||||
if (Buffer.isBuffer(signature)) signature = ECSignature.fromRSBuffer(signature)
|
||||
|
|
Loading…
Reference in a new issue