Browse Source

Add support for BU's nolnet

Also update testnet servers
Add missing self. in print_error call
283
Neil Booth 8 years ago
parent
commit
8888a50549
  1. 4
      electrum
  2. 12
      lib/bitcoin.py
  3. 2
      lib/blockchain.py
  4. 1
      lib/commands.py
  5. 11
      lib/network.py
  6. 4
      lib/simple_config.py

4
electrum

@ -361,6 +361,10 @@ if __name__ == '__main__':
bitcoin.set_testnet() bitcoin.set_testnet()
network.set_testnet() network.set_testnet()
if config.get('nolnet'):
bitcoin.set_nolnet()
network.set_nolnet()
# run non-RPC commands separately # run non-RPC commands separately
if cmdname in ['create', 'restore']: if cmdname in ['create', 'restore']:
run_non_RPC(config) run_non_RPC(config)

12
lib/bitcoin.py

@ -38,6 +38,7 @@ import pyaes
# Bitcoin network constants # Bitcoin network constants
TESTNET = False TESTNET = False
NOLNET = False
ADDRTYPE_P2PKH = 0 ADDRTYPE_P2PKH = 0
ADDRTYPE_P2SH = 5 ADDRTYPE_P2SH = 5
ADDRTYPE_P2WPKH = 6 ADDRTYPE_P2WPKH = 6
@ -57,6 +58,17 @@ def set_testnet():
XPUB_HEADER = 0x043587cf XPUB_HEADER = 0x043587cf
HEADERS_URL = "https://headers.electrum.org/testnet_headers" 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"

2
lib/blockchain.py

@ -56,7 +56,7 @@ class Blockchain(util.PrintError):
def verify_header(self, header, prev_header, bits, target): def verify_header(self, header, prev_header, bits, target):
prev_hash = self.hash_header(prev_header) 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')) 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')) assert bits == header.get('bits'), "bits mismatch: %s vs %s" % (bits, header.get('bits'))
_hash = self.hash_header(header) _hash = self.hash_header(header)
assert int('0x' + _hash, 16) <= target, "insufficient proof of work: %s vs target %s" % (int('0x' + _hash, 16), target) assert int('0x' + _hash, 16) <= target, "insufficient proof of work: %s vs target %s" % (int('0x' + _hash, 16), target)

1
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("-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("--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("--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(): def get_parser():
# create main parser # create main parser

11
lib/network.py

@ -68,7 +68,16 @@ def set_testnet():
DEFAULT_PORTS = {'t':'51001', 's':'51002'} DEFAULT_PORTS = {'t':'51001', 's':'51002'}
DEFAULT_SERVERS = { DEFAULT_SERVERS = {
'14.3.140.101': DEFAULT_PORTS, '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 NODES_RETRY_INTERVAL = 60

4
lib/simple_config.py

@ -82,6 +82,8 @@ class SimpleConfig(PrintError):
if self.get('testnet'): if self.get('testnet'):
path = os.path.join(path, '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. # Make directory if it does not yet exist.
if not os.path.exists(path): if not os.path.exists(path):
@ -89,7 +91,7 @@ class SimpleConfig(PrintError):
raise BaseException('Dangling link: ' + path) raise BaseException('Dangling link: ' + path)
os.mkdir(path) os.mkdir(path)
print_error("electrum directory", path) self.print_error("electrum directory", path)
return path return path
def fixup_config_keys(self, config, keypairs): def fixup_config_keys(self, config, keypairs):

Loading…
Cancel
Save