aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorSebastian Falbesoner <sebastian.falbesoner@gmail.com>2023-02-20 00:34:48 +0100
committerSebastian Falbesoner <sebastian.falbesoner@gmail.com>2023-02-20 00:34:48 +0100
commit7554b1fd663fe2010edb0e8a93ab85a6cb10a323 (patch)
treea0020f9e106c13e7875fdf6318d68633be1c861f /src/rpc
parent4395b7f0845d2dca60f3b4e007ef5770ce8e2aa9 (diff)
rpc: fix successful broadcast count in `submitpackage` error msg
If a `submitpackage` RPC call errors due to any of the individual tx broadcasts failing, the returned error message is supposed to contain the number of successful broadcasts so far. Right now this is wrongly always shown as zero. Fix this by adding the missing counting. (Note though that the error should be really rare, as all txs have already been submitted succesfully to the mempool.)
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/mempool.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/rpc/mempool.cpp b/src/rpc/mempool.cpp
index 44f7435a26..3143434633 100644
--- a/src/rpc/mempool.cpp
+++ b/src/rpc/mempool.cpp
@@ -839,15 +839,16 @@ static RPCHelpMan submitpackage()
NONFATAL_UNREACHABLE();
}
}
+ size_t num_broadcast{0};
for (const auto& tx : txns) {
- size_t num_submitted{0};
std::string err_string;
- const auto err = BroadcastTransaction(node, tx, err_string, 0, true, true);
+ const auto err = BroadcastTransaction(node, tx, err_string, /*max_tx_fee=*/0, /*relay=*/true, /*wait_callback=*/true);
if (err != TransactionError::OK) {
throw JSONRPCTransactionError(err,
strprintf("transaction broadcast failed: %s (all transactions were submitted, %d transactions were broadcast successfully)",
- err_string, num_submitted));
+ err_string, num_broadcast));
}
+ num_broadcast++;
}
UniValue rpc_result{UniValue::VOBJ};
UniValue tx_result_map{UniValue::VOBJ};