Installing a mainnet LND node on Windows and controlling it from an iPhone Toxonaut Follow Dec 20, 2018 · 5 min read

Currently there is no working lightning wallet for iPhone that hosts a lightning node on the phone itself. There are a few wallets however which allow to access a node that you host yourself.

Thin wallet

Shango wallet

Zap wallet

In this tutorial I will show you how to install a Bitcoin full node and a LND node on a PC and then remote controlling it with an iPhone from outside the home network.

Step 1. Install Bitcoin Core

Go to https://bitcoin.org/en/download and download the window Bitcoin installer (exe or zip) for 32 bit or 64 bit depending on your system.

Run the installer and install on the default location (e.g. C:\Program Files\Bitcoin).

From the install location open Bitcoin Core via the bitcoin-qt.exe

When asked, select the default data directory.

Bitcoin Core will then download the blockchain, which can take a few hours to several days. You can continue with the next few steps while the node synchronizes.

Step 2. Install LND

Go to https://github.com/lightningnetwork/lnd/releases and download lnd for windows (32 bit or 64 bit).

Create a folder C:\Users\<username>\AppData\Local\Lnd\bin and copy the two files lncli.exe and lnd.exe from the zip file to it.

Create a text file lnd.conf in C:\Users\<username>\AppData\Local\Lnd with the following content:

debuglevel=info listen=127.0.0.1:9735

externalip=<your external ip>

rpclisten=0.0.0.0:10012

restlisten=0.0.0.0:10013

tlsextraip=<your external ip> alias=<Node name>

color=#ffdc00

maxpendingchannels=10 bitcoin.mainnet=1

bitcoin.active=1

bitcoin.node=bitcoind

bitcoind.rpcuser=<username to remote control bitcoin core>

bitcoind.rpcpass=<password to remote control core>

bitcoind.zmqpubrawblock=tcp://127.0.0.1:18502

bitcoind.zmqpubrawtx=tcp://127.0.0.1:18503

Step 3. Open ports

Next you need to forward the ports 8333 and 9735 to the internal IP address of the machine you are running Bitcoin Core and LND. For this you have to log into your router. Check your ISP’s user manual for how to do that. Often is is done by browsing to 192.168.1.1 or a fixed name for the router like e.g. internetbox.home.

Once you are logged in you have to find the screen for port forwading. Usually an advanced or expert mode has to be activated first to get to these settings. Set the port 8333 similarly as shown on the screen below:

Repeat these steps also for port 9735. For remote controlling LND from wallets we need to set the listening ports to the internal ports 10009 and 10010. Use some unused external ports, e.g. 10012 and 10013. To do this proceed as in the example above with 8333, but use 10012 for the entry port and 10009 for the destination port. Then repeat for 10013 (entry) and 10010 (destination).

Next search for “firewall” in the search function of windows at the bottom left. Select “Windows Firewall” or “Windows Defender Firewall” from the results. Then click “Advanced settings” and select “Inbound rules”.

On the right hand side click on “New Rule”. Select “Port” and click “Next”. Enter 8333 in the “Specific local ports” section, then hit “Next” three times in a row. Give your rule a name and hit “Finish”.

Repeat the above steps for ports 9735, 10012 and 10013.

Step 4. Edit the Bitcoin Core config file.

Once the Bitcoin node has finished synching you can continue with the following steps. Close Bitcoin Core and open bitcoin.conf from the bitcoin default data directory (which you specified when installing Bitcoin core in step 1). Enter the following in the file:

testnet=0

server=1

rpcuser=<username to remote control bitcoin core>

rpcpassword=<password to remote control bitcoin core>

txindex=1

zmqpubrawblock=tcp://127.0.0.1:18502

zmqpubrawtx=tcp://127.0.0.1:18503

addresstype=p2sh-segwit

Use the same rpcuser and rpcpassword as you used in step 2 for parameters bitcoind.rpcuser and bitcoind.rpcpass.

Step 5. Start Bitcoin and LND

Open a command prompt and enter:

"C:\Program Files\Bitcoin\bitcoin-qt.exe" -conf=<bitcoin default data directory>\bitcoin.conf

Wait until Bitcoin Core syncs, then open a second command window and enter:

"C:\Users\<Username>\AppData\Local\Lnd\bin\lnd.exe" --lnddir="C:\Users\<Username>\AppData\Local\Lnd"

The result of this should look like:

Open a third command window and enter

"C:\Users\<Username>\AppData\Local\Lnd\bin\lndcli.exe" create

Then enter your new password and confirm it.

Enter “n” and press enter. Then press enter again when asked for a cipher seed passphrase.

Now you can try to log into LND. First close all command windows, then open a new one and enter:

"C:\Users\<Username>\AppData\Local\Lnd\bin\lnd.exe" --lnddir="C:\Users\<Username>\AppData\Local\Lnd"

In a second command window enter:

"C:\Users\<Username>\AppData\Local\Lnd\bin\lndcli.exe" unlock

Enter the password. In the first window you should see the LND node now running. This is visible by the occasional scrolling of status messages.

Step 6. Set up iPhone wallets

Navigate to C:\Users\<Username>\AppData\Local\Lnd and open tls.cert. Copy its contents to a text editor for further use.

Open the following location in a browser:

http://tomeko.net/online_tools/file_to_hex.php?lang=en

Uncheck the checkbox “Use 0x and comma as separator (C-like)”

Press “Choose File” and in the file dialog navigate to C:\Users\<Username>\AppData\Local\Lnd\data\chain\bitcoin\mainnet and open the file admin.macaroon.

Press convert. The Output window shows a hexidecimal string. Copy the whole string into a text editor for further use.

Next, download either Shango wallet or Union7 LND thin wallet for iPhone

Use the two strings you prepared in a text editor (macaroon and tls.cert) to fill out the respective setting screens in either of the applications as shown below:

If you did everything correctly you should now be able to use lightning from your iPhone.

For Zap wallet you need to install lndconnect from here:

https://github.com/LN-Zap/lndconnect

Then run

lndconnect -o --adminmacaroonpath=C:\Users\<Username>\AppData\Local\Lnd\data\chain\bitcoin\mainnet\admin.macaroon --tlscertpath C:\Users\<Username>\AppData\Local\Lnd\tls.cert --host=<Your IP> — port=10012

The application will then generate a .png file lndconnect-qr.png

In Zap, go to Settings -> Reset Remote Node Connection and select scan

Scan the QR code in the file lndconnect-qr.png

You should now be connected to your node.

If you want to access your lightning node from a PC you can follow the steps described in my next tutorial: