Skip to content

Commit

Permalink
rpc: Fix for segfault if combinepsbt called with empty inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Feb 5, 2019
1 parent e508535 commit 30d0f7b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/rpc/rawtransaction.cpp
Expand Up @@ -1514,6 +1514,9 @@ UniValue combinepsbt(const JSONRPCRequest& request)
// Unserialize the transactions
std::vector<PartiallySignedTransaction> psbtxs;
UniValue txs = request.params[0].get_array();
if (txs.empty()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Parameter 'txs' cannot be empty");
}
for (unsigned int i = 0; i < txs.size(); ++i) {
PartiallySignedTransaction psbtx;
std::string error;
Expand Down
3 changes: 3 additions & 0 deletions test/functional/rpc_psbt.py
Expand Up @@ -269,6 +269,9 @@ def run_test(self):
combined = self.nodes[2].combinepsbt(combiner['combine'])
assert_equal(combined, combiner['result'])

# Empty combiner test
assert_raises_rpc_error(-8, "Parameter 'txs' cannot be empty", self.nodes[0].combinepsbt, [])

# Finalizer test
for finalizer in finalizers:
finalized = self.nodes[2].finalizepsbt(finalizer['finalize'], False)['psbt']
Expand Down

0 comments on commit 30d0f7b

Please sign in to comment.