Skip to content

Instantly share code, notes, and snippets.

@dcr-uncle
Last active May 3, 2022 03:04
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dcr-uncle/11b30f44e73b55cc31fb75881f9b4643 to your computer and use it in GitHub Desktop.
Decred Lightning Node Setup Guide
1 - Preparation
Select a Virtual Private Sever (VPS) provider
Cost $5-15 per month
Linux OS – during setup, choose the latest version of Ubuntu
Hardware specifications – comfortably above expected usage
2 vCore
2 GB RAM
40 GB hard drive
Desirable / optional VPS provider capabilities
Unmetered bandwidth (no overage fees)
For future growth, allows creation of additional servers in separate datacenters
Server snapshot backups
File backup / sync to cloud location that allows hourly schedule jobs
Port monitoring and alerts
For DCR network decentralization, setup nodes in location that are not already top countries or top networks
DCR node map: https://nodes.jholdstock.uk/
Generate and store secure passwords
Select and setup an app to store the many passwords you'll generate throughout the Decred node setup
Passwords should be randomly generated 8-20 characters including uppercase, lowercase, number, and special characters
You can use https://passwordsgenerator.net/ to generate the passwords
1 - Setup OS
If using a Raspberry Pi or existing server you can start here
Login to the VPS
In your VPS provider’s website / control panel, note your new server’s IP address and root password, and document them in your password app
Login to the server using ssh
From a Windows computer:
Press the Windows key
Type powershell
Open Windows PowerShell
Type: ssh -l root <server IP address>
Upon first login, ignore the expected ssh host authenticity warning
Enter the root password
You’ll end up at a shell prompt that looks like: root@localhost:~#
From a non Windows computer or older Windows version you may need to download and learn how to use a compatible ssh client
Set a new root password
In the shell prompt, type: passwd
Follow the prompts
Document the new root password in your password app
It’s a great time to perform a server-wide software update before anything else
Type: apt update && apt upgrade -y
Find instructions online for how to check if ipv6 is enabled in Ubuntu, if so, find instructions to permanently disable ipv6
Reboot the server
Type: shutdown -r now
Upon reboot, reconnect to the server using ssh, and confirm ipv6 is still disabled
Add a dedicated service account for decred, so you’re not using the root account for this
Decide what to name the service account, for example “decredservice”
Type: adduser <new service account name>
Follow the prompts to set the password and optional account info
Exit the ssh session
Type: exit
2 - Setup dcrd
Reconnect to ssh using the service account
Type: ssh -l <service account> <server IP address>
Download Decred release
On your computer (not the VPS) copy the Decred download link to your clipboard
Browse to https://github.com/decred/decred-release/releases
Find the latest version download link that matches the machine hardware architecture, typically it’s amd64 (64-bit)
Copy the corresponding hyperlink (this is the download link)
On the server, ensure you’re in the service account’s home directory
Type: cd ~
Download Decred
Type: wget <download link>
for example wget https://github.com/decred/decred-release/releases/download/v1.7.1/dcrinstall-linux-amd64-v1.7.1
Make the installer file executable
Type: chmod u+x dcrinstall – then press TAB on the keyboard to complete the file name, then press Enter
Run the installer: Type ./dcrinstall – then press TAB to complete the file name, then press Enter
Follow the prompts to setup a new Lightning wallet
Set private passprase
You can skip the additional layer of encryption
Respond 'no' to existing wallet seed
Document the wallet generation seed and Hex in your password app
Near the bottom of the install confirmation message, note the command to run dcrd
Run dcrd
Ensure you’re in your home directory
Type: cd ~
Type: nohup ~/decred/dcrd > dcrd.log & disown
Check dcrd is running
Type: tail -f dcrd.log
Wait 3-4 hours to to sync the DCR blockchain
When complete (100% progress) press CTRL-C to return to the shell prompt
3 - Setup dcrlnd
dcrd must be running and fully synced before setting up dcrlnd
Note the server IP address
Type: hostname -I
Open the configuration file in a text editor
Type: nano ~/.dcrlnd/dcrlnd.conf
Edit the text file to uncomment (delete the ; in front of) and update the following settings:
listen=0.0.0.0:9735
rpclisten=localhost:10009
externalip=<server IP address>
node=dcrd
defaultchanconfs=1
Exit the text editor: Press CTRL-X, ‘Y’, Enter
Run dcrlnd
Ensure you’re in your home directory
Type: cd ~
Type: nohup ~/decred/dcrlnd > dcrlnd.log & disown
During the dcrinstall, you were prompted to create a new DCR wallet, in the next step you will create a separate DCR Lightning wallet
Type: ~/decred/dcrlncli create
Follow the prompts to set the wallet password
Do not use an existing cipher seed
Blank cipher seed passphrase
Document the wallet generation seed in your password app
Check dcrlnd is running
Type: tail -f dcrlnd.log
Wait around 30 minutes to sync the wallet, look in the log for [INF] RPCS: RPC server listening on 127.0.0.1:10009
Press CTRL-C to return to the shell prompt
Unlock the wallet: Type ~/decred/dcrlncli unlock
Connect to the DCR Lightning Network
Ensure you’re in your home directory: In the server command prompt, type cd ~
Check the node peers, Type: ~/decred/dcrlncli listpeers
The list should be empty
Find a DCR Lightning Network peer
Browse to https://decred.lighting (note it’s lighting, not lightning)
Find a reasonably well-connected node on the map, but not necessarily the best-connected node
Document the node’s Pubkey and Address
Type: ~/decred/dcrlncli connect <Pubkey@IP:Port>
Example: ~/decred/dcrlncli connect 0204380154466972338341f5a5b5814be7a96e35f2a76ab3a45fd0baee5bafbd00@51.15.91.167:9735
Check the node peers
Type: ~/decred/dcrlncli listpeers
Initially there should be 1 peer
Try again within a few hours there should be 5+ peers, then your node is connected to the Decred Lightning Network
4 - Next Steps
To best service the Decred mainnet, there are more steps to prepare and protect your LN node, not covered in this Setup Guide
Optimize memory settings / swap file
Complete dcrd and dcrlnd configuration, for example setup watchtowers, Tor, etc.
Firewall and other security hardening
Acquire a domain name, setup DNS records to your server, optionally a SSL certificate
Server backups to off-site location, especially wallet and channel backups
Test backup recovery
Port monitoring and alerts
Open channels with multiple other LN nodes - requires DCR coins
Keep in mind you will provide a critical network service in exchange for Lightning transaction fees, you’re expected to apply best operating practices and meet professional standards
Send questions, suggestions, feedback by email to ( b i g @ decred.energy)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment