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.
1// Copyright (c) 2024-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_POLICY_EPHEMERAL_POLICY_H6#define BITCOIN_POLICY_EPHEMERAL_POLICY_H8#include <consensus/amount.h>9#include <policy/packages.h>10#include <primitives/transaction.h>12#include <optional>14class CFeeRate;15class CTxMemPool;16class TxValidationState;18/** These utility functions ensure that ephemeral dust is safely19* created and spent without unduly risking them entering the utxo20* set.22* This is ensured by requiring:23* - PreCheckEphemeralTx checks are respected24* - The parent has no child (and 0-fee as implied above to disincentivize mining)25* - OR the parent transaction has exactly one child, and the dust is spent by that child26*27* Imagine three transactions:28* TxA, 0-fee with two outputs, one non-dust, one dust29* TxB, spends TxA's non-dust30* TxC, spends TxA's dust31*32* All the dust is spent if TxA+TxB+TxC is accepted, but the mining template may just pick33* up TxA+TxB rather than the three "legal configurations":34* 1) None35* 2) TxA+TxB+TxC36* 3) TxA+TxC37* By requiring the child transaction to sweep any dust from the parent txn, we ensure that38* there is a single child only, and this child, or the child's descendants,39* are the only way to bring fees.40*/42/* All the following checks are only called if standardness rules are being applied. */44/** Called for each transaction once transaction fees are known.45* Does context-less checks about a single transaction.46* @returns false if the fee is non-zero and dust exists, populating state. True otherwise.47*/48bool PreCheckEphemeralTx(const CTransaction& tx, CFeeRate dust_relay_rate, CAmount base_fee, CAmount mod_fee, TxValidationState& state);50/** Called for each transaction(package) if any dust is in the package.51* Checks that each transaction's parents have their dust spent by the child,52* where parents are either in the mempool or in the package itself.53* Sets out_child_state and out_child_wtxid on failure.54* @returns true if all dust is properly spent.55*/56bool CheckEphemeralSpends(const Package& package, CFeeRate dust_relay_rate, const CTxMemPool& tx_pool, TxValidationState& out_child_state, Wtxid& out_child_wtxid);58#endif // BITCOIN_POLICY_EPHEMERAL_POLICY_H