Skip to content

Instantly share code, notes, and snippets.

View michaelfolkson's full-sized avatar

Michael Folkson michaelfolkson

View GitHub Profile
@morcos
morcos / FeeEstimationHighLevel.md
Last active June 14, 2023 10:57
Bitcoin Core Fee Estimation Algorithm
View FeeEstimationHighLevel.md

High level description Bitcoin Core's fee estimation algorithm

The algorithm takes as input a target which represents a number of blocks within which you would like your transaction to be included in the blockchain. It returns a fee rate that you should use on your transaction in order to achieve this.

The algorithm is conceptually very simple and does not attempt to have any predictive power over future conditions. It only looks at some recent history of transactions and returns the lowest fee rate such that in that recent history a very high fraction of transactions with that fee rate were confirmed in the block chain in less than the target number of blocks.

Transactions can occur with a nearly continuous range of fee rates and so in order to avoid tracking every historical transaction independently, they are grouped into fee rate "buckets". A fee rate bucket represents a range of fee rates within which the algorithm treats all transactions as having approximately the same fee rate and the answer th