ptarmigan

Lightning Network (BOLT)

View the Project on GitHub nayutaco/ptarmigan

How to Pay starblocks (or Your Lightning Node) from ptarmigan Node

2018/09/09

Overview of Payment for Starblocks

Concrete operational method

  1. Install bitcoind Preparebitcoin.conf file
sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt-get update
sudo apt-get install bitcoind

~/.bitcoin/bitcoin.conf

rpcuser=bitcoinuser
rpcpassword=bitcoinpassword
server=1
txindex=1
testnet=1

rpcuser and rpcpassword must be specified.

  1. Execute bitcoind
bitcoid -daemon
  1. Wait untill fully synchronized with bitcoin testnet blockchain (it may take a few hours)

  2. Generate bitcoin address by bitcoind. Get testnet bitcoin from bitcoin faucet WEB

bitcoin-cli getnewaddress

Example of faucet WEB

  1. Install ptarmigan
sudo apt install -y git autoconf pkg-config libcurl4-openssl-dev libjansson-dev libev-dev libboost-all-dev build-essential libtool jq bc
git clone https://github.com/nayutaco/ptarmigan.git
cd ptarmigan
make full
  1. Start node daemon ptarmd
cd install
./new_nodedir.sh
cd node
../ptarmd --network=testnet&

Default mode is private node in which mode node does not announce IP address.
Open another Ubuntu window and control ptarmd from such window, because ptarmd is daemon.

  1. Connect other lightning network node from ptarmd
../ptarmcli -c [peer node_id]@[peer IP address]:[peer port]

When ptarmd successfully connect other node, you receive the large amount of node information from peer node.
You should wait untill finishing log output.

  1. Confirm connection between ptarmd and peer
../ptarmcli -l | jq

ptarmcli shows current connection information.
Connected node status is "connected" in the log.

  1. Generate funding transactionn related command file

First, send testnet bitcoin to segwit address, then send testnet bitcoinn payment channnel.

../pay_fundin.py 1000000 500000

These command generate a file fund_yyyymmddhhmmss.conf.
File contents means the following:

  1. create 10mBTC segwit transaction
  2. send the transaction
  3. fund channel 10mBTC (give 500000msat for peer node)

Note that unit is satoshi.

  1. Fund payment channel
../ptarmcli -c [peer node_id] -f fund_yyyymmddhhmmss.conf
  1. Wait until funding transaction get into bitcoin testnet block (it will take time)
../ptarmcli -l | jq

Number of comfirmation is depend on peer node(c-lightning default value is 1. lnd default value is 3).
Display node status.
When channel is established, status change from "wait_minimum_depth" to "established".
You should wait 6 confirmation, because broadcasting of channel start after 6 confirmation.
You can check current number of confirmationn by command ptarmcli -l.

  1. Generate invoice on Starblocks Web

The following are famous Lightning Network(testnet) payment DEMO WEB site.

Here, we explain how to pay starblocks.
Push “Add to Cart” button, and push checkout button.
Then, invoice number is displayed.
Long strings like lntb********************..... is invoice text.

  1. Execute payment from ptarmigan
../ptarmcli -l | jq

Display the node status.

../ptarmcli -r [invoice text]

Execute payment from ptarmigan.
When payment starts, ptarmigan show message “Progressing”.
If payment for starblocks successfuly executed, starblocks WEB changes status.

Because Lightning Network is P2P payment, payment does not complete if even one node on the path doesn’t correspond correctly.
When payment is not completed, ptarmigan execute path re-serach.

It may take time.
When ptarmigan is retrying payment, ptarmcli -l shows “paying” message.

When ptarmigan can not find route finally, it output “fail routing” error message.
This mean that ptarmigan can not find route from current local channel network view.