Skip to content

Instantly share code, notes, and snippets.

@asbjornenge
Last active February 7, 2018 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asbjornenge/110274c65113672c3c57814366eb98fb to your computer and use it in GitHub Desktop.
Save asbjornenge/110274c65113672c3c57814366eb98fb to your computer and use it in GitHub Desktop.
bcoin playing nice with neutrino via docker

A short demo of neutrino support in bcoin ⚡ 🎉

Prerequisites

In order to test our neutrino node, we need to mine a few test-coins we can send. For that we need the primary wallet address of our fullnode.

By default bcoin stores it's configuration in ~/.bcoin (/root/.bcoin inside the container). We want this configuration to stay consisten between container restarts, so we mount it to a temporary path on our local filesystem (/tmp/bcoin).

docker run --rm -v /tmp/bcoin:/root/.bcoin --name bcoin -d asbjornenge/bcoin:neutrino ./bin/bcoin --network=simnet

That should have started a fullnode in a container in the background. Next, let's get the primary address, set it to a variable and kill the container (we are going to restart it with a new parameter).

docker exec -it bcoin ./bin/bcoin wallet --network=simnet --api-key=yolo account get default
export NODE_ADDR=<receiveAddress>
docker kill bcoin

Bcoin fullnode

Next, we can start the bcoin fullnode with neutrino support.

docker run --rm -v /tmp/bcoin:/root/.bcoin --name bcoin -it asbjornenge/bcoin:neutrino ./bin/bcoin --network=simnet --cf --index-filter --coinbase-address=$NODE_ADDR --http-host=0.0.0.0 --api-key=yolo

We also need to mine some testcoins we can send.

docker exec -it bcoin ./bin/bcoin cli --network=simnet --api-key=yolo rpc setgenerate 1

Neutrino node

Before we can start the neutrino node, we need to get the ip address of the fullnode.

docker exec -it bcoin ip addr show eth0
export NODE_IP=<ip>

Next, lets start the neutrino node ✨

docker run --rm --name neutrino -it asbjornenge/bcoin:neutrino ./bin/neutrino --network=simnet --nodes=$NODE_IP --api-key=yolo

Send coins

Let's send some coins from bcoin to neutrino 💰

docker exec -it neutrino ./bin/bcoin wallet --network=simnet --api-key=yolo account get default
export NEUTRINO_ADDR=<receiveAddress>
docker exec -it bcoin ./bin/bcoin wallet --network=simnet --api-key=yolo send $NEUTRINO_ADDR 1

Check out balance on the neutrino node.

docker exec -it neutrino ./bin/bcoin wallet --network=simnet --api-key=yolo balance
{
  "account": -1,
  "tx": 1,
  "coin": 1,
  "unconfirmed": 100000000,
  "confirmed": 100000000
}

We successfully sendt some coins from a bcoin fullnode to a neutrino node. 🎉 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment