From 8888a5054960233126f030a77369d43b6ce3848d Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sat, 4 Mar 2017 11:01:32 +0900 Subject: [PATCH] Add support for BU's nolnet Also update testnet servers Add missing self. in print_error call --- electrum | 4 ++++ lib/bitcoin.py | 12 ++++++++++++ lib/blockchain.py | 2 +- lib/commands.py | 1 + lib/network.py | 11 ++++++++++- lib/simple_config.py | 4 +++- 6 files changed, 31 insertions(+), 3 deletions(-) diff --git a/electrum b/electrum index e74328436..646af517b 100755 --- a/electrum +++ b/electrum @@ -361,6 +361,10 @@ if __name__ == '__main__': bitcoin.set_testnet() network.set_testnet() + if config.get('nolnet'): + bitcoin.set_nolnet() + network.set_nolnet() + # run non-RPC commands separately if cmdname in ['create', 'restore']: run_non_RPC(config) diff --git a/lib/bitcoin.py b/lib/bitcoin.py index 739847cb2..cfba0b664 100644 --- a/lib/bitcoin.py +++ b/lib/bitcoin.py @@ -38,6 +38,7 @@ import pyaes # Bitcoin network constants TESTNET = False +NOLNET = False ADDRTYPE_P2PKH = 0 ADDRTYPE_P2SH = 5 ADDRTYPE_P2WPKH = 6 @@ -57,6 +58,17 @@ def set_testnet(): XPUB_HEADER = 0x043587cf HEADERS_URL = "https://headers.electrum.org/testnet_headers" +def set_nolnet(): + global ADDRTYPE_P2PKH, ADDRTYPE_P2SH, ADDRTYPE_P2WPKH + global XPRV_HEADER, XPUB_HEADER + global NOLNET, HEADERS_URL + NOLNET = True + ADDRTYPE_P2PKH = 0 + ADDRTYPE_P2SH = 5 + ADDRTYPE_P2WPKH = 6 + XPRV_HEADER = 0x0488ade4 + XPUB_HEADER = 0x0488b21e + HEADERS_URL = "https://headers.electrum.org/nolnet_headers" diff --git a/lib/blockchain.py b/lib/blockchain.py index 48b3bcd18..596404275 100644 --- a/lib/blockchain.py +++ b/lib/blockchain.py @@ -56,7 +56,7 @@ class Blockchain(util.PrintError): def verify_header(self, header, prev_header, bits, target): prev_hash = self.hash_header(prev_header) assert prev_hash == header.get('prev_block_hash'), "prev hash mismatch: %s vs %s" % (prev_hash, header.get('prev_block_hash')) - if bitcoin.TESTNET: return + if bitcoin.TESTNET or bitcoin.NOLNET: return assert bits == header.get('bits'), "bits mismatch: %s vs %s" % (bits, header.get('bits')) _hash = self.hash_header(header) assert int('0x' + _hash, 16) <= target, "insufficient proof of work: %s vs target %s" % (int('0x' + _hash, 16), target) diff --git a/lib/commands.py b/lib/commands.py index 3e47b165c..57b2f4e49 100644 --- a/lib/commands.py +++ b/lib/commands.py @@ -778,6 +778,7 @@ def add_global_options(parser): group.add_argument("-w", "--wallet", dest="wallet_path", help="wallet path") group.add_argument("--testnet", action="store_true", dest="testnet", default=False, help="Use Testnet") group.add_argument("--segwit", action="store_true", dest="segwit", default=False, help="The Wizard will create Segwit seed phrases (Testnet only).") + group.add_argument("--nolnet", action="store_true", dest="nolnet", default=False, help="Use Nolnet") def get_parser(): # create main parser diff --git a/lib/network.py b/lib/network.py index 4fa6ee319..a862ca60f 100644 --- a/lib/network.py +++ b/lib/network.py @@ -68,7 +68,16 @@ def set_testnet(): DEFAULT_PORTS = {'t':'51001', 's':'51002'} DEFAULT_SERVERS = { '14.3.140.101': DEFAULT_PORTS, - 'testnet.not.fyi': DEFAULT_PORTS + 'testnet.hsmiths.com': {'t':'53011', 's':'53012'}, + 'electrum.akinbo.org': DEFAULT_PORTS, + 'ELEX05.blackpole.online': {'t':'52011', 's':'52002'}, + } + +def set_nolnet(): + global DEFAULT_PORTS, DEFAULT_SERVERS + DEFAULT_PORTS = {'t':'52001', 's':'52002'} + DEFAULT_SERVERS = { + '14.3.140.101': DEFAULT_PORTS, } NODES_RETRY_INTERVAL = 60 diff --git a/lib/simple_config.py b/lib/simple_config.py index 4c7f201c6..3e88f4bd6 100644 --- a/lib/simple_config.py +++ b/lib/simple_config.py @@ -82,6 +82,8 @@ class SimpleConfig(PrintError): if self.get('testnet'): path = os.path.join(path, 'testnet') + elif self.get('nolnet'): + path = os.path.join(path, 'nolnet') # Make directory if it does not yet exist. if not os.path.exists(path): @@ -89,7 +91,7 @@ class SimpleConfig(PrintError): raise BaseException('Dangling link: ' + path) os.mkdir(path) - print_error("electrum directory", path) + self.print_error("electrum directory", path) return path def fixup_config_keys(self, config, keypairs):