Skip to content

Commit ea269c7

Browse files
committed
contrib: parse I2P addresses in generate-seeds.py
1 parent d22e7ee commit ea269c7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

contrib/seeds/generate-seeds.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<ip>:<port>
1717
[<ipv6>]:<port>
1818
<onion>.onion:<port>
19+
<i2p>.b32.i2p:<port>
1920
2021
The output will be two data structures with the peers in binary format:
2122
@@ -52,6 +53,12 @@ def name_to_bip155(addr):
5253
return (BIP155Network.TORV3, vchAddr[:32])
5354
else:
5455
raise ValueError('Invalid onion %s' % vchAddr)
56+
elif addr.endswith('.b32.i2p'):
57+
vchAddr = b32decode(addr[0:-8] + '====', True)
58+
if len(vchAddr) == 32:
59+
return (BIP155Network.I2P, vchAddr)
60+
else:
61+
raise ValueError(f'Invalid I2P {vchAddr}')
5562
elif '.' in addr: # IPv4
5663
return (BIP155Network.IPV4, bytes((int(x) for x in addr.split('.'))))
5764
elif ':' in addr: # IPv6

0 commit comments

Comments
 (0)