LN Toolkit Command

Installing

QuickStart

  1. Run:

    docker pull lntoolkit/lntoolkit:latest
    
  2. Test it's all working with this command:

    docker run --rm --network=host -v=$HOME/.lnd:/root/.lnd lntoolkit:latest test-connection
    

    That command should output something like the following, assuming your LND node is up and fully syncedP:

    2019/04/01 18:31:21 📄 Connection successful! LND pubkey is: 02639adf914ec9dfd8649c47de1d232de4a23b0719b1d8bd2bef9beb32f948018e, synced to chain is: true
    2019/04/01 18:31:21 📄 No tip to send. That's OK, I still love you! 🥰

    If it outputs an error, then check the parameters because it looks like there’s a problem connecting to your server. Running with the --verbose flag may give you more information on the source of the problem:

    docker run --rm --network=host -v=$HOME/.lnd:/root/.lnd lntoolkit:latest test-connection --verbose
    
  3. (Optional) If all that works, you can make running the docker command a little easier with a script.

Scripts

Using docker provides a simple deployment mechanism for updates but it does make it harder to call the executables.

The docker parameters usually stay the same for every call we make, so what we want is to reduce calls like this:

docker run --rm --network=host -v=$HOME/.lnd:/root/.lnd lntoolkit:latest is-synced --quiet

To calls like this:

lntoolkit is-synced --quiet

That’s not only shorter, it’s much clearer what’s going on.

To do that, create a script called lntoolkit in your $PATH that takes care of all the default parameters for your situation. That gives you a simple interface to the commands while still maintaining all of docker’s flexibility.

All lntoolkit programs themselves take a lot of command-line parameters, so a simple alias won't be enough. Instead the following scripts extract the command name from the start and put the remaining arguments at the end, allowing us to insert additional arguments.

Basic Script

Here’s a simple script that will call the programs in the docker container with certificates and macaroons in the usual place, and with the LND server on the same machine on the default port:

#! /usr/bin/env bash

remainder="${@:2}"

docker run --rm --network=host -v=$HOME/.lnd:/root/.lnd lntoolkit:latest $1 $remainder

Specifying a different server

Here’s a different script that assumes certificates and macaroons are in the usual place, but the server is on a different IP address and/or port - for example if you're running lntoolkit from a different machine. If this is the case, we don't need the --network=host option for docker, but we do need to specify which server and port the lntoolkit commands should use:

#! /usr/bin/env bash

remainder="${@:2}"

docker run --rm -v=$HOME/.lnd:/root/.lnd lntoolkit:latest $1 --server <your-server-ip>:<your-server-port> $remainder

Specifying different TLS certificate or macaroon file locations

There are a couple of ways to do this.

Method 1

All the lntoolkit commands can take a --certificate <tls-certificate-file-location> parameter and a --macaroon <admin-macaroon-file-location>, so you can just map whatever directory location(s) you want in docker and specify these mapped locations as parameters.

For example, say you have your TLS certificate (named ‘mytls.cert’) and macaroon (named ‘mymacaroon.macaroon’), both in a directory called ‘stuff’ in your home directory.

You’d then map the ‘stuff’ directory in the docker part of the command, and use the lntoolkit parameters to specify these mapped locations:

#! /usr/bin/env bash

remainder="${@:2}"

docker run --rm -v=$HOME/stuff:/root/stuff lntoolkit:latest $1 --certificate /root/stuff/mytls.cert --macaroon /root/stuff/mymacaroon.macaroon $remainder
Method 2

Alternatively you can just use docker’s mapping mechanism to map those files to the appropriate default locations and have lntoolkit pick the files up from those locations automatically:

#! /usr/bin/env bash

remainder="${@:2}"

docker run --rm -v=$HOME/stuff/mytls.cert:/root/.lnd/tls.cert  -v=$HOME/stuff/mymacaroon.macaroon:/root/.lnd/data/chain/bitcoin/testnet/admin.macaroon lntoolkit:latest $1 $remainder