Skip to content

Commit 30d0f7b

Browse files
committed
rpc: Fix for segfault if combinepsbt called with empty inputs
1 parent e508535 commit 30d0f7b

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/rpc/rawtransaction.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,6 +1514,9 @@ UniValue combinepsbt(const JSONRPCRequest& request)
15141514
// Unserialize the transactions
15151515
std::vector<PartiallySignedTransaction> psbtxs;
15161516
UniValue txs = request.params[0].get_array();
1517+
if (txs.empty()) {
1518+
throw JSONRPCError(RPC_INVALID_PARAMETER, "Parameter 'txs' cannot be empty");
1519+
}
15171520
for (unsigned int i = 0; i < txs.size(); ++i) {
15181521
PartiallySignedTransaction psbtx;
15191522
std::string error;

test/functional/rpc_psbt.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ def run_test(self):
269269
combined = self.nodes[2].combinepsbt(combiner['combine'])
270270
assert_equal(combined, combiner['result'])
271271

272+
# Empty combiner test
273+
assert_raises_rpc_error(-8, "Parameter 'txs' cannot be empty", self.nodes[0].combinepsbt, [])
274+
272275
# Finalizer test
273276
for finalizer in finalizers:
274277
finalized = self.nodes[2].finalizepsbt(finalizer['finalize'], False)['psbt']

0 commit comments

Comments
 (0)