Bitcoin Forum
May 11, 2024, 05:59:47 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: c-lightning on testnet: problems and questions  (Read 400 times)
mocacinno (OP)
Legendary
*
Offline Offline

Activity: 3388
Merit: 4922


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
January 11, 2018, 10:09:05 AM
Last edit: January 11, 2018, 12:41:06 PM by mocacinno
Merited by OgNasty (1), achow101 (1), vokain (1)
 #1

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/72181b4f63ec65890884eed89153046659c8c77951d146f076b7fe3daf8b292b
immediately, the stdout of lightningd showed following info "lightningd(18315): Owning output 0 5000000000 (P2SH) txid 72181b4f63ec65890884eed89153046659c8c77951d146f076b7fe3daf8b292b"

great Smiley... However....

Code:
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 }

Code:
cli/lightning-cli addfunds 0100000001aa85ac933d75d6f4e6ec401241f7c1ed89b771a7129377916329b70e4e51fc1f000000006b4830450221008ebc5b65ad97ce91408338be25cc4a448b2b3c4a7d4ea4331cfb060e4448c568022026b47d6383ba005dc168463e6d8ec04d8e26f6144610cfb915391330c1b397cd01210394bef21f302409bf762a5725f1831f747e51d2698da25131554a975f55912db8fdffffff0200f2052a0100000017a9146a0224cc128dbddaf60d0019fad95f6c41cb803b87f803ce780d0000001976a9148c9973ba715da98adcacfb40953209b24e207bc488ac00000000
Could not add outputs to wallet

hmm... something strange is going on, Could not add outputs to wallet

Code:
cli/lightning-cli listfunds
{ "outputs" :
        [
                { "txid" : "72181b4f63ec65890884eed89153046659c8c77951d146f076b7fe3daf8b292b", "output" : 0, "value" : [b]705032704 [/b]} ] }

Wait... What?Huh output 0 of txid 72181b4f63ec65890884eed89153046659c8c77951d146f076b7fe3daf8b292b has a value of 5000000000, why does my lightningd shows a value of 705032704 Huh

I disregarded the value mismatch, and concluded my daemon did have at least some funds to open a channel, so i tryd connecting

Code:
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:

Code:
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:

Code:
cli/lightning-cli fundchannel [my id, still not going to disclose this one] 500000000
"Peer not connected"

Code:
cli/lightning-cli getpeers
{ "peers" :
        [  ] }

Code:
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:
Code:
cli/lightning-cli addfunds 0200000001b0f4b5f77eb4f6c1cf38970ab1a329e4be503d56ed33febfc6cee0766658e117000000006a473044022006ddd04d56fcc4db3f6913bc5e662988e621916e9d304ed4ad4f1d6c06e89d3e0220475dff4d08cfb22c982dd33cb1cb47d1b0eb12670a3d072cbe3ec91f1fc4956401210287cc1d734d607b1126daccca6a502cedbf356c655a99d8620a8e3f23d28ddf4afeffffff0200b33f710000000017a914db4e4f5a29c45babc3a823e27128a24bd495e4ad873f89f505000000001976a914950b4d42b397c992c6ffe205fe8c012f9589092b88acac331300
{ "outputs" : 1, "satoshis" : 1900000000 }

Code:
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,
  • , [4]) = 0
29445 getsockopt(16, SOL_SOCKET, SO_ERROR,
  • , [4]) = 0
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


█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
1715407187
Hero Member
*
Offline Offline

Posts: 1715407187

View Profile Personal Message (Offline)

Ignore
1715407187
Reply with quote  #2

1715407187
Report to moderator
1715407187
Hero Member
*
Offline Offline

Posts: 1715407187

View Profile Personal Message (Offline)

Ignore
1715407187
Reply with quote  #2

1715407187
Report to moderator
If you want to be a moderator, report many posts with accuracy. You will be noticed.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
Cdecker
Hero Member
*****
Offline Offline

Activity: 489
Merit: 504



View Profile WWW
January 11, 2018, 11:15:38 PM
Merited by achow101 (1), mocacinno (1), LeGaulois (1)
 #2

Hey mocacinno, thanks for giving c-lightning a shot. The value mismatch is actually important, no one has ever tried to give that many funds to a lightning wallet so far, and indeed you stumbled over a bug when reading back the funds from the DB. It is fixed in a PR and should be merged soon, at which point the true value of the output will show up :-)

As for the disconnection I don't really know. Are you trying to connect to yourself? `connect <myid> <myip> 9735` seems to suggest that.

Want to see what developers are chatting about? http://bitcoinstats.com/irc/bitcoin-dev/logs/
Bitcoin-OTC Rating
mocacinno (OP)
Legendary
*
Offline Offline

