ptarmigan

Lightning Network (BOLT)

View the Project on GitHub nayutaco/ptarmigan

How to use

Installation

start ptarmd(ptarmigan daemon)

rpcuser=bitcoinuser
rpcpassword=bitcoinpassword
server=1
txindex=1
testnet=1
# create work folder
cd ptarmigan/install
./new_nodedir.sh [NODE_NAME]
cd [NODE_NAME]

# start with testnet!
../ptarmd --network=testnet

daemon control ptarmcli(ptarmigan client)

get information

Show my node information.

../ptarmcli --getinfo

connect node

Connecting known lightning node, use -c command. If you have channels, ptarmd try connect the peers automatically.

# two connection method

# a. Only connect peer(not request peer's routing information)
../ptarmcli -c NODE_ID@IPv4_ADDRESS:PORT

# b. Get peer's all routing information by `--initroutesync`.
#    Routing information is used for payment.
#    (If you have already connected, disconnect and connect with `--initroutesync`.)
../ptarmcli -c NODE_ID@IPv4_ADDRESS:PORT --initroutesync

open channel

After connecting, you can open channel with connection node.

# create funding file
../pay_fundin.py AMOUNT_SAT
(create fund_xxxx.conf)

../ptarmcli -c NODE_ID -f fund_xxxx.conf

Establishing channel need some blocks. You can check channel status with ptarmcli --getinfo.

memo

pay_fundin.py only support P2PKH / native P2WPKH / P2WPKH nested in BIP16 P2SH.
If using “regtest”, you send to bitcoin-cli getnewaddress.

bitcoin-cli sendtoaddress `bitcoin-cli getnewaddress` 0.1

request payment

# request 1000msat
../ptarmcli --createinvoice 1000
(print BOLT11 invoice)

send payment

../ptarmcli --sendpayment [BOLT11 INVOICE]
(print PAYMENT_ID)
# all payment list
../ptarmcli --listpayment

# specify PAYMENT_ID
../ptarmcli --listpayment=PAYMENT_ID

close channel

Closing a channel uses ptarmcli -x command. Amount in channel will pay to bitcoind after some blocks.

../ptarmcli -c NODE_ID -x
# check payable transaction
#   if no input found or too less to use input, outputs "no input".
../ptarmcli --paytowallet

# from internal wallet to bitcoind
../ptarmcli --paytowallet=1

troubleshooting

startup

wrong conf file

fail: no rpcuser or rpcpassword[xxx/.bitcoin/bitcoin.conf]
fail: wrong conf file.

can’t access bitcoind

fail: initialize btcrpc

DB file version mismatch

DB checking: open...done!
DB checking: version...fail: version mismatch : X(require Y)
invalid version
fail: node init

Payment

ptarmcli --sendpayment always fail