[#node-BroadcastTransaction] = xref:node.adoc[node]::BroadcastTransaction :relfileprefix: ../ :mrdocs: Submit a transaction to the mempool and (optionally) relay it to all P2P peers. == Synopsis Declared in `<node/transaction.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- [[nodiscard]] xref:node/TransactionError.adoc[TransactionError] BroadcastTransaction( xref:node/NodeContext.adoc[NodeContext]& node, xref:CTransactionRef.adoc[CTransactionRef] tx, std::string& err_string, xref:CAmount.adoc[CAmount] const& max_tx_fee, xref:node/TxBroadcast.adoc[TxBroadcast] broadcast_method, bool wait_callback); ---- == Description 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. == Return Value TransactionError::OK on success, or an error code describing why submission or broadcast failed. [NOTE] ==== The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^]. ==== == Parameters [cols="1,4"] |=== | 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. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#