Activity: 3388
Merit: 4922


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
January 12, 2018, 07:35:26 AM
Last edit: January 12, 2018, 07:54:43 AM by mocacinno
 #3

Hey mocacinno, thanks for giving c-lightning a shot. The value mismatch is actually important, no one has ever tried to give that many funds to a lightning wallet so far, and indeed you stumbled over a bug when reading back the funds from the DB. It is fixed in a PR and should be merged soon, at which point the true value of the output will show up :-)

As for the disconnection I don't really know. Are you trying to connect to yourself? `connect <myid> <myip> 9735` seems to suggest that.

Hi,

It's great to see the dev team active on bitcointalk  Smiley I'll try to pull the new code, recompile and put the old ~/.lightning folder back to verify if i see the 50 tbtc value.
As for your second question, yes, i started lightningd on the same machine as bitcoind. Bitcoind is running in daemon mode, lightningd runs in a screen session. I then tryd to connect using lightning-cli on the same machine as lightningd and bitcoind were running. I verified using "lsof -i :9735" and found a possible error:

Code:
COMMAND    PID    USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
lightning 8622 testnet    4u  IPv6 2484389      0t0  TCP *:9735 (LISTEN)

For some reason it's IPv6 instead of IPv4, eventough no other service is listening on this port... I tried many other ports, but the debug always shows

Code:
lightning_gossipd(9238): TRACE: Failed to bind on 2 socket: Address already in use

Afterwards it always seems to listen on the ipv6 socket...

EDIT:
on a sidenote, the bug is fixed Smiley
Code:
li/lightning-cli listfunds
{ "outputs" :
        [
                { "txid" : "redacted", "output" : 0, "value" : 5000000000 },
                { "txid" : "redacted", "output" : 0, "value" : 1900000000 } ] }

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
Cdecker
Hero Member
*****
Offline Offline

Activity: 489
Merit: 504



View Profile WWW
January 12, 2018, 09:11:10 AM
 #4

Lucky I was pointed here by someone who saw your message, I only occasionally check bitcointalk. Bug reports and help should go to the github, mailing list or IRC channel, to ensure we see them :-)

Thanks for confirming that the patch worked ^^

Are you trying to connect the daemon to itself? Not sure why you'd do that, and pretty sure we close self-connections, try connecting to some other node on the network (https://explorer.acinq.co/ for (id, ip, port)-tuples)

Want to see what developers are chatting about? http://bitcoinstats.com/irc/bitcoin-dev/logs/
Bitcoin-OTC Rating
YuriF
Newbie
*
Offline Offline

Activity: 2
Merit: 2


View Profile
January 25, 2018, 10:24:50 AM
Merited by achow101 (1), Welsh (1)
 #5

I set lightning network of ElementsProject : https://github.com/ElementsProject/lightning run command getinfo :
Code:
"version" : "v0.5.2-2016-11-21-1655-g2f4ba73", "blockheight" : 472053, "network" : "bitcoin"
and help and  there are list of commands:

Code:
{ "command" : "dev-blockheight", "description" : "Show current block height" },
{ "command" : "dev-setfees", "description" : "Set feerate in satoshi-per-kw for {immediate}, {normal} and {slow} (each optional) and show the value of those three feerates" },
{ "command" : "listnodes", "description" : "Show all nodes in our local network view" },
{ "command" : "getroute", "description" : "Show route to {id} for {msatoshi}, using {riskfactor} and optional {cltv} (default 9)" },
{ "command" : "listchannels", "description" : "Show all known channels" },
{ "command" : "invoice", "description" : "Create an invoice for {msatoshi} with {label} and {description} with optional {expiry} seconds (default 1 hour)" },
{ "command" : "listinvoice", "description" : "(DEPRECATED) Show invoice {label} (or all, if no {label}))" },
{ "command" : "listinvoices", "description" : "Show invoice {label} (or all, if no {label})" },
{ "command" : "delinvoice", "description" : "Delete unpaid invoice {label} with {status}" },
{ "command" : "waitanyinvoice", "description" : "Wait for the next invoice to be paid, after {lastpay_index} (if supplied)" },
{ "command" : "waitinvoice", "description" : "Wait for an incoming payment matching the invoice with {label}" },
{ "command" : "decodepay", "description" : "Decode {bolt11}, using {description} if necessary" },
{ "command" : "help", "description" : "Show available commands"},
{ "command" : "stop", "description" : "Shut down the lightningdprocess" },
{ "command" : "getlog", "description" : "Show logs, with optional log {level} (info|unusual|debug|io)" },
{ "command" : "dev-rhash", "description" : "Show SHA256 of {secret}" },
{ "command" : "dev-crash", "description" : "Crash lightningd by calling fatal()" },
{ "command" : "getinfo", "description" : "Show information about this node" },
{ "command" : "sendpay", "description" : "Send along {route} in return for preimage of {rhash}" },
{ "command" : "pay", "description" : "Send payment specified by {bolt11} with optional {msatoshi} (if and only if {bolt11} does not have amount), {description} (required if {bolt11} uses description hash) and {riskfactor} (d                    efault 1.0)" },
{ "command" : "listpayments", "description" : "Show outgoing payments" },
{ "command" : "connect", "description" : "Connect to {id} at {host} (which can end in ':port' if not default)" },
{ "command" : "listpeers", "description" : "Show current peers, if {level} is set, include {log}s" },
{ "command" : "fundchannel", "description" : "Fund channel with {id} using {satoshi} satoshis" },
{ "command" : "close", "description" : "Close the channel with peer {id}" },
{ "command" : "dev-sign-last-tx", "description" : "Sign and show the last commitment transaction with peer {id}" },
{ "command" : "dev-fail", "description" : "Fail with peer {id}" },
{ "command" : "dev-reenable-commit", "description" : "Re-enable the commit timer on peer {id}" },
{ "command" : "dev-ping", "description" : "Send {peerid} a ping of length {len} asking for {pongbytes}" },
{ "command" : "dev-memdump", "description" : "Show memory objects currently in use" },
{ "command" : "dev-memleak", "description" : "Show unreferenced memory objects" },
{ "command" : "withdraw", "description" : "Send to {destination} address {satoshi} (or 'all') amount via Bitcoin transaction" },
{ "command" : "newaddr", "description" : "Get a new address to fund a channel" },
{ "command" : "listfunds", "description" : "Show funds available for opening channels" }

