# Capítulo 9 ###### tags: `MB` [TOC] ## Material Principal Leer el Capítulo 9 del Libro **Mastering Bitcoin**.Enlace a la versión del [libro en inglés](https://github.com/bitcoinbook/bitcoinbook) y de la versión del [libro en español](https://drive.google.com/file/d/18NDHehFLGBDi_EVQQ59wQ2I99cvrrTJZ/view?usp=sharing). **Se recomienda leer en inglés, ya que es la versión más actualizada y completa**, pero es tu elección. Hemos estructurado las sesiones de acuerdo con los capítulos del libro en inglés. :::info Importante: Los términos técnicos siempre se dirán en inglés para facilitar el aprendizaje del idioma y la inmersión en el desarrollo de software de Bitcoin y LN. [Ver metodología de traducción](https://docs.google.com/document/d/1uPy771hf2xUElcaOR_Sk9NTqODeg9QZENYWL9leQc1g/edit?usp=sharing). ::: ## Lecturas complementarias | Contenido | Tiempo (min) | |:-------- |:--------:| |[Blockchain](https://en.wikipedia.org/wiki/Blockchain)| 90| |[What Is a Blockchain?](https://river.com/learn/what-is-a-blockchain/)| 60| |[IBD](https://bitcoincore.reviews/24858)| 30| |[Estructura de transacciones y bloques en Bitcoin](https://es.wikipedia.org/wiki/Anexo:Estructura_de_transacciones_y_bloques_en_Bitcoin)| 20| ## Preguntas de discusión :::warning Antes de resolver las preguntas del capítulo revisa las instrucciones de trabajo de la sesión [aquí](https://hackmd.io/tJ56-ztCT6WERvNdx1N10g?view#Instrucciones-de-aprendizaje) ::: 1. The genesis block contains a hidden message within it. What field is used to this and what are some other examples of this field being used? Do you think superfluous data should be allowed in the blockchain? 2. How much data would be required to calculate a Merkle path for a tree with 4 transactions? 3. What is _signet_ and how is it different than _testnet_ and _regtest_? 4. Bonus: _Bloom filters_ have some problems, how are _block filters_ better? :::spoiler En Español 1. El bloque genesis contiene un mensaje oculto en él. ¿Que campo se utiliza para esto y qué otros ejemplos hay del uso de este campo? ¿Crees que información trivial debería ser permitida en la blockchain? 2. ¿Cuánta información se requiere para calcular un path de Merkle para un árbol de 4 transacciones? 3. ¿Qué es la _signet_ y como difiere de _testnet_ y _regtest_? 4. Bonus: Los _Bloom filters_ tienen algunos problemas, porque son mejores los _block filters_? ::: ## Preguntas de aprendizaje 1. What is a blockchain? 2. How do nodes share the blockchain? 3. Where are the blocks stored?; Are the blocks ordered in this storage? 4. What is a parent block and what are the child blocks? 5. What does a block header contain? 6. How do you get a block hash? 7. What is Nonce? What is it for? 8. What is a candidate block? 9. How are blocks linked in the blockchain? 10. What’s a merkle tree? How does it work? How are they created? 11. How does Merkle Tree work in SPV nodes? 12. Why are the merkle trees used? :::spoiler En Español 1. ¿Qué es una cadena de bloques? 2. ¿Cómo comparten los nodos la cadena de bloques? 3. ¿Dónde se almacenan los bloques?, ¿Los bloques van ordenados en ese almacenamiento? 4. ¿Qué es un bloque padre y cuáles son los bloques hijos? 5. ¿Qué contiene un encabezado de bloque? 6. ¿Cómo se obtiene el hash de un bloque? 7. ¿Qué es el nonce?, ¿Para qué sirve? 8. ¿Qué es un bloque candidato? 9. ¿Cómo se vinculan los bloques en la cadena de bloques? 10. ¿Qué es un Merkle Tree?, ¿Cómo funciona?, ¿Cómo se crean? 11. ¿Cómo funciona el Merkle Tree en los nodos SPV? 12. ¿Por qué se utilizan los Merkle Trees? ::: ### Ejercicios :::info 13. Create a diagram showing how do Merkle Trees work and share it with your study partners. 14. Create a diagram showing the contents of the block header and share it with your study partners. 15. Download, compile and run the following code [merkle.cpp](https://github.com/bitcoinbook/bitcoinbook/blob/develop/code/merkle.cpp), more instructions in the following [book section](https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch09.asciidoc#merkle_example_run). 16. On your bitcoin node, do the following: - Locate the block hash of the genesis block and display the contents of the sole transaction of this block. ```sass bitcoin-cli getblock <block-hash> bitcoin-cli getrawtransaction <tx> ``` - Why do you think that message is displayed? - How do you think you could display the content of this transaction? :bulb: Tip: The command _"bitcoin-cli help <command>"_ shows the verbose options of any command. - If you could display the content of the coinbase transaction of the genesis block, locate the input script of the transaction and intruduce it in the following command (for linux or MacOS) What is the result of this command? ``` sass echo "script_content_goes_here" | xxd -r -p ``` ::: :::spoiler En Español :::info 13. Crea un diagrama de como funcionan los Merkle Trees y compartelo con tus compañeros. 14. Crea un diagrama del encabezado del bloque y compartelo con tus compañeros 15. Descargar, compilar y ejecutar el siguiente código [merkle.cpp](https://github.com/bitcoinbook/bitcoinbook/blob/develop/code/merkle.cpp), más instrucciones en la siguiente [sección del libro](https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch09.asciidoc#merkle_example_run). 16. En tu nodo de bitcoin realiza lo siguiente: - Localiza el hash del bloque genesis y visualiza el contenido de la única transacción de este bloque. ```sass bitcoin-cli getblock <block-hash> bitcoin-cli getrawtransaction <tx> ``` - ¿Porque crees que manda el mensaje al visualizar la transacción? - ¿Cómo crees que podrías vistualizar la transacción del bloque genesis? :bulb: Tip: El comando _"bitcoin-cli help <comando>"_ te muestra las opciones de verbose de cualquier comando. - Si lograste visualizar el contenido de la transacción coinbase del bloque genesis, localiza el script de entrada de la transacción e introdúcelo en el siguiente comando (en linux o MacOS) ¿Cuál es el resultado del comando?: ``` sass echo "aqui_va_el_contenido_del_script" | xxd -r -p ``` :::