25 std::string &err_string_out) {
39 std::string &err_string,
40 const Amount max_tx_fee,
bool relay,
50 std::promise<void> promise;
51 TxId txid = tx->GetId();
52 bool callback_set =
false;
60 for (
size_t o = 0; o < tx->vout.size(); o++) {
70 if (!
node.mempool->exists(txid)) {
76 node.chainman->ProcessTransaction(tx,
true);
80 }
else if (result.
m_base_fees.value() > max_tx_fee) {
86 node.chainman->ProcessTransaction(tx,
false);
97 node.mempool->AddUnbroadcastTx(txid);
110 [&promise] { promise.set_value(); });
119 promise.get_future().wait();
123 node.peerman->RelayTransaction(txid);
133 if (mempool && !block_index) {
142 if (
g_txindex->FindTx(txid, block_hash, tx)) {
143 if (!block_index || block_index->
GetBlockHash() == block_hash) {
148 hashBlock = block_hash;
156 for (
const auto &tx : block.
vtx) {
157 if (tx->GetId() == txid) {
std::vector< CTransactionRef > vtx
The block chain is a tree shaped structure starting with the genesis block at the root,...
BlockHash GetBlockHash() const
CCoinsView that adds a memory cache for transactions to another CCoinsView.
const Coin & AccessCoin(const COutPoint &output) const
Return a reference to Coin in the cache, or coinEmpty if not found.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
CTransactionRef get(const TxId &txid) const
std::string ToString() const
Maintains a tree of blocks (stored in m_block_index) which is consulted to determine where the most-w...
bool ReadBlockFromDisk(CBlock &block, const FlatFilePos &pos) const
Functions for disk access for blocks.
@ TX_MISSING_INPUTS
transaction was missing some of its inputs
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
TransactionError BroadcastTransaction(const NodeContext &node, const CTransactionRef tx, std::string &err_string, const Amount max_tx_fee, bool relay, bool wait_callback)
Submit a transaction to the mempool and (optionally) relay it to all P2P peers.
CTransactionRef GetTransaction(const CBlockIndex *const block_index, const CTxMemPool *const mempool, const TxId &txid, BlockHash &hashBlock, const BlockManager &blockman)
Return transaction with a given txid.
static TransactionError HandleATMPError(const TxValidationState &state, std::string &err_string_out)
std::shared_ptr< const CTransaction > CTransactionRef
static constexpr Amount zero() noexcept
A BlockHash is a unqiue identifier for a block.
Validation result for a transaction evaluated by MemPoolAccept (single or package).
const ResultType m_result_type
Result type.
const TxValidationState m_state
Contains information about why the transaction failed.
@ VALID
Fully validated, valid.
const std::optional< Amount > m_base_fees
Raw base fees in satoshis.
A TxId is the identifier of a transaction.
NodeContext struct containing references to chain state and connection state.
std::unique_ptr< TxIndex > g_txindex
The global transaction index, used in GetTransaction. May be null.
void CallFunctionInValidationInterfaceQueue(std::function< void()> func)
Pushes a function to callback onto the notification queue, guaranteeing any callbacks generated prior...