Please note that running LN on mainnet is NOT deemed safe for mainnet yet - all testing should be done on testnet. Be aware of the risks and only send bitcoins you are willing to lose.
This quick gist uses bitcoind
and lightningd
to run a LN node on mainnet, and it assumes the following:
- Ubuntu Linux (16.04.3 on this walkthrough)
- some spare bitcoins you are willing to lose
sudo apt-get install -y autoconf automake build-essential git libtool libgmp-dev libsqlite3-dev python python3 net-tools jq
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt-get update
sudo apt-get install -y bitcoind
mkdir builds && cd builds
git clone https://github.com/ElementsProject/lightning.git
cd lightning
make
- Add the following lines to bitcoin.conf
walletbroadcast=0
txindex=1
bitcoind -daemon
Seeing as the current blockchain size is ~170GB, this might take a few days to fully download.
- Make a file called
check_lastblock_date.sh
#!/bin/bash
lastblockdate=`bitcoin-cli getblockchaininfo | jq .mediantime`
blockdate=`date -d @$lastblockdate`
echo -e "The date of the last synchronised block is: \n $blockdate"
- Run a
watch
command to monitor it - time configurable, I chose 5 seconds:watch -n 5 ./check_lastblock_date.sh
Paste the following on your Lightning config (by default found in ~/.lightning/config
)
alias=INSERTNAMEHERE
./lightningd/lightningd --network=bitcoin --log-level=debug
This will be the multisig address used as the LN node wallet. Send money to it from any Bitcoin wallet, and wait six confirmations.
./cli/lightning-cli newaddr
Once six confirmations have passed, make sure funds have arrived (they will be denominated in satoshi)
./cli/lightning-cli listfunds
Pick any node on http://lnd.rompert.com/, and replace node_id
, node_ip
and port
as needed. Well connected nodes are somewhat preferred, as it means fewer hops and lower fees.
./cli/lightning-cli connect <node_id> <node_ip> [<port>]
./cli/lightning-cli fundchannel <node_id> <amount in satoshis>
NODE_ID=`./cli/lightning-cli getinfo | jq -r .id` # saves your node ID on a variable
./cli/lightning-cli listchannels | grep $NODE_ID # you want to see the channel open, and "public" set as "true" - when this is done, the channel has been funded
You're now ready to pay and receive payments!
Below is the payment part, once you are sent the long string (BOLT #11 encoded)
Analyse the BOLT encoded payment - shows metadata such as amount, description, timestamp, expiry date, etc.
./cli/lightning-cli decodepay <payment BOLT string> | jq
./cli/lightning-cli pay <payment BOLT string>