rpc: Fix for segfault if combinepsbt called with empty inputs
This commit is contained in:
parent
e50853501b
commit
30d0f7be6e
2 changed files with 6 additions and 0 deletions
|
@ -1514,6 +1514,9 @@ UniValue combinepsbt(const JSONRPCRequest& request)
|
||||||
// Unserialize the transactions
|
// Unserialize the transactions
|
||||||
std::vector<PartiallySignedTransaction> psbtxs;
|
std::vector<PartiallySignedTransaction> psbtxs;
|
||||||
UniValue txs = request.params[0].get_array();
|
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) {
|
for (unsigned int i = 0; i < txs.size(); ++i) {
|
||||||
PartiallySignedTransaction psbtx;
|
PartiallySignedTransaction psbtx;
|
||||||
std::string error;
|
std::string error;
|
||||||
|
|
|
@ -269,6 +269,9 @@ class PSBTTest(BitcoinTestFramework):
|
||||||
combined = self.nodes[2].combinepsbt(combiner['combine'])
|
combined = self.nodes[2].combinepsbt(combiner['combine'])
|
||||||
assert_equal(combined, combiner['result'])
|
assert_equal(combined, combiner['result'])
|
||||||
|
|
||||||
|
# Empty combiner test
|
||||||
|
assert_raises_rpc_error(-8, "Parameter 'txs' cannot be empty", self.nodes[0].combinepsbt, [])
|
||||||
|
|
||||||
# Finalizer test
|
# Finalizer test
|
||||||
for finalizer in finalizers:
|
for finalizer in finalizers:
|
||||||
finalized = self.nodes[2].finalizepsbt(finalizer['finalize'], False)['psbt']
|
finalized = self.nodes[2].finalizepsbt(finalizer['finalize'], False)['psbt']
|
||||||
|
|
Loading…
Reference in a new issue