Category: bitcoin

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.

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.

If you control the private key, you control the sats.

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

Paper wallets should not be confused with mnemonic seed backups. Paper wallets store one public-private key pair, whereas mnemonics are human-readable seeds for re-generating multiple keys and addresses.

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

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?

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 shit coins have usually not done enough research.

Websites:

Options:

Articles:

Books:

  • makingtheswitch
  • 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

Books to avoid:

  • Making the Switch: A Guide to Safely Joining the Bitcoin Economy by Matthias J Karber - is a rank average book with lots of waffle but not content that will truly help you understand. Furthermore it talks about cryptocurrencies - not just the real deal - Bitcoin.

Yeticold

I like python, so testing out yeticold was alright. I managed to get it up and running on my raspberry pi (although thy recommend using a generic craptop).

There are 3 options of wallet to choose:

  • Level 3 (for > $50000) - never connected to the net
  • level 2 (for $5000 to $50000) requiring a single laptop
  • level 1 (for up to $5000) only requiring a single laptop

Yeticold Level 1

I would suggest using the testnet as the blockchain is about 14 Gb and not 380Gb.

The process:

  1. It downloads bitcoin core and verifies its has not been modified
  2. It installs bitcoin core and downloads the block chain
  3. Then it starts a flask app (yeticold)
  4. The webpage gives a few options: create wallet, recover wallet and erase laptop
  5. Creating a wallet - requires the full blockchain to download - which takes fucking ages at least from my context. Espescailly with bitcoinqt - bitcoind takes less time.
  6. You then click Next and it will go to YHopenbitcoin redirecting to YHgetseed - to further randomise (add entrophy) to your bitcoin seed.you type 0 and 1 for 256 characters and then click Next

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 Info

There are a few ways to get information

bitcoin-cli help | grep info
getblockchaininfo
getmempoolinfo
gettxoutsetinfo ( "hash_type" )
getmemoryinfo ( "mode" )
getrpcinfo
getmininginfo
getaddednodeinfo ( "node" )
getnetworkinfo
getpeerinfo
getdescriptorinfo "descriptor"
getindexinfo ( "index_name" )
getaddressinfo "address"
getwalletinfo

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
685608

Raspberry Pi dedicated bitcoin node with Ubuntu ARM Instructions

In this post, we build a bitcoin node with a raspberry pi.

Requirements

  • Raspberry Pi with 4Gb or more
  • External hardrive 500Gb or more
  • SD card reader

Installing Ubuntu Server

Use these intructions to Install ubuntu server for raspberry pi

Use Ubuntu Server 20.04.1 LTS

Secure Ubuntu

Copy your over to authorized keys over to raspbeery pi with:

ssh-copy-id ubuntu@rasp_ip

Now you can edit sudo vim /etc/ssh/sshd_config and set:

PasswordAuthentication no
PermitRootLogin no
UsePAM no
X11Forwarding no

Reload SSH:

sudo systemctl reload ssh

You can also use this more pedantic openSSH hardening guide

Then you want to enable ufw Uncomplicated firewall - an interface to iptables.

Check the current ufw status with:

sudo ufw status

Allow ssh and enable:

sudo ufw allow OpenSSH
sudo ufw enable

I think by default incoming traffic not in the allowed will be blocked

Install Bitcoin Core

Go to https://bitcoin.org/bin and download the arm version you need:

Importantly you want bitcoin-0.21.0-aarch64-linux-gnu.tar.gz.

I thought this was the one bitcoin-0.21.0-arm-linux-gnueabihf.tar.gz but it is not. Perhaps it is for 32 bit CPU architecture - I'm not sure

Ensure you have your 500Gb or more external storage plugged in and use this tutorial to mount the partition permanently

Download bticoin core, verify and unpack:

cd /opt
sudo wget https://bitcoincore.org/bin/bitcoin-core-0.21.0/bitcoin-0.21.0-aarch64-linux-gnu.tar.gz
sha256-sum bitcoin-0.21.0-aarch64-linux-gnu.tar.gz
# Ensure it matches the given signatures on bticoin.org
tar xzf bitcoin-0.21.0-aarch64-linux-gnu.tar.gz
sudo install -m 0755 -o root -g root -t /usr/local/bin/ bitcoin-0.21.0/bin/*

Now bitcoind and bitcoin-cli should be in your path.

Make a directory on your 500GB plus HD:

cd /mnt/my-hd
mkdir bitcoin

Start bitcoind specifying the datadir:

bitcoind -daemon -datadir=/mnt/my-hd/bitcoin

This should also create a directory in ~/.bitcoin/bitcoin.conf specifying that location.

Now you have to wait for the entire blockchain - journal of transaction from the epoch of bitcoin to download

Ensure you have downloaded the full blockchain by checking the blockcount on bitinfo, then checking what your node block count is:

bitcoin-cli getblockcount
659835

Open up your node to the Internet

Inbound connections need to be enabled for port 8333 from the public internet.

So enable that with the firewall ufw:

sudo ufw allow 8333

Ensure all is good:

udo ufw status
Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere                  
8333                       ALLOW       Anywhere                  
OpenSSH (v6)               ALLOW       Anywhere (v6)             
8333 (v6)                  ALLOW       Anywhere (v6)    

Then you need to do the following things:

  1. Giving your computer a static (unchanging) internal IP address by configuring the Dynamic Host Configuration Protocol (DHCP) on your router.
  2. Forwarding inbound connections from the Internet through your router to your computer where Bitcoin Core can process them.

The above tasks can be done in your router with DHCP address reservation and using NAT (Network Address Translation) port forwarding

You can test connectivity with:

bitcoin-cli getnetworkinfo

Ensure there are inbound connections "connections_in": 0,

or by going to bitnodes

Ensure bitcoind starts at startup - for power failure events

The crontab entry suggested by the full node guide does not work for me.

@reboot bitcoind -daemon

Rather create a file:

sudo touch /etc/systemd/system/bitcoind.service

Add:

[Unit]
Description=bitcoin
After=network.target

[Service]
Type=simple
User=ubuntu
Group=ubuntu

Environment=BITCOIN_PID=/home/ubuntu/bitcoin/bitcoin.pid
Environment=BITCOIN_HOME=/home/ubuntu/bitcoin/.bitcoin

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

[Install]
WantedBy=multi-user.target

Then enable and start:

sudo systemctl daemon-reload
sudo systemctl enable bitcoind
sudo systemctl start bitcoind

Update April 2021

The problem is I was using a lot of data.
Which was okay but I think my ISP starts capping (it claims not to though).

2000GB in a month, at about 80GB a day is a problem.
I wasn't even at home during a lot of that time.

bitcoin-node-uses lots of data

So the best thing to do is limit the usage in your bitcoin.conf as suggested by this reddit post.

maxconnections=10
maxuploadtarget=50

That limits the number of connected peers and sets the max upload per day at 50MB - thereafter no historical blocks will be sent over the network. I will play my part but not at the expenses of productivity on my network.

There is also a good article on reducing traffic .

Sources