How to run a Bitcoin Lightning Network node on Windows

Johnny Pham
12 min readJun 24, 2018

--

Updated Nov 2023

This tutorial will go through the steps needed to set up a Lightning Network (LN) node on Bitcoin mainnet using a Windows computer.

Requirements

  • A computer that is running Windows 10 (or above) and capable of running a Bitcoin full node (pruning is allowed)
  • A small amount of bitcoin to make test payments with. A good amount would be 0.001 BTC
  • A basic understanding of how the LN works will be helpful

Sources

This tutorial combines information from different sources and has been modified to be a little more beginner-friendly. Sources include:

A note on offline LN nodes

Running a LN node on a machine that sees significant downtime is not recommended. Offline nodes cannot relay transactions and funds locked in a channel cannot be used for anything else, so node operators may close channels with a peer that is frequently offline.

One final warning

Lightning Network Daemon (LND) and other LN node implementations are still in beta and there’s a small chance any funds locked to your LN node could be permanently lost. Only use amounts you’re comfortable with potentially losing.

Let’s get started

Bitcoin full node configuration

Even if you already have a running full node, you should still go through this section.

If you aren’t already running a Bitcoin full node, there are many resources out there to help you set one up. Comprehensive documentation can be found here: https://bitcoin.org/en/full-node

Note that LND does not require a non-pruning node but aggressive pruning will impact performance.

Once your full node has downloaded the entire blockchain, you have to edit your bitcoin.conf file. The default location for this file is :

C:\Users\replace_with_your_username\AppData\Roaming\Bitcoin

If it doesn’t already exist at that path, create a new file called bitcoin.conf. Note that the file’s extension should be .conf, not something else like bitcoin.conf.txt. Open it with a text editor and add the following lines. Choose a username and password for rpcuser and rpcpassword:

server=1
daemon=1
rpcuser=replace_with_your_username
rpcpassword=replace_with_your_password
zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28333

If you’re running an unpruned node, you can add txindex=1 on a separate line for a small performance improvement. This will use up more disk space.

Your bitcoin.conf should look something like this:

bitcoin.conf file

Save the file. Restart Bitcoin Core for the changes to take effect.

Lightning Network Daemon (LND)

LND is an implementation of a LN node; in other words, it is one of many available programs to interact with the LN. Other popular implementations include Core Lightning, Eclair, Electrum and Rust Lightning.

Many nodes on the LN require a minimum balance to establish a channel with them. This minimum may be too high for someone who’s experimenting with LN for the first time and is uncomfortable handling relatively large amounts of money. To avoid this, this tutorial will show you how to set up 2 LN nodes, establish a channel between them and send small payments back and forth with yourself. Afterwards, you can use these same techniques to connect to other nodes.

Download and configure LND

Go to https://github.com/lightningnetwork/lnd/releases

For the latest release, go to Assets and select Show all assets. Download the appropriate LND binaries for Windows, e.g. lnd-windows-amd64-v0.15.2-beta.zip for 64-bit machines.

Extract the downloaded zip archive. Note that there are two binaries: lnd.exe and lncli.exe:

  • lnd.exe is the component that runs the actual LN node
  • lncli.exe is a command-line program to manage and interact with your LN node. If you prefer to use a GUI, see the section “GUI-based web apps for LN” near the end of this article.

Open a command prompt in the extracted directory containing lnd.exe and lncli.exe.

To begin initialization of a LN node, run lnd.exe with the following arguments. Set bitcoind.rpcuser and bitcoind.rpcpass to the corresponding values from your bitcoin.conf file. Set externalip to your IP address to accept incoming connections from other nodes:

lnd.exe --bitcoin.active --bitcoin.mainnet --bitcoin.node=bitcoind --bitcoind.rpcuser=replace_with_rpcuser_from_bitcoin.conf --bitcoind.rpcpass=replace_with_rpcpassword_from_bitcoin.conf --bitcoind.zmqpubrawblock=tcp://127.0.0.1:28332 --bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333 --externalip=X.X.X.X

