Category: bitcoin

Running a mainnet and testnet on the same bitcoin node

In this post I will tell you how to run a mainnet and testnet bitcoin node simulataneously on the same device.

Bitcoin Conf Sections

It boils down to splitting out the bitcoin.conf into sections:


Then adding an additional systemd startup script for bitcoind -testnet -daemon

You dont need to set the rpcport or other options as they are different anyway:

  • Default Bitcoin network protocol listen port is 18333 (instead of 8333)
  • Default RPC connection port is 18332 (instead of 8332)

Setup Systemd scripts





ExecStart=/usr/local/bin/bitcoind -testnet
ExecStop=/bin/kill -15 $MAINPID






ExecStop=/bin/kill -15 $MAINPID


Enable the services:

sudo systemctl enable bitcoind_test
sudo systemctl enable bitcoind

Start the services:

sudo systemctl start bitcoind_test
sudo systemctl start bitcoind

Identifying Net in Commands

Now the problem is that when running bitcoin-cli commands it will by default use mainnet, so you must specify testnet.

Example calling mainnet:

bitcoin-cli getblockcount

Example calling testnet:

bitcoin-cli -testnet getblockcount


Getting your bitcoin off the exchange and into a wallet you control

Pragmatic Application

Before jumping into the theory I like to understand it practically in the real world. The best tool for this is setting up (and printing) a paper wallet.

Do not send bitcoin to the paper wallet yet, we are only trying to grasp the wallet idea

Go to either of:

You will need to move your mouse around to add randomness (entropy) to ensure the private-public key pair generated is random enough.

Print out the wallet.

Read the instructions.

Look at the key contents of it:

  • Private key
  • Public key

Your public key, is something that can be shared and given to anyone. It is public information. If you want to receive sats (portions of bitcoin) then this key is what you will give someone. It is your bitcoin address.

The private key, is something that should be kept private. Only you should know your private key (or have access to it). Your private key is what is used to sign transactions - movement from your address to somewhere else - to spend your bitcoin.

If you control the keys, you control the sats.

The reason paper wallets are not recommended anymore is because they encourage address reuse.

Paper wallets should not be seed backups. Paper wallets store one public-private key pair, whereas seeds can be used for re-generating multiple keys and addresses. This is called a HD - hierachical deterministic wallet. A single seed in a HD wallet can be used to dervice millions of addresses. The seed is what should be backed up.

If a hardware wallet malfunctions, is stolen, or destroyed, the private keys can be restored to a new wallet using the seed backup.

Take note that I do not say mnemonic seed - as bitcoin core (the reference implementation) has not adopted mnemonic seeds BIP 39

Can a duplicate of the wallet you just viewed or printed exist? Can the next person generating a wallet randomly get the exact same wallet at you?

Yes. But the chances of this are so astronomically low that it is as good as 0% chance.

A Word on Researching Bitcoin

An important tip is that you should beware of researching content that mentions cryptocurrencies and not just bitcoin. People who do no understand the superiority of bitcoin over the shitcoins have usually not done enough research.


Which Wallet should I use to get my satoshis off the Exchange and in to my possession?

A third party you trust is holding the private keys to your bitcoin. It is important that you and only you hold the private keys to your possession - sats.

There are many options shown below, however none have as many eyes on them as the original bitcoin reference implementation by Satoshi Nakamoto. It is the most widely used as a node, wallet and miner.

After trying many options - the one that really stuck with me - after learning the fundamentals was bitcoin-core with binaries available at

So I would always recommend using Bitcoin core and using the testnet thoroughly before even thinking of using mainnet.

Other options:

Avoid small time guides and tutorials - like Yeticold by JW Weatherman. He is incompetent and the application is dangerous - you will lose bitcoin! Best to understand the fundamentals thoroughly and bitcoin core.

What Wallet should I use and how should I get my bitcoin off the exchange?

My method

  • You should use a dedicated device - a device that will only be used for bitcoin.
  • The device should never connect to a network.
  • Use bitcoin-core for your wallet.
  • Encrypt the wallet - with a password you are gauranteed to remember - write it down.
  • Backup the seed on physical.
  • Use the testnet to do all the above and transfer your testnet utxo to your wallet - practice sending and receiving.
  • When you are confident use mainnet.

To achieve the above a good repo to use is Learning Bitcoin from the Command Line

