Skip to content

Commit 0117459

Browse files
committed
signrawtransactionwithkey: report error when missing redeemScript/witnessScript param
1 parent 413e438 commit 0117459

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/rpc/rawtransaction_util.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ UniValue SignTransaction(CMutableTransaction& mtx, const UniValue& prevTxsUnival
221221
// Automatically also add the P2WSH wrapped version of the script (to deal with P2SH-P2WSH).
222222
keystore->AddCScript(GetScriptForWitness(witnessScript));
223223
}
224+
if (rs.isNull() && ws.isNull()) {
225+
throw JSONRPCError(RPC_INVALID_PARAMETER, "Missing redeemScript/witnessScript");
226+
}
224227
}
225228
}
226229
}

test/functional/rpc_createmultisig.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ def do_multisig(self):
101101
outval = value - decimal.Decimal("0.00001000")
102102
rawtx = node2.createrawtransaction([{"txid": txid, "vout": vout}], [{self.final: outval}])
103103

104+
prevtx_err = dict(prevtxs[0])
105+
del prevtx_err["redeemScript"]
106+
107+
assert_raises_rpc_error(-8, "Missing redeemScript/witnessScript", node2.signrawtransactionwithkey, rawtx, self.priv[0:self.nsigs-1], [prevtx_err])
108+
104109
rawtx2 = node2.signrawtransactionwithkey(rawtx, self.priv[0:self.nsigs - 1], prevtxs)
105110
rawtx3 = node2.signrawtransactionwithkey(rawtx2["hex"], [self.priv[-1]], prevtxs)
106111

0 commit comments

Comments
 (0)