Bitcoin YearsThe Atlas
Menu

The Ship of Theseus Bitcoin Core, 2009–2026

If every plank is replaced, is it still the same ship?

Bitcoin’s code has been rewritten line by line for 17 years. We asked the version history, release by release, how much of the code from Satoshi Nakamoto’s time is still in Bitcoin Core.


310,672lines of Bitcoin Core’s own C++ code in version 32.0 (2026/10)
1,747of them still date from Satoshi’s time: the first commit or a commit by Satoshi Nakamoto
0.6%of today’s code. In version 0.2 (2009) it was 99%.

Bitcoin Core’s code, layer by layer

Each band is code last written in a pair of years. The orange layer is everything from 2009 and 2010, the years Satoshi Nakamoto was active. Watch it thin as new layers pile on top.

Figure 1 · Lines of code by year last written, at each release
Lines of Bitcoin Core code by the years they were last written, at each release0k100k200k300k400kWritten 2009–10. 0.2: 18,816; 0.3: 18,961; 0.4: 20,004; 0.5: 12,506; 0.6: 11,499; 0.7: 10,236; 0.8: 9,217; 0.9: 7,416; 0.10: 5,213; 0.12: 4,593; 0.14: 3,512; 0.16: 3,202; 0.18: 2,886; 0.20: 2,716; 22.0: 2,343; 24.0: 2,095; 26.0: 1,983; 28.0: 1,945; 30.0: 1,803; 32.0: 1,755Written 2011–12. 0.4: 5,795; 0.5: 18,616; 0.6: 25,980; 0.7: 34,511; 0.8: 39,624; 0.9: 33,628; 0.10: 28,744; 0.12: 25,862; 0.14: 23,072; 0.16: 20,296; 0.18: 17,732; 0.20: 16,617; 22.0: 14,954; 24.0: 13,763; 26.0: 13,239; 28.0: 12,935; 30.0: 12,295; 32.0: 12,094Written 2013–14. 0.8: 1,193; 0.9: 21,688; 0.10: 40,797; 0.12: 40,096; 0.14: 35,779; 0.16: 31,481; 0.18: 28,163; 0.20: 25,293; 22.0: 22,844; 24.0: 21,585; 26.0: 20,955; 28.0: 19,911; 30.0: 18,987; 32.0: 18,589Written 2015–16. 0.10: 343; 0.12: 20,829; 0.14: 43,939; 0.16: 38,776; 0.18: 34,514; 0.20: 31,433; 22.0: 27,896; 24.0: 25,571; 26.0: 24,301; 28.0: 23,183; 30.0: 21,409; 32.0: 18,860Written 2017–18. 0.14: 2,753; 0.16: 27,471; 0.18: 53,844; 0.20: 48,037; 22.0: 42,252; 24.0: 38,482; 26.0: 36,690; 28.0: 35,011; 30.0: 32,196; 32.0: 29,855Written 2019–20. 0.18: 3,327; 0.20: 32,483; 22.0: 64,820; 24.0: 64,443; 26.0: 61,521; 28.0: 59,097; 30.0: 53,116; 32.0: 49,796Written 2021–22. 22.0: 17,559; 24.0: 53,060; 26.0: 61,944; 28.0: 59,995; 30.0: 56,481; 32.0: 52,581Written 2023–24. 26.0: 21,674; 28.0: 50,776; 30.0: 65,370; 32.0: 70,271Written 2025–26. 30.0: 15,164; 32.0: 56,8710.220090.420110.620120.820130.1020150.1420170.18201922.0202126.0202330.0202532.02026
2009–102011–122013–142015–162017–182019–202021–222023–242025–26
Bitcoin Core’s own C and C++ files at 20 releases from 0.2 to 32.0; third-party libraries left out. Hover a band for the counts. Source: git blame of the Bitcoin Core repository.

Satoshi’s planks: his code in Bitcoin Core

Two sets of lines can be dated to Satoshi’s time from the version history alone. The first commit of 30 August 2009 brought the code that already existed into version control on SourceForge. After that, Satoshi committed under the name s_nakamoto until December 2010.

The count peaked at 18,943 lines in version 0.4. Since then almost every one has been reformatted, renamed, moved or replaced.

1,747 lines remain, 487 of them in src/script/interpreter.cpp.

Figure 2 · Satoshi-era lines still in the code
Lines from the first commit and from Satoshi Nakamoto’s commits still in the code, at each release0k5k10k15k20k1,4363110.2 (2009): 18,711 of 18,816 lines (99.4%)0.220090.3 (2010): 18,861 of 18,961 lines (99.5%)0.4 (2011): 18,943 of 25,799 lines (73.4%)0.420110.5 (2011): 12,325 of 31,122 lines (39.6%)0.6 (2012): 11,337 of 37,479 lines (30.2%)0.620120.7 (2012): 10,128 of 44,747 lines (22.6%)0.8 (2013): 9,121 of 50,034 lines (18.2%)0.820130.9 (2014): 7,335 of 62,732 lines (11.7%)0.10 (2015): 5,152 of 75,097 lines (6.9%)0.1020150.12 (2016): 4,536 of 91,380 lines (5.0%)0.14 (2017): 3,461 of 109,055 lines (3.2%)0.1420170.16 (2018): 3,177 of 121,226 lines (2.6%)0.18 (2019): 2,878 of 140,466 lines (2.0%)0.1820190.20 (2020): 2,708 of 156,579 lines (1.7%)22.0 (2021): 2,335 of 192,668 lines (1.2%)22.0202124.0 (2022): 2,087 of 218,999 lines (1.0%)26.0 (2023): 1,975 of 242,307 lines (0.8%)26.0202328.0 (2024): 1,937 of 262,853 lines (0.7%)30.0 (2025): 1,795 of 276,821 lines (0.6%)30.0202532.0 (2026): 1,747 of 310,672 lines (0.6%)32.020261,747
BothFirst commitCommits by s_nakamoto
A line counts if git blame still credits it to the first commit or to an s_nakamoto commit at that release. Hover a point for the share of all code.

