mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 23:07:59 +01:00
contrib: update generate-seeds.py to ignore torv2 addresses
This commit is contained in:
parent
8be56f0f8e
commit
5f7e086dac
1 changed files with 11 additions and 6 deletions
|
@ -37,7 +37,7 @@ import re
|
||||||
class BIP155Network(Enum):
|
class BIP155Network(Enum):
|
||||||
IPV4 = 1
|
IPV4 = 1
|
||||||
IPV6 = 2
|
IPV6 = 2
|
||||||
TORV2 = 3
|
TORV2 = 3 # no longer supported
|
||||||
TORV3 = 4
|
TORV3 = 4
|
||||||
I2P = 5
|
I2P = 5
|
||||||
CJDNS = 6
|
CJDNS = 6
|
||||||
|
@ -46,11 +46,11 @@ def name_to_bip155(addr):
|
||||||
'''Convert address string to BIP155 (networkID, addr) tuple.'''
|
'''Convert address string to BIP155 (networkID, addr) tuple.'''
|
||||||
if addr.endswith('.onion'):
|
if addr.endswith('.onion'):
|
||||||
vchAddr = b32decode(addr[0:-6], True)
|
vchAddr = b32decode(addr[0:-6], True)
|
||||||
if len(vchAddr) == 10:
|
if len(vchAddr) == 35:
|
||||||
return (BIP155Network.TORV2, vchAddr)
|
assert vchAddr[34] == 3
|
||||||
elif len(vchAddr) == 35:
|
|
||||||
assert(vchAddr[34] == 3)
|
|
||||||
return (BIP155Network.TORV3, vchAddr[:32])
|
return (BIP155Network.TORV3, vchAddr[:32])
|
||||||
|
elif len(vchAddr) == 10:
|
||||||
|
return (BIP155Network.TORV2, vchAddr)
|
||||||
else:
|
else:
|
||||||
raise ValueError('Invalid onion %s' % vchAddr)
|
raise ValueError('Invalid onion %s' % vchAddr)
|
||||||
elif addr.endswith('.b32.i2p'):
|
elif addr.endswith('.b32.i2p'):
|
||||||
|
@ -100,6 +100,9 @@ def parse_spec(s):
|
||||||
|
|
||||||
host = name_to_bip155(host)
|
host = name_to_bip155(host)
|
||||||
|
|
||||||
|
if host[0] == BIP155Network.TORV2:
|
||||||
|
return None # TORV2 is no longer supported, so we ignore it
|
||||||
|
else:
|
||||||
return host + (port, )
|
return host + (port, )
|
||||||
|
|
||||||
def ser_compact_size(l):
|
def ser_compact_size(l):
|
||||||
|
@ -136,6 +139,8 @@ def process_nodes(g, f, structname):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
spec = parse_spec(line)
|
spec = parse_spec(line)
|
||||||
|
if spec is None: # ignore this entry (e.g. no longer supported addresses like TORV2)
|
||||||
|
continue
|
||||||
blob = bip155_serialize(spec)
|
blob = bip155_serialize(spec)
|
||||||
hoststr = ','.join(('0x%02x' % b) for b in blob)
|
hoststr = ','.join(('0x%02x' % b) for b in blob)
|
||||||
g.write(f' {hoststr},\n')
|
g.write(f' {hoststr},\n')
|
||||||
|
|
Loading…
Add table
Reference in a new issue