The Rules Are 7% of the Program

A line count of Bitcoin Core 32.1

Release 32.1, branch 32.x, commit f0de87f, 26 October 2026. Current-tree figures are tokei 14 code lines. History figures are git numstat on non-merge commits.

The consensus rules are 10,122 code lines. The implementation they sit in is 151,004. The code that applies those rules, stores the result, or chooses what to relay and mine is 20,366, twice the rules. The other 120,516 lines are the wallet, the GUI, RPC, P2P transport, and the rest of the node.

A wrong rule forks the network. A policy disagreement does not. The two live in the same program, and the rules are the thin slice. That is the measurement behind The Vertical Layer Problem and Why Bitcoin Needs a Specification That Humans Can Read.


Contents


I. What was counted

Tokei parsed 2,698 files and 719,989 code lines. Qt locale files are 103 of those files and 286,741 of those lines. Tokei counts them as TypeScript. They are translations, and the charts below leave them off. Every other parsed file is in exactly one bucket.

The headline is the implementation. Vendored libraries are another 112,703. First-party code, implementation plus tests plus contrib, build, and docs, is 320,545. Those three figures, 286,741 plus 112,703 plus 320,545, are the 719,989.


II. The tree

Code lines, scaled to the tests
Tests
154,273
Implementation
151,004
Vendored
112,703
Contrib
9,062
Build and CI
6,206
Code, comments, and blanks, scaled to the implementation

CodeComments and blanks

Implementation
151,004 code · 756 files
Tests
154,273 code · 921 files
Vendored
112,703 code · 526 files
Docs
0 code · 189 files
Contrib
9,062 code · 97 files
Build and CI
6,206 code · 106 files

The program carries about as much test code as implementation code. On this release the test pile is the larger of the two. Implementation bodies are 73.8% C++ and 25.6% headers.


III. The implementation

Seven hundred fifty-six files. The median file is 66 code lines. Thirty-three files of 1,000 lines or more hold 38.9% of the implementation. Fifty-four files hold half of it.

Implementation code lines, scaled to the wallet
Wallet
21,687
GUI
19,668
Validation
17,926
P2P
16,880
RPC and HTTP
16,520
Support
15,606
Crypto
10,122
Script
9,734
Mempool
8,363
The crypto bar is that directory. The 10,122 in section IV is a different cut.
The rest of the implementation, scaled to the executables
Executables
3,094
Peer seeds
2,679
Init
2,318
Node interfaces
1,719
Mining templates
1,019
Addresses
816
Logging
812
Interfaces
734
IPC
668
ZMQ
639

src/node is not all P2P. Block storage and chainstate in that directory are in the validation bar. P2P is the network files only.


IV. The rules

Consensus here means the code that decides whether a block or a transaction is valid. The bundled signature library is outside this split. It is counted in section VII.

Share of the 151,004 implementation lines
■ Rules, 10,122 ■ Adjacent, 20,366 ■ The rest, 120,516
What the 10,122 rule lines are, scaled to the hash code
SHA-256, RIPEMD
3,803
Script interpreter
2,772
PoW, merkle, deploy
1,312
Keys and integers
1,117
validation.cpp checks
562
Block and tx types
556
SHA-1, SHA-3, and SHA-512 are in the rest. The interpreter itself is 1,584 of the 2,772.

Core's exported libbitcoinconsensus is 4,757 of these lines. The kernel target is a different list, and it still compiles policy and mempool.


V. What sits beside the rules

Adjacent means the code that applies the rules, stores the result, or chooses what to relay and mine. An index can be wrong without making a block invalid. A policy limit can change without forking.

The 20,366 adjacent lines, scaled to policy and mempool
Policy, mempool
8,747
Chainstate
8,318
Indexes
2,282
Mining templates
1,019

validation.cpp is mostly the machine around the checks

The file is 4,247 code lines. CheckBlock, ConnectBlock's checks, the subsidy, and BIP30 stay with the rules. The undo write stays with chainstate. MemPoolAccept stays with policy.

validation.cpp, 4,247 code lines
Chainstate machine
2,645
Mempool acceptance
997
Validity checks
562
Progress and errors
43

VI. Tests

Tests are 154,273 code lines, about as many as the implementation.

Test lines per implementation line, scaled to the rules
Rules
1.47
The rest
1.01
Adjacent
0.88
Test lines by bucket, scaled to everything else
The rest
121,558
Adjacent
17,840
Rules
14,875
Rule and adjacent tests, scaled to mempool and policy
Mempool and policy
8,073
Mining and indexes
6,746
Rule functional tests
5,375
Named rule unit and fuzz
4,517
Script and tx vectors
3,580
Chainstate unit and fuzz
3,021
Hash and block fuzz
1,403