The initialization should proceed until it waits for a wallet encryption password. There’s more configuration to be done, so let’s shut down this LN node for now (ctrl+C to shut it down in command prompt).

Let’s create lnd.conf to simplify the above command. The default location is:

C:\Users\replace_with_your_username\AppData\Local\Lnd

In the Lnd folder, create a new file called lnd.conf, open it with a text editor and add the following lines. Set bitcoind.rpcuser and bitcoind.rpcpass to the corresponding values from your bitcoin.conf file. Set externalip to your IP address. The optional color and alias fields specify the colour and name your LN node will have on LN explorers:

[Bitcoin]
bitcoin.active=1
bitcoin.node=bitcoind
bitcoin.mainnet=1
[bitcoind]
bitcoind.rpcuser=replace_with_rpcuser_from_bitcoin.conf
bitcoind.rpcpass=replace_with_rpcpassword_from_bitcoin.conf
bitcoind.zmqpubrawblock=tcp://127.0.0.1:28332
bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333
[Application Options]
externalip=X.X.X.X
color=#FF9900
alias=sashimi negitoro

Your lnd.conf should look something like this:

lnd.conf file

Copy the entire lnd folder so that you now have two folders, for example C:\Users\replace_with_your_username\AppData\Local\Lnd and C:\Users\replace_with_your_username\AppData\Local\Lnd-2. These folders will be referred to as LND data folder #1 and LND data folder #2.

Initialize LN nodes and create wallets

Let’s run 2 LN nodes using the new lnd.conf file.

Copy and paste the entire downloaded lnd folder so that there are two folders, each with their own lnd.exe and lncli.exe. You should now have something like this:

C:\lnd-windows-amd64-v0.15.2-beta\lnd.exeC:\lnd-windows-amd64-v0.15.2-beta\lncli.exeC:\lnd-windows-amd64-v0.15.2-beta - Copy\lnd.exeC:\lnd-windows-amd64-v0.15.2-beta - Copy\lncli.exe

