Lightning Network Node Guide

Peercoin Lightning Network Guide

The current state of matters is that unless you want to give private key of your coins to somebody else, you need to run a local lightning node, connect it to lightning network and have sufficiently funded channel to be able to pay instantly on lightning network. To receive payments you need channel funded in your direction. Simplest for this to happen is to pay for something.

Installing peercoin lightning node

Using docker compose (easy way)

docker-compose.yml

version: "3"
services:
  peercoind:
    image: peercoin/peercoind:0.8.4
    container_name: peercoind
    environment:
      - RPC_USER=peercoind
      - RPC_PASSWORD=peercoindrpc
    command:
      -testnet
      -nominting
    expose:
      - "9903"
    ports:
      - "0.0.0.0:19904:9904"
    volumes:
      - "peercoin_datadir:/data"

  clightning_peercoin:
    image: peercoin/lightningd
    container_name: lightningd
    command:
      - --bitcoin-rpcconnect=peercoind
      - --bitcoin-rpcport=9904
      - --bitcoin-rpcuser=peercoind
      - --bitcoin-rpcpassword=peercoindrpc
      - --network=peercoin-testnet
      - --alias=peercoinlove
      - --log-level=debug
    environment:
      EXPOSE_TCP: "true"
    expose:
      - "9735"
    ports:
      - "0.0.0.0:19735:9735"
    volumes:
      - "clightning_peercoin_datadir:/root/.lightning"
      - "peercoin_datadir:/etc/bitcoin"
    links:
      - peercoind

volumes:
  peercoin_datadir:
  clightning_peercoin_datadir:

docker-compose up -d

Verify that all is running:

docker-compose ps

Running docker peercoin and clightning (the hard way)

If you don’t have peercoin container running, start it

  • Make sure your data directory (ie /var/lib/peercoin) exists if you want to preserve data

$ docker run --env PPC_DATA=/var/lib/peercoin --name peercoind -d peercoin/peercoind -rpcuser=foo -rpcpassword=bar -testnet -nominting

  • Wait for peercoin node to sync completely

Run lightningd node

  • $ docker run --name lightningd --link=peercoind --publish 9735 -d peercoin/lightningd --bitcoin-rpcconnect=lpeercoind --bitcoin-rpcport=9904 --bitcoin-rpcuser=foo --bitcoin-rpcpassword=bar --network=peercoin-testnet --alias=peercoinlove --log-level=debug

Once your lightning node is running

You can query it by running lightning-cli command

$ lightning-cli help

If you are using docker do:

$ docker exec -it lightningd /bin/bash

See status of node

$ lightning-cli getinfo

{
   "id": "02e6873965f202fa776a8f3236ebd36a13e99c147e29db9c8b7fae995f0f26bc29",
   "alias": "ANGRYMASTER",
   "color": "02e687",
   "num_peers": 1,
   "num_pending_channels": 0,
   "num_active_channels": 1,
   "num_inactive_channels": 0,
   "address": [],
   "binding": [
      {
         "type": "ipv6",
         "address": "::",
         "port": 9735
      },
      {
         "type": "ipv4",
         "address": "0.0.0.0",
         "port": 9735
      }
   ],
   "version": "v0.7.3rc2-7-g0dbcf9e-modded",
   "blockheight": 425848,
   "network": "peercoin-testnet",
   "msatoshi_fees_collected": 0,
   "fees_collected_msat": "0msat"
}

Connect to explorer node

$ lightning-cli connect 026c7ff7adc7e4c01c3d953fee7d35ddeba6ecdbd8f80e4e0e02a3fcac5547e06a@explorer.peercoin.net

{
   "id": "026c7ff7adc7e4c01c3d953fee7d35ddeba6ecdbd8f80e4e0e02a3fcac5547e06a"
}

Generate new address keypair inside lightning node:

$ lightning-cli newaddr

{
   "address": "tpc1qf2ukcsp0s38eue5ge2pqkta23sgds2skr45cau",
   "bech32": "tpc1qf2ukcsp0s38eue5ge2pqkta23sgds2skr45cau"
}

Send some peercoin to the node wallet

$ peercoin-cli sendtoaddress tpc1qf2ukcsp0s38eue5ge2pqkta23sgds2skr45cau 100

Or just use faucet

Query node until funds become available

$ lightning-cli listfunds

Fund channel between your node and explorer node for 1 ppc

$ lightning-cli fundchannel 026c7ff7adc7e4c01c3d953fee7d35ddeba6ecdbd8f80e4e0e02a3fcac5547e06a 1000000

Wait for transaction to be confirmed and channel will be open

$ lightning-cli getinfo | grep active_channels

"num_active_channels": 1,

Now request a payment

Misc commands that are helpful to know

To output all channels known to the network

$ lightning-cli listchannels

To know your addresses

$ lightning-cli dev-listaddrs

4 Likes

To simplify working with your node, you can use spark wallet: https://github.com/shesek/spark-wallet

You can install it on the same machine your lightning node is running like this:

$ npx spark-wallet -i 0.0.0.0

This will serve a web app that you can access from browser https://localhost:9737/

It will ask you for login / password that are stored locally in ~/.spark-wallet/cookie:

$ cat  ~/.spark-wallet/cookie && echo
rmqbd:4XoFPz6Itb8_2gw:hk0awOiC4IqKAfPOmv3Sr65j3Ff38moQoyDFcr90P0

Which means you have to enter rmqbd as login and 4XoFPz6Itb8_2gw as pwd and will be presented with something like this:

To enable debug tools, you need to press on version number (v0.2.9) and you will turn extra functionality like console and logs.

6 Likes