2.9 KiB
Testing eclair and lightningd
Configure bitcoind to run in regtest mode
Important: you need a segwit version of bitcoin core for this test (see https://github.com/sipa/bitcoin/tree/segwit-master). Make sure that bitcoin-cli is on the path and edit ~/.bitcoin/bitcoin.conf and add:
server=1
regtest=1
rpcuser=***
rpcpassword=***
To check that segwit is enabled run:
bitcoin-cli getblockchaininfo
and check bip9_softforks:
...
"bip9_softforks": {
"csv": {
"status": "active",
"startTime": 0,
"timeout": 999999999999
},
"witness": {
"status": "active",
"startTime": 0,
"timeout": 999999999999
}
}
Start bitcoind
Mine enough blocks to activate segwit blocks:
bitcoin-cli generate 500
Start lightningd (here we’ll use port 46000)
lightningd --port 46000
Start eclair:
mvn exec:java -Dexec.mainClass=fr.acinq.eclair.Boot
Tell eclair to connect to lightningd
curl -X POST -H "Content-Type: application/json" -d '{
"method": "connect",
"params" : [ "localhost", 46000, 3000000 ]
}' http://localhost:8080
Since eclair is funder, it will create and publish the funding tx
Mine a few blocks to confirm the funding tx:
bitcoin-cli generate 10
eclair and lightningd are now both in NORMAL state. You can check this by running:
lightning-cli getpeers
or
curl -X POST -H "Content-Type: application/json" -d '{
"method": "list",
"params" : [ ]
}' http://localhost:8080
Tell eclair to send a htlc
We’ll use the following values for R and H:
R = 0102030405060708010203040506070801020304050607080102030405060708
H = 8cf3e5f40cf025a984d8e00b307bbab2b520c91b2bde6fa86958f8f4e7d8a609
You’ll need a unix timestamp that is not too far into the future. Now + 100000 is fine:
curl -X POST -H "Content-Type: application/json" -d "{
\"method\": \"addhtlc\",
\"params\" : [ 70000000, \"8cf3e5f40cf025a984d8e00b307bbab2b520c91b2bde6fa86958f8f4e7d8a609\", $((`date +%s` + 100000)), \"021acf75c92318d3723098294d2a6a4b08d9abba2ebb5f2df2b4a8e9153e96a5f4\" ]
}" http://localhost:8080
Tell eclair to commit its changes
curl -X POST -H "Content-Type: application/json" -d "{
\"method\": \"sign\",
\"params\" : [ \"d3f056a084e266ad06ea1ca28a1e080ca07c6b61fac7ce116e48a5c31d688eee\" ]
}" http://localhost:8080
Tell lightningd to fulfill the HTLC:
./lightning-cli fulfillhtlc 03befb4f8ad1d87d4c41acbb316791fe157f305caf2123c848f448975aaf85c1bb 0102030405060708010203040506070801020304050607080102030405060708
Check balances on both eclair and lightningd
Close the channel
./lightning-cli close 03befb4f8ad1d87d4c41acbb316791fe157f305caf2123c848f448975aaf85c1bb
Mine a few blocks to bury the closing tx
bitcoin-cli generate 10
The channel is now in CLOSED state