Another good resource I found is Arman the parman - Get better at Bitcoin Storage. A lot of the examples use the mainnet but I suggest using the testnet first.




  • Certified Bitcoin Professional Exam Prep by C4
  • Hands-On Bitcoin Programming with Python by Harish
  • Grokking Bitcoin by Kalle Rosenbaum
  • Programming bitcoin learn how to program bitcoin from scratch by Song, Jimmy
  • Bіtсоіn Standard Beginners Guide. 2021 Beginners Guide. Everything You Need to Know About Bitcoin (Miner, Wallet, Standard, Mining Hardware etc.) by Bitensbury, Andrew [Bitensbury, Andrew]
  • The Blockchain and Bitcoin Fundamental Understand the Basic Principles of Blockchain and Bitcoin in This Master Course by Fredrick Martins [Martins, Fredrick]
  • Mastering Bitcoin by Andreas M. Antonopoulos

Cool things to see and do on a bitcoin node

Here is a list of cool things you can see, do and find out on a bitcoin node. Specifically for full nodes running in CLI or daemon mode - not GUI client.

Get Block Count

Get the total number of blocks in your version of the blockchain - the one on your local node. If it is up to date then this will be the number of blocks in total verified on the bitcoin blockchain.

bitcoin-cli getblockcount

Get the total amount of bitcoin that has been mined

To check the total amount of bitcoin that has been mined execute:

ubuntu@btc:~$ bitcoin-cli gettxoutsetinfo
  "height": 713513,
  "bestblock": "00000000000000000000e786c548255af5b4509c16d909b03c65568dc4ab998a",
  "transactions": 46621408,
  "txouts": 77012436,
  "bogosize": 5761235215,
  "hash_serialized_2": "4edfcd9e471794a587ac32dd26d2285829b89d0999ab4740391593bc7358a63c",
  "disk_size": 4705170290,
  "total_amount": 18896756.29158394

The "total_amount": 18896756.29158394 is the total from the max of 21000000

Get the time (in UTC not blockheight) a block was mined

Get the hash, get the block verbosely and convert the unix epoch time into human readable. Use the mediantime.

Mediantime is the median time of the past 11 block timestamps

bitcoin-cli getblockhash 100000
bitcoin-cli getblock 000000000003ba27aa200b1cecaad478d2b00432346c3f1f3986da1afd33e506 2
date -d @1293622620
Wed 29 Dec 2010 11:37:00 AM UTC

Some dates:

  • block 100,000: Wed 29 Dec 2010 11:37:00 AM UTC
  • block 200,000: Sat 22 Sep 2012 09:57:08 AM UTC
  • block 300,000: Sat 10 May 2014 05:54:38 AM UTC
  • block 400,000: Thu 25 Feb 2016 03:52:57 PM UTC
  • block 500,000: Mon 18 Dec 2017 06:14:46 PM UTC
  • block 600,000: Fri 18 Oct 2019 11:09:37 PM UTC
  • block 700,000: Sat 11 Sep 2021 04:14:32 AM UTC

The number of blocks per gregorean year:

365 days * 24 hours * 6 blocks an hour

Get the Genesis Block

Get the block hash at height 0:

ubuntu@btc:~$ bitcoin-cli getblockhash 0

Verbosely get the block by the hash:

ubuntu@btc:~$ bitcoin-cli getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f 2
  "hash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
  "confirmations": 695440,
  "strippedsize": 285,
  "size": 285,
  "weight": 1140,
  "height": 0,
  "version": 1,
  "versionHex": "00000001",
  "merkleroot": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
  "tx": [
      "txid": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
      "hash": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
      "version": 1,
      "size": 204,
      "vsize": 204,
      "weight": 816,
      "locktime": 0,
      "vin": [
          "coinbase": "04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73",
          "sequence": 4294967295
      "vout": [
          "value": 50.00000000,
          "n": 0,
          "scriptPubKey": {
            "asm": "04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f OP_CHECKSIG",
            "hex": "4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac",
            "type": "pubkey"
      "hex": "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000"
  "time": 1231006505,
  "mediantime": 1231006505,
  "nonce": 2083236893,
  "bits": "1d00ffff",
  "difficulty": 1,
  "chainwork": "0000000000000000000000000000000000000000000000000000000100010001",
  "nTx": 1,
  "nextblockhash": "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048"

Decode the hex field - with the iconic Chancellor on brink evidence

ubuntu@btc:~$ echo “01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000” | xxd -r -p
????M??EThe Times 03/Jan/2009 Chancellor on brink of second bailout for banks?????*CAg????UH'g?q0?\֨(?9 ?yb??a޶I???L?8??U???\8M??

Get Info

There are a few ways to get information

bitcoin-cli help | grep info
gettxoutsetinfo ( "hash_type" )
getmemoryinfo ( "mode" )
getaddednodeinfo ( "node" )
getdescriptorinfo "descriptor"
getindexinfo ( "index_name" )
getaddressinfo "address"