1
0

read checkpoints file in NetworkConstants, add it to setup.py

This commit is contained in:
ThomasV
2017-12-12 11:10:50 +01:00
parent 40e13224f7
commit 44a83c2401
6 changed files with 21 additions and 30 deletions

View File

@@ -37,13 +37,13 @@ from . import version
from .util import print_error, InvalidPassword, assert_bytes, to_bytes, inv_dict
from . import segwit_addr
def read_json_dict(filename):
def read_json(filename, default):
path = os.path.join(os.path.dirname(__file__), filename)
try:
with open(path, 'r') as f:
r = json.loads(f.read())
except:
r = {}
r = default
return r
@@ -78,10 +78,10 @@ class NetworkConstants:
cls.ADDRTYPE_P2PKH = 0
cls.ADDRTYPE_P2SH = 5
cls.SEGWIT_HRP = "bc"
cls.HEADERS_URL = "https://headers.electrum.org/blockchain_headers"
cls.GENESIS = "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
cls.DEFAULT_PORTS = {'t': '50001', 's': '50002'}
cls.DEFAULT_SERVERS = read_json_dict('servers.json')
cls.DEFAULT_SERVERS = read_json('servers.json', {})
cls.CHECKPOINTS = read_json('checkpoints.json', [])
@classmethod
def set_testnet(cls):
@@ -90,10 +90,10 @@ class NetworkConstants:
cls.ADDRTYPE_P2PKH = 111
cls.ADDRTYPE_P2SH = 196
cls.SEGWIT_HRP = "tb"
cls.HEADERS_URL = "https://headers.electrum.org/testnet_headers"
cls.GENESIS = "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"
cls.DEFAULT_PORTS = {'t':'51001', 's':'51002'}
cls.DEFAULT_SERVERS = read_json_dict('servers_testnet.json')
cls.DEFAULT_SERVERS = read_json('servers_testnet.json', {})
cls.CHECKPOINTS = read_json('checkpoints_testnet.json', [])
NetworkConstants.set_mainnet()