
Mastering Bitcoin

The Bitcoin transaction script language contains many operators, but is deliberately limited in one important way—there are no loops or complex flow control capabilities other than conditional flow control. This ensures that the language is not Turing Complete, meaning that scripts have limited complexity and predictable execution times. Script is
... See moreDavid A. Harding • Mastering Bitcoin
where K is the public key and A is the resulting commitment. Now that we understand how to make a commitment to a public key, we need to figure out how to use it in a transaction. Consider the following output script: OP_DUP OP_HASH160 <Bob's commitment> OP_EQUAL OP_CHECKSIG And also the following input script: <Bob's signature> <Bob
... See moreDavid A. Harding • Mastering Bitcoin
Satoshi Nakamoto’s invention is also a practical and novel solution to a problem in distributed computing, known as the “Byzantine Generals’ Problem.” Briefly, the problem consists of trying to get multiple participants without a leader to agree on a course of action by exchanging information over an unreliable and potentially compromised network.
... See moreDavid A. Harding • Mastering Bitcoin
The process described in steps 7 through 9 continues from the process described previously in “Generating a recovery code”: The first parameter to the PBKDF2 key-stretching function is the entropy produced from step 6. The second parameter to the PBKDF2 key-stretching function is a salt. The salt is composed of the string constant "mnemonic&qu
... See moreDavid A. Harding • Mastering Bitcoin
The transaction input list starts with an integer indicating the number of inputs in the transaction. The minimum value is one. There’s no explicit maximum value, but restrictions on the maximum size of a transaction effectively limit transactions to a few thousand inputs. The number is encoded as a compactSize unsigned integer.
David A. Harding • Mastering Bitcoin
The Bitcoin transaction script language is stateless, in that there is no state prior to execution of the script or state saved after execution of the script. All the information needed to execute a script is contained within the script and the transaction executing the script. A script will predictably execute the same way on any system. If your s
... See moreDavid A. Harding • Mastering Bitcoin
Figure 6-6. A byte map of Alice’s transaction. Legacy Serialization The serialization format described in this chapter is used for the majority of new Bitcoin transactions as of the writing of this book, but an older serialization format is still used for many transactions. That older format, called legacy serialization, must be used on the Bitcoin
... See moreDavid A. Harding • Mastering Bitcoin
Bitcoin consists of: A decentralized peer-to-peer network (the Bitcoin protocol) A public transaction journal (the blockchain) A set of rules for independent transaction validation and currency issuance (consensus rules) A mechanism for reaching global decentralized consensus on the valid blockchain (proof-of-work algorithm) As a developer, I see B
... See moreDavid A. Harding • Mastering Bitcoin
For more details on the available script operators and functions, see Bitcoin Wiki’s script page.