43 std::promise<void> promise;
44 Txid txid = tx->GetHash();
45 uint256 wtxid = tx->GetWitnessHash();
46 bool callback_set =
false;
54 for (
size_t o = 0; o < tx->vout.size(); o++) {
61 if (
auto mempool_tx =
node.mempool->get(txid); mempool_tx) {
69 wtxid = mempool_tx->GetWitnessHash();
78 }
else if (result.
m_base_fees.value() > max_tx_fee) {
93 node.mempool->AddUnbroadcastTx(txid);
96 if (wait_callback &&
node.validation_signals) {
105 node.validation_signals->CallFunctionInValidationInterfaceQueue([&promise] {
116 promise.get_future().wait();
120 node.peerman->RelayTransaction(txid, wtxid);
128 if (mempool && !block_index) {
135 if (
g_txindex->FindTx(hash, block_hash, tx)) {
136 if (!block_index || block_index->
GetBlockHash() == block_hash) {
140 hashBlock = block_hash;
148 for (
const auto& tx : block.
vtx) {
149 if (tx->GetHash() == hash) {
int64_t CAmount
Amount in satoshis (Can be negative)
std::vector< CTransactionRef > vtx
The block chain is a tree shaped structure starting with the genesis block at the root,...
uint256 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.
An outpoint - a combination of a transaction hash and an index n into its vout.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
CTransactionRef get(const uint256 &hash) const
bool IsSpent() const
Either this coin never existed (see e.g.
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(NodeContext &node, const CTransactionRef tx, std::string &err_string, const CAmount &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 uint256 &hash, uint256 &hashBlock, const BlockManager &blockman)
Return transaction with a given hash.
static TransactionError HandleATMPError(const TxValidationState &state, std::string &err_string_out)
is a home for public enum and struct type definitions that are used by internally by node code,...
std::shared_ptr< const CTransaction > CTransactionRef
Validation result for a transaction evaluated by MemPoolAccept (single or package).
const ResultType m_result_type
Result type.
const std::optional< CAmount > m_base_fees
Raw base fees in satoshis.
const TxValidationState m_state
Contains information about why the transaction failed.
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.