From 4f85615734e782c9ff4ab1c95a96ae22d6d0aa12 Mon Sep 17 00:00:00 2001 From: Janus Troelsen Date: Fri, 22 Jun 2018 17:07:07 +0200 Subject: [PATCH] add simnet support (#4455) --- electrum | 2 ++ lib/commands.py | 1 + lib/constants.py | 11 +++++++++++ lib/simple_config.py | 3 +++ 4 files changed, 17 insertions(+) diff --git a/electrum b/electrum index 6bef64b7b..150e4adab 100755 --- a/electrum +++ b/electrum @@ -401,6 +401,8 @@ if __name__ == '__main__': constants.set_testnet() elif config.get('regtest'): constants.set_regtest() + elif config.get('simnet'): + constants.set_simnet() # run non-RPC commands separately if cmdname in ['create', 'restore']: diff --git a/lib/commands.py b/lib/commands.py index f89ba62dd..71f7b2919 100644 --- a/lib/commands.py +++ b/lib/commands.py @@ -835,6 +835,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("--regtest", action="store_true", dest="regtest", default=False, help="Use Regtest") + group.add_argument("--simnet", action="store_true", dest="simnet", default=False, help="Use Simnet") def get_parser(): # create main parser diff --git a/lib/constants.py b/lib/constants.py index 8642f0e16..939d738ce 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -101,9 +101,20 @@ class BitcoinRegtest(BitcoinTestnet): CHECKPOINTS = [] +class BitcoinSimnet(BitcoinTestnet): + + SEGWIT_HRP = "sb" + GENESIS = "683e86bd5c6d110d91b94b97137ba6bfe02dbbdb8e3dff722a669b5d69d77af6" + DEFAULT_SERVERS = read_json('servers_regtest.json', {}) + CHECKPOINTS = [] + + # don't import net directly, import the module instead (so that net is singleton) net = BitcoinMainnet +def set_simnet(): + global net + net = BitcoinSimnet def set_mainnet(): global net diff --git a/lib/simple_config.py b/lib/simple_config.py index 4f0168cc9..bc88f2667 100644 --- a/lib/simple_config.py +++ b/lib/simple_config.py @@ -113,6 +113,9 @@ class SimpleConfig(PrintError): elif self.get('regtest'): path = os.path.join(path, 'regtest') make_dir(path, allow_symlink=False) + elif self.get('simnet'): + path = os.path.join(path, 'simnet') + make_dir(path, allow_symlink=False) self.print_error("electrum directory", path) return path