Please describe the feature you’d like to see added.
Use the IPv4-encoded IPv6 addresses that start with a reserved prefix to support nodes with non-default ports in bootstrapping process.
There are 7k IPv4 reachable nodes and some of them use non-default ports:
Example: Port 39388 is used by more than 1000 nodes
The scripts used in this testing guide can be helpful to discover more nodes with non-default ports: https://web.archive.org/web/20230129111013/https://github.com/bitcoin-core/bitcoin-devwiki/wiki/23.0-Release-Candidate-Testing-Guide
Is your feature related to a problem, if so please describe it.
Non-default ports are supported in automatic connections since v23.0: #23542. However, DNS seeds cannot return port numbers in DNS queries. So, the nodes with non-default port will never be a part of bootstrapping.
Related discussion:
https://delvingbitcoin.org/t/hardcoded-seeds-dns-seeds-and-darknet-nodes/1123/8
Describe the solution you’d like
IPv4 address and port number can be encoded in an IPv6 address by DNS seeds. IPv6 address format:
0| 80 bits | 32 bits | 16 bits |
1|----------------------------------|-----------------|---------|
2| 0000 0000 0000 0000 abcd (prefix)| IPv4 Address | Port |
Python script to encode and decode: https://gitlab.com/-/snippets/3746764
01. Encode
12. Decode
23. Exit
3Enter your choice: 1
4Enter IPv4 address: 127.0.0.1
5Enter port number: 8080
6Encoded IPv6: 0000:0000:0000:0000:abcd:7f00:0001:1f90
71. Encode
82. Decode
93. Exit
10Enter your choice: 2
11Enter the encoded IPv6 address: ::abcd:7f00:1:1f90
12Decoded Data (IPv4, Port): 127.0.0.1, 8080
I am using clouflare for DNS and tested this on a domain:
IPv6 addresses are valid, AAAA for domain is resolved successfully by getaddrinfo
and Google DNS: https://dns.google/resolve?name=test.joinstr.xyz&type=AAAA&cd=true
Describe any alternatives you’ve considered
-
IPv4 mapped IPv6 addresses are supported based on RFC 4291 and I tested it on Cloudflare. However, you cannot add anything more than IPv4 address.
https://datatracker.ietf.org/doc/html/rfc4291#section-2.5.5.2
-
NULL and TXT records
Related issues:
https://delvingbitcoin.org/t/hardcoded-seeds-dns-seeds-and-darknet-nodes/1123/6