Skip to content

Commit 5f7e086

Browse files
committed
contrib: update generate-seeds.py to ignore torv2 addresses
1 parent 8be56f0 commit 5f7e086

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

contrib/seeds/generate-seeds.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
class BIP155Network(Enum):
3838
IPV4 = 1
3939
IPV6 = 2
40-
TORV2 = 3
40+
TORV2 = 3 # no longer supported
4141
TORV3 = 4
4242
I2P = 5
4343
CJDNS = 6
@@ -46,11 +46,11 @@ def name_to_bip155(addr):
4646
'''Convert address string to BIP155 (networkID, addr) tuple.'''
4747
if addr.endswith('.onion'):
4848
vchAddr = b32decode(addr[0:-6], True)
49-
if len(vchAddr) == 10:
50-
return (BIP155Network.TORV2, vchAddr)
51-
elif len(vchAddr) == 35:
52-
assert(vchAddr[34] == 3)
49+
if len(vchAddr) == 35:
50+
assert vchAddr[34] == 3
5351
return (BIP155Network.TORV3, vchAddr[:32])
52+
elif len(vchAddr) == 10:
53+
return (BIP155Network.TORV2, vchAddr)
5454
else:
5555
raise ValueError('Invalid onion %s' % vchAddr)
5656
elif addr.endswith('.b32.i2p'):
@@ -100,7 +100,10 @@ def parse_spec(s):
100100

101101
host = name_to_bip155(host)
102102

103-
return host + (port, )
103+
if host[0] == BIP155Network.TORV2:
104+
return None # TORV2 is no longer supported, so we ignore it
105+
else:
106+
return host + (port, )
104107

105108
def ser_compact_size(l):
106109
r = b""
@@ -136,6 +139,8 @@ def process_nodes(g, f, structname):
136139
continue
137140

138141
spec = parse_spec(line)
142+
if spec is None: # ignore this entry (e.g. no longer supported addresses like TORV2)
143+
continue
139144
blob = bip155_serialize(spec)
140145
hoststr = ','.join(('0x%02x' % b) for b in blob)
141146
g.write(f' {hoststr},\n')

0 commit comments

Comments
 (0)