Bitcoin Core 28.99.0
P2P Digital Currency
Functions
ephemeral_policy.cpp File Reference
#include <consensus/validation.h>
#include <policy/ephemeral_policy.h>
#include <policy/feerate.h>
#include <policy/packages.h>
#include <policy/policy.h>
#include <primitives/transaction.h>
#include <txmempool.h>
#include <util/check.h>
#include <util/hasher.h>
#include <algorithm>
#include <cstdint>
#include <map>
#include <memory>
#include <unordered_set>
#include <utility>
#include <vector>
Include dependency graph for ephemeral_policy.cpp:

Go to the source code of this file.

Functions

bool PreCheckEphemeralTx (const CTransaction &tx, CFeeRate dust_relay_rate, CAmount base_fee, CAmount mod_fee, TxValidationState &state)
 These utility functions ensure that ephemeral dust is safely created and spent without unduly risking them entering the utxo set. More...
 
bool CheckEphemeralSpends (const Package &package, CFeeRate dust_relay_rate, const CTxMemPool &tx_pool, TxValidationState &out_child_state, Txid &out_child_txid)
 Must be called for each transaction(package) if any dust is in the package. More...
 

Function Documentation

◆ CheckEphemeralSpends()

bool CheckEphemeralSpends ( const Package package,
CFeeRate  dust_relay_rate,
const CTxMemPool tx_pool,
TxValidationState out_child_state,
Txid out_child_txid 
)

Must be called for each transaction(package) if any dust is in the package.

Checks that each transaction's parents have their dust spent by the child, where parents are either in the mempool or in the package itself. Sets out_child_state and out_child_txid on failure.

Returns
true if all dust is properly spent.

Definition at line 33 of file ephemeral_policy.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PreCheckEphemeralTx()

bool PreCheckEphemeralTx ( const CTransaction tx,
CFeeRate  dust_relay_rate,
CAmount  base_fee,
CAmount  mod_fee,
TxValidationState state 
)

These utility functions ensure that ephemeral dust is safely created and spent without unduly risking them entering the utxo set.

This is ensured by requiring:

  • PreCheckEphemeralTx checks are respected
  • The parent has no child (and 0-fee as implied above to disincentivize mining)
  • OR the parent transaction has exactly one child, and the dust is spent by that child

Imagine three transactions: TxA, 0-fee with two outputs, one non-dust, one dust TxB, spends TxA's non-dust TxC, spends TxA's dust

All the dust is spent if TxA+TxB+TxC is accepted, but the mining template may just pick up TxA+TxB rather than the three "legal configurations": 1) None 2) TxA+TxB+TxC 3) TxA+TxC By requiring the child transaction to sweep any dust from the parent txn, we ensure that there is a single child only, and this child, or the child's descendants, are the only way to bring fees. Must be called for each transaction once transaction fees are known. Does context-less checks about a single transaction.

Returns
false if the fee is non-zero and dust exists, populating state. True otherwise.

Definition at line 23 of file ephemeral_policy.cpp.

Here is the call graph for this function: