32

The most important reason is that the original Satoshi codebase was written in C++. A system like Bitcoin has extremely strong requirements about consistency in behaviour: all nodes on the network must accept and reject the exact same blocks, or we risk a fork. The first choice to avoid bugs that risk introducing inconsistency is to not rewrite the code from ...


28

I gave a keynote address at cppcon 2016 about almost this exact issue. There are a variety of reasons why C++ is an excellent language choice for blockchain applications like Bitcoin. Blockchain applications have a large attack surface. They're meant to interoperate with a large number of untrusted endpoints while still providing reliable service to local ...


17

As someone who was involved in doing that migration at the time, I believe it was the right decision. LevelDB is far from perfect, but I wouldn't know what else to use. In particular: BDB is much slower for our usage (large atomic batch writes, small random reads). There were reports of database corruption as well with BDB, at a time when it was used far ...


16

Pay-to-PubKey (P2PK) and pay-to-PubKey-Hash (P2PKH) were both introduced in the original Bitcoin 0.1 release. P2PK was used by default for mining and payments received using the interactive IP-to-IP payment protocol; P2PKH was intended for use in non-interactive payments---but P2PKH transactions take up more space in the blockchain than P2PK. Is this space ...


15

I assume this question is about Bitcoin Core's internal operations. This description is valid for version 0.8 and later (up to 0.14 at least). One part of the system deals with the active chain, which is the longest valid chain of blocks (stored in $DATADIR/blocks) that we know of. This active chain gets blocks appended to - and occasionally removed when ...


15

In my view, the main implementation detail to be worked out with Dandelion is ensuring that there are no new DoS vectors introduced. In the existing transaction relay model of Bitcoin Core, transactions that do not make it into a node's mempool -- a proxy for what we expect to be (eventually) mined -- do not get relayed to other nodes. In the Dandelion ...


15

Someone wrote a Bitcoin protocol decoder for Wireshark, several years ago. I assume it was included in the Wireshark distribution. Wireshark simply knows about the Bitcoin protocol. There is no magic involved.


14

Disclosure: I'm a Blockstream co-founder Major feature contributions to Bitcoin Core: Greg Maxwell, Andrew Poelstra and myself (as well as several other contributors) worked on libsecp256k1, a well-tested library for efficient elliptic curve cryptography using the curve secp256k1. Bitcoin Core switched signing to it in 0.10 and verification in 0.12 (with a ...


13

The book Mastering Bitcoin would be a good solid start (although it might not answer all your questions). It is also available for free.


13

Introduction The key to finding out where a piece of code is without already knowing where it is is to start at the thing that will eventually lead to what you want to find. These can be logically thought through. For example, for relay and validation, these all occur after a node has received a block or transaction, so begin at the point where a block or ...


12

I am not aware of an extensively commented version of the Bitcoin sourcecode, but you could check out the Bitcoin Developer Reference and you can read online the book Mastering Bitcoin by Andreas M. Antonopoulos, which covers Bitcoin's technical aspects extensively. There is also Princeton's Free Online Bitcoin course, which goes into details on some ...


12

Both answers by James C. and sanket1729 are very good, but I wanted to give a very high-level answer: Miniscript is an intermediate more structured representation for actual Bitcoin Scripts. It is useful as a toolbox because it simplifies static analysis of scripts, and things like generic signing. The policy language is intended to simplify designing ...


11

If there is a need for them, additional decimal places can be added with concensus of the network. This is why some refer to "infinite" divisibility, because we can select the level that we need as time goes on. The current level selected in the code (by Satoshi) is 8 decimal places (1 satoshi = 0.00000001 BTC) hence the nickname for the smallest unit ...


11

Most of the fixes have been implemented in Bitcoin Core's master branch, or earlier versions, as standard transaction checks that prevent default Bitcoin Core nodes from relaying or mining transactions that break the rules. Here are some details: Non-DER encoded ECDSA signatures These are currently non-standard, so Bitcoin Core nodes (since 0.8.0,...


11

To understand Bitcoin Core, the best resource is probably the source code itself: https://github.com/bitcoin/bitcoin To help understand what is going on in the code, try the developer documentation and the Princeton Bitcoin Book. Keep in mind that the code gets updated faster than the documentation, so the code should be your source of truth. Some ...


