commit eba3fa03ee2ac70a6cf2516bf5b9aa6452547304
parent 1ac41b33a21fa04c7a6b8457a3a5460f65b66340
Author: SomberNight <somber.night@protonmail.com>
Date: Fri, 15 May 2020 19:11:31 +0200
kivy: confirm all actions even if there is no PIN set
eh.. I've just consolidated hundreds of testnet UTXOs by accident
Diffstat:
5 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/electrum/gui/kivy/main_window.py b/electrum/gui/kivy/main_window.py
@@ -1153,14 +1153,21 @@ class ElectrumWindow(App):
def protected(self, msg, f, args):
if self.electrum_config.get('pin_code'):
- on_success = lambda pw: f(*(args + (self.password,)))
+ msg += "\n" + _("Enter your PIN code to proceed")
+ on_success = lambda pw: f(*args, self.password)
self.pincode_dialog(
message = msg,
check_password=self.check_pin_code,
on_success=on_success,
on_failure=lambda: None)
else:
- f(*(args + (self.password,)))
+ d = Question(
+ msg,
+ lambda b: f(*args, self.password) if b else None,
+ yes_str=_("OK"),
+ no_str=_("Cancel"),
+ title=_("Confirm action"))
+ d.open()
def toggle_lightning(self):
if self.wallet.has_lightning():
@@ -1202,7 +1209,8 @@ class ElectrumWindow(App):
def _delete_wallet(self, b):
if b:
basename = self.wallet.basename()
- self.protected(_("Enter your PIN code to confirm deletion of {}").format(basename), self.__delete_wallet, ())
+ self.protected(_("Are you sure you want to delete wallet {}?").format(basename),
+ self.__delete_wallet, ())
def __delete_wallet(self, pw):
wallet_path = self.get_wallet_path()
@@ -1220,7 +1228,7 @@ class ElectrumWindow(App):
self.load_wallet_by_name(new_path)
def show_seed(self, label):
- self.protected(_("Enter PIN code to display your seed"), self._show_seed, (label,))
+ self.protected(_("Display your seed?"), self._show_seed, (label,))
def _show_seed(self, label, password):
if self.wallet.has_password() and password is None:
@@ -1316,7 +1324,7 @@ class ElectrumWindow(App):
except InvalidPassword:
self.show_error("Invalid PIN")
return
- self.protected(_("Enter your PIN code in order to decrypt your private key"), show_private_key, (addr, pk_label))
+ self.protected(_("Decrypt your private key?"), show_private_key, (addr, pk_label))
def import_channel_backup(self, encrypted):
d = Question(_('Import Channel Backup?'), lambda b: self._import_channel_backup(b, encrypted))
diff --git a/electrum/gui/kivy/uix/dialogs/lightning_open_channel.py b/electrum/gui/kivy/uix/dialogs/lightning_open_channel.py
@@ -146,7 +146,7 @@ class LightningOpenChannelDialog(Factory.Popup):
if self.ipport:
conn_str += '@' + self.ipport.strip()
amount = self.app.get_amount(self.amount)
- self.app.protected('Enter PIN to create a new channel', self.do_open_channel, (conn_str, amount))
+ self.app.protected('Create a new channel?', self.do_open_channel, (conn_str, amount))
self.dismiss()
def do_open_channel(self, conn_str, amount, password):
diff --git a/electrum/gui/kivy/uix/dialogs/question.py b/electrum/gui/kivy/uix/dialogs/question.py
@@ -13,6 +13,8 @@ Builder.load_string('''
id: popup
title: ''
message: ''
+ yes_str: ''
+ no_str: ''
size_hint: 0.8, 0.5
pos_hint: {'top':0.9}
BoxLayout:
@@ -27,14 +29,14 @@ Builder.load_string('''
orientation: 'horizontal'
size_hint: 1, 0.2
Button:
- text: _('No')
+ text: root.no_str
size_hint: 0.5, None
height: '48dp'
on_release:
root.callback(False)
popup.dismiss()
Button:
- text: _('Yes')
+ text: root.yes_str
size_hint: 0.5, None
height: '48dp'
on_release:
@@ -46,8 +48,12 @@ Builder.load_string('''
class Question(Factory.Popup):
- def __init__(self, msg, callback):
+ def __init__(self, msg, callback, *,
+ yes_str: str = None, no_str: str = None,
+ title: str = None):
Factory.Popup.__init__(self)
- self.title = _('Question')
+ self.yes_str = yes_str or _('Yes')
+ self.no_str = no_str or _('No')
+ self.title = title or _('Question')
self.message = msg
self.callback = callback
diff --git a/electrum/gui/kivy/uix/dialogs/tx_dialog.py b/electrum/gui/kivy/uix/dialogs/tx_dialog.py
@@ -253,7 +253,7 @@ class TxDialog(Factory.Popup):
self.do_sign()
def do_sign(self):
- self.app.protected(_("Enter your PIN code in order to sign this transaction"), self._do_sign, ())
+ self.app.protected(_("Sign this transaction?"), self._do_sign, ())
def _do_sign(self, password):
self.status_str = _('Signing') + '...'
diff --git a/electrum/gui/kivy/uix/screens.py b/electrum/gui/kivy/uix/screens.py
@@ -374,7 +374,6 @@ class SendScreen(CScreen):
feerate_warning = simple_config.FEERATE_WARNING_HIGH_FEE
if fee > feerate_warning * tx.estimated_size() / 1000:
msg.append(_('Warning') + ': ' + _("The fee for this transaction seems unusually high."))
- msg.append(_("Enter your PIN code to proceed"))
self.app.protected('\n'.join(msg), self.send_tx, (tx,))
def send_tx(self, tx, password):