Skip to content

Commit 8c5b6bd

Browse files
committed
Read default server list from file. Update list with 1.1 servers. Remove nolnet option.
1 parent dd2b7e4 commit 8c5b6bd

8 files changed

Lines changed: 264 additions & 84 deletions

File tree

electrum

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,6 @@ if __name__ == '__main__':
355355

356356
if config.get('testnet'):
357357
bitcoin.set_testnet()
358-
network.set_testnet()
359-
360-
if config.get('nolnet'):
361-
bitcoin.set_nolnet()
362-
network.set_nolnet()
363358

364359
# run non-RPC commands separately
365360
if cmdname in ['create', 'restore']:

lib/bitcoin.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import re
2929
import hmac
3030
import os
31+
import json
3132

3233
import ecdsa
3334
import pyaes
@@ -37,6 +38,14 @@
3738
from .util import print_error, InvalidPassword, assert_bytes, to_bytes
3839
from . import segwit_addr
3940

41+
def read_json_dict(filename):
42+
path = os.path.join(os.path.dirname(__file__), filename)
43+
try:
44+
r = json.loads(open(path, 'r').read())
45+
except:
46+
r = {}
47+
return r
48+
4049

4150
# Bitcoin network constants
4251
TESTNET = False
@@ -48,13 +57,17 @@
4857
XPUB_HEADER = 0x0488b21e
4958
HEADERS_URL = "https://headers.electrum.org/blockchain_headers"
5059
GENESIS = "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
60+
SERVERLIST = 'servers.json'
61+
DEFAULT_PORTS = {'t':'50001', 's':'50002'}
62+
DEFAULT_SERVERS = read_json_dict('servers.json')
5163

5264
def set_testnet():
5365
global ADDRTYPE_P2PKH, ADDRTYPE_P2SH
5466
global XPRV_HEADER, XPUB_HEADER
5567
global TESTNET, HEADERS_URL
5668
global GENESIS
5769
global SEGWIT_HRP
70+
global DEFAULT_PORTS, SERVERLIST
5871
TESTNET = True
5972
ADDRTYPE_P2PKH = 111
6073
ADDRTYPE_P2SH = 196
@@ -63,20 +76,9 @@ def set_testnet():
6376
XPUB_HEADER = 0x043587cf
6477
HEADERS_URL = "https://headers.electrum.org/testnet_headers"
6578
GENESIS = "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"
66-
67-
def set_nolnet():
68-
global ADDRTYPE_P2PKH, ADDRTYPE_P2SH
69-
global XPRV_HEADER, XPUB_HEADER
70-
global NOLNET, HEADERS_URL
71-
global GENESIS
72-
TESTNET = True
73-
ADDRTYPE_P2PKH = 0
74-
ADDRTYPE_P2SH = 5
75-
XPRV_HEADER = 0x0488ade4
76-
XPUB_HEADER = 0x0488b21e
77-
HEADERS_URL = "https://headers.electrum.org/nolnet_headers"
78-
GENESIS = "663c88be18d07c45f87f910b93a1a71ed9ef1946cad50eb6a6f3af4c424625c6"
79-
79+
SERVERLIST = 'servers_testnet.json'
80+
DEFAULT_PORTS = {'t':'51001', 's':'51002'}
81+
DEFAULT_SERVERS = read_json_dict('servers_testnet.json')
8082

8183

8284
################################## transactions

lib/commands.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,6 @@ def add_global_options(parser):
826826
group.add_argument("-w", "--wallet", dest="wallet_path", help="wallet path")
827827
group.add_argument("--testnet", action="store_true", dest="testnet", default=False, help="Use Testnet")
828828
group.add_argument("--segwit", action="store_true", dest="segwit", default=False, help="The Wizard will create Segwit seed phrases (Testnet only).")
829-
group.add_argument("--nolnet", action="store_true", dest="nolnet", default=False, help="Use Nolnet")
830829

831830
def get_parser():
832831
# create main parser

lib/network.py

Lines changed: 6 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
# Electrum - Lightweight Bitcoin Client
23
# Copyright (c) 2011-2016 Thomas Voegtlin
34
#
@@ -35,7 +36,6 @@
3536
import traceback
3637
from collections import defaultdict, deque
3738
import threading
38-
3939
import socket
4040
import json
4141

@@ -47,54 +47,6 @@
4747
from . import blockchain
4848
from .version import ELECTRUM_VERSION, PROTOCOL_VERSION
4949

