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

Interaction between components

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.16.3. 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: /home/USERNAME/.litecoin/litecoin.conf

txindex=1

server=1

daemon=1

debug=1

discardfee=0.00000001

mintxfee=0.00000001

minrelaytxfee=0.00000001

rpcuser=jason

rpcpassword=litecoin

zmqpubrawblock=tcp://127.0.0.1:28332

zmqpubrawtx=tcp://127.0.0.1:28333

Then download Litecoin core and run litecoind with the following commands:

decompress the tar ball:

tar zxf litecoin-0.16.3-x86_64-linux-gnu.tar.gz

Run litecoind:

litecoin-0.16.3/bin/litecoind

Setup lnd

lnd, c-lightning and ecliar are 3 different implementations of lightning protocol. We will compile lnd v0.4-beta with 2 patches.

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: Go and dep and export related environment variables

sudo apt-get install golang-1.10-go export GOPATH=~/gocode export PATH=$PATH:$GOPATH/bin:/usr/lib/go-1.10/bin 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”

cd $GOPATH/src/github.com/lightningnetwork/lnd 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:

dep ensure

go install . ./cmd/...

Run lnd:

lnd --litecoin.active --litecoin.mainnet --debuglevel=debug --litecoin.node=litecoind --litecoind.rpcuser=jason --litecoind.rpcpass=litecoin --litecoind.zmqpubrawblock=tcp://127.0.0.1:28332 --litecoind.zmqpubrawtx=tcp://127.0.0.1:28333--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

lnd start

Open another terminal and run command lncli --network mainnet --chain litecoin 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.

lnd sync blocks

lnd finished catching up block hashes

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 --network mainnet--chain litecoin 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 :

Bitrefill URI

The URI consists of PUB_KEY@IP:PORT.

Use the following command to connect to “Jason_LTC” from “Jason_test”:

lncli --network mainnet--chain litecoin connect 032647b6f59ba2fe29e30da79d58e5e79461daab57f66302baf5eaef88dce97773@174.138.5.208: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 --network mainnet--chain litecoin 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 lncli --network mainnet--chain litecoin listchannels

"channels": [

{

"active": true,

"remote_pubkey": "026b36cc275199b5c38e9509da2e2ec497508bef97ff2ab06c2afa02c6d567ff1b",

"channel_point": "6cba219c3e113861fc3eb702db4de9082e58ac681cabfbdf7c9589a7684c4638:0",

"chan_id": "1533526250656432128",

"capacity": "200000",

"local_balance": "0",

"remote_balance": "181900",

"commit_fee": "18100",

"commit_weight": "552",

"fee_per_kw": "25000",

"unsettled_balance": "0",

"total_satoshis_sent": "0",

"total_satoshis_received": "0",

"num_updates": "0",

"pending_htlcs": [

],

"csv_delay": 576

},

Since the local balance is 0 at “Jason_LTC”, we generate an invoice and ask “Jason_test” to pay.

lncli --network mainnet--chain litecoin 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” .

{

"r_hash": "5aba7a6d8103370266508921d2c80960bf14c3cbe5ac7b11979eaa337378aaea",

"pay_req": "lnltc1m1pdtaggcpp5t2a85mvpqvmsyejs3ysa9jqfvzl3fs7tukk8kyvhn64rxumc4t4qdqcd4u47ar9wd697urp09kk2mn5cqzjqxqzuywpn6mhcu4s7fj9q3ndu09805t3q8jwllcd8p2e9plrfcehw3xyr9lpnux9jgcv64mwpvk3599qza6a32uzak2y03ttrgnrmf554ffrgpxnnrk4"

}

Now copy the invoice and paste in node “Jason_test”:

lncli --network mainnet--chain litecoin payinvoice lnltc1m1pdtaggcpp5t2a85mvpqvmsyejs3ysa9jqfvzl3fs7tukk8kyvhn64rxumc4t4qdqcd4u47ar9wd697urp09kk2mn5cqzjqxqzuywpn6mhcu4s7fj9q3ndu09805t3q8jwllcd8p2e9plrfcehw3xyr9lpnux9jgcv64mwpvk3599qza6a32uzak2y03ttrgnrmf554ffrgpxnnrk4

The following json is returned upon successful payment:

{

"payment_error": "",

"payment_preimage": "a985f9d31c1e6ffc8b226f1436cd57c57f692497bf2e611b48efbf48e66f5bc3",

"payment_route": {

"total_time_lock": 1395328,

"total_amt": 100000,

"hops": [

{

"chan_id": 1529615287798333440,

"chan_capacity": 200000,

"amt_to_forward": 100000,

"expiry": 1395328

}

]

}

}

Go back to node “Jason_LTC” and use command lncli --network mainnet--chain litecoin 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!