contrib: update generate-seeds.py to ignore torv2 addresses

pull/826/head
Jon Atack 4 years ago
parent 8be56f0f8e
commit 5f7e086dac
No known key found for this signature in database
GPG Key ID: 4F5721B3D0E3921D

@ -37,7 +37,7 @@ import re
class BIP155Network(Enum):
IPV4 = 1
IPV6 = 2
TORV2 = 3
TORV2 = 3 # no longer supported
TORV3 = 4
I2P = 5
CJDNS = 6
@ -46,11 +46,11 @@ def name_to_bip155(addr):
'''Convert address string to BIP155 (networkID, addr) tuple.'''
if addr.endswith('.onion'):
vchAddr = b32decode(addr[0:-6], True)
if len(vchAddr) == 10:
return (BIP155Network.TORV2, vchAddr)
elif len(vchAddr) == 35:
assert(vchAddr[34] == 3)
if len(vchAddr) == 35:
assert vchAddr[34] == 3
return (BIP155Network.TORV3, vchAddr[:32])
elif len(vchAddr) == 10:
return (BIP155Network.TORV2, vchAddr)
else:
raise ValueError('Invalid onion %s' % vchAddr)
elif addr.endswith('.b32.i2p'):
@ -100,7 +100,10 @@ def parse_spec(s):
host = name_to_bip155(host)
return host + (port, )
if host[0] == BIP155Network.TORV2:
return None # TORV2 is no longer supported, so we ignore it
else:
return host + (port, )
def ser_compact_size(l):
r = b""
@ -136,6 +139,8 @@ def process_nodes(g, f, structname):
continue
spec = parse_spec(line)
if spec is None: # ignore this entry (e.g. no longer supported addresses like TORV2)
continue
blob = bip155_serialize(spec)
hoststr = ','.join(('0x%02x' % b) for b in blob)
g.write(f' {hoststr},\n')

Loading…
Cancel
Save