commit b4d71e651b16a16afc427f87542b8fd9e05b66e3
parent b68f5645cbab180d0687b2b2e4f17adfe529191a
Author: fivepiece <fivepiece@users.noreply.github.com>
Date: Wed, 11 Apr 2018 20:10:14 +0300
add regtest support (#4242)
* add regtest support
* set default regtest ssl and tcp ports to 51002 and 51002
* regtest inherits parameters from testnet
Diffstat:
6 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/electrum b/electrum
@@ -401,6 +401,8 @@ if __name__ == '__main__':
if config.get('testnet'):
constants.set_testnet()
+ elif config.get('regtest'):
+ constants.set_regtest()
# run non-RPC commands separately
if cmdname in ['create', 'restore']:
diff --git a/lib/commands.py b/lib/commands.py
@@ -817,6 +817,7 @@ def add_global_options(parser):
group.add_argument("-P", "--portable", action="store_true", dest="portable", default=False, help="Use local 'electrum_data' directory")
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")
def get_parser():
# create main parser
diff --git a/lib/constants.py b/lib/constants.py
@@ -93,6 +93,14 @@ class BitcoinTestnet:
}
+class BitcoinRegtest(BitcoinTestnet):
+
+ SEGWIT_HRP = "bcrt"
+ GENESIS = "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"
+ DEFAULT_SERVERS = read_json('servers_regtest.json', {})
+ CHECKPOINTS = []
+
+
# don't import net directly, import the module instead (so that net is singleton)
net = BitcoinMainnet
@@ -105,3 +113,8 @@ def set_mainnet():
def set_testnet():
global net
net = BitcoinTestnet
+
+
+def set_regtest():
+ global net
+ net = BitcoinRegtest
diff --git a/lib/servers_regtest.json b/lib/servers_regtest.json
@@ -0,0 +1,8 @@
+{
+ "127.0.0.1": {
+ "pruning": "-",
+ "s": "51002",
+ "t": "51001",
+ "version": "1.2"
+ }
+}
diff --git a/lib/simple_config.py b/lib/simple_config.py
@@ -115,6 +115,9 @@ class SimpleConfig(PrintError):
if self.get('testnet'):
path = os.path.join(path, 'testnet')
make_dir(path)
+ elif self.get('regtest'):
+ path = os.path.join(path, 'regtest')
+ make_dir(path)
self.print_error("electrum directory", path)
return path
diff --git a/setup.py b/setup.py
@@ -74,6 +74,7 @@ setup(
'electrum': [
'servers.json',
'servers_testnet.json',
+ 'servers_regtest.json',
'currencies.json',
'checkpoints.json',
'checkpoints_testnet.json',