signrawtransactionwithkey: report error when missing redeemScript/witnessScript param

Github-Pull: #16250
Rebased-From: 01174596e6
This commit is contained in:
Anthony Towns
2019-06-20 21:36:45 +10:00
parent 629c7b029c
commit 1dc357dabb
2 changed files with 8 additions and 0 deletions

View File

@@ -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). // Automatically also add the P2WSH wrapped version of the script (to deal with P2SH-P2WSH).
keystore->AddCScript(GetScriptForWitness(witnessScript)); keystore->AddCScript(GetScriptForWitness(witnessScript));
} }
if (rs.isNull() && ws.isNull()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Missing redeemScript/witnessScript");
}
} }
} }
} }

View File

@@ -129,6 +129,11 @@ class RpcCreateMultiSigTest(BitcoinTestFramework):
outval = value - decimal.Decimal("0.00001000") outval = value - decimal.Decimal("0.00001000")
rawtx = node2.createrawtransaction([{"txid": txid, "vout": vout}], [{self.final: outval}]) 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) rawtx2 = node2.signrawtransactionwithkey(rawtx, self.priv[0:self.nsigs - 1], prevtxs)
rawtx3 = node2.signrawtransactionwithkey(rawtx2["hex"], [self.priv[-1]], prevtxs) rawtx3 = node2.signrawtransactionwithkey(rawtx2["hex"], [self.priv[-1]], prevtxs)