Study Sessions

If you have any interest computer science or own any money at all then learning about Bitcoin is time well spent. The best training resource that you can start with is the “Saylor Academy : Bitcoin for developers

The video below was first broadcast 8th March 2023 and just after halfway through has a great demo of how to create, sign, and send a transaction (using the regetest network). It also shows how to get a minimalist install of Bitcoin Core set up.

This is by far the best, shortest and most accurate demo I’ve seen. So where does Python or Rust fit in?

Bitcoin Nodes and Wallets

Rust features in the “BDK” Bitcoin Developer Kit and as for Python, you may not know but pretty much all of the tests for Bitcoin Core are written in Python.

Bitcoin Core Python tests

If you want to see one of the smaller tests have a look at this one :

It uses the test framework and you’ll also see ‘setmocktime’ which interestingly is one of the Hidden bitcoin core RPC commands

import time

from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_raises_rpc_error

Below we can see the class Uptime inherits from the parent “BitcoinTestFramework”

class UptimeTest(BitcoinTestFramework):
    def set_test_params(self):
        self.num_nodes = 1
        self.setup_clean_chain = True

Note also how “run_test” calls the other 2 tests below: _test_negative_time and _test_uptime

    def run_test(self):

    def _test_negative_time(self):
        assert_raises_rpc_error(-8, "Mocktime cannot be negative: -1.", self.nodes[0].setmocktime, -1)

    def _test_uptime(self):
        wait_time = 10
        self.nodes[0].setmocktime(int(time.time() + wait_time))
        assert self.nodes[0].uptime() >= wait_time

Anyway, this was a quick intro to some of the big subjects that are open to you to you if you want to learn from – the free course, videos, and the Bitcoin Core open source code on GitHub. Looking the the Python code is a good way to learn about how Bitcoin works and vice versa.

Take some of the Bitcoin Core test framework and dissect it to learn about it!