Inside Bitcoin
Opening the selected file…
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2017-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#ifndef BITCOIN_NODE_TRANSACTION_H6#define BITCOIN_NODE_TRANSACTION_H8#include <common/messages.h>9#include <node/types.h>10#include <policy/feerate.h>11#include <primitives/transaction.h>13class CBlockIndex;14class CTxMemPool;15namespace Consensus {16struct Params;17}19namespace node {20class BlockManager;21struct NodeContext;23/** Maximum fee rate for sendrawtransaction and testmempoolaccept RPC calls.24* Also used by the GUI when broadcasting a completed PSBT.25* By default, a transaction with a fee rate higher than this will be rejected26* by these RPCs and the GUI. This can be overridden with the maxfeerate argument.27*/28inline constexpr CFeeRate DEFAULT_MAX_RAW_TX_FEE_RATE{COIN / 10};30/** Maximum burn value for sendrawtransaction, submitpackage, and testmempoolaccept RPC calls.31* By default, a transaction with a burn value higher than this will be rejected32* by these RPCs and the GUI. This can be overridden with the maxburnamount argument.33*/34inline constexpr CAmount DEFAULT_MAX_BURN_AMOUNT{0};36/**37* Submit a transaction to the mempool and (optionally) relay it to all P2P peers.38*39* Mempool submission can be synchronous (will await mempool entry notification40* over the CValidationInterface) or asynchronous (will submit and not wait for41* notification), depending on the value of wait_callback. wait_callback MUST42* NOT be set while cs_main, cs_mempool or cs_wallet are held to avoid43* deadlock.44*45* @param[in] node reference to node context46* @param[in] tx the transaction to broadcast47* @param[out] err_string reference to std::string to fill with error string if available48* @param[in] max_tx_fee reject txs with fees higher than this (if 0, accept any fee)49* @param[in] broadcast_method whether to add the transaction to the mempool and how to broadcast it50* @param[in] wait_callback wait until callbacks have been processed to avoid stale result due to a sequentially RPC.51* return error52*/53[[nodiscard]] TransactionError BroadcastTransaction(NodeContext& node,54CTransactionRef tx,55std::string& err_string,56const CAmount& max_tx_fee,57TxBroadcast broadcast_method,58bool wait_callback);60/**61* Return transaction with a given hash.62* If mempool is provided and block_index is not provided, check it first for the tx.63* If -txindex is available, check it next for the tx.64* Finally, if block_index is provided, check for tx by reading entire block from disk.65*66* @param[in] block_index The block to read from disk, or nullptr67* @param[in] mempool If provided, check mempool for tx68* @param[in] hash The txid69* @param[in] blockman Used to access and read blocks from disk70* @param[out] hashBlock The block hash, if the tx was found via -txindex or block_index71* @returns The tx if found, otherwise nullptr72*/73CTransactionRef GetTransaction(const CBlockIndex* block_index, const CTxMemPool* mempool, const Txid& hash, const BlockManager& blockman, uint256& hashBlock);74} // namespace node76#endif // BITCOIN_NODE_TRANSACTION_H