From 5f7e086dac78c9070f8292a1757d7e77e110f772 Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Wed, 26 May 2021 16:35:28 +0200 Subject: contrib: update generate-seeds.py to ignore torv2 addresses --- contrib/seeds/generate-seeds.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'contrib/seeds') diff --git a/contrib/seeds/generate-seeds.py b/contrib/seeds/generate-seeds.py index 9560b586ec..dbecba7d1d 100755 --- a/contrib/seeds/generate-seeds.py +++ b/contrib/seeds/generate-seeds.py @@ -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') -- cgit v1.2.3