mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
add remove_lightning command
This commit is contained in:
parent
db833e1ba3
commit
a13cea6f8a
3 changed files with 30 additions and 2 deletions
|
@ -628,6 +628,11 @@ class Commands:
|
||||||
wallet.init_lightning()
|
wallet.init_lightning()
|
||||||
return "Lightning keys have been created."
|
return "Lightning keys have been created."
|
||||||
|
|
||||||
|
@command('w')
|
||||||
|
async def remove_lightning(self, wallet: Abstract_Wallet = None):
|
||||||
|
"""Disable lightning payments"""
|
||||||
|
wallet.remove_lightning()
|
||||||
|
|
||||||
@command('w')
|
@command('w')
|
||||||
async def lightning_history(self, show_fiat=False, wallet: Abstract_Wallet = None):
|
async def lightning_history(self, show_fiat=False, wallet: Abstract_Wallet = None):
|
||||||
""" lightning history """
|
""" lightning history """
|
||||||
|
|
|
@ -2390,6 +2390,15 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||||
if d.exec_():
|
if d.exec_():
|
||||||
self.set_contact(line2.text(), line1.text())
|
self.set_contact(line2.text(), line1.text())
|
||||||
|
|
||||||
|
def disable_lightning(self):
|
||||||
|
warning = _('This will delete your lightning private keys')
|
||||||
|
r = self.question(_('Disable Lightning payments?') + '\n\n' + warning)
|
||||||
|
if not r:
|
||||||
|
return
|
||||||
|
self.wallet.remove_lightning()
|
||||||
|
self.show_warning(_('Lightning keys have been removed. This wallet will be closed'))
|
||||||
|
self.close()
|
||||||
|
|
||||||
def enable_lightning(self):
|
def enable_lightning(self):
|
||||||
warning1 = _("Lightning support in Electrum is experimental. Do not put large amounts in lightning channels.")
|
warning1 = _("Lightning support in Electrum is experimental. Do not put large amounts in lightning channels.")
|
||||||
warning2 = _("Funds stored in lightning channels are not recoverable from your seed. You must backup your wallet file everytime you crate a new channel.")
|
warning2 = _("Funds stored in lightning channels are not recoverable from your seed. You must backup your wallet file everytime you crate a new channel.")
|
||||||
|
@ -2397,7 +2406,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||||
if not r:
|
if not r:
|
||||||
return
|
return
|
||||||
self.wallet.init_lightning()
|
self.wallet.init_lightning()
|
||||||
self.show_warning(_('Lightning keys have been initialized. Please restart Electrum'))
|
self.show_warning(_('Lightning keys have been initialized. This wallet will be closed'))
|
||||||
|
self.close()
|
||||||
|
|
||||||
def show_wallet_info(self):
|
def show_wallet_info(self):
|
||||||
dialog = WindowModalDialog(self, _("Wallet Information"))
|
dialog = WindowModalDialog(self, _("Wallet Information"))
|
||||||
|
@ -2425,10 +2435,14 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||||
grid.addWidget(QLabel(ks_type), 4, 1)
|
grid.addWidget(QLabel(ks_type), 4, 1)
|
||||||
# lightning
|
# lightning
|
||||||
if self.wallet.has_lightning():
|
if self.wallet.has_lightning():
|
||||||
lightning_b = None
|
lightning_b = QPushButton(_('Disable'))
|
||||||
|
lightning_b.clicked.connect(dialog.close)
|
||||||
|
lightning_b.clicked.connect(self.disable_lightning)
|
||||||
lightning_label = QLabel(_('Enabled'))
|
lightning_label = QLabel(_('Enabled'))
|
||||||
|
lightning_b.setDisabled(bool(self.wallet.lnworker.channels))
|
||||||
else:
|
else:
|
||||||
lightning_b = QPushButton(_('Enable'))
|
lightning_b = QPushButton(_('Enable'))
|
||||||
|
lightning_b.clicked.connect(dialog.close)
|
||||||
lightning_b.clicked.connect(self.enable_lightning)
|
lightning_b.clicked.connect(self.enable_lightning)
|
||||||
lightning_label = QLabel(_('Disabled'))
|
lightning_label = QLabel(_('Disabled'))
|
||||||
grid.addWidget(QLabel(_('Lightning')), 5, 0)
|
grid.addWidget(QLabel(_('Lightning')), 5, 0)
|
||||||
|
|
|
@ -260,6 +260,15 @@ class Abstract_Wallet(AddressSynchronizer):
|
||||||
node = BIP32Node.from_rootseed(seed, xtype='standard')
|
node = BIP32Node.from_rootseed(seed, xtype='standard')
|
||||||
ln_xprv = node.to_xprv()
|
ln_xprv = node.to_xprv()
|
||||||
self.storage.put('lightning_privkey2', ln_xprv)
|
self.storage.put('lightning_privkey2', ln_xprv)
|
||||||
|
self.storage.write()
|
||||||
|
|
||||||
|
def remove_lightning(self):
|
||||||
|
if not self.storage.get('lightning_privkey2'):
|
||||||
|
return
|
||||||
|
if bool(self.lnworker.channels):
|
||||||
|
raise Exception('Error: This wallet has channels')
|
||||||
|
self.storage.put('lightning_privkey2', None)
|
||||||
|
self.storage.write()
|
||||||
|
|
||||||
def stop_threads(self):
|
def stop_threads(self):
|
||||||
super().stop_threads()
|
super().stop_threads()
|
||||||
|
|
Loading…
Add table
Reference in a new issue