chips-blockchain / bet

This repository holds the implementation code of Pangea Poker white paper: https://bit.ly/3bdCz0Z
https://chips.cash
16 stars 17 forks source link

Issue in LN channel establishing due to empty IP Address #175

Open sg777 opened 3 years ago

sg777 commented 3 years ago

Right now, the bet node runs lightning-cli getinfo and parses the output and reads the id and ip from the output and with those values an uri string is formed id@ip and using which an LN channel is established.

But if the LN node is not public or the IP is not configured in the LN node, the lightning-cli getinfo command returns NULL in addresses field and which result in reading NULL for IP address and that causing the segmentation fault and aborting of the player node.

satindergrewal commented 3 years ago

I think I have the potential solution for this problem. I tested this command to get public IP of the computer and set it to lightningd at command line:

lightningd --ipaddr=$(curl ifconfig.co) --log-level=debug &

This will return output as expected for lightning-cli getinfo:

satinder@pangeaplayer:~$ lightning-cli getinfo | jq .
{
  "id": "022ff6959d36ba4cffa8286783f56fafaf514ddf08eeed4f22af8a07d338988296",
  "port": 9735,
  "address": [
    {
      "type": "ipv4",
      "address": "YOUR_PUBLIC_IP_HERE",
      "port": 9735
    }
  ],
  "version": "chipsln.0.0.0",
  "blockheight": 7715055,
  "network": "chips"
}

And in case if it's the latest c-lightning fork, which will soon be updated after initial testing, that command will be like this:

pi@raspberrypi:~/grewal/lightning $ ./lightningd/lightningd --network chips --announce-addr $(curl ifconfig.co) --log-level=debug &

And output of it will be like this:

pi@raspberrypi:~ $ lightning-cli getinfo | jq .
{
  "id": "034502e8f501b76d4d3a9aec49ac7da1e28ca9401d94337f7d76402ec3d52b787a",
  "alias": "ORANGEBAGEL",
  "color": "034502",
  "num_peers": 0,
  "num_pending_channels": 0,
  "num_active_channels": 0,
  "num_inactive_channels": 0,
  "address": [
    {
      "type": "ipv4",
      "address": "YOUR_PUBLIC_IP_HERE",
      "port": 9735
    }
  ],
  "binding": [],
  "version": "chipsln.0.0.0",
  "blockheight": 7715045,
  "network": "chips",
  "msatoshi_fees_collected": 0,
  "fees_collected_msat": "0msat",
  "lightning-dir": "/home/pi/.chipsln/chips"
}