5

Bitcoin uses a DNS-based bootstrapping mechanism to help new nodes find peers. As far as I'm aware, Lightning doesn't have such mechanism, and new users are supposed to just search for node addresses on the web (or use nodes maintained / recommended by their wallet developers, or whatever).

What is the rationale behind this design decision?

1 Answer 1

4

It does! There is even a BOLT for it (check out: https://github.com/lightningnetwork/lightning-rfc/blob/master/10-dns-bootstrap.md )

from there you have the following example:

dig lseed.bitcoinstats.com AAAA
lseed.bitcoinstats.com. 60      IN      AAAA    2a02:aa16:1105:4a80:1234:1234:37c1:9c9

Christian Decker is maintaining the dns seed list. I even used this in my autopilot (the c-lightning wrapper). check out:

  def __get_seed_keys(self):
        """
        retrieve the nodeids of the ln seed nodes from lseed.bitcoinstats.com
        """
        domain = "lseed.bitcoinstats.com"
        srv_records = dns.resolver.query(domain,"SRV")
        res = []
        for srv in srv_records:
            bech32 = str(srv.target).rstrip(".").split(".")[0]
            data = bech32_decode(bech32)[1]
            decoded = convertbits(data, 5, 4)
            res.append("".join(
                ['{:1x}'.format(integer) for integer in decoded])[:-1])
        return res


    def __connect_to_seeds(self):
        """
        sets up peering connection to seed nodes of the lightning network

        This is necessary in case the node operating the autopilot has never
        been connected to the lightning network.
        """
        try:
            for nodeid in random.shuffle(self.__get_seed_keys()):
                self.__clogger.info("peering with node: " + nodeid)
                self.__rpc_interface.connect(nodeid)
                # FIXME: better strategy than sleep(2) for building up
                time.sleep(2)
        except:
            pass
3
  • Nice, thanks! So the logical continuation of my question would then be - why isn't it used as the default connection mechanism, as in Bitcoin? (Or is it? I'm experimenting with Eclair and it I don't see that option; do c-lightning or LND have it?) Jun 11, 2019 at 13:32
  • That I don't know :( When you use my autopilot plugin it is being used. I guess in lightning the process is different. You only peer with a node when you want to create a channel anyway. So I guess the indirect answer is that the power of choice was left to the user Jun 11, 2019 at 13:42
  • Got it! The last thing I don't quite understand is how to specify the DNS query to get a testnet node. BOLT10 says that the "realm byte" r is "used to specify what realm the returned nodes must support" with the default value of "0 (Bitcoin)", but it doesn't mention the values for other networks... Jun 11, 2019 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.