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# Package Mempool Accept3## Definitions5A **package** is an ordered list of transactions, representable by a connected Directed Acyclic6Graph (a directed edge exists between a transaction that spends the output of another transaction).8For every transaction `t` in a **topologically sorted** package, if any of its parents are present9in the package, they appear somewhere in the list before `t`.11A **child-with-parents** package is a topologically sorted package that consists of exactly one child and at least one12of its unconfirmed parents. Not all unconfirmed parents need to be present but no other transactions may be present; the13parent of a parent should not be in this package (unless this "grandparent" is also a direct parent of the child).15## Package Mempool Acceptance Rules17The following rules are enforced for all packages:19* Packages cannot exceed `MAX_PACKAGE_COUNT=25` count and `MAX_PACKAGE_WEIGHT=404000` total weight20(#20833)22- *Rationale*: We want package size to be as small as possible to mitigate DoS via package23validation. However, we want to make sure that the limit does not restrict ancestor24packages that would be allowed if submitted individually.26- Note that, if these mempool limits change, package limits should be reconsidered. Users may27also configure their mempool limits differently.29- Note that this is transaction weight, not "virtual" size as with other limits to allow30simpler context-less checks.32* Packages must be topologically sorted. (#20833)34* Packages cannot have conflicting transactions, i.e. no two transactions in a package can spend35the same inputs. Packages cannot have duplicate transactions. (#20833)37* Only limited package replacements are currently considered. (#28984)39- Packages are 1-parent-1-child, with no in-mempool ancestors of the package.41- The number of distinct clusters containing conflicting transactions can be no more than 100, analogous to42regular [replacement rule](./mempool-replacements.md) 5).44- Replacements must pay more total fees at the incremental relay fee (analogous to45regular [replacement rules](./mempool-replacements.md) 3 and 4).47- Parent feerate must be lower than package feerate.49- Must improve [feerate diagram](https://delvingbitcoin.org/t/mempool-incentive-compatibility/553). (#29242)51- *Rationale*: Basic support for package RBF can be used by wallets52by making chains of no longer than two, then directly conflicting53those chains when needed. Combined with TRUC transactions this can54result in more robust fee bumping. More general package RBF may be55enabled in the future.57The following rules are only enforced for packages to be submitted to the mempool (not58enforced for test accepts):60* Packages must be child-with-parents packages. This also means packages must contain at61least 1 transaction. (#31096)63- *Rationale*: This allows for fee-bumping by CPFP. Allowing multiple parents makes it possible64to fee-bump a batch of transactions. Restricting packages to a defined topology is easier to65reason about and simplifies the validation logic greatly.67- Warning: Batched fee-bumping may be unsafe for some use cases. Users and application developers68should take caution if utilizing multi-parent packages.70* Transactions in the package that have the same txid as another transaction already in the mempool71will be removed from the package prior to submission ("deduplication").73- *Rationale*: Node operators are free to set their mempool policies however they please, nodes74may receive transactions in different orders, and malicious counterparties may try to take75advantage of policy differences to pin or delay propagation of transactions. As such, it's76possible for some package transaction(s) to already be in the mempool, and there is no need to77repeat validation for those transactions or double-count them in fees.79- *Rationale*: We want to prevent potential censorship vectors. We should not reject entire80packages because we already have one of the transactions. Also, if an attacker first broadcasts81a competing package or transaction with a mutated witness, even though the two82same-txid-different-witness transactions are conflicting and cannot replace each other, the83honest package should still be considered for acceptance.85### Package Fees and Feerate87*Package Feerate* is the total modified fees (base fees + any fee delta from88`prioritisetransaction`) divided by the total virtual size of all transactions in the package.89If any transactions in the package are already in the mempool, they are not submitted again90("deduplicated") and are thus excluded from this calculation.92To meet the dynamic mempool minimum feerate, i.e., the feerate determined by the transactions93evicted when the mempool reaches capacity (not the static minimum relay feerate), the total package94feerate instead of individual feerate can be used. For example, if the mempool minimum feerate is955sat/vB and a 1sat/vB parent transaction has a high-feerate child, it may be accepted if96submitted as a package.98*Rationale*: This can be thought of as "CPFP within a package," solving the issue of a presigned99transaction (i.e. in which a replacement transaction with a higher fee cannot be signed) being100rejected from the mempool when transaction volume is high and the mempool minimum feerate rises.102Implementation Note: Transactions within a package are always validated individually first, and103package validation is used for the transactions that failed. Since package feerate is only104calculated using transactions that are not in the mempool, this implementation detail affects the105outcome of package validation.107*Rationale*: It would be incorrect to use the fees of transactions that are already in the mempool, as108we do not want a transaction's fees to be double-counted.110*Rationale*: Packages are intended for incentive-compatible fee-bumping: transaction B is a111"legitimate" fee-bump for transaction A only if B is a descendant of A and has a *higher* feerate112than A. We want to prevent "parents pay for children" behavior; fees of parents should not help113their children, since the parents can be mined without the child. More generally, if transaction A114is not needed in order for transaction B to be mined, A's fees cannot help B. In a115child-with-parents package, simply excluding any parent transactions that meet feerate requirements116individually is sufficient to ensure this.118*Rationale*: We must not allow a low-feerate child to prevent its parent from being accepted; fees119of children should not negatively impact their parents, since they are not necessary for the parents120to be mined. More generally, if transaction B is not needed in order for transaction A to be mined,121B's fees cannot harm A. In a child-with-parents package, simply validating parents individually122first is sufficient to ensure this.124*Rationale*: As a principle, we want to avoid accidentally restricting policy in order to be125backward-compatible for users and applications that rely on p2p transaction relay. Concretely,126package validation should not prevent the acceptance of a transaction that would otherwise be127policy-valid on its own. By always accepting a transaction that passes individual validation before128trying package validation, we prevent any unintentional restriction of policy.
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.