mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
rpc: Fix for segfault if combinepsbt called with empty inputs
This commit is contained in:
parent
e50853501b
commit
30d0f7be6e
@ -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;
|
||||
|
@ -269,6 +269,9 @@ class PSBTTest(BitcoinTestFramework):
|
||||
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']
|
||||
|
Loading…
Reference in New Issue
Block a user