Skip to content

Commit

Permalink
kivy: disable wallet creation without password if single_password is set
Browse files Browse the repository at this point in the history
  • Loading branch information
ecdsa committed Jan 12, 2021
1 parent ab4be21 commit e53d7d3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion electrum/gui/kivy/main_window.py
Expand Up @@ -736,10 +736,13 @@ def on_channels(self, evt, wallet):
if self._channels_dialog:
Clock.schedule_once(lambda dt: self._channels_dialog.update())

def is_wallet_creation_disabled(self):
return bool(self.electrum_config.get('single_password')) and self.password is None

def wallets_dialog(self):
from .uix.dialogs.wallets import WalletDialog
dirname = os.path.dirname(self.electrum_config.get_wallet_path())
d = WalletDialog(dirname, self.load_wallet_by_name)
d = WalletDialog(dirname, self.load_wallet_by_name, self.is_wallet_creation_disabled())
d.open()

def popup_dialog(self, name):
Expand Down
2 changes: 1 addition & 1 deletion electrum/gui/kivy/uix/dialogs/password_dialog.py
Expand Up @@ -336,7 +336,7 @@ def __init__(self, app, path, callback):

def select_file(self):
dirname = os.path.dirname(self.app.electrum_config.get_wallet_path())
d = WalletDialog(dirname, self.init_storage_from_path)
d = WalletDialog(dirname, self.init_storage_from_path, self.app.is_wallet_creation_disabled())
d.open()

def init_storage_from_path(self, path):
Expand Down
8 changes: 6 additions & 2 deletions electrum/gui/kivy/uix/dialogs/wallets.py
Expand Up @@ -16,6 +16,7 @@
title: _('Wallets')
id: popup
path: ''
disable_new: True
BoxLayout:
orientation: 'vertical'
padding: '10dp'
Expand All @@ -33,7 +34,8 @@
cols: 3
size_hint_y: 0.1
Button:
id: open_button
id: new_button
disabled: root.disable_new
size_hint: 0.1, None
height: '48dp'
text: _('New')
Expand All @@ -53,12 +55,14 @@

class WalletDialog(Factory.Popup):

def __init__(self, path, callback):
def __init__(self, path, callback, disable_new):
Factory.Popup.__init__(self)
self.path = path
self.callback = callback
self.disable_new = disable_new

def new_wallet(self, dirname):
assert self.disable_new is False
def cb(filename):
if not filename:
return
Expand Down

0 comments on commit e53d7d3

Please sign in to comment.