Skip to content

Commit 7554b1f

Browse files
committed
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.)
1 parent 4395b7f commit 7554b1f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/rpc/mempool.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -839,15 +839,16 @@ static RPCHelpMan submitpackage()
839839
NONFATAL_UNREACHABLE();
840840
}
841841
}
842+
size_t num_broadcast{0};
842843
for (const auto& tx : txns) {
843-
size_t num_submitted{0};
844844
std::string err_string;
845-
const auto err = BroadcastTransaction(node, tx, err_string, 0, true, true);
845+
const auto err = BroadcastTransaction(node, tx, err_string, /*max_tx_fee=*/0, /*relay=*/true, /*wait_callback=*/true);
846846
if (err != TransactionError::OK) {
847847
throw JSONRPCTransactionError(err,
848848
strprintf("transaction broadcast failed: %s (all transactions were submitted, %d transactions were broadcast successfully)",
849-
err_string, num_submitted));
849+
err_string, num_broadcast));
850850
}
851+
num_broadcast++;
851852
}
852853
UniValue rpc_result{UniValue::VOBJ};
853854
UniValue tx_result_map{UniValue::VOBJ};

0 commit comments

Comments
 (0)