Inside Bitcoin
Opening the selected file…
Inside Bitcoin
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.
502// Remember all added transactions503std::set<CTransactionRef> added;504auto txr = std::make_shared<TransactionsDelta>(added);505node.validation_signals->RegisterSharedValidationInterface(txr);507// When there are multiple transactions in the package, we call ProcessNewPackage(txs, test_accept=false)508// and AcceptToMemoryPool(txs.back(), test_accept=true). When there is only 1 transaction, we might flip it509// (the package is a test accept and ATMP is a submission).510auto single_submit = txs.size() == 1 && fuzzed_data_provider.ConsumeBool();512// Exercise client_maxfeerate logic513std::optional<CFeeRate> client_maxfeerate{};514if (fuzzed_data_provider.ConsumeBool()) {515client_maxfeerate = CFeeRate(fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(-1, 50 * COIN), 100);516}518const auto result_package = WITH_LOCK(::cs_main,519return ProcessNewPackage(chainstate, tx_pool, txs, /*test_accept=*/single_submit, client_maxfeerate));521// Always set bypass_limits to false because it is not supported in ProcessNewPackage and522// can be a source of divergence.523const auto res = WITH_LOCK(::cs_main, return AcceptToMemoryPool(chainstate, txs.back(), GetTime(),524/*bypass_limits=*/false, /*test_accept=*/!single_submit));525const bool passed = res.m_result_type == MempoolAcceptResult::ResultType::VALID;527node.validation_signals->SyncWithValidationInterfaceQueue();528node.validation_signals->UnregisterSharedValidationInterface(txr);530// There is only 1 transaction in the package. We did a test-package-accept and a ATMP531if (single_submit) {532Assert(passed != added.empty());533Assert(passed == res.m_state.IsValid());534if (passed) {535Assert(added.size() == 1);536Assert(txs.back() == *added.begin());537}538} else if (result_package.m_state.GetResult() != PackageValidationResult::PCKG_POLICY) {539// We don't know anything about the validity since transactions were randomly generated, so540// just use result_package.m_state here. This makes the expect_valid check meaningless, but541// we can still verify that the contents of m_tx_results are consistent with m_state.542const bool expect_valid{result_package.m_state.IsValid()};543Assert(!CheckPackageMempoolAcceptResult(txs, result_package, expect_valid, &tx_pool));544} else {545// This is empty if it fails early checks, or "full" if transactions are looked at deeper546Assert(result_package.m_tx_results.size() == txs.size() || result_package.m_tx_results.empty());547}549CheckMempoolTRUCInvariants(tx_pool);551// Dust checks only make sense when dust is enforced552if (tx_pool.m_opts.require_standard) {553CheckMempoolEphemeralInvariants(tx_pool);554}555}557node.validation_signals->UnregisterSharedValidationInterface(outpoints_updater);559WITH_LOCK(::cs_main, tx_pool.check(chainstate.CoinsTip(), chainstate.m_chain.Height() + 1));560}561} // namespace
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.