The long bar is wallet, GUI, P2P transport, lint, and CI. A test that calls the interpreter under another name is in that bar.


VII. Bundled code

Vendored trees sum to 112,703 code lines. 89,312 (79%) are maintained as Bitcoin Core projects. 23,391 (21%) are forks of Google libraries. secp256k1 is most of the first group, and it is 7.6 times the first-party rules.

Bundled code lines, scaled to libsecp256k1
secp256k1
76,503
leveldb
21,721
libmultiprocess
5,540
minisketch
4,534
univalue
2,033
crc32c
1,670
ctaes
702

Since the projects split, Google has changed leveldb about ten times as much as this fork has. crc32c has barely moved on either side.

Lines changed since the shared ancestor, scaled to Google's leveldb history
leveldb, Google
+2,335−1,886
leveldb, the fork
+242−194
crc32c, Google
+54−38
crc32c, the fork
+46−24

Qt, Boost, SQLite, ZeroMQ, Cap'n Proto, qrencode, and systemtap are fetched when the node is built. They are not in this checkout, so they have no line count here.

Public-key checks in src/pubkey.cpp call into secp256k1. That library is a Core project, used by other software, and it sits outside the node's own source.


VIII. Who added the lines

1,122,543 lines were added and 614,627 were deleted. 55% of what was added was later deleted. Net is added minus deleted. It is not the lines still in the tree. That count is section IX. The filter is code files only. Comments and blanks count. Vendored trees, Qt translations, and build scripts do not.

Of the lines added to code files, through 26 October 2026
Added
+1,122,543
Deleted
−614,627
Net
+507,916

Lines added and deleted, by year

AddedDeleted

0255075100091011121314151617181920212223242526

Thousands of lines, rounded. The largest net is 2020, at 44,625. 2010's net is 3,185.

Code commits by year

01,0002,0003,000091011121314151617181920212223242526

The peak is 2,606 commits in 2020.

Distinct people by year

04080120160091011121314151617181920212223242526

The peak is 144 people in 2018. 2023 falls to 76.

Lines added by person, bulk imports omitted, scaled to Pieter Wuille
Pieter Wuille
132,987
Wladimir
97,885
Marco Falke
72,530
Ava Chow
61,034
Satoshi Nakamoto
50,604
Gavin Andresen
42,191
900 people, after dropping two bulk imports, sirius-m and Vinnie Falco. The top five added 39.5%. The top ten added 52.3%. Satoshi's row is the git string s_nakamoto.
Lines added and deleted by person, scaled to Pieter Wuille

AddedDeleted

Pieter Wuille
+132,987
−59,517
net +73,470 · 1,703 commits · deletes 45%
Wladimir J. van der Laan
+97,885
−47,828
net +50,057 · 1,337 commits · deletes 49%
Marco Falke
+72,530
−61,422
net +11,108 · 2,879 commits · deletes 85%
Ava Chow
+61,034
−41,384
net +19,650 · 1,274 commits · deletes 68%
Satoshi Nakamoto
+50,604
−45,881
net +4,723 · 237 commits · deletes 91%
Gavin Andresen
+42,191
−36,796
net +5,395 · 393 commits · deletes 87%
John Newbery
+24,882
−26,142
net −1,260 · 749 commits · deletes 105%
Suhas Daftuar
+24,723
−8,580
net +16,143 · 438 commits · deletes 35%
Russell Yanofsky
+22,958
−13,286
net +9,672 · 414 commits · deletes 58%
Gloria Zhao
+19,444
−5,951
net +13,493 · 390 commits · deletes 31%
Michael Ford
+19,053
−17,676
net +1,377 · 601 commits · deletes 93%
Ryan Ofsky
+17,697
−6,601
net +11,096 · 272 commits · deletes 37%

Michael Ford's small net skips build scripts. His merge share is a different ranking, in Who Controls Bitcoin.


Where the work went

The 55% figure above counts every filtered code file, including tests. Restricted to implementation files, and split with the same system lists as section III, 672,059 lines were added and 431,312 were deleted. 64.2% of what was added was later deleted. No system has a majority. Wallet is the largest share of lines added, at 14.9%. Validation is 14.8%. The top four, wallet, validation, the GUI, and P2P, are 55.3%.

Implementation lines added and deleted, scaled to the wallet

AddedDeleted

