From f708db95edd19c81896cb28bc7bfe96efd9dde39 Mon Sep 17 00:00:00 2001 From: Janus Date: Thu, 5 Apr 2018 17:05:39 +0200 Subject: [PATCH] lightning: add --simnet and --lightning switches --- electrum/commands.py | 1 + electrum/constants.py | 26 +++++++++++++++++++++++++- electrum/gui/qt/main_window.py | 5 +++-- lib/lightning.py | 4 ++-- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/electrum/commands.py b/electrum/commands.py index 422849b79..a3b918091 100644 --- a/electrum/commands.py +++ b/electrum/commands.py @@ -935,6 +935,7 @@ def add_global_options(parser): 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") + group.add_argument("--lightning", action="store_true", dest="lightning", default=False, help="Enable Lightning support") def get_parser(): # create main parser diff --git a/electrum/constants.py b/electrum/constants.py index af3f7205a..716848544 100644 --- a/electrum/constants.py +++ b/electrum/constants.py @@ -101,6 +101,31 @@ class BitcoinTestnet(AbstractNet): } BIP44_COIN_TYPE = 1 +class BitcoinSimnet: + ADDRTYPE_P2PKH = 0x3f + ADDRTYPE_P2SH = 0x7b + SEGWIT_HRP = "sb" + GENESIS = "683e86bd5c6d110d91b94b97137ba6bfe02dbbdb8e3dff722a669b5d69d77af6" + WIF_PREFIX = 0x00 + TESTNET = True + DEFAULT_PORTS = {} + DEFAULT_SERVERS = {} + CHECKPOINTS = [] + + XPRV_HEADERS = { + 'standard': 0x04358394, # tprv + 'p2wpkh-p2sh': 0x044a4e28, # uprv + 'p2wsh-p2sh': 0x024285b5, # Uprv + 'p2wpkh': 0x045f18bc, # vprv + 'p2wsh': 0x02575048, # Vprv + } + XPUB_HEADERS = { + 'standard': 0x043587cf, # tpub + 'p2wpkh-p2sh': 0x044a5262, # upub + 'p2wsh-p2sh': 0x024285ef, # Upub + 'p2wpkh': 0x045f1cf6, # vpub + 'p2wsh': 0x02575483, # Vpub + } class BitcoinRegtest(BitcoinTestnet): @@ -129,7 +154,6 @@ def set_mainnet(): global net net = BitcoinMainnet - def set_testnet(): global net net = BitcoinTestnet diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py index fecd5a744..4a0c5228a 100644 --- a/electrum/gui/qt/main_window.py +++ b/electrum/gui/qt/main_window.py @@ -160,8 +160,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): tabs.addTab(self.create_history_tab(), QIcon(":icons/tab_history.png"), _('History')) tabs.addTab(self.send_tab, QIcon(":icons/tab_send.png"), _('Send')) tabs.addTab(self.receive_tab, QIcon(":icons/tab_receive.png"), _('Receive')) - self.lightning_invoices_tab = self.create_lightning_invoices_tab(wallet) - tabs.addTab(self.lightning_invoices_tab, _("Lightning Invoices")) + if config.get("lightning", False): + self.lightning_invoices_tab = self.create_lightning_invoices_tab(wallet) + tabs.addTab(self.lightning_invoices_tab, _("Lightning Invoices")) def add_optional_tab(tabs, tab, icon, description, name): tab.tab_icon = icon diff --git a/lib/lightning.py b/lib/lightning.py index 9a0ce1686..ec8b1f600 100644 --- a/lib/lightning.py +++ b/lib/lightning.py @@ -32,8 +32,8 @@ NETWORK = None CONFIG = None locked = set() -machine = "148.251.87.112" -#machine = "127.0.0.1" +#machine = "148.251.87.112" +machine = "127.0.0.1" def WriteDb(json): req = rpc_pb2.WriteDbRequest()