Disclaimer: I must admit i'm very late at reading up on the lightning network. For a long time, i just tought: dev's are working on it, and sooner or later they'll deliver a usable daemon/wallet. I never bothered digging into the protocol.
Since the fees i payed for my transactions last month totalled over $200 in fiat terms, i wanted to gain some knowledge about LN, so i could start using it as soon as i deem it to be stable.
In order to gain a lot of knowledge fast, i figured it would be best to just use one of my testnet nodes, compile c-lightning and start running a lightning node on the testnet to play with... The problems i ran into might be trivial, but i could not find the answers anywhere... If i really dug into the protocol and the sourcecode of c-lightning, i might find the answers myself, i just don't have the time to spend days on these problems right now.
What happened:
i'm running a bitcoin tesnetnet node on debian 16.04.1. The version i'm running is 150100 and it's fully sync'ed
i compiled c-lightning (
https://github.com/ElementsProject/lightning)
i started lightningd in a screen session => lightningd/lightningd --network=testnet --log-level=debug
i created a new address => cli/lightning-cli newaddr
i funded this address, not from the node's wallet, but from electrum (i realise this might have been stupid)
the funding transaction is/was
https://www.blocktrail.com/tBTC/tx/72181b4f63ec65890884eed89153046659c8c77951d146f076b7fe3daf8b292bimmediately, the stdout of lightningd showed following info "lightningd(18315): Owning output 0 5000000000 (P2SH) txid 72181b4f63ec65890884eed89153046659c8c77951d146f076b7fe3daf8b292b"
great
... However....
cli/lightning-cli getinfo
{ "id" : "nah, i'm not going to disclose my id", "port" : 9735, "address" :
[
{ "type" : "ipv4", "address" : "nah, i'm not going to disclose my ip", "port" : 9735 } ], "version" : "v0.5.2-2016-11-21-1477-gfdbf2f4", "blockheight" : 1258409 }
cli/lightning-cli addfunds 0100000001aa85ac933d75d6f4e6ec401241f7c1ed89b771a7129377916329b70e4e51fc1f000000006b4830450221008ebc5b65ad97ce91408338be25cc4a448b2b3c4a7d4ea4331cfb060e4448c568022026b47d6383ba005dc168463e6d8ec04d8e26f6144610cfb915391330c1b397cd01210394bef21f302409bf762a5725f1831f747e51d2698da25131554a975f55912db8fdffffff0200f2052a0100000017a9146a0224cc128dbddaf60d0019fad95f6c41cb803b87f803ce780d0000001976a9148c9973ba715da98adcacfb40953209b24e207bc488ac00000000
Could not add outputs to wallet
hmm... something strange is going on,
Could not add outputs to walletcli/lightning-cli listfunds
{ "outputs" :
[
{ "txid" : "72181b4f63ec65890884eed89153046659c8c77951d146f076b7fe3daf8b292b", "output" : 0, "value" : [b]705032704 [/b]} ] }
Wait... What? output 0 of txid 72181b4f63ec65890884eed89153046659c8c77951d146f076b7fe3daf8b292b has a value of 5000000000, why does my lightningd shows a value of 705032704 I disregarded the value mismatch, and concluded my daemon did have at least some funds to open a channel, so i tryd connecting
cli/lightning-cli connect [my id, still not going to disclose this one] [my ip] 9735
the debug on my lightningd immediately showed me following output:
lightningd(18315): Connected json input
lightning_gossipd(18323): TRACE: req: type WIRE_GOSSIPCTL_PEER_ADDRHINT len 42
lightning_gossipd(18323): TRACE: req: type WIRE_GOSSIPCTL_REACH_PEER len 35
lightning_gossipd(18323): TRACE: Responder: Act 1
lightning_gossipd(18323): TRACE: Connected out for [my id, still not going to disclose this one]
lightning_gossipd(18323): TRACE: Initiator: Act 1
lightning_gossipd(18323): TRACE: Initiator: Act 2
lightning_gossipd(18323): TRACE: Responder: Act 2
lightning_gossipd(18323): TRACE: Responder: Act 3
lightning_gossipd(18323): TRACE: Initiator: Act 3
lightning_gossipd(18323): UPDATE WIRE_GOSSIP_PEER_CONNECTED
lightning_gossipd(18323): UPDATE WIRE_GOSSIP_PEER_CONNECTED
lightningd(18315):jcon fd 14: Success
lightning_gossipd(18323): UPDATE WIRE_GOSSIP_PEER_CONNECTED
lightning_gossipd(18323): UPDATE WIRE_GOSSIP_PEER_CONNECTED
lightning_gossipd(18323): TRACE: req: type WIRE_GOSSIPCTL_HAND_BACK_PEER len 189
lightningd(18315):jcon fd 14: Closing (Bad file descriptor)
lightning_gossipd(18323): TRACE: hand_back_peer [my id, still not going to disclose this one]: now local again
lightning_gossipd(18323): TRACE: req: type WIRE_GOSSIPCTL_HAND_BACK_PEER len 189
lightning_gossipd(18323): TRACE: hand_back_peer [my id, still not going to disclose this one]: reconnected, dropping handback
lightning_gossipd(18323): TRACE: Forgetting remote peer [my id, still not going to disclose this one]
seems like i'm unable to connect....
It became painfully obvious i wasn't connected:
cli/lightning-cli fundchannel [my id, still not going to disclose this one] 500000000
"Peer not connected"
cli/lightning-cli getpeers
{ "peers" :
[ ] }
cli/lightning-cli getchannels
{ "channels" :
[ ] }
Just to re-try, i funded the wallet of my node that lightningd was connected to, created a new address, funded it from my node (which i had to fund first to begin with). I'm skipping some steps, but it boiled down to the following:
cli/lightning-cli addfunds 0200000001b0f4b5f77eb4f6c1cf38970ab1a329e4be503d56ed33febfc6cee0766658e117000000006a473044022006ddd04d56fcc4db3f6913bc5e662988e621916e9d304ed4ad4f1d6c06e89d3e0220475dff4d08cfb22c982dd33cb1cb47d1b0eb12670a3d072cbe3ec91f1fc4956401210287cc1d734d607b1126daccca6a502cedbf356c655a99d8620a8e3f23d28ddf4afeffffff0200b33f710000000017a914db4e4f5a29c45babc3a823e27128a24bd495e4ad873f89f505000000001976a914950b4d42b397c992c6ffe205fe8c012f9589092b88acac331300
{ "outputs" : 1, "satoshis" : 1900000000 }
cli/lightning-cli listfunds
{ "outputs" :
[
{ "txid" : "72181b4f63ec65890884eed89153046659c8c77951d146f076b7fe3daf8b292b", "output" : 0, "value" : 705032704 },
{ "txid" : "be4dc02b23190136dc603d521c0c54a51e82cb09780d2c37b6ed7a0cd36e5cc2", "output" : 0, "value" : 1900000000 } ] }
But still, i couldn't connect (same error message), nor could i fund a channel (since i wasn't connected)
I finally decided to stop my lightningd,rename ~/.lightning, restart my lightningd, fund it from my node's wallet, but still i'm unable to connect.
I must be doing something stupid... I just can't figure out what...
Oh, before anyone asks, i did trace the process when i was trying to connect... Following lines might be interesting:
29445 socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 16
29445 fcntl(16, F_GETFL) = 0x2 (flags O_RDWR)
29445 fcntl(16, F_SETFL, O_RDWR|O_NONBLOCK) = 0
29445 fcntl(16, F_GETFD) = 0
29445 fcntl(16, F_SETFD, FD_CLOEXEC) = 0
29445 setsockopt(16, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
29445 epoll_ctl(3, EPOLL_CTL_ADD, 16, {EPOLLOUT, {u32=16, u64=16}}) = 0
29445 epoll_ctl(3, EPOLL_CTL_DEL, 16, 0x7ffe275412e0) = 0
29445 epoll_ctl(3, EPOLL_CTL_ADD, 16, {EPOLLOUT, {u32=16, u64=16}}) = 0
29445 connect(16, {sa_family=AF_INET, sin_port=htons(18332), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress)
29445 epoll_ctl(3, EPOLL_CTL_DEL, 16, 0x7ffe27541230) = 0
29445 epoll_ctl(3, EPOLL_CTL_ADD, 16, {EPOLLOUT, {u32=16, u64=16}}) = 0
29445 epoll_wait(3, [{EPOLLOUT, {u32=16, u64=16}}], 32, 900000) = 1
29445 getsockopt(16, SOL_SOCKET, SO_ERROR,
29445 getsockopt(16, SOL_SOCKET, SO_ERROR,
29445 writev(16, [{"POST / HTTP/1.1\r\nHost: 127.0.0.1"..., 146}, {"{\"method\":\"estimatesmartfee\",\"pa"..., 65}], 2) = 211
29445 epoll_ctl(3, EPOLL_CTL_DEL, 16, 0x7ffe275412c0) = 0
29445 epoll_ctl(3, EPOLL_CTL_ADD, 16, {EPOLLIN, {u32=16, u64=16}}) = 0
29445 epoll_wait(3, [{EPOLLIN, {u32=16, u64=16}}], 32, 900000) = 1
29445 ioctl(16, FIONREAD, [192]) = 0
29445 readv(16, [{"HTTP/1.1 200 OK\r\nContent-Type: a"..., 192}], 1) = 192
29445 epoll_ctl(3, EPOLL_CTL_DEL, 16, 0x7ffe27541260) = 0
29445 shutdown(16, SHUT_WR) = 0
29445 close(16) = 0
...
29201 close(16) = -1 EBADF (Bad file descriptor)
the debug.log of bitcoind didn't show anything usefull