Wallet
+100,177
−71,056
net +29,121 · 4,074 commits · 14.9%
Validation
+99,577
−67,991
net +31,586 · 4,295 commits · 14.8%
GUI
+91,333
−65,302
net +26,031 · 3,070 commits · 13.6%
P2P
+80,675
−51,106
net +29,569 · 3,382 commits · 12.0%
RPC and HTTP
+63,238
−39,140
net +24,098 · 3,142 commits · 9.4%
Support
+59,510
−33,237
net +26,273 · 2,630 commits · 8.9%
Crypto
+36,031
−20,597
net +15,434 · 969 commits · 5.4%
Script
+34,561
−19,247
net +15,314 · 958 commits · 5.1%
Mempool
+24,463
−11,426
net +13,037 · 1,093 commits · 3.6%
A commit that touches two systems is counted in both commit totals. The lines are a partition.

The early years are the GUI. In 2009–2013 the GUI is 28.7% of implementation lines added. Wallet is the plurality in 2018–2021, at 26.3%. From 2022 through 26 October, validation leads, at 16.2%, and the GUI's net is +261. Wallet is the largest tree today because older lines survived.

Share of implementation lines added, by era
2009–2013
2014–2017
2018–2021
2022–2026
■ GUI ■ Validation ■ Wallet ■ P2P ■ RPC ■ Support ■ Mempool ■ The rest

What changes in the same commit

61.0% of wallet commits touch no other implementation system, and 13.7% of them also touch validation. The tight pair is mempool and validation: 36.7% of mempool commits also edit validation. RPC is the least separate. It is alone in 45.9% of its commits, and those commits also touch validation 23.6% of the time and wallet 23.2%.

Share of a system's commits that touch no other implementation system
GUI
66.8%3,070 commits · wallet 17.7%
Wallet
61.0%4,074 commits · RPC 17.9%, validation 13.7%
P2P
60.3%3,382 commits · validation 20.8%, RPC 15.9%
Validation
52.5%4,295 commits · RPC 17.3%, P2P 16.4%
Support
49.5%2,630 commits · validation 23.8%, P2P 20.1%
Crypto
49.1%969 commits · support 26.7%, validation 26.6%
Script
48.0%958 commits · wallet 29.4%, validation 25.9%
RPC
45.9%3,142 commits · validation 23.6%, wallet 23.2%
Mempool
45.5%1,093 commits · validation 36.7%, RPC 20.9%

In the last three years the GUI fell to 47% alone. Wallet stayed near 68%, and validation near 62%.


IX. Who last touched what remains

git blame -w on the 756 implementation files. Each non-blank line goes to the last commit that changed it. validation.cpp is split on the same function boundaries as section IV. Comments count, so these totals sit above the tokei code lines: 12,734 non-blank rule lines against 10,122 code lines.

Who last touched the rule lines, scaled to Pieter Wuille
Pieter Wuille
44.2%
Jorge Timón
12.4%
Anthony Towns
5.4%
Marco Falke
3.8%
Cory Fields
3.3%
Wladimir
3.3%
Johnson Lau
3.0%
Largest share of the lines that remain, scaled to the rules
Rules, Pieter Wuille
44.2% · 2017
Adjacent, Pieter Wuille
24.1% · 2023
The rest, Ava Chow
11.4% · 2021

Pieter Wuille last touched 13.9% of all 187,516 non-blank implementation lines, against 44.2% of the rules. Satoshi's author string leads a large share of historical additions and is absent from the lines that remain. Who would make the next change is the next section.


Who still edits a system

Over the three years ending 26 October 2026, validation's 798 commits come from 66 people, and seven of them cover half. Lőrinc is 15%. Marco Falke is 10%. TheCharlatan, including commits signed sedited, is 9%. Mempool is the concentrated system: Pieter Wuille is 36% and Suhas Daftuar is 12%, just under half together, and three people cover half. Wallet takes three people to reach half. Ava Chow, including commits signed Andrew Chow, is 31% of them.

Largest share of a system's commits, last three years, scaled to mempool
Mempool, Pieter Wuille
36%
Wallet, Ava Chow
31%
Script, Ava Chow
29%
Support, Marco Falke
24%
GUI, Marco Falke
20%
P2P, Gloria Zhao
17%
Validation, Lőrinc
15%
People editing each system, last three years, scaled to RPC
RPC
737 to half · top three 33% · 562 commits
Validation
667 to half · top three 34% · 798 commits
Wallet
633 to half · top three 52% · 665 commits
P2P
587 to half · top three 37% · 549 commits
Support
585 to half · top three 43% · 539 commits
Mempool
403 to half · top three 58% · 401 commits
GUI
343 to half · top three 52% · 197 commits
Script
343 to half · top three 52% · 174 commits
Crypto
325 to half · top three 39% · 178 commits