11

The Schnorr implementation was never in Bitcoin Core. Rather it is in the libsecp256k1 library that is a subtree in Bitcoin Core. The commit you reference is actually a commit in that library which appears in Core's commit history because the subtree in Core is periodically updated with the libsecp256k1 upstream source code. The reason for removal is ...


11

The separation between internal and external addresses comes from BIP32. Using a different chain for each permits you to give out an xpub for just the external ones to an auditor. They would then be able to observe your incoming payments, but not your spending.


9

In the Bitcoin blockchain, each block has a 32-bit field called version. Right now, it takes on simple small values like 2 or 3. As an example of changes, block version 3 introduced new rules about transaction validity, as well as anti-malleability measures. Miners with the new Bitcoin client create blocks with the version set to 3 to signal their ...


9

The Developer Documentation may also be of use.


9

Do you modify the block or do you not modify the block? If you don't modify the block, it still pays the mining reward to the same account. So you've just done what everyone wants you to do. If you do modify the block, it won't be valid anymore until and unless you mine it. That leaves you two choices: 1) You can ignore this block and mine some other ...


9

At a high level: The policy is compiled to Minsicript. Miniscript is encoded to bitcoin Script. (One to One Mapping) Bitcoin Script is decoded back to Miniscript. (One to One Mapping) Policy and Miniscript can both be lifted to another representation for static analysis. Following invariants are respected in Miniscript: Let ms be a miniscript, s be ...


9

There are benefits to both users and developers to having Bitcoin Core split into separate node, wallet and GUI processes. As Alyssa Hertig outlines here the benefit to users will be being able to run the Bitcoin Core node on a different machine to the Bitcoin Core wallet rather than being forced to run them on the same machine. A user could leave a node ...


9

The introduction of descriptor wallets presents an opportunity to introduce a new database backend as descriptor wallets are backwards incompatible. The following is taken from Andrew Chow's blog post on what's coming to the Bitcoin Core wallet in 0.21. (There was also discussion on this GitHub Issue.) Why move from Berkeley DB? Not designed to be used as ...


9

"Best-effort". Formal proofs don't help. All one can do is to write tests, like any other well-written piece of software. They also maintain forks of some dependencies such as LevelDB and don't update some of them such as BerkeleyDB. See What Went Wrong. Especially the 2013 hardfork wouldn't have happened if they could ensure an unchanged consensus ...


9

Turing completeness includes the capability to run programs that might not terminate or that might terminate after a very long time. This would cause the blockchain to stall, hence it is a must to keep the number of instructions to be run predetermined (like BTC) or to be run according to a budget (like ETH).


8

I was asked by Hasan Hasan, a junior developer, which of the following three books I'd recommend. Personally I think all three books are fantastic (I would recommend them all) but they do approach the topic from very different angles. Mastering Bitcoin (2nd edition, Andreas Antonopoulos) was the first technical Bitcoin book to be published. The 2nd edition ...


8

Here is a list of people who have had commit access to Bitcoin Core. This list can also be found on Bitcointalk and on Reddit (it's the same list just in two different places). All lists are kept up to date and in sync. This list contains the names and usernames of everyone who I can find evidence for ever having commit access to Bitcoin Core, the dates ...


8

That's because of the QT translation files, see https://github.com/bitcoin/bitcoin/search?l=typescript I'm not sure why they are recognized as TypeScript (it's just XML), I guess it's because of the filename extension .ts.


8

Looking at this diagram of OP_CHECKSIG steps and the Bitcoin Script wiki, OP_CODESEPARATOR is used to make OP_CHECKSIG check only part of the scriptPubKey. Essentially, only the script that goes after the last OP_CODESEPARATOR is used to sign the transaction and hence evaluated by OP_CHECKSIG. In theory, a spending transaction could change the part of the ...


8

My new book "A Dissection of Bitcoin" examines the original Bitcoin source code written by Satoshi. As for now, it is the first and only book available that helps you read the Bitcoin source code.


Only top voted, non community-wiki answers of a minimum length are eligible