Browse Source

add regtest support (#4242)

* add regtest support

* set default regtest ssl and tcp ports to 51002 and 51002

* regtest inherits parameters from testnet
3.2.x
fivepiece 7 years ago
committed by ghost43
parent
commit
b4d71e651b
  1. 2
      electrum
  2. 1
      lib/commands.py
  3. 13
      lib/constants.py
  4. 8
      lib/servers_regtest.json
  5. 3
      lib/simple_config.py
  6. 1
      setup.py

2
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']:

1
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

13
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

8
lib/servers_regtest.json

@ -0,0 +1,8 @@
{
"127.0.0.1": {
"pruning": "-",
"s": "51002",
"t": "51001",
"version": "1.2"
}
}

3
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

1
setup.py

@ -74,6 +74,7 @@ setup(
'electrum': [
'servers.json',
'servers_testnet.json',
'servers_regtest.json',
'currencies.json',
'checkpoints.json',
'checkpoints_testnet.json',

Loading…
Cancel
Save