项目作者: ccyanxyz

项目描述 :
Bitcoin lightning testnet box
高级语言: Makefile
项目地址: git://github.com/ccyanxyz/lightning-testnet-box.git
创建时间: 2019-03-31T16:18:54Z
项目社区:https://github.com/ccyanxyz/lightning-testnet-box

开源协议:

下载


Lightning Demo

1.Get the box

​ Build it yourself:

  1. git clone https://github.com/ccyanxyz/lightning-testnet-box.git
  2. cd lightning-testnet-box
  3. docker build -t lightning-testnet-box .

​ OR pull the image from docker hub:

  1. docker pull ccyanxyz/lightning-testnet-box:latest

2.Start everything

​ Start the container:

  1. docker run -it lightning-testnet-box

​ Start bitcoind & lightningd:

  1. make start-bitcoind
  2. make start-lightningd

3.Generate some blocks

​ Make them rich:

  1. b1 generate 100 # alias to bitcoin-cli -datadir=/root/lightning-testnet-box/node1, see .bashrc
  2. b2 generate 100
  3. b3 generate 100
  4. b4 generate 101

4.State channel

​ Generate new address and send some bitcoin to the address:

  1. l1 newaddr
  2. b1 sendtoaddress <ADDRESS> <AMOUNT IN BITCOIN>
  3. b1 generate 6 # make sure the tx is confirmed
  4. l1 listfunds # list the output, if empty, just wait a minute and try again

​ Connect to node2 and fund channel:

  1. l2 getinfo # copy the id of lightning node2
  2. l1 connect <PEER ID>@127.0.0.1:9736
  3. l1 fundchannel <PEER ID> <AMOUNT IN SAT>
  4. l1 listfunds # channels is open now

​ Assume that node1 have to pay node2 some btc, node2 has to generate an invoice:

  1. l2 invoice <AMOUNT IN mSAT> <LABEL> <DESCRIPTION>

​ Now node1 can pay node2 use the serialized invoice ‘bolt11’:

  1. l1 decodepay <BOLT11> # inspect the content of the serialized invoice
  2. l1 getroute <PEER ID> <AMOUND IN mSAT> <RISK FACTOR>
  3. l1 pay <BOLT11>
  4. l2 listfunds # now node2 should have received the money, see 'channel_sat'

​ Close channel:

  1. l1 close <PEER ID>
  2. b1 generate 101
  3. l1 listfunds # now the channel should be closed

5.Make a network of lightning nodes

​ Lazy… TBD…

6.Acknowledgement

This testnet box is modified from the bitcoin-testnet-box.