electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit a13cea6f8ac47b37ad1740539072321e2418bf8c
parent db833e1ba351edbb71bdf4be5712a7792305302b
Author: ThomasV <thomasv@electrum.org>
Date:   Mon, 14 Oct 2019 11:18:57 +0200

add remove_lightning command

Diffstat:
Melectrum/commands.py | 5+++++
Melectrum/gui/qt/main_window.py | 18++++++++++++++++--
Melectrum/wallet.py | 9+++++++++
3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/electrum/commands.py b/electrum/commands.py @@ -629,6 +629,11 @@ class Commands: 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') async def lightning_history(self, show_fiat=False, wallet: Abstract_Wallet = None): """ lightning history """ lightning_history = wallet.lnworker.get_history() if wallet.lnworker else [] diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py @@ -2390,6 +2390,15 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): if d.exec_(): 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): 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.") @@ -2397,7 +2406,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): if not r: return 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): dialog = WindowModalDialog(self, _("Wallet Information")) @@ -2425,10 +2435,14 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): grid.addWidget(QLabel(ks_type), 4, 1) # 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_b.setDisabled(bool(self.wallet.lnworker.channels)) else: lightning_b = QPushButton(_('Enable')) + lightning_b.clicked.connect(dialog.close) lightning_b.clicked.connect(self.enable_lightning) lightning_label = QLabel(_('Disabled')) grid.addWidget(QLabel(_('Lightning')), 5, 0) diff --git a/electrum/wallet.py b/electrum/wallet.py @@ -260,6 +260,15 @@ class Abstract_Wallet(AddressSynchronizer): node = BIP32Node.from_rootseed(seed, xtype='standard') ln_xprv = node.to_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): super().stop_threads()