The rule files are their own count. In the same three years, 169 commits touch them, from 31 people, and five cover half. Marco Falke is 18%. Anthony Towns and Lőrinc are the next two, and the three together hold 42%. Pieter Wuille's 44.2% is the text that remains, and the median of those lines is 2017. These recent commits are a different list. The 562 check lines inside validation.cpp are left out of this count. That file is mostly chainstate and mempool.

People to cover half the commits, last three years, scaled to validation
Validation
766 people · Lőrinc 15%
Rule files
531 people · Marco Falke 18%
Mempool
340 people · Pieter Wuille 36%
Wallet
363 people · Ava Chow 31%

Two git names that share an email are one person. RPC has the most people, 73. The GUI is the quiet tree, 197 commits.


The size of the contract

At this release the tree exposes 171 RPC methods, 36 P2P message types, and 5 named deployment slots. Named slots went 1, 5, 6, then 5. Taproot left the named list. The rule is still in the interpreter.

RPC methods and P2P message types, end of each era

RPC methodsP2P messages

0501001502002013201720212026

X. Patch debt

The January 2026 debt study scores a file from how often it is edited in small diffs and how long it has gone without a large rewrite. This is the same formula, rerun on 17,072 merged pull requests through 12 October 2026. It is a churn score. It is not a bug count.

Counting every path that history ever touched, including files that are gone, 28.2% score above 50 and the patch-to-refactor ratio is 3.0. RPC is 63% of that wider count.

Restricted to files still in this tree, 15.8% of files score above 50, and those files hold 10.2% of current code lines. High-scoring files are smaller than average. Many of the old high scores were paths that no longer exist (main.cpp, ui.cpp). Among living files the ratio is 3.6 patches per refactor. Wallet is 6.9 to 1. The study's own consensus bucket, 26 files, is patched once per refactor, and 42% of those files still score above 50. That bucket is not the 10,122 rule lines.

Living files scoring above 50, scaled to the study's consensus bucket
Consensus files
42.3%
Wallet
25.5%
RPC
23.9%
Script
18.9%
GUI
14.5%
Network
12.7%

XI. What the count is for

The rules that have to be specified, audited, and matched by any other implementation are 10,122 code lines, plus a signature library that is larger than they are. The program operators download is the other 93% of the implementation, the tests, and the bundled trees. Treating a release as "the consensus rules" collapses those piles.

Don't Trust, Verify is about that collapse at the review layer. The first independent audit of Bitcoin Core, Quarkslab in September 2025, scoped P2P, mempool, block validation, and chain state. Those are mostly the adjacent lines in section V, plus some of the checks. The interpreter, the hash implementations, and the type of the transaction are the rest of the 10,122, and secp256k1 is another 76,503.

Who Controls Bitcoin measures who merges. This article measures who wrote lines and who last touched the lines that remain. The rankings differ. Merge concentration answers who can land a change. The blame in section IX answers whose text is still in the rule files. Both can be true, and neither is a substitute for the other. The later sections answer three further questions. Wallet commits also touch validation 13.7% of the time. Over the last three years, the rule files' 169 commits come from 31 people, and five cover half. Validation's wider tree comes from 66. A release exposes 171 RPC methods, 36 P2P message types, and 5 deployment slots.

Bitcoin Core: The Biggest Fallacies argues the client is a monolith because the wallet, the network, and the rules ship together. The line count is the size of that claim. Seven percent is the rules. Eighty percent is the rest of the same binary.

What Bitcoin's Stalled Proposals Tell You uses the authorship Gini from the governance research. That Gini is on pull-request authorship. The added-line shares in section VIII are a third cut. Top-five line additions at 39.5% and a historical authorship Gini near 0.85 are the same shape at two resolutions. They are not the same number.

The cost of storing the chain this program validates is a separate account, in Full Cost of Running a Bitcoin Node.


XII. Method

Snapshot. Bitcoin Core 32.1, branch 32.x, commit f0de87f040621468b956f01f526a43a010310501, 26 October 2026, "Merge bitcoin/bitcoin#36658: [32.x] Finalise 32.1". The tag matches the branch tip. Not shallow. 50,657 commits, 16,987 of them merges. Line counts are this release. Authorship is history through this commit.

Code lines. tokei 14.0.0. A file is in one bucket. Implementation is src/ excluding vendored prefixes (secp256k1, leveldb, crc32c, minisketch, univalue, libmultiprocess, ctaes), Qt locale, tests, fuzz, bench, markdown, and CMakeLists.txt. The system split uses explicit file lists for src/node, because that directory is not all P2P. src/node/mining_args.cpp, mining_args.h, and mining_types.h are in mining templates.

