|
|
@ -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) |
|
|
|