Skip to content

Commit

Permalink
Merge pull request #2236 from kyuupichan/master
Browse files Browse the repository at this point in the history
Add support for BU's nolnet
  • Loading branch information
ecdsa committed Mar 6, 2017
2 parents 1922389 + 8888a50 commit 6977ba6
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 3 deletions.
4 changes: 4 additions & 0 deletions electrum
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,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)
Expand Down
12 changes: 12 additions & 0 deletions lib/bitcoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

# Bitcoin network constants
TESTNET = False
NOLNET = False
ADDRTYPE_P2PKH = 0
ADDRTYPE_P2SH = 5
ADDRTYPE_P2WPKH = 6
Expand All @@ -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"



Expand Down
2 changes: 1 addition & 1 deletion lib/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def init(self):
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)
Expand Down
1 change: 1 addition & 0 deletions lib/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,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
Expand Down
11 changes: 10 additions & 1 deletion lib/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lib/simple_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,16 @@ def electrum_path(self):

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):
if os.path.islink(path):
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):
Expand Down

0 comments on commit 6977ba6

Please sign in to comment.