Browse Source

kivy: confirm all actions even if there is no PIN set

eh.. I've just consolidated hundreds of testnet UTXOs by accident
master
SomberNight 5 years ago
parent
commit
eba3fa03ee
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 18
      electrum/gui/kivy/main_window.py
  2. 2
      electrum/gui/kivy/uix/dialogs/lightning_open_channel.py
  3. 14
      electrum/gui/kivy/uix/dialogs/question.py
  4. 2
      electrum/gui/kivy/uix/dialogs/tx_dialog.py
  5. 1
      electrum/gui/kivy/uix/screens.py

18
electrum/gui/kivy/main_window.py

@ -1153,14 +1153,21 @@ class ElectrumWindow(App):
def protected(self, msg, f, args): def protected(self, msg, f, args):
if self.electrum_config.get('pin_code'): 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( self.pincode_dialog(
message = msg, message = msg,
check_password=self.check_pin_code, check_password=self.check_pin_code,
on_success=on_success, on_success=on_success,
on_failure=lambda: None) on_failure=lambda: None)
else: 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): def toggle_lightning(self):
if self.wallet.has_lightning(): if self.wallet.has_lightning():
@ -1202,7 +1209,8 @@ class ElectrumWindow(App):
def _delete_wallet(self, b): def _delete_wallet(self, b):
if b: if b:
basename = self.wallet.basename() 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): def __delete_wallet(self, pw):
wallet_path = self.get_wallet_path() wallet_path = self.get_wallet_path()
@ -1220,7 +1228,7 @@ class ElectrumWindow(App):
self.load_wallet_by_name(new_path) self.load_wallet_by_name(new_path)
def show_seed(self, label): 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): def _show_seed(self, label, password):
if self.wallet.has_password() and password is None: if self.wallet.has_password() and password is None:
@ -1316,7 +1324,7 @@ class ElectrumWindow(App):
except InvalidPassword: except InvalidPassword:
self.show_error("Invalid PIN") self.show_error("Invalid PIN")
return 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): def import_channel_backup(self, encrypted):
d = Question(_('Import Channel Backup?'), lambda b: self._import_channel_backup(b, encrypted)) d = Question(_('Import Channel Backup?'), lambda b: self._import_channel_backup(b, encrypted))

2
electrum/gui/kivy/uix/dialogs/lightning_open_channel.py

@ -146,7 +146,7 @@ class LightningOpenChannelDialog(Factory.Popup):
if self.ipport: if self.ipport:
conn_str += '@' + self.ipport.strip() conn_str += '@' + self.ipport.strip()
amount = self.app.get_amount(self.amount) 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() self.dismiss()
def do_open_channel(self, conn_str, amount, password): def do_open_channel(self, conn_str, amount, password):

14
electrum/gui/kivy/uix/dialogs/question.py

@ -13,6 +13,8 @@ Builder.load_string('''
id: popup id: popup
title: '' title: ''
message: '' message: ''
yes_str: ''
no_str: ''
size_hint: 0.8, 0.5 size_hint: 0.8, 0.5
pos_hint: {'top':0.9} pos_hint: {'top':0.9}
BoxLayout: BoxLayout:
@ -27,14 +29,14 @@ Builder.load_string('''
orientation: 'horizontal' orientation: 'horizontal'
size_hint: 1, 0.2 size_hint: 1, 0.2
Button: Button:
text: _('No') text: root.no_str
size_hint: 0.5, None size_hint: 0.5, None
height: '48dp' height: '48dp'
on_release: on_release:
root.callback(False) root.callback(False)
popup.dismiss() popup.dismiss()
Button: Button:
text: _('Yes') text: root.yes_str
size_hint: 0.5, None size_hint: 0.5, None
height: '48dp' height: '48dp'
on_release: on_release:
@ -46,8 +48,12 @@ Builder.load_string('''
class Question(Factory.Popup): 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) 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.message = msg
self.callback = callback self.callback = callback

2
electrum/gui/kivy/uix/dialogs/tx_dialog.py

@ -253,7 +253,7 @@ class TxDialog(Factory.Popup):
self.do_sign() self.do_sign()
def do_sign(self): 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): def _do_sign(self, password):
self.status_str = _('Signing') + '...' self.status_str = _('Signing') + '...'

1
electrum/gui/kivy/uix/screens.py

@ -374,7 +374,6 @@ class SendScreen(CScreen):
feerate_warning = simple_config.FEERATE_WARNING_HIGH_FEE feerate_warning = simple_config.FEERATE_WARNING_HIGH_FEE
if fee > feerate_warning * tx.estimated_size() / 1000: if fee > feerate_warning * tx.estimated_size() / 1000:
msg.append(_('Warning') + ': ' + _("The fee for this transaction seems unusually high.")) 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,)) self.app.protected('\n'.join(msg), self.send_tx, (tx,))
def send_tx(self, tx, password): def send_tx(self, tx, password):

Loading…
Cancel
Save