chatochi_notes/mastering_bitcoin_notes.md

52 lines
2 KiB
Markdown
Raw Permalink Normal View History

# Mastering Bitcoin notes
So, after years of messing around with Bitcoin, the time has finally come to
reach the bottom of the rabbit hole and understand things down to the code
level.
I'm going to use this document to keep my notes and thoughts while going
through the book.
----------
"There's a lot more to Bitcoin than first meets the eye." Joder, ya te digo.
----------
Finally, I get to discover what the hell is an `SPV`: simplified payment
verification, which is fancy pants language for a client that keeps keys and
performs operations but relies on another full-node for following the protocol
and getting the blockchain data from other peers. So, if I understand
correctly, an Electrum Personal Server fits the definition of an SPV.
----------
Andreas mentions that we should talk about "mnemonic phrase", and not a "seed
phrase", because "even though common, its use is incorrect". But, why? -> So
it works this way: technically, the seed is a 512-bit piece of data, which is
the actual piece of information used to generate the keys of a wallet. The
mnemonic is just a human-readeable proxy to this seed, hence why mnemonic !=
seed.
This sparked my curiosity and I have been reading more low level details on how
seed generation works.
The first thing that's required is randomness. To get this, a series of bits is
generated. Specifically, the entropy should be between 128 and 256 bits (that
means, 128 to 256 random zeros and ones).
The checksum for this entropy is computed the following way:
- Generate the SHA256 hash of the entropy.
- Starting from the left, grab one bit of the hash for every 32 bits of length
in the original entropy (if the entropy is 128 bits, 128/32 = 4, you grab the 4
first bits of the hash).
2022-01-14 09:43:21 +01:00
- I got bored of writing, so I made some code. See `seed_playground.py`.
----------
Another interesting fact: miner fees for a transaction are not explicitly
specified anywhere, but are simply calculated as the difference between the
2022-01-14 09:43:21 +01:00
inputs and the outputs of the transaction.