Like me, you’re probably more comfortable on a CLI. Here’s a quick way to use docker to set up a Bitcoin Wallet and trade Bitcoin for free on Testnet with Electrum. You can use the same tools to manage your real Bitcoin wallet too.

Setup

Make sure you have Docker for your OS ( Mac, Windows, Linux)

Run the electrum-cli docker image

Electrum is a python-based Docker wallet with a both a gui and good cli. I’ve put together electrum-cli, a lightweight Alpine-linux Docker image with Electrum signed and installed with jq.

docker run -it tonymet/electrum-cli

Create a wallet

First , create the wallet & testnet wallet.

# electrum requires first a real wallet. We won't use it afterward
$ electrum create
# create testnet wallet
$ electrum --testnet create

Now start the daemon in the background. This manages network connections

$ electrum --testnet daemon&
# tell the daemon to load your testnet wallet
$ electrum --testnet daemon load_wallet
# electrum --testnet getbalance | jq .confirmed
"0"

At this point your wallet is loaded

Receive Some Bitcoin from Testnet

Get your wallet address

# use jq to get your first address.
$ electrum --testnet listaddresses |jq .[0]
"mn9Rxxxxxxxxxxxxxxxxx"

Visit a popular → Bitcoin Testnet Faucet to get some coin. Enter your testnet wallet address there. They will give you a txid for you to pull using electrum gettransaction

Now fetch the transaction

$ electrum --testnet gettransaction TRANSACTION_ID
# get the latest transaction
$ electrum --testnet history|jq '.[-1]'

{
  "confirmations": 1,
  "date": "2017-12-01 01:42",
  "height": 1251680,
  "input_addresses": [
    "xxxxx"
  ],
  "label": "",
  "output_addresses": [
    "xxxxx",
    "xxxxx"
  ],
  "timestamp": 1512092568,
  "txid": "xxxxx",
  "value": "2.29999999"
}

Now you should have some real Bitcoin on Testnet! Let’s check our balance using electrum getbalance and jq

$ electrum --testnet getbalance | jq .confirmed
"3.19757632"

Security Concerns

Even though this is a testnet wallet, let’s always keep security top of mind. For one, you may accidentally push your image to a docker repo and expose your wallet. Also, your docker images are not (yet) encrypted, so any wallet info in these images should be considered compromised.

Next Steps

In upcoming sessions we’ll look into securing your wallet using encrypted images and docker volumes.