Goal, assumption and requirements: It assumed a linux box running Ubuntu with bitcoind already running. It also assumed that golang binary is installed.
ubuntu@bitcoin:~$ go version
go version go1.17.4 linux/arm64
ubuntu@bitcoin:~$ bitcoind --version
Bitcoin Core version v22.0.0
Bitcoind must be configured to use zeromq, as it's the way lnd and bitcoin will talk to each other. Configuration file must have following lines:
# zmq
zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28333
zmqpubhashblock=tcp://127.0.0.1:28334
Get the latest release according to your architecture from here
go get -u github.com/golang/dep/cmd/dep
curl -OL https://github.com/lightningnetwork/lnd/releases/download/v0.14.1-beta/lnd-linux-arm64-v0.14.1-beta.tar.gz
tar zxvf lnd-linux-arm64-v0.14.1-beta.tar.gz
cd lnd-linux-arm64-v0.14.1-beta/
make install tags="signrpc walletrpc chainrpc invoicesrpc"
Tags above are optional, but are required if you want to install stuffs like lightning terminal.
By default, configuration will be stored on $HOME/.lnd/lnd.conf
. This file can be updated or completely moved to a different location (which is my case, as I use an external storage). This is an example file:
[Application Options]
listen=0.0.0.0:9735
rpclisten=0.0.0.0:10009
restlisten=0.0.0.0:8080
maxpendingchannels=3
minchansize=10000
accept-keysend=true
tlsautorefresh=1
tlsdisableautofill=1
feeurl=
datadir=/data/lnd/data
logdir=/data/lnd/logs
[Bitcoind]
bitcoind.rpchost=127.0.0.1
bitcoind.rpcuser=USER
bitcoind.rpcpass=SUPERSECRETPASSWD
bitcoind.zmqpubrawblock=tcp://127.0.0.1:28332
bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333
[Bitcoin]
bitcoin.active=1
bitcoin.mainnet=1
bitcoin.node=bitcoind
bitcoin.defaultchanconfs=2
[tor]
tor.active=1
tor.control=127.0.0.1:9051
tor.socks=127.0.0.1:9050
tor.targetipaddress=127.0.0.1
tor section is optional, but luckily some people still wants to live in the shadows.
Create the /lib/systemd/system/lnd.service
with the following content:
[Unit]
Description=LND daemon
Requires=bitcoind.service
After=bitcoind.service
[Service]
ExecStart=/home/ubuntu/go/bin/lnd -C /data/lnd/lnd.conf
ExecStop=/home/ubuntu/go/bin/lncli stop
PIDFile=/tmp/lnd.pid
User=satoshi
Type=simple
[Install]
WantedBy=multi-user.target
Once the above is done, we need to reload systemd daemon and we can start the service:
sudo systemctl daemon-reload
sudo systemctl start lnd.service
sudo systemctl enable lnd.service
When we ran make install
we also installed lncli
which is the "control plane for your Lightning Network Daemon (lnd)".
lncli create # Initialize a wallet when starting lnd for the first time.
lncli unlock # Unlock an encrypted wallet at startup.
lncli newaddress # Generates a new address.
lncli addinvoice --amt 200 --memo "this is a description of the invoice" # Add a new invoice.
Once a new invoice is created, this is the output you'll get:
ubuntu@bitcoin:~$ lncli addinvoice --amt 200 --memo "this is a description of the memo"
{
"r_hash": "30751465db136f20a11b4991d080946ed9ead41b86538efb0f5aeb095cd2c31a",
"payment_request": "lnbc2u1psm82typp5xp63gewmzdhjpggmfxgapqy5dmv744qmsefca7c0tt4sjhxjcvdqdp4w35xjueqd9ejqcfqv3jhxcmjd9c8g6t0dcsx7e3qw35x2grdv4kk7cqzpgxqyz5vqsp5cdxv0r47ctjn3ykg2j7lwv3snzuxts7euaf8qpykxmtqf5ek9fys9qyyssqt2klfz0cdapy84mzt9q9y37atzmv2zph3776rn56wxtngk7d4rxh8vq48el0z2r49wv6564sexwwdh48c3v3y6lzw67x0xka7ltpjxgqj52qkk",
"add_index": "2",
"payment_addr": "c34cc78ebec2e53892c854bdf7323098b865c3d9e75270049636d604d3362a49"
}
If you want to pay this invoice, you need to use the payment_request
(if you want, you can pay it and I'll get 200 sats).