kivy: toggle lightning dialog
This commit is contained in:
@@ -42,6 +42,7 @@ from .uix.dialogs.installwizard import InstallWizard
|
|||||||
from .uix.dialogs import InfoBubble, crash_reporter
|
from .uix.dialogs import InfoBubble, crash_reporter
|
||||||
from .uix.dialogs import OutputList, OutputItem
|
from .uix.dialogs import OutputList, OutputItem
|
||||||
from .uix.dialogs import TopLabel, RefLabel
|
from .uix.dialogs import TopLabel, RefLabel
|
||||||
|
from .uix.dialogs.question import Question
|
||||||
|
|
||||||
#from kivy.core.window import Window
|
#from kivy.core.window import Window
|
||||||
#Window.softinput_mode = 'below_target'
|
#Window.softinput_mode = 'below_target'
|
||||||
@@ -613,7 +614,6 @@ class ElectrumWindow(App):
|
|||||||
if not ask_if_wizard:
|
if not ask_if_wizard:
|
||||||
launch_wizard()
|
launch_wizard()
|
||||||
else:
|
else:
|
||||||
from .uix.dialogs.question import Question
|
|
||||||
def handle_answer(b: bool):
|
def handle_answer(b: bool):
|
||||||
if b:
|
if b:
|
||||||
launch_wizard()
|
launch_wizard()
|
||||||
@@ -676,6 +676,9 @@ class ElectrumWindow(App):
|
|||||||
d.open()
|
d.open()
|
||||||
|
|
||||||
def lightning_channels_dialog(self):
|
def lightning_channels_dialog(self):
|
||||||
|
if not self.wallet.has_lightning():
|
||||||
|
self.show_error('Lightning not enabled on this wallet')
|
||||||
|
return
|
||||||
if self._channels_dialog is None:
|
if self._channels_dialog is None:
|
||||||
self._channels_dialog = LightningChannelsDialog(self)
|
self._channels_dialog = LightningChannelsDialog(self)
|
||||||
self._channels_dialog.open()
|
self._channels_dialog.open()
|
||||||
@@ -1073,8 +1076,39 @@ class ElectrumWindow(App):
|
|||||||
else:
|
else:
|
||||||
f(*(args + (None,)))
|
f(*(args + (None,)))
|
||||||
|
|
||||||
|
def toggle_lightning(self):
|
||||||
|
if self.wallet.has_lightning():
|
||||||
|
if not bool(self.wallet.lnworker.channels):
|
||||||
|
warning = _('This will delete your lightning private keys')
|
||||||
|
d = Question(_('Disable Lightning?') + '\n\n' + warning, self._disable_lightning)
|
||||||
|
d.open()
|
||||||
|
else:
|
||||||
|
self.show_info('This wallet has channels')
|
||||||
|
else:
|
||||||
|
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.")
|
||||||
|
d = Question(_('Enable Lightning?') + '\n\n' + warning1 + '\n\n' + warning2, self._enable_lightning)
|
||||||
|
d.open()
|
||||||
|
|
||||||
|
def _enable_lightning(self, b):
|
||||||
|
if not b:
|
||||||
|
return
|
||||||
|
wallet_path = self.get_wallet_path()
|
||||||
|
self.wallet.init_lightning()
|
||||||
|
self.show_info(_('Lightning keys have been initialized.'))
|
||||||
|
self.stop_wallet()
|
||||||
|
self.load_wallet_by_name(wallet_path)
|
||||||
|
|
||||||
|
def _disable_lightning(self, b):
|
||||||
|
if not b:
|
||||||
|
return
|
||||||
|
wallet_path = self.get_wallet_path()
|
||||||
|
self.wallet.remove_lightning()
|
||||||
|
self.show_info(_('Lightning keys have been removed.'))
|
||||||
|
self.stop_wallet()
|
||||||
|
self.load_wallet_by_name(wallet_path)
|
||||||
|
|
||||||
def delete_wallet(self):
|
def delete_wallet(self):
|
||||||
from .uix.dialogs.question import Question
|
|
||||||
basename = os.path.basename(self.wallet.storage.path)
|
basename = os.path.basename(self.wallet.storage.path)
|
||||||
d = Question(_('Delete wallet?') + '\n' + basename, self._delete_wallet)
|
d = Question(_('Delete wallet?') + '\n' + basename, self._delete_wallet)
|
||||||
d.open()
|
d.open()
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ Popup:
|
|||||||
BoxLabel:
|
BoxLabel:
|
||||||
text: _("Wallet type:")
|
text: _("Wallet type:")
|
||||||
value: app.wallet.wallet_type
|
value: app.wallet.wallet_type
|
||||||
|
BoxLabel:
|
||||||
|
text: _("Lightning:")
|
||||||
|
value: _('Enabled') if app.wallet.has_lightning() else _('Disabled')
|
||||||
BoxLabel:
|
BoxLabel:
|
||||||
text: _("Balance") + ':'
|
text: _("Balance") + ':'
|
||||||
value: app.format_amount_and_units(root.confirmed + root.unconfirmed + root.unmatured)
|
value: app.format_amount_and_units(root.confirmed + root.unconfirmed + root.unmatured)
|
||||||
@@ -77,6 +80,13 @@ Popup:
|
|||||||
on_release:
|
on_release:
|
||||||
root.dismiss()
|
root.dismiss()
|
||||||
app.delete_wallet()
|
app.delete_wallet()
|
||||||
|
Button:
|
||||||
|
size_hint: 0.5, None
|
||||||
|
height: '48dp'
|
||||||
|
text: _('Disable LN') if app.wallet.has_lightning() else _('Enable LN')
|
||||||
|
on_release:
|
||||||
|
root.dismiss()
|
||||||
|
app.toggle_lightning()
|
||||||
Button:
|
Button:
|
||||||
size_hint: 0.5, None
|
size_hint: 0.5, None
|
||||||
height: '48dp'
|
height: '48dp'
|
||||||
|
|||||||
Reference in New Issue
Block a user