Mastering Bitcoin
Citation. Andreas M. Antonopoulos and David A. Harding. Mastering Bitcoin: Programming the Open Blockchain, 3rd edition. O'Reilly, November 2023. ISBN 978-1-098-15009-9. The text is open at github.com/bitcoinbook/bitcoinbook. The 1st edition (2014) was by Antonopoulos alone. No funding is stated. A mismatch in the licence: the repository's LICENSE gives the third edition's first print the Creative Commons Attribution-ShareAlike 4.0 licence. The README says CC BY-NC-ND, and the preface says "CC-BY-NC". The copyright year is 2023 in LICENSE and 2024 on the copyright page.
Status. Planned. Crypto is one of the project's markets. The book sets out what on-chain data mean and when they are final, and what a transfer costs and how long it takes. The cost model (#9) and any on-chain feature need both. No code in the repo uses it.
Read. Read on 2026-11-28 from the book's AsciiDoc source, at commit 275c4eb of 26 December 2024, through a subagent. It read these chapters in full: fees (9), the blockchain (11), mining (12), security (13) and the preface. It read the parts of chapters 6 (transactions), 10 (the network) and 14 (payment channels) that bear on the issue's questions. It also read the whitepaper's calculations in Appendix A. The text dates from mid-2023: it says block 800,000 "was reached during the writing of this book". I checked the quotes below against the source.
Summary
Claim. A technical guide to how Bitcoin works. It covers keys and wallets, transactions and scripts, fees, the peer-to-peer network, the blockchain, mining and consensus, security and payment channels. It explains the rules as Bitcoin Core implements them in 2023.
Method. Explanation with worked examples, code and commands run against Bitcoin Core. No data analysis.
Findings, as the source reports them.
| Setting | Number | Value |
|---|---|---|
| Block subsidy | at the start, and how often it halves | 50 BTC, every 210,000 blocks |
| Halvings | dates | November 2012, July 2016, May 2020, and block 840,000 expected in "April or May of 2024" |
| Total supply | in satoshis | "almost 2,099,999,997,690,000", near 21 million BTC, in about 2140 |
| Difficulty | retarget interval, and the largest change | every 2,016 blocks, a factor of 4 |
| Block timestamps | allowed range | after the median of the last 11 blocks, and no more than two hours ahead |
| Blocks | mean interval | 10 minutes |
| A coinbase output | blocks before it can be spent | 100 |
| A large payment | confirmations to wait | "at least six" |
| A hashrate attack | share of hash rate it can need | "as little as 30%" |
The authors write that a fee is "much more like a bid in an auction", not an amount that the protocol or a miner sets. They write that "Forks are almost always resolved within one block". On custody, they write that keys are "equivalent to possession of cash … users have no recourse within the protocol".
Where the claims go beyond the evidence
Finality has no number in the main text. "Six confirmations" is a convention, stated three ways ("more than six", "at least six", and "six or more" in the glossary). The only probability is in the reproduced whitepaper: an attacker with 10% of the hash rate catches up from six blocks behind with probability 0.0002428. The book gives no data on how often real reorganisations happen or how deep they go.
Nothing on prices, labels or forked coins. The book says nothing on how markets priced the halvings, and nothing on labelling addresses as exchanges. It also says nothing on how to account for coins from a chain split, such as Bitcoin Cash. These are outside its scope, but they are what a backtest on crypto needs.
The text is dated. It stops before the halving of April 2024, which cut the subsidy to 3.125 BTC. Some first-edition wording remains, such as "Over the past three years" in chapter 13.
Inconsistencies. The fee rate is defined once as "size divided by weight", which should be the fee over the size. Chapter 12 puts the median-time-past lag at "about one hour", and chapter 6 at "an hour or two". The max_money.py example, run under Python 3, prints 2,100,000,000,000,000 rather than the total it shows, because it divides with floats.
Credit. The authors flag where Bitcoin's policy may have changed since writing, such as the dust limit and full replace-by-fee. They warn that fee estimation "can never be perfect", and that an attack on the hash rate doesn't need a majority.
Use in this repo
On-chain data are point-in-time, but the newest blocks are provisional. A block's contents don't change once it is deep in the chain. So fees, transaction counts and the subsidy, read from a block, are as known at the time. Two cautions:
- The newest blocks can be replaced. A reorganisation usually replaces one block, so a feature read from the last few blocks may change. The tick should record the block hash with each value, and a backtest should treat values less than six blocks old as provisional.
- Block timestamps are set by miners. They can be up to two hours ahead, and need only be later than the median of the last 11 blocks. So consecutive blocks can be out of order. A feature that needs a time should use the time the tick saw the block (
seen_at), not the block's own timestamp.
Derived series are estimates. The hash rate comes from the difficulty and the times between blocks, so it is an estimate with a large error over a few blocks. Labels that call an address an exchange are guesses from outside the chain. They change as the labeller learns, so a series of exchange flows is revised after the fact, as FRED's vintages are (#295). It would need a vintage per pull, or it can't be used in a backtest.
The halving is a scheduled event. Its block height is known years ahead, and its date to within weeks. That makes it a candidate for the event-study method (event-studies.md), with the caveat that four halvings give four events. That is far too few to test, as forking-paths.md warns.
#9: costs of moving coins. costs.py charges Coinbase's trading fees, but nothing for moving coins on-chain between venues. A strategy that moves coins needs two more costs:
- The network fee. It is set by auction, in satoshis per virtual byte, and spikes when blocks are full. A cost model should take the fee rate from the data at the time, not a constant.
- The delay. A transfer is safe after about six confirmations, an hour on average, and longer by chance. A strategy that arbitrages between venues carries the price risk of that hour.
Forks for the ledger. A chain split gives each holder coins on both chains. The book doesn't say how to account for them. The project's ledger should record such coins as a separate asset from the day of the split, with no cost basis. The tax regimes (#9, #34) must say how each treats them.
Custody is a risk outside the returns. The book's examples are exchanges' hot wallets that were hacked. Another is almost 7,000 BTC lost with their keys in July 2011. A crypto strategy that keeps coins on an exchange carries the exchange's risk of failure. Its stress report (#219) should name the venue, and the share of capital held there. This is the same risk as a venue that changes its terms (chokepoint-capitalism.md).
#84 and #85. Wash trading inflates exchanges' reported volume (crypto-wash-trading.md). On-chain volume is harder to fake, but it isn't free to fake, because fees cost little. Dead coins vanish from exchanges' listings (crypto-survivorship-bias.md), but their chains, where they exist, keep their history.