算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
bitcoin-rbf-cpfp【设计与创意】Replace-by-Fee (BIP125, full-RBF) and Child-Pays-For-Parent fee bumping. Cluster mempool policy (Core 31.0+), package CPFP via submitpackage, TRUC v3 (BIP431). Wallet-level fee bump strategies. USE WHEN: implementing fee bumping, debugging "stuck transaction", designing wallet UX for fee acceleration.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
See also ../../protocol/transactions/quick-ref/rbf-cpfp.md for protocol-level details. This SKILL.md focuses on wallet implementation.
1. Build initial tx with sequence 0xfffffffd on every input (the
BIP125 opt-in signal, and the ecosystem-majority value — see
"nSequence is a fingerprint" below). Under full-RBF policy this
does not decide replaceability; it is an anti-fingerprinting
default.
2. Sign and broadcast.
3. After N blocks of non-confirmation OR explicit user request:
a. Estimate new fee rate.
b. Build replacement: same outputs, possibly different change
amount (smaller, since more goes to fee).
c. Verify the replacement rules: pays more than the sum of the
replaced fees, plus incrementalrelayfee × vsize.
d. Sign and broadcast.
4. Old tx is dropped from mempool; new tx awaits confirmation.
Core's policy has drifted away from BIP125; the live specification is
doc/policy/mempool-replacements.md, not the BIP. For replacement R
of original set O (the directly conflicting txs plus their in-mempool
descendants), as of Bitcoin Core 31.1 (July 2026) — numbered as in
that doc:
3. R pays an absolute fee at least the sum paid by O.
4. R pays for its own bandwidth: the fee delta is at least
incrementalrelayfee × R.vsize (the default dropped from
1 sat/vB to 0.1 sat/vB in Core 30.0, October 2025).
5. R conflicts with at most 100 distinct clusters.
6. R strictly improves the mempool's feerate diagram. For a
singleton — a tx alone in its cluster — a higher fee and a
higher feerate is sufficient.
Rules 1 and 2 are both marked "(Removed)" in that doc. Rule 1 was the opt-in signalling requirement; rule 2 was "no new unconfirmed inputs", dropped in Core 31.0 (April 2026), so a replacement may now spend unconfirmed outputs the original did not. Rule 6 was, before 31.0, the Core 0.12 constraint that R beat the feerate of every directly conflicting tx; the feerate-diagram form replaced it with cluster mempool.
Bitcoin Core 28.0 made full-RBF the default — even txs without
opt-in signal (sequence ≥ 0xfffffffe) can be replaced. Core 29.0 then
removed the -mempoolfullrbf opt-out entirely (PR #30592), so as of
Bitcoin Core 31.1 (July 2026) a default-policy node replaces any
transaction regardless of its nSequence values.
Because default-policy nodes ignore the signal, the nSequence value a
wallet picks no longer controls replaceability — it mainly identifies
the wallet that built the transaction. rkrux opened Bitcoin Core #35405
in May 2026 to stop the Core wallet signalling by default, using MAX-1
(0xfffffffe, where MAX is 0xffffffff), and took the question —
should wallets converge on a single value? — to bitcoin-dev in June
2026. Murch and Electrum contributor SomberNight objected: MAX-2
(0xfffffffd) is already the dominant value — roughly 75–78% of
transactions as of June 2026 (mainnet-observer, as read by Optech #410
and by the #35405 thread), and nearly all Electrum transactions — so
moving Core to a non-signalling MAX-1 would make Core txs stand out
rather than blend in. rkrux closed the PR in light of that feedback;
Core's wallet default is unchanged (DEFAULT_WALLET_RBF = true,
emitting MAX_BIP125_RBF_SEQUENCE = 0xfffffffd) as of September 2026.
Practical rule: emit 0xfffffffd on every input unless you need
nSequence for a BIP68 relative timelock. Choosing a distinctive value
to "opt out" of replacement buys nothing under full-RBF policy and
costs privacy.
Core 31.0 (April 2026) reimplemented the mempool as a cluster
mempool. Ancestor and descendant count/size limits are no longer
enforced. In their place, a cluster — any set of mempool transactions
connected through parent/child relationships — is capped at 64
transactions and 101 kB of virtual size. Both limits are overridable
from the command line (see -help-debug). Wallets that budgeted chain
depth against the pre-31.0 defaults (25 ancestors, 25 descendants,
101 kvB each) must budget against the cluster instead.
Within the mempool, transactions are ordered by chunk feerate — the
feerate of the set that would be mined together, e.g. a parent and its
child. That ordering drives block template selection, eviction and relay
announcement, and it is what makes CPFP work. New in 31.0:
getmempoolcluster and getmempoolfeeratediagram; getmempoolentry
now also reports chunk size and chunk fees.
The CPFP carveout — one extra child, at most 10 kvB with exactly one ancestor, allowed past the descendant limit — was removed in 31.0. Nothing bypasses the cluster count limit; TRUC plus sibling eviction is the replacement mechanism for those use cases.
User-facing controls:
When sender's tx is stuck and CPFP is the only option (e.g., tx is non-RBF or is from someone else):
1. Identify a UTXO from the stuck tx that you control (your change
output, or a received output).
2. Build a child tx spending that UTXO.
3. Compute child fee such that:
package_fee_rate = (parent_fee + child_fee) / (parent_vsize + child_vsize)
≥ target_rate
4. Broadcast child via submitpackage (Core 26.0+, December 2023), or
via sendrawtransaction and rely on opportunistic 1p1c relay
(Core 28.0+).
If you're the receiver of an unconfirmed payment that's stuck:
submitpackage)submitpackage RPC accepts a [parent, child] array atomically; it
landed in Bitcoin Core 26.0 (December 2023). Before it, a child alone
was rejected if the parent was below mempool min. Now the package
effective rate is computed.
This is Core's own RPC, not an implementation of BIP331. BIP331
("Ancestor Package Relay") is still Status: Draft as of September 2026
and its sendpackages / pkgtxns P2P messages do not exist in Core
31.1. What Core relays over P2P is a narrower, opportunistic
1-parent-1-child (1p1c) scheme carried on the existing transaction
relay protocol: added in 28.0 (October 2024), and widened in 31.0
(April 2026) so the parent of a non-TRUC 1p1c package may also pay below
-minrelaytxfee, even 0 fee.
bitcoin-cli submitpackage '["<parent_hex>","<child_hex>"]'
Strict version=3 transactions for Lightning-style use:
Combined with ephemeral anchors (value=0 anchor outputs that must be spent in the same package), gives non-pinnable Lightning fee bumping.
LSP and self-custodial Lightning wallets implement these via:
chantools transient-fee-bumper (legacy) or built-in fee
bumping for anchor channels.feebumper plugin or core support.OnchainTxHandler orchestrates child txs.size instead of vsize → underpays
for SegWit txs.0xffffffff or 0xfffffffe believing it makes
the tx non-replaceable → it does not (full-RBF), and it marks the
transaction as coming from a minority wallet.