aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2019-07-02 17:20:58 -0400
committerMarcoFalke <falke.marco@gmail.com>2019-07-02 17:21:02 -0400
commite06067387e758e86f82b126867338faeb6220de7 (patch)
tree19bc10f3da6d1920209e99639b93f58356abb107 /src
parent4db2f8cf0f63cf2a130e238d59f5b6032420f83d (diff)
parent01174596e69568c434198a86f54cb9ea6740e6c2 (diff)
downloadbitcoin-e06067387e758e86f82b126867338faeb6220de7.tar.xz
Merge #16250: signrawtransactionwithkey: report error when missing redeemScript/witnessScript
01174596e69568c434198a86f54cb9ea6740e6c2 signrawtransactionwithkey: report error when missing redeemScript/witnessScript param (Anthony Towns) Pull request description: Adding support for "witnessScript" as an alternative to "redeemScript" when using "signrawtransactionwithkey" meant that the `RPCTypeCheckObj()` call in `SignTransaction` can't error out just because either parameter is missing -- it's only a problem if both are missing, which isn't a state `RPCTypeCheckObj()` tests for. This results in the regression described in #16249. This patch adds some code to test for this case and give a similar error, namely: error code: -8 error message: Missing redeemScript/witnessScript Fixes: #16249 ACKs for top commit: meshcollider: utACK https://github.com/bitcoin/bitcoin/pull/16250/commits/01174596e69568c434198a86f54cb9ea6740e6c2 promag: ACK 01174596e. Could also write test without `dict`/`del`: Tree-SHA512: cf51346b7dea551b7f18f2a93c2a336a293b2535c62c03a5263cd2be8c58cf0cc302891da659c167e88ad1a68a756472c3c07e99f71627c61d32886fc5a3a353
Diffstat (limited to 'src')
-rw-r--r--src/rpc/rawtransaction_util.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/rpc/rawtransaction_util.cpp b/src/rpc/rawtransaction_util.cpp
index 9c4cdc3a90..14fcb628eb 100644
--- a/src/rpc/rawtransaction_util.cpp
+++ b/src/rpc/rawtransaction_util.cpp
@@ -221,6 +221,9 @@ UniValue SignTransaction(CMutableTransaction& mtx, const UniValue& prevTxsUnival
// Automatically also add the P2WSH wrapped version of the script (to deal with P2SH-P2WSH).
keystore->AddCScript(GetScriptForWitness(witnessScript));
}
+ if (rs.isNull() && ws.isNull()) {
+ throw JSONRPCError(RPC_INVALID_PARAMETER, "Missing redeemScript/witnessScript");
+ }
}
}
}