The first folder (LND folder #1) will be used for LN node #1 and the second folder (LND folder #2) will be used for LN node #2.

Open up 2 command prompts in LND folder #1 (I’ll refer to them as command prompt #1 and command prompt #2).

To start up LN node #1, run lnd.exe with the following arguments in command prompt #1. Since you’ll be running 2 LN nodes, you’ll specify the ports you want each node to be listening to:

lnd.exe --rpclisten=127.0.0.1:10001 --listen=127.0.0.1:10011 --restlisten=localhost:8001

The initialization will proceed until it waits for a wallet encryption password. You will now use command prompt #2 to interact with LN node #1, which is running in command prompt #1.

To start the process of creating a wallet for LN node #1, run the following lncli.exe create command in command prompt #2:

lncli.exe --rpcserver=127.0.0.1:10001 create

Follow the instructions to set a password for your wallet. Record the password and seed phrase it gives you.

Keep the 2 command prompts open. Now, you’ll do the same process for LND folder #2, to create a wallet for LN node #2.

Open up 2 more command prompts in LND folder #2 (I’ll refer to them as command prompt #3 and command prompt #4).

To start up LN node #2, run lnd.exe with the following arguments in command prompt #3. Note that LN node #2 will be listening for commands on different ports and also note the additional datadir argument which should be set to LND data folder #2:

lnd.exe --rpclisten=127.0.0.1:10002 --listen=127.0.0.1:10012 --restlisten=localhost:8002 --datadir="C:\Users\replace_with_your_username\AppData\Local/lnd-2"

When it waits for a wallet encryption password, you will now use command prompt #4 to interact with LN node #2, which is running in command prompt #3.

To start the process of creating a wallet for LN node #2, run the following lncli.exe create command in command prompt #4:

lncli.exe --rpcserver=127.0.0.1:10002 create

Follow the instructions to set a password for your wallet. Record the password and seed phrase it gives you.

You should now have 4 open command prompts:

Command prompt #1 is running LN node #1

Command prompt #2 is open in LND folder #1, and waiting for further commands

Command prompt #3 is running LN node #2

Command prompt #4 is open in LND folder #2, and waiting for further commands

Funding LN nodes

You will now fund your LN nodes.

First, you must find the path where your admin.macaroon file is stored. Macaroons are used by LND for RPC authentication (more info here: https://github.com/lightningnetwork/lnd/blob/master/docs/macaroons.md). Because you’re trying to run 2 LN nodes, you must specify the macaroon each instance of lncli.exe should use, depending on which LND node you’re trying to communicate with.

In LND data folder #1, there should now be several macaroon files. Go to this path:

C:\Users\replace_with_your_username\AppData\Local\Lnd\data\chain\bitcoin\mainnet

Make note of the full path of the admin.macaroon file:

.macaroon files

To create a new on-chain address for LN node #1, run the following lncli.exe newaddress command in command prompt #2. Set macaroonpath to the full path of your admin.macaroon file in LND data folder #1:

lncli.exe --rpcserver=127.0.0.1:10001 --macaroonpath=”C:\Users\replace_with_your_username\AppData\Local\Lnd\data\chain\bitcoin\mainnet\admin.macaroon” newaddress p2wkh

A new address is generated for LN node #1. Record it somewhere:

The generated on-chain address (output of newaddress command)

Now, let’s do the same process for LN node #2. Inside LND data folder #2, there should be a separate set of .macaroon files, for example C:\Users\replace_with_your_username\AppData\Local\Lnd-2\chain\bitcoin\mainnet.

To create a new on-chain address for LN node #2, run the following lncli.exe newaddress command in command prompt #4 . Set macaroonpath to the full path of your admin.macaroon file in LND data folder #2:

lncli.exe --rpcserver=127.0.0.1:10002 --macaroonpath=”C:\Users\replace_with_your_username\AppData\Local\Lnd-2\data\chain\bitcoin\mainnet\admin.macaroon” newaddress p2wkh

A new address is generated for LN node #2. Record it somewhere.

To fund your 2 LN nodes, send bitcoin to the 2 generated addresses.

To check the on-chain balance of your LN nodes, you can run the following lncli.exe walletbalance commands in command prompts #2 and #4 respectively:

lncli.exe --rpcserver=127.0.0.1:10001 --macaroonpath=”C:\Users\replace_with_your_username\AppData\Local\Lnd\data\chain\bitcoin\mainnet\admin.macaroon” walletbalancelncli.exe --rpcserver=127.0.0.1:10002 --macaroonpath=”C:\Users\replace_with_your_username\AppData\Local\Lnd-2\data\chain\bitcoin\mainnet\admin.macaroon” walletbalance

Depending on the confirmation status of the transaction, the confirmed_balance or unconfirmed_balance fields should be equal to the amount you sent:

Wallet balance of a LN node (output of walletbalance command)

Connecting a LN node with a peer

You will now connect LN node #1 with LN node #2. Note that this is not the same thing as setting up a payment channel; you will do that in the next section.

To get the public key of LN node #2, run the following lncli.exe getinfo command in command prompt #4:

lncli.exe --rpcserver=127.0.0.1:10002 --macaroonpath=”C:\Users\replace_with_your_username\AppData\Local\Lnd-2\data\chain\bitcoin\mainnet\admin.macaroon” getinfo

The public key should be near the top, labeled as identity_pubkey:

State of a LN node, including the public key (partial output of getinfo command)

To connect LN node #1 with LN node #2, run the following lncli.exe connect command in command prompt #2. Replace public_key_of_LN_node_#2 with the public key that you obtained from the previous command:

lncli.exe --rpcserver=127.0.0.1:10001 --macaroonpath=”C:\Users\replace_with_your_username\AppData\Local\Lnd\data\chain\bitcoin\mainnet\admin.macaroon” connect “public_key_of_LN_node_#2@127.0.0.1:10012”

It should successfully connect.

To see a list of a node’s connected peers, run the following lncli.exe listpeers commands in command prompts #2 and #4 respectively:

lncli.exe --rpcserver=127.0.0.1:10001 --macaroonpath=”C:\Users\replace_with_your_username\AppData\Local\Lnd\data\chain\bitcoin\mainnet\admin.macaroon” listpeerslncli.exe --rpcserver=127.0.0.1:10002 --macaroonpath=”C:\Users\replace_with_your_username\AppData\Local\Lnd-2\data\chain\bitcoin\mainnet\admin.macaroon” listpeers
A connected peer of a LN node (partial output of listpeers command)

Establish a payment channel

Now that your 2 LN nodes are aware of each other, they can set up a payment channel.

To open a channel between your LN nodes, run the following lncli.exe openchannel command in command prompt #2. This will use LN node #1’s on-chain balance to send an on-chain transaction and lock those funds in a channel. Set node_key to the same public key as before. Set local_amt to the amount (in sats) you want to lock in the channel. Set sat_per_vbyte to an appropriate fee (in sats). Set min_confs to zero if the previous funding transactions are still unconfirmed:

lncli.exe --rpcserver=127.0.0.1:10001 --macaroonpath=”C:\Users\replace_with_your_username\AppData\Local\Lnd\data\chain\bitcoin\mainnet\admin.macaroon” openchannel --node_key=public_key_of_LN_node_#2 --local_amt=10000 --sat_per_vbyte=5 --min_confs=0

If successful, a transaction ID is displayed, which you can enter in a block explorer to track the on-chain confirmations. Smaller channels require 3 confirmations before they are established.

To see a list of channels your LN nodes have established, run the following lncli.exe listchannels commands in command prompts #2 and #4 respectively:

lncli.exe --rpcserver=127.0.0.1:10001 --macaroonpath=”C:\Users\replace_with_your_username\AppData\Local\Lnd\data\chain\bitcoin\mainnet\admin.macaroon” listchannelslncli.exe --rpcserver=127.0.0.1:10002 --macaroonpath=”C:\Users\replace_with_your_username\AppData\Local\Lnd-2\data\chain\bitcoin\mainnet\admin.macaroon” listchannels
A channel of a LN node (partial output of listchannels command)

Note that the local balance for LN node #1 will be equal to the amount that you sent in the previous transaction, while the local balance for LN node #2 will be 0.

Send a payment

LN node #2 has no outgoing capacity and cannot send payments. Your only choice is to send a payment from LN node #1.

To generate an invoice for LN node #2, run the following lncli.exe addinvoice command in command prompt #4. Set amt to the amount you want to send (in sats):

lncli.exe --rpcserver=127.0.0.1:10002 --macaroonpath=”C:\Users\replace_with_your_username\AppData\Local\Lnd-2\data\chain\bitcoin\mainnet\admin.macaroon” addinvoice --amt=10000

An invoice is generated. Copy the payment_request value:

An invoice generated by a LN node (output of addinvoice command)

To fulfil the above invoice and send a payment from LN node #1 to LN node #2, run the following lncli.exe sendpayment command in command prompt #2. Set pay_req to the payment request from the previous command:

lncli.exe --rpcserver=127.0.0.1:10001 --macaroonpath=”C:\Users\replace_with_your_username\AppData\Local\Lnd\data\chain\bitcoin\mainnet\admin.macaroon” sendpayment --pay_req=replace_with_payment_request_from_LN_node_#2

Type “yes” and hit enter to confirm the payment. The status field should indicate that the payment succeeded:

A successful payment (partial output of sendpayment command)

To check the updated balances of both nodes, run the following lncli.exe walletbalance commands in command prompts #2 and #4 respectively:

lncli.exe --rpcserver=127.0.0.1:10001 --macaroonpath=”C:\Users\replace_with_your_username\AppData\Local\Lnd\data\chain\bitcoin\mainnet\admin.macaroon” walletbalancelncli.exe --rpcserver=127.0.0.1:10002 --macaroonpath=”C:\Users\replace_with_your_username\AppData\Local\Lnd-2\data\chain\bitcoin\mainnet\admin.macaroon” walletbalance

That’s it! You just sent some bitcoin through an established payment channel between your two LN nodes.

Close a channel

To close the channel between the two nodes, you first need a way to uniquely identify the channel.

To get the unique channel identifier, run the following lncli.exe listchannels command in command prompt #2:

lncli.exe --rpcserver=127.0.0.1:10001 --macaroonpath=”C:\Users\replace_with_your_username\AppData\Local\Lnd\data\chain\bitcoin\mainnet\admin.macaroon” listchannels

You need the channel_point value. Channel_point consists of a long string (funding_txid) and a number (output_index), separated by a colon (funding_txid:output_index). With the below example, funding_txid is 1b64f61dfc6fbbaf93bd668ff184c64ee3445bc48b0b077f82b5e26e85864ace and output_index is 1:

channel_point uniquely identifies a channel (partial output of listchannels command)

To close the channel, run the following lncli.exe closechannel command in command prompt #2. Setfunding_txid and outout_index to the values from your channel_point:

lncli.exe --rpcserver=127.0.0.1:10001 --macaroonpath=”C:\Users\replace_with_your_username\AppData\Local\Lnd\data\chain\bitcoin\mainnet\admin.macaroon” closechannel --funding_txid=replace_with_funding_txid --output_index=replace_with_output_index

If successful, a transaction ID is displayed, which you can enter in a block explorer to track the closing transaction’s status.

To check the on-chain balance of both LN nodes and confirm that the LN payments you made have now been settled on the mainnet Bitcoin blockchain, run the following lncli.exe walletbalance commands in command prompts #2 and #4 respectively:

lncli.exe --rpcserver=127.0.0.1:10001 --macaroonpath=”C:\Users\replace_with_your_username\AppData\Local\Lnd\data\chain\bitcoin\mainnet\admin.macaroon” walletbalancelncli.exe --rpcserver=127.0.0.1:10002 --macaroonpath=”C:\Users\replace_with_your_username\AppData\Local\Lnd-2\data\chain\bitcoin\mainnet\admin.macaroon” walletbalance
New on-chain balance reflects payments made over LN (output of walletbalance command)

To send on-chain BTC from your LN node, run the following lncli.exe sendcoins commands in command prompts #2 and #4 respectively. Set addr to the receiving address, amt to the amount (in sats) you want to send and sat_per_vbyte to an appropriate fee (in sats):

lncli.exe --rpcserver=127.0.0.1:10001 --macaroonpath="C:\Users\replace_with_your_username\AppData\Local\Lnd\data\chain\bitcoin\mainnet\admin.macaroon" sendcoins --addr=onchain_bitcoin_address --amt=0 --sat_per_vbyte=1lncli.exe --rpcserver=127.0.0.1:10002 --macaroonpath=”C:\Users\replace_with_your_username\AppData\Local\Lnd-2\data\chain\bitcoin\mainnet\admin.macaroon” sendcoins --addr=onchain_bitcoin_address --amt=0 --sat_per_vbyte=1

To shut down LND, run the following lncli.exe stop commands in command prompts #2 and #4 respectively:

lncli.exe --rpcserver=127.0.0.1:10001 --macaroonpath="C:\Users\replace_with_your_username\AppData\Local\Lnd\data\chain\bitcoin\mainnet\admin.macaroon" stoplncli.exe --rpcserver=127.0.0.1:10002 --macaroonpath="C:\Users\replace_with_your_username\AppData\Local\Lnd-2\data\chain\bitcoin\mainnet\admin.macaroon" stop

GUI-based web apps for LN

If you don’t like using the command line to interact with your LN node, you can use GUI-based web apps such as Ride-The-Lightning (RTL): https://github.com/Ride-The-Lightning/RTL

Ride-The-Lightning user interface

LN Explorers

If you want to open channels with other public nodes or you want to see what your node looks like to peers, you can use a LN explorer such as:

https://terminal.lightning.engineering/
https://mempool.space/lightning
https://1ml.com/

Snapshot of a visualization of the LN (https://mempool.space)

Feedback

Let me know in the comments if anything was unclear and can be improved, or if you need help.

--

--