Forks. leveldb in this release is 13da2d67 (11 August 2026). The shared ancestor with Google is 0c40829 (5 November 2019). The Google tip in the comparison is bb74ef73 (8 October 2026). crc32c is efb8ea04 (30 August 2024), ancestor 21fc8ef (8 February 2022), Google tip 2bbb3be (7 April 2025). The bars are git numstat and include comments and blanks.

The three-way cut. Rule files are the SHA-256 and RIPEMD-160 sources, hash.cpp and hash.h, the script interpreter and script data, pubkey, arith_uint256, uint256, src/primitives, src/consensus, proof of work, versionbits, deployments, and signet. validation.cpp is split by function start, comment-stripped, then scaled from 4,187 raw code-like lines to tokei's 4,247. Adjacent is chainstate and storage, policy and mempool, indexes, and mining templates, including the matching parts of validation.cpp. SHA-1, SHA-3, and SHA-512 stay in the rest. The three parts sum to 151,004.

Tests. The named rule unit and fuzz files are the earlier filename list (4,517) plus integer, hash, script, and block tests that name a rule type (1,403). Functional rule tests are an explicit basename list: feature_block, feature_taproot, feature_segwit, feature_cltv, feature_csv_activation, feature_dersig, feature_nulldummy, feature_bip68_sequence, feature_signet, feature_versionbits_warning, p2p_segwit, p2p_invalid_block, p2p_invalid_tx, p2p_mutated_blocks. Adjacent adds an explicit list of mining, assumeutxo, pruning, index, fee, package, and chainstate tests to the mempool and policy filename prefix. A test outside those lists stays in the rest. That undercounts a functional test that exercises the interpreter under another name.

History. git log HEAD --no-merges --numstat. Renames of the form {old => new} are rewritten to the new path. Identity merges every pair of git names that share an email, and one name that used two addresses, plus the published aliases: Wladimir's three spellings, Ava Chow and Andrew Chow, Marco Falke and MarcoFalke, Gloria Zhao and glozow, Michael Ford and fanquake, jtimon and Jorge Timón. The tables use the release-note names. Satoshi Nakamoto's row is the s_nakamoto string. People who share only a first name stay separate. Ryan Ofsky and Russell Yanofsky are different people.

Systems over time. The same numstat history, implementation paths only, classified with the section III file lists, including the explicit src/node split. A path is classified by the name it had in that commit. Vendored trees and tests are out. The era chart uses that same partition in four spans: through 2013, through 2017, through 2021, and from 2022 through this release. Crypto, script, and the smaller systems are the remainder of each bar. A commit that touches two systems counts in both commit totals. "Only this system" means the commit touched no other classified implementation system. The three-year window is author dates from 26 October 2023 through this release. The people column merges git names that share an email, and the same published aliases as the history.

Rule-file editors. The same window and the same person merge. A commit counts once when it touches a file in the section IV rule list: the SHA-256 and RIPEMD-160 sources, hash.cpp and hash.h, the script interpreter and script data, pubkey, arith_uint256, uint256, src/primitives, src/consensus, proof of work, versionbits, deployments, and signet. validation.cpp is left out. Its 562 check lines share the file with chainstate and mempool.

The contract. RPC names are the command table when that table carries the method name (2013 and 2017) and RPCHelpMan / RPCMethod constructors when it does not (2021 and this release). Hidden methods are included. P2P names in 2013 are the message strings the network dispatcher in src/main.cpp, src/net.cpp, and src/alert.cpp receives or sends. From 2017 on they are the NetMsgType strings. Deployment slots are DEPLOYMENT_* enumerators other than testdummy, plus the block-version-2 height rule, with height-field aliases of the same fork collapsed to one name. Era tips are the last commit on this history at the end of 2013 (aec55a07), 2017 (c9439e73), 2021 (1831d43e), and this release.

Blame. git blame -w --line-porcelain on each implementation file. Whitespace-only changes do not move the line. Blank lines are dropped. The same alias list as the history.

Debt. scripts/analysis/code_turnover_analysis.py in the Bitcoin Governance Research repository, run on data/github/prs_raw.jsonl (25,506 pull requests, 17,072 merged with a date, last merge 12 October 2026). The score weights patch frequency, time since a large rewrite, age of files the script labels consensus, and modifications per estimated line. Change type is a size heuristic: a refactor is a change over 30% of the estimated file or over 200 lines. The script's subsystem labels are filename patterns. They are not the three-way cut in section IV. Living-file membership is the 32.1 tree.


Sources