Submit a transaction to the mempool and (optionally) relay it to all P2P peers.
Declared in <node/transaction.h>
[[nodiscard]]
TransactionError
BroadcastTransaction(
NodeContext& node,
CTransactionRef tx,
std::string& err_string,
CAmount const& max_tx_fee,
TxBroadcast broadcast_method,
bool wait_callback);
Mempool submission can be synchronous (will await mempool entry notification over the CValidationInterface) or asynchronous (will submit and not wait for notification), depending on the value of wait_callback. wait_callback MUST NOT be set while cs_main, cs_mempool or cs_wallet are held to avoid deadlock.
TransactionError::OK on success, or an error code describing why submission or broadcast failed.
The return value should not be discarded.
| Name | Description |
|---|---|
| node [in] | reference to node context |
| tx [in] | the transaction to broadcast |
| err_string [out] | reference to std::string to fill with error string if available |
| max_tx_fee [in] | reject txs with fees higher than this (if 0, accept any fee) |
| broadcast_method [in] | whether to add the transaction to the mempool and how to broadcast it |
| wait_callback [in] | wait until callbacks have been processed to avoid stale result due to a sequentially RPC. |