50-
DEFAULT_PORTS = {'t':'50001', 's':'50002'}
51-
52-
#There is a schedule to move the default list to e-x (electrumx) by Jan 2018
53-
#Schedule is as follows:
54-
#move ~3/4 to e-x by 1.4.17
55-
#then gradually switch remaining nodes to e-x nodes
56-
57-
DEFAULT_SERVERS = {
58-
'erbium1.sytes.net':DEFAULT_PORTS, # core, e-x
59-
'ecdsa.net':{'t':'50001', 's':'110'}, # core, e-x
60-
'gh05.geekhosters.com':DEFAULT_PORTS, # core, e-s
61-
'VPS.hsmiths.com':DEFAULT_PORTS, # core, e-x
62-
'electrum.anduck.net':DEFAULT_PORTS, # core, e-s; banner with version pending
63-
'electrum.no-ip.org':DEFAULT_PORTS, # core, e-s
64-
'electrum.be':DEFAULT_PORTS, # core, e-x
65-
'helicarrier.bauerj.eu':DEFAULT_PORTS, # core, e-x
66-
'elex01.blackpole.online':DEFAULT_PORTS, # core, e-x
67-
'electrumx.not.fyi':DEFAULT_PORTS, # core, e-x
68-
'node.xbt.eu':DEFAULT_PORTS, # core, e-x
69-
'kirsche.emzy.de':DEFAULT_PORTS, # core, e-x
70-
'electrum.villocq.com':DEFAULT_PORTS, # core?, e-s; banner with version recommended
71-
'us11.einfachmalnettsein.de':DEFAULT_PORTS, # core, e-x
72-
'electrum.trouth.net':DEFAULT_PORTS, # BU, e-s
73-
'Electrum.hsmiths.com':{'t':'8080', 's':'995'}, # core, e-x
74-
'electrum3.hachre.de':DEFAULT_PORTS, # core, e-x
75-
'b.1209k.com':DEFAULT_PORTS, # XT, jelectrum
76-
'elec.luggs.co':{ 's':'443'}, # core, e-x
77-
'btc.smsys.me':{'t':'110', 's':'995'}, # BU, e-x
78-
}
79-
80-
def set_testnet():
81-
global DEFAULT_PORTS, DEFAULT_SERVERS
82-
DEFAULT_PORTS = {'t':'51001', 's':'51002'}
83-
DEFAULT_SERVERS = {
84-
'testnetnode.arihanc.com': DEFAULT_PORTS,
85-
'testnet1.bauerj.eu': DEFAULT_PORTS,
86-
'14.3.140.101': DEFAULT_PORTS,
87-
'testnet.hsmiths.com': {'t':'53011', 's':'53012'},
88-
'electrum.akinbo.org': DEFAULT_PORTS,
89-
'ELEX05.blackpole.online': {'t':'52011', 's':'52002'},
90-
}
91-
92-
def set_nolnet():
93-
global DEFAULT_PORTS, DEFAULT_SERVERS
94-
DEFAULT_PORTS = {'t':'52001', 's':'52002'}
95-
DEFAULT_SERVERS = {
96-
'14.3.140.101': DEFAULT_PORTS,
97-
}
9850

9951
NODES_RETRY_INTERVAL = 60
10052
SERVER_RETRY_INTERVAL = 10
@@ -401,11 +353,10 @@ def get_interfaces(self):
401353
return list(self.interfaces.keys())
402354

403355
def get_servers(self):
356+
out = DEFAULT_SERVERS
404357
if self.irc_servers:
405-
out = self.irc_servers.copy()
406-
out.update(DEFAULT_SERVERS)
358+
out.update(filter_version(self.irc_servers.copy()))
407359
else:
408-
out = DEFAULT_SERVERS
409360
for s in self.recent_servers:
410361
try:
411362
host, port, protocol = deserialize_server(s)
@@ -510,7 +461,8 @@ def switch_to_random_interface(self):
510461
'''Switch to a random connected server other than the current one'''
511462
servers = self.get_interfaces() # Those in connected state
512463
if self.default_server in servers:
513-
servers.remove(self.default_server)
464+
servers.remov
465+
e(self.default_server)
514466
if servers:
515467
self.switch_to_interface(random.choice(servers))
516468

@@ -577,7 +529,7 @@ def process_response(self, interface, response, callbacks):
577529
self.on_notify_header(interface, result)
578530
elif method == 'server.peers.subscribe':
579531
if error is None:
580-
self.irc_servers = filter_version(parse_servers(result))
532+
self.irc_servers = parse_servers(result)
581533
self.notify('servers')
582534
elif method == 'server.banner':
583535
if error is None:

0 commit comments

Comments
 (0)