You don't have access to this class

Keep learning! Join and start boosting your career

Aprovecha el precio especial y haz tu profesión a prueba de IA

Antes: $249

Currency
$209
Suscríbete

Termina en:

1 Días
11 Hrs
27 Min
58 Seg
Curso de Bitcoin Core y Script

Curso de Bitcoin Core y Script

Juan Sebastián Marulanda

Juan Sebastián Marulanda

Ejecuta tus propios scripts

17/19
Resources

With bitcoin-cli it is very easy to start working with the Bitcoin programming language. Run some scripts that allow you to understand the workings of an unconventional, stack-based, incomplete Turing language.

How to do script debugging

Developing your own scripts to create Bitcoin transactions is a task that should not be taken lightly. You must have the necessary tools and knowledge to test the scripts and be 100% sure that they will not cause financial losses.

The Bitcoin community has developed a great tool for debugging scripts and testing them to be sure they work properly. btcdeb is another command line interface that will allow you to run a script and verify step by step how it works.

Professor Marulanda has taken the brilliant job of preparing a complete text guide where you will find the steps for its installation and use.

With btcdeb or Bitcoin Script Debugging, run a script, and with the step command you will be able to visualize step by step the execution of the script in stack format.

For example, if you want to run a script to add two numbers, you can run the following command where you will see the script and the stack that will be completed with each operator or script data, step by step.
Ejecución de script para sumar dos números

In the first step, the first number is saved on the stack.
Push del primer número en el stack

In the second step, the second number is saved in the stack.
Push del segundo número en el stack

In the third step, the two numbers are processed with the OP_ADD operator to add them and obtain the result.
Ejecución de la suma

In this way, we corroborate that the script is correct and fulfills its task of performing a sum.

Conclusion

You have seen that with this tool, in a very simple and visual way, you can start executing scripts of all kinds. From a simple addition, to validate complex BTC transactions.

The challenge for you, look for more complex scripts and start validating them. You can find some of them in the guide that the professor prepared for the Platzi community. Cheer up, take these first steps with Bitcoin Script.


Contributed by: Kevin Fiorentino (Platzi Contributor).

Contributions 4

Questions 0

Sort by:

Want to see more contributions, questions and answers from the community?

RESUMEN CLASE 17:
EJECUTA TUS PROPIOS
SCRIPTS

Verificamos si tenemos instalado btcdeb

$ which btcdeb

Instalamos btcdeb “Bitcoin Script Debugger” para depurar un script

$ sudo apt-get install git
$ git clone https://github.com/bitcoin-core/btcdeb.git

Ahora que ya clonaste el repositorio instalana C++ y algunos paquetes necesarios.

$ sudo apt-get install autoconf libtool g++ pkg-config make

Instala readline, herramienta que permite navegar sobre el depurador

$ sudo apt-get install libreadline-dev

Ahora, instala btcdeb:

$ cd btcdeb
$ ./autogen.sh
$ ./configure
$ make
$ sudo make install

Revisa si cuentas con una copia en tu máquina: /usr/local/bin/btcdeb

$ which btcdeb

Como depurar un script 1

$ btcdeb '[1 2 OP_ADD]'
> step

Como depuramos el script 2

$ btcdeb '[1 2 OP_ADD 2 OP_SUB]'
> step

Ejemplo de P2PKH

$ btcdeb '[304402201cc39005b076cb06534cd084fcc522e7bf937c4c9654c1c9dfba68b92cbab7d1022066f273178febc7a37568e2e9f4dec980a2e9a95441abe838c7ef64c39d85849c 0315a0aeb37634a71ede72d903acae4c6efa77f3423dcbcd6de3e13d9fd989438b OP_DUP OP_HASH160 41d83eaffbf80f82dee4c152de59a38ffd0b6021 OP_EQUALVERIFY OP_CHECKSIG]'

> step

Muy buena herramienta btcdeb. Poder visualizar paso a paso cómo interactua el script con la pila es brillante para comprender cómo funciona un lenguaje de programación basado en un stack y Turing incompleto.

Les recomiendo este IDE es muy bueno también
https://siminchen.github.io/bitcoinIDE/build/editor.html

no entiendo