diff options
author | fanquake <fanquake@gmail.com> | 2019-07-07 12:06:09 +0800 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2019-07-07 12:15:32 +0800 |
commit | 1fb747a8007caa922b29a69408c2152ba5575db5 (patch) | |
tree | 19521d4709f7340c41d927062244773ef4afd86b | |
parent | 629c7b029cf934932be3699da592cfbe6e146f8a (diff) | |
parent | 1dc357dabbd843da02d15316c55d63c566414069 (diff) | |
download | bitcoin-1fb747a8007caa922b29a69408c2152ba5575db5.tar.xz |
Merge #16342: 0.18 backport: report error when missing redeemScript/witnessScript
1dc357dab signrawtransactionwithkey: report error when missing redeemScript/witnessScript param (Anthony Towns)
Pull request description:
Backport of #16250 which fixes regression introduced in 0.18 in relation to signrawtransactionwithkey error handling (see #16249).
Tree-SHA512: 0d75fa2aa578b886ace3bda92a02e25993f9f51d41db8c0eb3013bd77d266c45ad8b67dd0ed11c66533724f892be4e254edeb59fa70585ff762f522791fcca36
-rw-r--r-- | src/rpc/rawtransaction.cpp | 3 | ||||
-rwxr-xr-x | test/functional/rpc_createmultisig.py | 5 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index ae4fed285a..c79ac45b01 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -886,6 +886,9 @@ UniValue SignTransaction(interfaces::Chain& chain, CMutableTransaction& mtx, con // 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"); + } } } } diff --git a/test/functional/rpc_createmultisig.py b/test/functional/rpc_createmultisig.py index 1f717f59d0..a4dabc8739 100755 --- a/test/functional/rpc_createmultisig.py +++ b/test/functional/rpc_createmultisig.py @@ -129,6 +129,11 @@ class RpcCreateMultiSigTest(BitcoinTestFramework): outval = value - decimal.Decimal("0.00001000") rawtx = node2.createrawtransaction([{"txid": txid, "vout": vout}], [{self.final: outval}]) + prevtx_err = dict(prevtxs[0]) + del prevtx_err["redeemScript"] + + assert_raises_rpc_error(-8, "Missing redeemScript/witnessScript", node2.signrawtransactionwithkey, rawtx, self.priv[0:self.nsigs-1], [prevtx_err]) + rawtx2 = node2.signrawtransactionwithkey(rawtx, self.priv[0:self.nsigs - 1], prevtxs) rawtx3 = node2.signrawtransactionwithkey(rawtx2["hex"], [self.priv[-1]], prevtxs) |