aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2020-03-31 13:36:34 -0400
committerAndrew Chow <achow101-github@achow101.com>2020-03-31 18:41:52 -0400
commitcd3b1569d9ad8e24d3a222aff74e0c254baadf79 (patch)
tree6571f3e20d4c9055f1f60f70ae72012a50978aa0 /src
parentd52ba21dfff99173abb927bc964ce7ceb711d789 (diff)
Correctly compute redeemScript from witnessScript for signrawtransaction
ParsePrevouts uses GetScriptForWitness on the given witnessScript to find the corresponding redeemScript. This is incorrect when the witnessScript is either a P2PK or P2PKH script as it returns the corresponding P2WPK script instead of turning the witnessScript into a P2WSH script. Instead this should make the script a WitnessV0ScriptHash destination and get the script for that. Test cases are also added.
Diffstat (limited to 'src')
-rw-r--r--src/rpc/rawtransaction_util.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/rpc/rawtransaction_util.cpp b/src/rpc/rawtransaction_util.cpp
index 54baec6c6f..7b701a2bbe 100644
--- a/src/rpc/rawtransaction_util.cpp
+++ b/src/rpc/rawtransaction_util.cpp
@@ -216,7 +216,7 @@ void ParsePrevouts(const UniValue& prevTxsUnival, FillableSigningProvider* keyst
keystore->AddCScript(script);
// Automatically also add the P2WSH wrapped version of the script (to deal with P2SH-P2WSH).
// This is done for redeemScript only for compatibility, it is encouraged to use the explicit witnessScript field instead.
- CScript witness_output_script{GetScriptForWitness(script)};
+ CScript witness_output_script{GetScriptForDestination(WitnessV0ScriptHash(script))};
keystore->AddCScript(witness_output_script);
if (!ws.isNull() && !rs.isNull()) {