The last planks

Every line in version 32.0 that still traces back to Satoshi’s time, 954 of them with more than braces or blank space. Lines with an orange edge came from an s_nakamoto commit, the rest from the first commit. Each links to the line on GitHub.

src/script/interpreter.cpp487 lines
46bool CastToBool(const valtype& vch)47{49 {50 if (vch[i] != 0)51 {52 // Can be negative zero53 if (i == vch.size()-1 && vch[i] == 0x80)54 return false;55 return true;56 }57 }58 return false;59}60 335 // Subset of script starting at the most recent codeseparator337 430 CScript::const_iterator pc = script.begin();431 CScript::const_iterator pend = script.end();432 CScript::const_iterator pbegincodehash = script.begin();433 opcodetype opcode;434 valtype vchPushValue;451 452 //453 // Read instruction454 //455 if (!script.GetOp(pc, opcode, vchPushValue))466 467 if (opcode == OP_CAT ||468 opcode == OP_SUBSTR ||469 opcode == OP_LEFT ||470 opcode == OP_RIGHT ||471 opcode == OP_INVERT ||472 opcode == OP_AND ||473 opcode == OP_OR ||474 opcode == OP_XOR ||475 opcode == OP_2MUL ||476 opcode == OP_2DIV ||477 opcode == OP_MUL ||478 opcode == OP_DIV ||479 opcode == OP_MOD ||480 opcode == OP_LSHIFT ||481 opcode == OP_RSHIFT)494 switch (opcode)495 {496 //497 // Push value498 //499 case OP_1NEGATE:500 case OP_1:501 case OP_2:502 case OP_3:503 case OP_4:504 case OP_5:505 case OP_6:506 case OP_7:507 case OP_8:508 case OP_9:509 case OP_10:510 case OP_11:511 case OP_12:512 case OP_13:513 case OP_14:514 case OP_15:515 case OP_16:516 {517 // ( -- value)519 stack.push_back(bn.getvch());606 case OP_NOP6: case OP_NOP7: case OP_NOP8: case OP_NOP9: case OP_NOP10:611 break;612 613 case OP_IF:614 case OP_NOTIF:615 {616 // <expression> if [statements] [else [statements]] endif617 bool fValue = false;618 if (fExec)619 {620 if (stack.size() < 1)638 fValue = CastToBool(vch);639 if (opcode == OP_NOTIF)640 fValue = !fValue;641 popstack(stack);642 }643 vfExec.push_back(fValue);644 }645 break;646 647 case OP_ELSE:648 {649 if (vfExec.empty())659 vfExec.pop_back();660 }661 break;662 663 case OP_VERIFY:664 {665 // (true -- ) or666 // (false -- false) and return667 if (stack.size() < 1)669 bool fValue = CastToBool(stacktop(-1));670 if (fValue)671 popstack(stack);672 else680 }681 break;682 683 684 //685 // Stack ops686 //687 case OP_TOALTSTACK:688 {689 if (stack.size() < 1)691 altstack.push_back(stacktop(-1));692 popstack(stack);693 }694 break;695 696 case OP_FROMALTSTACK:697 {698 if (altstack.size() < 1)700 stack.push_back(altstacktop(-1));701 popstack(altstack);702 }703 break;704 705 case OP_2DROP:706 {707 // (x1 x2 -- )708 if (stack.size() < 2)710 popstack(stack);711 popstack(stack);712 }713 break;714 715 case OP_2DUP:716 {717 // (x1 x2 -- x1 x2 x1 x2)718 if (stack.size() < 2)720 valtype vch1 = stacktop(-2);721 valtype vch2 = stacktop(-1);722 stack.push_back(vch1);723 stack.push_back(vch2);724 }725 break;726 727 case OP_3DUP:728 {729 // (x1 x2 x3 -- x1 x2 x3 x1 x2 x3)730 if (stack.size() < 3)732 valtype vch1 = stacktop(-3);733 valtype vch2 = stacktop(-2);734 valtype vch3 = stacktop(-1);735 stack.push_back(vch1);736 stack.push_back(vch2);737 stack.push_back(vch3);738 }739 break;740 741 case OP_2OVER:742 {743 // (x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2)744 if (stack.size() < 4)746 valtype vch1 = stacktop(-4);747 valtype vch2 = stacktop(-3);748 stack.push_back(vch1);749 stack.push_back(vch2);750 }751 break;752 753 case OP_2ROT:754 {755 // (x1 x2 x3 x4 x5 x6 -- x3 x4 x5 x6 x1 x2)756 if (stack.size() < 6)758 valtype vch1 = stacktop(-6);759 valtype vch2 = stacktop(-5);760 stack.erase(stack.end()-6, stack.end()-4);761 stack.push_back(vch1);762 stack.push_back(vch2);763 }764 break;765 766 case OP_2SWAP:767 {768 // (x1 x2 x3 x4 -- x3 x4 x1 x2)769 if (stack.size() < 4)771 swap(stacktop(-4), stacktop(-2));772 swap(stacktop(-3), stacktop(-1));773 }774 break;775 776 case OP_IFDUP:777 {778 // (x - 0 | x x)779 if (stack.size() < 1)781 valtype vch = stacktop(-1);782 if (CastToBool(vch))783 stack.push_back(vch);784 }785 break;786 787 case OP_DEPTH:788 {789 // -- stacksize791 stack.push_back(bn.getvch());792 }793 break;794 795 case OP_DROP:796 {797 // (x -- )798 if (stack.size() < 1)800 popstack(stack);801 }802 break;803 804 case OP_DUP:805 {806 // (x -- x x)807 if (stack.size() < 1)809 valtype vch = stacktop(-1);810 stack.push_back(vch);811 }812 break;813 814 case OP_NIP:815 {816 // (x1 x2 -- x2)817 if (stack.size() < 2)819 stack.erase(stack.end() - 2);820 }821 break;822 823 case OP_OVER:824 {825 // (x1 x2 -- x1 x2 x1)826 if (stack.size() < 2)828 valtype vch = stacktop(-2);829 stack.push_back(vch);830 }831 break;832 833 case OP_PICK:834 case OP_ROLL:835 {836 // (xn ... x2 x1 x0 n - xn ... x2 x1 x0 xn)837 // (xn ... x2 x1 x0 n - ... x2 x1 x0 xn)838 if (stack.size() < 2)844 valtype vch = stacktop(-n-1);845 if (opcode == OP_ROLL)846 stack.erase(stack.end()-n-1);847 stack.push_back(vch);848 }849 break;850 851 case OP_ROT:852 {853 // (x1 x2 x3 -- x2 x3 x1)854 // x2 x1 x3 after first swap855 // x2 x3 x1 after second swap856 if (stack.size() < 3)858 swap(stacktop(-3), stacktop(-2));859 swap(stacktop(-2), stacktop(-1));860 }861 break;862 863 case OP_SWAP:864 {865 // (x1 x2 -- x2 x1)866 if (stack.size() < 2)868 swap(stacktop(-2), stacktop(-1));869 }870 break;871 872 case OP_TUCK:873 {874 // (x1 x2 -- x2 x1 x2)875 if (stack.size() < 2)877 valtype vch = stacktop(-1);878 stack.insert(stack.end()-2, vch);879 }880 break;881 882 883 case OP_SIZE:884 {885 // (in -- in size)886 if (stack.size() < 1)889 stack.push_back(bn.getvch());890 }891 break;892 893 894 //895 // Bitwise logic896 //897 case OP_EQUAL:898 case OP_EQUALVERIFY:899 //case OP_NOTEQUAL: // use OP_NUMNOTEQUAL900 {901 // (x1 x2 - bool)902 if (stack.size() < 2)904 valtype& vch1 = stacktop(-2);905 valtype& vch2 = stacktop(-1);906 bool fEqual = (vch1 == vch2);907 // OP_NOTEQUAL is disabled because it would be too easy to say908 // something like n != 1 and have some wiseguy pass in 1 with extra909 // zero bytes after it (numerically, 0x01 == 0x0001 == 0x000001)910 //if (opcode == OP_NOTEQUAL)911 // fEqual = !fEqual;912 popstack(stack);913 popstack(stack);914 stack.push_back(fEqual ? vchTrue : vchFalse);915 if (opcode == OP_EQUALVERIFY)916 {917 if (fEqual)918 popstack(stack);919 else921 }922 }923 break;924 925 926 //927 // Numeric928 //929 case OP_1ADD:930 case OP_1SUB:931 case OP_NEGATE:932 case OP_ABS:933 case OP_NOT:934 case OP_0NOTEQUAL:935 {936 // (in -- out)937 if (stack.size() < 1)940 switch (opcode)941 {942 case OP_1ADD: bn += bnOne; break;943 case OP_1SUB: bn -= bnOne; break;944 case OP_NEGATE: bn = -bn; break;945 case OP_ABS: if (bn < bnZero) bn = -bn; break;946 case OP_NOT: bn = (bn == bnZero); break;947 case OP_0NOTEQUAL: bn = (bn != bnZero); break;949 }950 popstack(stack);951 stack.push_back(bn.getvch());952 }953 break;954 955 case OP_ADD:956 case OP_SUB:957 case OP_BOOLAND:958 case OP_BOOLOR:959 case OP_NUMEQUAL:960 case OP_NUMEQUALVERIFY:961 case OP_NUMNOTEQUAL:962 case OP_LESSTHAN:963 case OP_GREATERTHAN:964 case OP_LESSTHANOREQUAL:965 case OP_GREATERTHANOREQUAL:966 case OP_MIN:967 case OP_MAX:968 {969 // (x1 x2 -- out)970 if (stack.size() < 2)975 switch (opcode)976 {977 case OP_ADD:978 bn = bn1 + bn2;979 break;980 981 case OP_SUB:982 bn = bn1 - bn2;983 break;984 985 case OP_BOOLAND: bn = (bn1 != bnZero && bn2 != bnZero); break;986 case OP_BOOLOR: bn = (bn1 != bnZero || bn2 != bnZero); break;987 case OP_NUMEQUAL: bn = (bn1 == bn2); break;988 case OP_NUMEQUALVERIFY: bn = (bn1 == bn2); break;989 case OP_NUMNOTEQUAL: bn = (bn1 != bn2); break;990 case OP_LESSTHAN: bn = (bn1 < bn2); break;991 case OP_GREATERTHAN: bn = (bn1 > bn2); break;992 case OP_LESSTHANOREQUAL: bn = (bn1 <= bn2); break;993 case OP_GREATERTHANOREQUAL: bn = (bn1 >= bn2); break;994 case OP_MIN: bn = (bn1 < bn2 ? bn1 : bn2); break;995 case OP_MAX: bn = (bn1 > bn2 ? bn1 : bn2); break;997 }998 popstack(stack);999 popstack(stack);1000 stack.push_back(bn.getvch());1001 1002 if (opcode == OP_NUMEQUALVERIFY)1003 {1004 if (CastToBool(stacktop(-1)))1005 popstack(stack);1006 else1020 bool fValue = (bn2 <= bn1 && bn1 < bn3);1021 popstack(stack);1022 popstack(stack);1023 popstack(stack);1024 stack.push_back(fValue ? vchTrue : vchFalse);1025 }1026 break;1027 1028 1029 //1030 // Crypto1031 //1032 case OP_RIPEMD160:1033 case OP_SHA1:1034 case OP_SHA256:1035 case OP_HASH160:1036 case OP_HASH256:1037 {1038 // (in -- hash)1039 if (stack.size() < 1)1041 valtype& vch = stacktop(-1);1042 valtype vchHash((opcode == OP_RIPEMD160 || opcode == OP_SHA1 || opcode == OP_HASH160) ? 20 : 32);1043 if (opcode == OP_RIPEMD160)1053 popstack(stack);1054 stack.push_back(vchHash);1055 }1056 break;1057 1058 case OP_CODESEPARATOR:1059 {1063 // Hash starts after the code separator1064 pbegincodehash = pc;1066 }1067 break;1068 1069 case OP_CHECKSIG:1070 case OP_CHECKSIGVERIFY:1071 {1072 // (sig pubkey -- bool)1073 if (stack.size() < 2)1075 1076 valtype& vchSig = stacktop(-2);1077 valtype& vchPubKey = stacktop(-1);1078 1081 popstack(stack);1082 popstack(stack);1083 stack.push_back(fSuccess ? vchTrue : vchFalse);1084 if (opcode == OP_CHECKSIGVERIFY)1085 {1086 if (fSuccess)1087 popstack(stack);1088 else1115 case OP_CHECKMULTISIG:1116 case OP_CHECKMULTISIGVERIFY:1117 {1120 // ([sig ...] num_of_signatures [pubkey ...] num_of_pubkeys -- bool)1121 1147 1148 // Subset of script starting at the most recent codeseparator1150 1152 for (int k = 0; k < nSigsCount; k++)1153 {1154 valtype& vchSig = stacktop(-isig-k);1161 1162 bool fSuccess = true;1163 while (fSuccess && nSigsCount > 0)1164 {1165 valtype& vchSig = stacktop(-isig);1166 valtype& vchPubKey = stacktop(-ikey);1167 1180 isig++;1181 nSigsCount--;1182 }1183 ikey++;1184 nKeysCount--;1185 1186 // If there are more signatures left than keys left,1189 if (nSigsCount > nKeysCount)1190 fSuccess = false;1191 }1192 1215 stack.push_back(fSuccess ? vchTrue : vchFalse);1216 1217 if (opcode == OP_CHECKMULTISIGVERIFY)1218 {1219 if (fSuccess)1220 popstack(stack);1221 else1314 // Blank out other inputs' signatures1325 1708 // Hash type is one byte tacked on to the end of the signature
src/net.cpp208 lines
1// Copyright (c) 2009-2010 Satoshi Nakamoto5 114//115// Global state variables116//122 164 169 194 198 // It'll only connect to one or two seed nodes because once it connects,199 // it'll get a pile of addresses with newer timestamps.225 340 342{345}346 354{384{392 393 // Look for an existing connection397 }405 521 // Add node551 pnode->AddRef();552 556 return pnode;557 }562void CNode::CloseSocketDisconnect()563{564 fDisconnect = true;578}579 667 1667 // error1668 int nErr = WSAGetLastError();1686 1745 pnode->fDisconnect = true;1756 socklen_t len = sizeof(sockaddr);1940{1948 {1957 pnode->fDisconnect = true;1962 // Disconnect unused nodes1965 {1967 {1970 1988 // close socket and cleanup1989 pnode->CloseSocketDisconnect();1990 1994 // hold in disconnected pool until all refs are released1995 pnode->Release();1997 }1998 }2001 // Delete disconnected nodes2004 {2009 }2010 }2011 }2017}2032 }2035 2123}2132 {2149 2152}2153 2156{2165 2166 //2167 // Receive2168 //2175 continue;2204 // typical socket buffer is 8K-64K2214 if (nBytes > 0)2215 {2222 pnode->CloseSocketDisconnect();2228 }2229 }2230 else if (nBytes == 0)2231 {2232 // socket closed gracefully2236 pnode->CloseSocketDisconnect();2237 }2238 else if (nBytes < 0)2239 {2240 // error2241 int nErr = WSAGetLastError();2242 if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)2243 {2247 pnode->CloseSocketDisconnect();2248 }2249 }2250 }2251 2253 }2254}2257{2268 }2269}2280}2281 2289}2290 2430 2440 2594{2600 // Connect to specific addresses2602 {2607 {2609 {2617 for (int i = 0; i < 10 && i < nLoop; i++)2618 {2621 }2622 }2628 }2629 }2630 2631 // Initiate network connections2675 2714 }2715 }2716 2717 //2718 // Choose an address to connect to based on most recently seen2719 //2720 CAddress addrConnect;2721 2765 2867 2916 continue;2918 2930 continue;2932 2944 addrConnect = addr;2946 }2947 2974 }2975}2976 3098{3103 //3104 // Initiate outbound network connection3105 //3120 3123 if (!pnode)3126 3144}3145 3218{3224 {3237 // Receive messages3242 // Send messages3247 }3248 }3249 3255 }3256}3257 3373{3374 int nOne = 1;3375 3376 // Create socket for listening for incoming connections3378 socklen_t len = sizeof(sockaddr);3390 return false;3391 }3393 // Allow binding if the port is still in TIME_WAIT state after3399 3419 int nErr = WSAGetLastError();3420 if (nErr == WSAEADDRINUSE)3422 else3425 return false;3426 }3428 3429 // Listen for incoming connections3431 {3434 return false;3435 }3436 3438 return true;3439}3440 3442{3445 3450 }3609 //3610 // Start threads3611 //3615 3621 // Send and receive from sockets, accept connections3623 3628 3645 3646 // Process messages3648 3669}3670 3671class CNetCleanup3672{3673public:3676 ~CNetCleanup()3677 {3679 // Shutdown Windows Sockets3680 WSACleanup();3681#endif3682 }3757 pnode->CloseSocketDisconnect();3769}3933 pnode->fDisconnect = true;3952 pnode->fDisconnect = true;
src/serialize.h186 lines
1// Copyright (c) 2009-2010 Satoshi Nakamoto8 22#include <map>24#include <set>36 169 template<typename Stream> \171 template<typename Stream> \212 template <typename Stream> \217 } \218 template <typename Stream> \236// Templates for serializing to anything that looks like a stream,278 282 283 292{293 if (nSize < 253) return sizeof(unsigned char);297}298 301template<typename Stream>303{304 if (nSize < 253)305 {307 }309 {312 }314 {317 }318 else319 {322 }323 return;324}325 332template<typename Stream>334{337 if (chSize < 253)338 {339 nSizeRet = chSize;340 }341 else if (chSize == 253)342 {346 }347 else if (chSize == 254)348 {352 }353 else354 {358 }360 throw std::ios_base::failure("ReadCompactSize(): size too large");362 return nSizeRet;363}364 444 466 612 template<typename Stream>624 625 template<typename Stream>634 template<typename Stream>643 }644 645 template<typename Stream>703 709 727 733 739 745 751 757 758 764template <typename Stream, typename T>767{769}770 773template <typename Stream, typename T>776{778}779 787 template<typename Stream, typename T>789 790 template<typename Stream, typename T>823 824 825 826 830template<typename Stream, typename C>832{833 WriteCompactSize(os, str.size());834 if (!str.empty())836}837 838template<typename Stream, typename C>840{841 unsigned int nSize = ReadCompactSize(is);842 str.resize(nSize);843 if (nSize != 0)845}846 850template<typename Stream, typename C>852{853 WriteCompactSize(os, str.size());856 }858 866 WriteCompactSize(os, v.size());878 // Limit size per read so bogus size value won't cause out of memory879 v.clear();880 unsigned int nSize = ReadCompactSize(is);881 unsigned int i = 0;897template <typename Stream, typename T, typename A>899{901 WriteCompactSize(os, v.size());907 WriteCompactSize(os, v.size());913 }914}915 916 917template <typename Stream, typename T, typename A>919{921 // Limit size per read so bogus size value won't cause out of memory922 v.clear();923 unsigned int nSize = ReadCompactSize(is);924 unsigned int i = 0;927 v.resize(i + blk);929 i += blk;930 }933 }934}935 936 940template<typename Stream, typename K, typename T>942{945}946 947template<typename Stream, typename K, typename T>949{952}953 954 955 959template<typename Stream, typename K, typename T, typename Pred, typename A>961{962 WriteCompactSize(os, m.size());965}966 967template<typename Stream, typename K, typename T, typename Pred, typename A>969{970 m.clear();971 unsigned int nSize = ReadCompactSize(is);972 typename std::map<K, T, Pred, A>::iterator mi = m.begin();973 for (unsigned int i = 0; i < nSize; i++)974 {977 mi = m.insert(mi, item);978 }979}980 981 982 986template<typename Stream, typename K, typename Pred, typename A>988{989 WriteCompactSize(os, m.size());990 for (typename std::set<K, Pred, A>::const_iterator it = m.begin(); it != m.end(); ++it)992}993 994template<typename Stream, typename K, typename Pred, typename A>996{997 m.clear();998 unsigned int nSize = ReadCompactSize(is);999 typename std::set<K, Pred, A>::iterator it = m.begin();1000 for (unsigned int i = 0; i < nSize; i++)1001 {1002 K key;1004 it = m.insert(it, key);1005 }1006}1007 1008 1009 1017}1018 1019template<typename Stream, typename T>1036template<typename Stream, typename T>1083 1089 1101 1251 template <typename Stream>1257 template <typename Stream>
src/script/script.cpp166 lines
20{21 switch (opcode)22 {23 // push value24 case OP_0 : return "0";25 case OP_PUSHDATA1 : return "OP_PUSHDATA1";26 case OP_PUSHDATA2 : return "OP_PUSHDATA2";27 case OP_PUSHDATA4 : return "OP_PUSHDATA4";28 case OP_1NEGATE : return "-1";29 case OP_RESERVED : return "OP_RESERVED";30 case OP_1 : return "1";31 case OP_2 : return "2";32 case OP_3 : return "3";33 case OP_4 : return "4";34 case OP_5 : return "5";35 case OP_6 : return "6";36 case OP_7 : return "7";37 case OP_8 : return "8";38 case OP_9 : return "9";39 case OP_10 : return "10";40 case OP_11 : return "11";41 case OP_12 : return "12";42 case OP_13 : return "13";43 case OP_14 : return "14";44 case OP_15 : return "15";45 case OP_16 : return "16";46 47 // control48 case OP_NOP : return "OP_NOP";49 case OP_VER : return "OP_VER";50 case OP_IF : return "OP_IF";51 case OP_NOTIF : return "OP_NOTIF";52 case OP_VERIF : return "OP_VERIF";53 case OP_VERNOTIF : return "OP_VERNOTIF";54 case OP_ELSE : return "OP_ELSE";55 case OP_ENDIF : return "OP_ENDIF";56 case OP_VERIFY : return "OP_VERIFY";57 case OP_RETURN : return "OP_RETURN";58 59 // stack ops60 case OP_TOALTSTACK : return "OP_TOALTSTACK";61 case OP_FROMALTSTACK : return "OP_FROMALTSTACK";62 case OP_2DROP : return "OP_2DROP";63 case OP_2DUP : return "OP_2DUP";64 case OP_3DUP : return "OP_3DUP";65 case OP_2OVER : return "OP_2OVER";66 case OP_2ROT : return "OP_2ROT";67 case OP_2SWAP : return "OP_2SWAP";68 case OP_IFDUP : return "OP_IFDUP";69 case OP_DEPTH : return "OP_DEPTH";70 case OP_DROP : return "OP_DROP";71 case OP_DUP : return "OP_DUP";72 case OP_NIP : return "OP_NIP";73 case OP_OVER : return "OP_OVER";74 case OP_PICK : return "OP_PICK";75 case OP_ROLL : return "OP_ROLL";76 case OP_ROT : return "OP_ROT";77 case OP_SWAP : return "OP_SWAP";78 case OP_TUCK : return "OP_TUCK";79 80 // splice ops81 case OP_CAT : return "OP_CAT";82 case OP_SUBSTR : return "OP_SUBSTR";83 case OP_LEFT : return "OP_LEFT";84 case OP_RIGHT : return "OP_RIGHT";85 case OP_SIZE : return "OP_SIZE";86 87 // bit logic88 case OP_INVERT : return "OP_INVERT";89 case OP_AND : return "OP_AND";90 case OP_OR : return "OP_OR";91 case OP_XOR : return "OP_XOR";92 case OP_EQUAL : return "OP_EQUAL";93 case OP_EQUALVERIFY : return "OP_EQUALVERIFY";94 case OP_RESERVED1 : return "OP_RESERVED1";95 case OP_RESERVED2 : return "OP_RESERVED2";96 97 // numeric98 case OP_1ADD : return "OP_1ADD";99 case OP_1SUB : return "OP_1SUB";100 case OP_2MUL : return "OP_2MUL";101 case OP_2DIV : return "OP_2DIV";102 case OP_NEGATE : return "OP_NEGATE";103 case OP_ABS : return "OP_ABS";104 case OP_NOT : return "OP_NOT";105 case OP_0NOTEQUAL : return "OP_0NOTEQUAL";106 case OP_ADD : return "OP_ADD";107 case OP_SUB : return "OP_SUB";108 case OP_MUL : return "OP_MUL";109 case OP_DIV : return "OP_DIV";110 case OP_MOD : return "OP_MOD";111 case OP_LSHIFT : return "OP_LSHIFT";112 case OP_RSHIFT : return "OP_RSHIFT";113 case OP_BOOLAND : return "OP_BOOLAND";114 case OP_BOOLOR : return "OP_BOOLOR";115 case OP_NUMEQUAL : return "OP_NUMEQUAL";116 case OP_NUMEQUALVERIFY : return "OP_NUMEQUALVERIFY";117 case OP_NUMNOTEQUAL : return "OP_NUMNOTEQUAL";118 case OP_LESSTHAN : return "OP_LESSTHAN";119 case OP_GREATERTHAN : return "OP_GREATERTHAN";120 case OP_LESSTHANOREQUAL : return "OP_LESSTHANOREQUAL";121 case OP_GREATERTHANOREQUAL : return "OP_GREATERTHANOREQUAL";122 case OP_MIN : return "OP_MIN";123 case OP_MAX : return "OP_MAX";124 case OP_WITHIN : return "OP_WITHIN";125 126 // crypto127 case OP_RIPEMD160 : return "OP_RIPEMD160";128 case OP_SHA1 : return "OP_SHA1";129 case OP_SHA256 : return "OP_SHA256";130 case OP_HASH160 : return "OP_HASH160";131 case OP_HASH256 : return "OP_HASH256";132 case OP_CODESEPARATOR : return "OP_CODESEPARATOR";133 case OP_CHECKSIG : return "OP_CHECKSIG";134 case OP_CHECKSIGVERIFY : return "OP_CHECKSIGVERIFY";135 case OP_CHECKMULTISIG : return "OP_CHECKMULTISIG";136 case OP_CHECKMULTISIGVERIFY : return "OP_CHECKMULTISIGVERIFY";137 142 case OP_NOP4 : return "OP_NOP4";143 case OP_NOP5 : return "OP_NOP5";144 case OP_NOP6 : return "OP_NOP6";145 case OP_NOP7 : return "OP_NOP7";146 case OP_NOP8 : return "OP_NOP8";147 case OP_NOP9 : return "OP_NOP9";148 case OP_NOP10 : return "OP_NOP10";149 153 case OP_INVALIDOPCODE : return "OP_INVALIDOPCODE";164 while (pc < end())165 {166 opcodetype opcode;167 if (!GetOp(pc, opcode))168 break;169 if (opcode == OP_CHECKSIG || opcode == OP_CHECKSIGVERIFY)170 n++;171 else if (opcode == OP_CHECKMULTISIG || opcode == OP_CHECKMULTISIGVERIFY)268 while (pc < end())269 {270 opcodetype opcode;271 if (!GetOp(pc, opcode))314{315 opcodeRet = OP_INVALIDOPCODE;316 if (pvchRet)317 pvchRet->clear();323 return false;324 unsigned int opcode = *pc++;325 326 // Immediate operand327 if (opcode <= OP_PUSHDATA4)328 {330 if (opcode < OP_PUSHDATA1)331 {332 nSize = opcode;333 }334 else if (opcode == OP_PUSHDATA1)335 {337 return false;338 nSize = *pc++;339 }340 else if (opcode == OP_PUSHDATA2)341 {355 return false;356 if (pvchRet)357 pvchRet->assign(pc, pc + nSize);358 pc += nSize;359 }360
src/arith_uint256.h111 lines
24template <unsigned int BITS>25class base_uint26{45 pn[0] = (unsigned int)b;46 pn[1] = (unsigned int)(b >> 32);47 for (int i = 2; i < WIDTH; i++)48 pn[i] = 0;65 return ret;66 }67 69 71 {72 pn[0] = (unsigned int)b;73 pn[1] = (unsigned int)(b >> 32);74 for (int i = 2; i < WIDTH; i++)75 pn[i] = 0;76 return *this;77 }78 79 base_uint& operator^=(const base_uint& b)80 {81 for (int i = 0; i < WIDTH; i++)82 pn[i] ^= b.pn[i];83 return *this;84 }85 86 base_uint& operator&=(const base_uint& b)87 {88 for (int i = 0; i < WIDTH; i++)89 pn[i] &= b.pn[i];90 return *this;91 }92 93 base_uint& operator|=(const base_uint& b)94 {95 for (int i = 0; i < WIDTH; i++)96 pn[i] |= b.pn[i];97 return *this;98 }99 101 {102 pn[0] ^= (unsigned int)b;103 pn[1] ^= (unsigned int)(b >> 32);104 return *this;105 }106 108 {109 pn[0] |= (unsigned int)b;110 pn[1] |= (unsigned int)(b >> 32);111 return *this;112 }113 116 117 base_uint& operator+=(const base_uint& b)118 {120 for (int i = 0; i < WIDTH; i++)121 {123 pn[i] = n & 0xffffffff;124 carry = n >> 32;125 }126 return *this;127 }128 129 base_uint& operator-=(const base_uint& b)130 {131 *this += -b;132 return *this;133 }134 136 {137 base_uint b;138 b = b64;139 *this += b;140 return *this;141 }142 144 {145 base_uint b;146 b = b64;147 *this += -b;148 return *this;149 }150 154 155 base_uint& operator++()156 {157 // prefix operator158 int i = 0;165 {166 // postfix operator167 const base_uint ret = *this;168 ++(*this);169 return ret;170 }171 172 base_uint& operator--()173 {174 // prefix operator175 int i = 0;182 {183 // postfix operator184 const base_uint ret = *this;185 --(*this);186 return ret;187 }188 192 212 {213 return sizeof(pn);214 }215
src/validation.cpp95 lines
src/primitives/transaction.h52 lines
src/chain.h42 lines
src/test/sighash_tests.cpp40 lines
src/arith_uint256.cpp39 lines
src/script/script.h38 lines
src/net.h34 lines
src/uint256.h30 lines
src/primitives/transaction.cpp25 lines
src/net_processing.cpp24 lines
src/primitives/block.h16 lines
src/streams.h12 lines
src/consensus/tx_check.cpp11 lines
src/base58.cpp9 lines
src/key.h8 lines
src/wallet/db.h8 lines
src/node/blockstorage.cpp7 lines
src/base58.h6 lines
src/script/interpreter.h6 lines
src/validation.h6 lines
src/pow.cpp5 lines
src/consensus/tx_verify.cpp4 lines
src/common/system.cpp3 lines
src/support/allocators/secure.h3 lines
src/test/util/transaction_utils.cpp3 lines
src/wallet/walletdb.cpp3 lines
src/chain.cpp2 lines
src/init.h2 lines
src/node/miner.cpp2 lines
src/rpc/server.h2 lines
src/wallet/db.cpp2 lines
src/wallet/scriptpubkeyman.cpp2 lines
src/wallet/types.h2 lines
src/addresstype.cpp1 line
src/common/signmessage.cpp1 line
src/common/signmessage.h1 line
src/consensus/tx_verify.h1 line
src/httprpc.h1 line
src/httpserver.cpp1 line
src/httpserver.h1 line
src/index/coinstatsindex.cpp1 line
src/index/coinstatsindex.h1 line
src/index/db_key.h1 line
src/kernel/coinstats.cpp1 line
src/kernel/coinstats.h1 line
src/key_io.h1 line
src/merkleblock.h1 line
src/policy/rbf.cpp1 line
src/policy/rbf.h1 line
src/rest.cpp1 line
src/rest.h1 line
src/rpc/blockchain.cpp1 line
src/rpc/blockchain.h1 line
src/rpc/client.cpp1 line
src/rpc/client.h1 line
src/rpc/mempool.cpp1 line
src/rpc/mempool.h1 line
src/rpc/protocol.h1 line
src/rpc/rawtransaction_util.cpp1 line
src/rpc/request.cpp1 line
src/rpc/request.h1 line
src/rpc/util.cpp1 line
src/rpc/util.h1 line
src/script/verify_flags.h1 line
src/semaphore_grant.h1 line
src/test/fuzz/http_request.cpp1 line
src/test/httpserver_tests.cpp1 line
src/test/rest_tests.cpp1 line
src/test/util_check_tests.cpp1 line
src/util/check.cpp1 line
src/util/check.h1 line
src/util/hasher.h1 line
src/util/time.cpp1 line
src/wallet/rpc/addresses.cpp1 line
src/wallet/rpc/coins.cpp1 line
src/wallet/rpc/encrypt.cpp1 line
src/wallet/rpc/spend.cpp1 line
src/wallet/rpc/transactions.cpp1 line
src/wallet/rpc/wallet.cpp1 line

What was taken out

Some of Satoshi’s planks were not replaced but thrown overboard. Features that were once part of Bitcoin and are gone:

  1. 2010Feb 15, 2010

    The marketplace

    Version 0.2 shipped with unfinished code for products, reviews and a market. Satoshi Nakamoto removed it: “strip out unfinished product, review and market stuff”.

  2. 2010Aug 15, 2010

    OP_CAT and other opcodes switched off

    In a commit titled “misc changes”, Satoshi made any script that uses OP_CAT or 14 other opcodes fail, and cut the largest data push from 5,000 to 520 bytes. The opcodes stayed disabled; their code was deleted in 2013.

  3. 2011v0.5.0

    The wxWidgets interface

    Satoshi’s original desktop interface was replaced by the Qt interface that Bitcoin Core still uses.

  4. 2013v0.8.2

    Finding peers through IRC

    Early nodes found each other by joining an IRC channel. The code was removed in 2013, “now that lfnet is down”, the IRC network it relied on.

  5. 2016v0.13.0

    The alert system

    A signed-message system let a key holder broadcast warnings to every node. It was turned off by default in 0.12.1 and removed in 0.13.0.

  6. 2016v0.13.0

    The built-in miner

    The wallet could mine with the computer’s CPU (setgenerate). CPU mining had long stopped paying; the miner was removed.

  7. 2020v0.20.0

    The payment protocol (BIP70)

    Support for signed payment requests from merchants was fully removed.

Who wrote today’s code

By author name in the version history, the most lines in version 32.0. Line counts measure the last edit, not the effort or the importance of a change: a person who reformats a file is credited with every line they touched.

Author (as in git)Lines
Pieter Wuille46,853
MarcoFalke22,037
Wladimir J. van der Laan13,150
Ava Chow10,440
Andrew Chow10,419
glozow9,296
Russell Yanofsky8,818
TheCharlatan8,130

Questions

How much of Satoshi Nakamoto's code is still in Bitcoin Core?

1,747 of the 310,672 lines of Bitcoin Core's own C++ code in version 32.0 (2026) still trace back to Satoshi's time: the first commit of August 2009 or a commit by s_nakamoto. That is 0.6% of the code; in version 0.2 it was 99%.

Is Bitcoin still the same software Satoshi wrote?

The rules are largely the same, the code mostly is not. Almost every line has been rewritten, reformatted, moved or replaced over the years, the way the planks of the ship of Theseus were replaced one by one. Signatures, proof of work, the block chain and the 21 million limit work as Satoshi designed them.

Who wrote most of today's Bitcoin Core code?

By author name in the version history, Pieter Wuille (46,853 lines), MarcoFalke (22,037 lines), Wladimir J. van der Laan (13,150 lines) are credited with the most lines in version 32.0. Line counts measure the last edit, not the importance of a change.

Which features from Satoshi's Bitcoin were removed?

Among others: the marketplace, OP_CAT and other opcodes switched off, the wxWidgets interface, finding peers through IRC, the alert system. Each one, with its date and source, is listed on this page.

How was the code counted?

With git blame -w -M -C at each release on Bitcoin Core's own C and C++ files, leaving out bundled libraries. Blame credits a line to the last commit that changed it, so the survival figures are a lower bound.

How we counted, and what it misses

The method

At each release we ran git blame -w -M -C on every C and C++ file of Bitcoin Core’s own code (the top level in early versions, then src/). Libraries kept in the tree, such as LevelDB, libsecp256k1 and UniValue, and generated interface code are left out.

Old code can look new

Blame credits a line to the last commit that changed it. A whitespace-only change is ignored and moved lines are followed, but a rename, a reformat or a split file can still make an old line look new. The survival figures are therefore a lower bound.

Names are commit names

Code Satoshi wrote but someone else committed counts under that person. The first commit holds all code written before 30 August 2009; “Satoshi’s time” here means that commit plus the s_nakamoto commits, nothing more.

Data: /data/theseus/strata.json (CC BY 4.0), computed from the Bitcoin Core repository (code under the MIT licence) up to v32.0 (465dde277447). First commit: e071a3f6c06f (SVN trunk r1). Related: Primary sources · Proof of history · Cryptography Lab.