Browse Source

tests: add independent error message for missing witnessScript

hk-custom-address
Daniel Cousens 7 years ago
parent
commit
098188dd3a
  1. 7
      src/transaction_builder.js
  2. 22
      test/fixtures/transaction_builder.json

7
src/transaction_builder.js

@ -332,11 +332,14 @@ function prepareInput (input, kpPubKey, redeemScript, witnessValue, witnessScrip
signScript = witnessScript signScript = witnessScript
} else if (input.prevOutType) { } else if (input.prevOutType) {
// embedded scripts are not possible without a redeemScript // embedded scripts are not possible without a redeemScript
if (input.prevOutType === scriptTypes.P2SH || if (input.prevOutType === scriptTypes.P2SH) {
input.prevOutType === scriptTypes.P2WSH) {
throw new Error('PrevOutScript is ' + input.prevOutType + ', requires redeemScript') throw new Error('PrevOutScript is ' + input.prevOutType + ', requires redeemScript')
} }
if (input.prevOutType === scriptTypes.P2WSH) {
throw new Error('PrevOutScript is ' + input.prevOutType + ', requires witnessScript')
}
prevOutType = input.prevOutType prevOutType = input.prevOutType
prevOutScript = input.prevOutScript prevOutScript = input.prevOutScript
expanded = expandOutput(input.prevOutScript, input.prevOutType, kpPubKey) expanded = expandOutput(input.prevOutScript, input.prevOutType, kpPubKey)

22
test/fixtures/transaction_builder.json

@ -1966,6 +1966,28 @@
} }
] ]
}, },
{
"exception": "PrevOutScript is witnessscripthash, requires witnessScript",
"inputs": [
{
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"vout": 1,
"prevTxScript": "OP_0 0f9ea7bae7166c980169059e39443ed13324495b0d6678ce716262e879591210",
"signs": [
{
"keyPair": "KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn",
"throws": true
}
]
}
],
"outputs": [
{
"script": "OP_DUP OP_HASH160 aa4d7985c57e011a8b3dd8e0e5a73aaef41629c5 OP_EQUALVERIFY OP_CHECKSIG",
"value": 1000
}
]
},
{ {
"exception": "Inconsistent redeemScript", "exception": "Inconsistent redeemScript",
"network": "testnet", "network": "testnet",

Loading…
Cancel
Save