Litecoin Lightning howto
Lightning has been deployed on Bitcoin mainnet and testnet for some time. There are more than 1000 lightning nodes on Bitcoin mainnet at the time of writing. However, Litecoin lightning has just began.
To use Litecoin ligthning network, you need at least:
- litecoind/ltcd: to interact with litecoin blockchain, for on-chain operations like open channel and close channel.
- lnd/c-lightning/eclair: to interact with lightning network, for sending and receiving lightning payment
You may also want some other tools such as:
- wallet: Zap lightning wallet
- network explorer: to view nodes and channels in the network
In this tutorial, we will go through:
- setup a litecoin daemon for lnd
- setup lnd
- open channel between nodes and send payment
Setup litecoind for lnd
This step is easy, a stock Litecoin Core will do the job. I will use the latest version available V0.15.1. However, it need some special parameters to work with lnd. To make things easier, I save the parameters in the default litecoin config file at default data directory:
Then download Litecoin core and run litecoind with the following commands:
decompress the tar ball:
Edit: lnd v0.4.2-beta has been released, please be advised to download the binary from LND github. In this new version, the patches have already been merged so you can skip the compilation and jump to step “Run lnd”.
Before compiling lnd, we need to install dependencies:
dep and export related environment variables
sudo apt-get install golang-1.10-go
go get -u github.com/golang/dep/cmd/dep
Download lnd source from github:
git clone https://github.com/lightningnetwork/lnd $GOPATH/src/github.com/lightningnetwork/lnd
checkout tag “v0.4-beta”
git checkout v0.4-beta
apply first patch to fix LTC dust limit:
git cherry-pick 0162b93 -m 1
apply second patch to fix DNS bootstrapper:
git cherry-pick ce856323906e4c7eafd55de8500e75f42fa93ca0
compile and install lnd:
go install . ./cmd/...
lnd --litecoin.active --litecoin.mainnet --debuglevel=debug --litecoin.node=litecoind --litecoind.rpcuser=jason --litecoind.rpcpass=litecoin --litecoind.zmqpath=tcp://127.0.0.1:28332 --externalip=MY_EXT_IP --alias=Jason_LTC
You will be asked to create a wallet (for the first time) or to unlock an existing wallet as shown below
Open another terminal and run command
lncli create to create a lightning wallet and then lnd will continue to sync blocks. It will take some time to catch up to latest block which is about 1390000.
I created 2 lightning nodes with alias “Jason_LTC” and “Jason_test”.
Before opening a channel and sending payments, we should first send some LTC to our lightning wallets. Use command
lncli newaddress p2wkh to get a native bech32 address which start with “ltc”. You need a litecoin wallet that support bech32 address, Electrum-LTC is one of them.
open channel between nodes and send payment
From the network explorer, you can find the URI of a node :
The URI consists of PUB_KEY@IP:PORT.
Use the following command to connect to “Jason_LTC” from “Jason_test”:
lncli connect email@example.com:9735
After that you can open a channel. The openchannel command accepts the public key of target node, local amount(number of satoshis that you commit to the channel) and push amount(number of satoshis pushed to target node during the initialization of the channel). Transaction fee can also be set with option “sat_per_byte”.
lncli openchannel --sat_per_byte 1 032647b6f59ba2fe29e30da79d58e5e79461daab57f66302baf5eaef88dce97773 200000 0
It returns the ID of the funding transaction. As opening a channel is an on-chain operation so we have to wait until the funding transaction is mined and 3 confirmation has been achieved. You can view the channel on network explorer.
At node “Jason_LTC”, we can check channel balance with command
Since the local balance is 0 at “Jason_LTC”, we generate an invoice and ask “Jason_test” to pay.
lncli addinvoice --memo="my_test_payment" --expiry 900 100000
It generates an invoice with expiry time 900 seconds and payment amount 100000 satoshis. The command returns the invoice starting with “lnltc” in the value of “pay_req” .
Now copy the invoice and paste in node “Jason_test”:
The following json is returned upon successful payment:
Go back to node “Jason_LTC” and use command
lncli listchannels and you should see the local balance has been increased to 100000.
We just finished our first Litecoin lightning payment. Since Bitrefill has enabled payment with Litecoin lightning, you can try to top up your mobile phones with LTC lightning!