lightning: add --simnet and --lightning switches
This commit is contained in:
parent
c93ad2bcb2
commit
ea5a42d2eb
@ -855,6 +855,7 @@ def add_global_options(parser):
|
|||||||
group.add_argument("--testnet", action="store_true", dest="testnet", default=False, help="Use Testnet")
|
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("--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("--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():
|
def get_parser():
|
||||||
# create main parser
|
# create main parser
|
||||||
|
|||||||
@ -94,6 +94,31 @@ class BitcoinTestnet:
|
|||||||
}
|
}
|
||||||
BIP44_COIN_TYPE = 1
|
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):
|
class BitcoinRegtest(BitcoinTestnet):
|
||||||
|
|
||||||
@ -122,6 +147,9 @@ def set_mainnet():
|
|||||||
global net
|
global net
|
||||||
net = BitcoinMainnet
|
net = BitcoinMainnet
|
||||||
|
|
||||||
|
def set_simnet():
|
||||||
|
global net
|
||||||
|
net = BitcoinSimnet
|
||||||
|
|
||||||
def set_testnet():
|
def set_testnet():
|
||||||
global net
|
global net
|
||||||
|
|||||||
@ -141,8 +141,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
|||||||
tabs.addTab(self.create_history_tab(), QIcon(":icons/tab_history.png"), _('History'))
|
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.send_tab, QIcon(":icons/tab_send.png"), _('Send'))
|
||||||
tabs.addTab(self.receive_tab, QIcon(":icons/tab_receive.png"), _('Receive'))
|
tabs.addTab(self.receive_tab, QIcon(":icons/tab_receive.png"), _('Receive'))
|
||||||
self.lightning_invoices_tab = self.create_lightning_invoices_tab(wallet)
|
if config.get("lightning", False):
|
||||||
tabs.addTab(self.lightning_invoices_tab, _("Lightning Invoices"))
|
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):
|
def add_optional_tab(tabs, tab, icon, description, name):
|
||||||
tab.tab_icon = icon
|
tab.tab_icon = icon
|
||||||
|
|||||||
@ -1095,7 +1095,8 @@ class Network(util.DaemonThread):
|
|||||||
def asyncioThread():
|
def asyncioThread():
|
||||||
asyncio.set_event_loop(loop)
|
asyncio.set_event_loop(loop)
|
||||||
self.lightninglock.acquire()
|
self.lightninglock.acquire()
|
||||||
task = asyncio.ensure_future(asyncio.gather(self.lightningrpc.run(networkAndWalletLock), self.lightningworker.run(networkAndWalletLock)))
|
if self.lightningrpc is not None and self.lightningworker is not None:
|
||||||
|
task = asyncio.ensure_future(asyncio.gather(self.lightningrpc.run(networkAndWalletLock), self.lightningworker.run(networkAndWalletLock)))
|
||||||
loop.run_forever()
|
loop.run_forever()
|
||||||
threading.Thread(target=asyncioThread).start()
|
threading.Thread(target=asyncioThread).start()
|
||||||
networkAndWalletLock.acquire()
|
networkAndWalletLock.acquire()
|
||||||
|
|||||||
@ -109,13 +109,11 @@ class SimpleConfig(PrintError):
|
|||||||
make_dir(path, allow_symlink=False)
|
make_dir(path, allow_symlink=False)
|
||||||
if self.get('testnet'):
|
if self.get('testnet'):
|
||||||
path = os.path.join(path, 'testnet')
|
path = os.path.join(path, 'testnet')
|
||||||
make_dir(path, allow_symlink=False)
|
|
||||||
elif self.get('regtest'):
|
elif self.get('regtest'):
|
||||||
path = os.path.join(path, 'regtest')
|
path = os.path.join(path, 'regtest')
|
||||||
make_dir(path, allow_symlink=False)
|
|
||||||
elif self.get('simnet'):
|
elif self.get('simnet'):
|
||||||
path = os.path.join(path, 'simnet')
|
path = os.path.join(path, 'simnet')
|
||||||
make_dir(path, allow_symlink=False)
|
make_dir(path, allow_symlink=False)
|
||||||
|
|
||||||
self.print_error("electrum directory", path)
|
self.print_error("electrum directory", path)
|
||||||
return path
|
return path
|
||||||
|
|||||||
@ -1301,8 +1301,11 @@ class Abstract_Wallet(PrintError):
|
|||||||
self.verifier = SPV(self.network, self)
|
self.verifier = SPV(self.network, self)
|
||||||
self.synchronizer = Synchronizer(self, network)
|
self.synchronizer = Synchronizer(self, network)
|
||||||
network.add_jobs([self.verifier, self.synchronizer])
|
network.add_jobs([self.verifier, self.synchronizer])
|
||||||
network.lightningworker = LightningWorker(lambda: self, lambda: network, lambda: network.config)
|
network.lightningworker = None
|
||||||
network.lightningrpc = LightningRPC()
|
network.lightningrpc = None
|
||||||
|
if network.config.get("lightning", False):
|
||||||
|
network.lightningworker = LightningWorker(lambda: self, lambda: network, lambda: network.config)
|
||||||
|
network.lightningrpc = LightningRPC()
|
||||||
network.lightninglock.release()
|
network.lightninglock.release()
|
||||||
else:
|
else:
|
||||||
self.verifier = None
|
self.verifier = None
|
||||||
|
|||||||
@ -32,8 +32,8 @@ NETWORK = None
|
|||||||
CONFIG = None
|
CONFIG = None
|
||||||
locked = set()
|
locked = set()
|
||||||
|
|
||||||
machine = "148.251.87.112"
|
#machine = "148.251.87.112"
|
||||||
#machine = "127.0.0.1"
|
machine = "127.0.0.1"
|
||||||
|
|
||||||
def WriteDb(json):
|
def WriteDb(json):
|
||||||
req = rpc_pb2.WriteDbRequest()
|
req = rpc_pb2.WriteDbRequest()
|
||||||
|
|||||||
@ -398,6 +398,9 @@ if __name__ == '__main__':
|
|||||||
elif config.get('simnet'):
|
elif config.get('simnet'):
|
||||||
constants.set_simnet()
|
constants.set_simnet()
|
||||||
|
|
||||||
|
if config.get('simnet'):
|
||||||
|
constants.set_simnet()
|
||||||
|
|
||||||
# run non-RPC commands separately
|
# run non-RPC commands separately
|
||||||
if cmdname in ['create', 'restore']:
|
if cmdname in ['create', 'restore']:
|
||||||
run_non_RPC(config)
|
run_non_RPC(config)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user