Fee Estimation Algorithm

The specific model a wallet uses to turn mempool data into a suggested fee rate.

Basically

Your wallet estimates the fee your Bitcoin transaction needs to be confirmed in time. It aims to balance speed against cost.

Key Takeaways

  • Fee estimation algorithms predict the fee rate your Bitcoin transaction needs to confirm within a target number of blocks, balancing speed against cost.
  • Two main approaches exist: historical estimators such as Bitcoin Core's CBlockPolicyEstimator track past confirmation data, while mempool-based estimators analyse the current queue of unconfirmed transactions in real time.
  • No estimator is perfect because the mempool is inherently unpredictable, so Replace-by-Fee (RBF) serves as a vital fallback when initial estimates prove too low.

What Is a Fee Estimation Algorithm?

A fee estimation algorithm is a method used by Bitcoin wallets and nodes to predict how much you should pay in transaction fees to get a transaction confirmed within a desired timeframe. Bitcoin blocks have limited space, so miners prioritise transactions offering higher fees per unit of block weight. The algorithm's job is to suggest a fee rate, measured in satoshis per virtual byte, that is high enough to achieve timely confirmation without dramatically overpaying.

Fee estimation is necessary because the Bitcoin fee market is a continuous auction. Demand for block space fluctuates constantly: during quiet periods a 1 sat/vB transaction might confirm in the next block, while during congestion even 50 sat/vB may not be enough. You would have to guess an appropriate fee manually without estimation, risking either overpayment or stuck transactions.

How It Works

Fee estimation algorithms fall into two broad families: historical (confirmation-based) estimators and mempool-based (queue-based) estimators. Many wallets and services combine elements of both.

Historical Estimation: Bitcoin Core's CBlockPolicyEstimator

Bitcoin Core's built-in estimator, CBlockPolicyEstimator, is the most widely deployed historical fee estimator. CBlockPolicyEstimator tracks how long transactions at various fee rates have historically taken to confirm rather than examining the current mempool. The algorithm works as follows:

Three Estimation Horizons

CBlockPolicyEstimator maintains three separate time horizons, each with its own decay rate. The horizons are listed below.

The multi-horizon approach lets the estimator balance responsiveness to recent conditions against the stability that comes from longer observation windows. The estimator can therefore respond to recent conditions without losing the benefit of longer observation windows.

Conservative vs. Economical Mode

Bitcoin Core's estimatesmartfee RPC offers two modes. The modes are listed below.

The estimator has one important limitation. The node must have been running and observing transactions for at least twice the requested confirmation target in blocks before the estimator can return an estimate.

Mempool-Based Estimation

Mempool-based estimators take a fundamentally different approach. They examine the current queue of unconfirmed transactions in the mempool and simulate what a miner would include in upcoming blocks instead of looking at historical confirmations.

The most widely used mempool-based estimator is mempool.space, which re-implements Bitcoin Core's transaction selection algorithm against the live mempool. It rebuilds projected blocks approximately every two seconds and returns fee rates for multiple confirmation tiers:

Mempool-based estimators react much faster to changing conditions. A mempool-based estimator immediately adjusts its recommendations upward when a large batch of high-fee transactions suddenly enters the mempool. A historical estimator, by contrast, would not reflect the change until those transactions start confirming, or failing to confirm at lower fee rates.

Blended Approaches

Some wallets and services combine both methods. The LN-Zap bitcoin-blended-fee-estimator project, for example, uses mempool.space data for near-term targets, meaning the next few blocks, where real-time accuracy matters most, and falls back to Bitcoin Core's historical estimator for longer confirmation horizons where the mempool's current state is less predictive.

Why Estimation Is Hard

Fee estimation is an inherently difficult prediction problem for several reasons. The reasons are set out below.

You can find a deeper analysis of how these dynamics play out in the research article on Bitcoin fee market dynamics. The article examines these dynamics in more detail.

Wallet Fee Selection

The most common use case is helping you choose an appropriate fee when sending Bitcoin. Most wallets present two or three tiers, such as fast, medium and economy, derived from a fee estimation algorithm. The coin selection algorithm then uses the chosen fee rate to construct the transaction.

Lightning Channel Management

Lightning Network nodes rely heavily on fee estimation for on-chain operations: opening channels, closing channels, especially force closes where timelocks create urgency, and posting anchor output fee bumps. Poor fee estimation can leave a channel close unconfirmed during a critical timelock window.

Exchange and Payment Processing

Exchanges processing thousands of withdrawals use fee estimation to balance user experience against cost. Many use transaction batching combined with conservative fee estimates and then bump fees via RBF if confirmation takes too long.

Layer 2 Protocols

Layer 2 systems like Spark benefit from advancements in fee estimation because they reduce users' exposure to on-chain fee volatility entirely. Moving transactions off-chain lets you avoid the fee estimation problem for routine payments while still relying on accurate estimates for the less frequent on-chain anchoring transactions. You can compare different fee estimation approaches in the research article on Bitcoin fee estimation algorithm comparison.

RBF as a Fee Estimation Safety Net

Replace-by-Fee (RBF) serves as a vital fallback mechanism because no estimation algorithm can perfectly predict fees. You can adopt a "start low, bump if needed" strategy rather than trying to guess the perfect fee upfront.

Bitcoin Core's bumpfee RPC automates this process. The replacement transaction must pay at least 1 sat/vB more than the original fee rate to satisfy relay rules. Newer Bitcoin Core versions can add inputs automatically when the original transaction's change output is insufficient to cover the bump.

Child-Pays-for-Parent (CPFP) offers an alternative when RBF is not available, for instance if the original transaction did not signal replaceability: the recipient creates a high-fee child transaction that spends an output of the stuck parent, incentivising miners to confirm both together. You can find a practical guide to both techniques in Bitcoin fee bumping: RBF and CPFP guide.

Overpayment

Conservative fee estimates protect against stuck transactions but can lead to significant overpayment, especially during quiet fee periods. Small overestimates add up over thousands of transactions. High-volume senders like exchanges find this particularly costly.

Stuck Transactions

Underestimation leaves transactions unconfirmed, potentially for hours or days during congestion events. RBF and CPFP provide remedies, but they add complexity and cost. Mempool eviction may drop transactions that fall below the minimum relay fee from mempools entirely.

Cold Start Problem

Historical estimators like Bitcoin Core's require a warm-up period: the node must observe enough transactions confirming at various fee rates before it can produce reliable estimates. A freshly started node returns no estimates until it has seen at least twice the target number of blocks. Lightweight or mobile clients typically rely on external fee estimation APIs instead, because historical estimation is impractical for them.

Manipulation

Fee estimators can theoretically be manipulated. An attacker could flood the mempool with high-fee transactions to inflate mempool-based estimates, or broadcast and then replace transactions to skew historical data. Bitcoin Core's use of exponential decay and multiple horizons provides some resistance to manipulation, but no estimator is immune.

The glossary entry is for informational purposes only and does not constitute financial or investment advice. You should always do your own research before using any protocol or technology.

0

← All 1876 glossary terms