How did you run command addfunds ? It's  :
Code:
"Unknown command 'addfunds'"
Cdecker
Hero Member
*****
Offline Offline

Activity: 489
Merit: 504



View Profile WWW
January 25, 2018, 11:28:16 AM
 #6

Yes, `addfunds` was recently removed and we now rely on tracking the blockchain to tell us about incoming funds.

Want to see what developers are chatting about? http://bitcoinstats.com/irc/bitcoin-dev/logs/
Bitcoin-OTC Rating
YuriF
Newbie
*
Offline Offline

Activity: 2
Merit: 2


View Profile
January 26, 2018, 03:08:51 PM
 #7

Cdecker, does c-lightning only for testing but for work(planning to do an exchange) I go to install a Lightning Network Daemon (lnd) - ?
cr1776
Legendary
*
Offline Offline

Activity: 4032
Merit: 1301


View Profile
January 26, 2018, 06:22:11 PM
 #8

Cdecker, does c-lightning only for testing but for work(planning to do an exchange) I go to install a Lightning Network Daemon (lnd) - ?

c-lightning and lnd both work for testnet and mainnet - if that is what you are asking. It isn’t completely clear.

c-lightning coexists with bitcoin core whereas right now lnd doesn’t.
Cdecker
Hero Member
*****
Offline Offline

Activity: 489
Merit: 504



View Profile WWW
January 26, 2018, 06:41:20 PM
 #9

Would be kind of overkill to create a full lightning implementation just for testing :-)

Want to see what developers are chatting about? http://bitcoinstats.com/irc/bitcoin-dev/logs/
Bitcoin-OTC Rating
Anti-Cen
Member
**
Offline Offline

Activity: 210
Merit: 26

High fees = low BTC price


View Profile
January 28, 2018, 12:31:16 AM
 #10

Cdecker, does c-lightning only for testing but for work(planning to do an exchange) I go to install a Lightning Network Daemon (lnd) - ?

Here is a map of the LN network and it's not Bob connecting to Peter to send money to Alice and as you can see contains major hubs that
charge both interest if you have a bi-directional channel open and LN tx fees too.

https://lnmainnet.gaben.win/

Your always free not to use it and pay BTC miners $20 per transaction instead if you don't like bankers but the
thing is it will be the miners running these banking hubs on LN anyway so they have you by the balls and anyway
I like my data "On-Chain" and paying $0.10 per transaction without no up front fees to banks just like it was with
Bitcoin about a year ago.

Banking hubs are not an option in LN because if everyone paid for two channels to create a disbursed network then
it would take 50,000 hops to cross the network so that's not going to work but it's what they were trying to lead
people to believe.   




Mining is CPU-wars and Intel, AMD like it nearly as much as big oil likes miners wasting electricity. Is this what mankind has come too.
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6635


Just writing some code


View Profile WWW
January 29, 2018, 12:57:59 AM
 #11

c-lightning coexists with bitcoin core whereas right now lnd doesn’t.
LND has the option to use Bitcoin Core as the full node backend.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!