diff options
Diffstat (limited to 'contrib/seeds/generate-seeds.py')
-rwxr-xr-x | contrib/seeds/generate-seeds.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/contrib/seeds/generate-seeds.py b/contrib/seeds/generate-seeds.py index 2790ef4acd..fe7cd1d597 100755 --- a/contrib/seeds/generate-seeds.py +++ b/contrib/seeds/generate-seeds.py @@ -11,7 +11,7 @@ argument: nodes_main.txt nodes_test.txt -These files must consist of lines in the format +These files must consist of lines in the format <ip> <ip>:<port> @@ -34,7 +34,8 @@ These should be pasted into `src/chainparamsseeds.h`. from base64 import b32decode from binascii import a2b_hex -import sys, os +import sys +import os import re # ipv4 in ipv6 prefix @@ -46,7 +47,7 @@ def name_to_ipv6(addr): if len(addr)>6 and addr.endswith('.onion'): vchAddr = b32decode(addr[0:-6], True) if len(vchAddr) != 16-len(pchOnionCat): - raise ValueError('Invalid onion %s' % s) + raise ValueError('Invalid onion %s' % vchAddr) return pchOnionCat + vchAddr elif '.' in addr: # IPv4 return pchIPv4 + bytearray((int(x) for x in addr.split('.'))) @@ -126,13 +127,13 @@ def main(): g.write(' * Each line contains a 16-byte IPv6 address and a port.\n') g.write(' * IPv4 as well as onion addresses are wrapped inside an IPv6 address accordingly.\n') g.write(' */\n') - with open(os.path.join(indir,'nodes_main.txt'),'r') as f: + with open(os.path.join(indir,'nodes_main.txt'), 'r', encoding="utf8") as f: process_nodes(g, f, 'pnSeed6_main', 8333) g.write('\n') - with open(os.path.join(indir,'nodes_test.txt'),'r') as f: + with open(os.path.join(indir,'nodes_test.txt'), 'r', encoding="utf8") as f: process_nodes(g, f, 'pnSeed6_test', 18333) g.write('#endif // BITCOIN_CHAINPARAMSSEEDS_H\n') - + if __name__ == '__main__': main() |