mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
ensure wallet file access, fix #4507
This commit is contained in:
parent
04432fe93e
commit
dba9eb9b3a
5 changed files with 22 additions and 1 deletions
|
@ -509,6 +509,9 @@ class ElectrumWindow(App):
|
||||||
return
|
return
|
||||||
wallet = self.daemon.load_wallet(path, None)
|
wallet = self.daemon.load_wallet(path, None)
|
||||||
if wallet:
|
if wallet:
|
||||||
|
if not wallet.storage.file_writable():
|
||||||
|
self.show_error(_("Wallet file not writable"))
|
||||||
|
return
|
||||||
if wallet.has_password():
|
if wallet.has_password():
|
||||||
self.password_dialog(wallet, _('Enter PIN code'), lambda x: self.load_wallet(wallet), self.stop)
|
self.password_dialog(wallet, _('Enter PIN code'), lambda x: self.load_wallet(wallet), self.stop)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -61,5 +61,9 @@ class WalletDialog(Factory.Popup):
|
||||||
d.open()
|
d.open()
|
||||||
|
|
||||||
def open_wallet(self, app):
|
def open_wallet(self, app):
|
||||||
app.load_wallet_by_name(self.ids.wallet_selector.selection[0])
|
path = self.ids.wallet_selector.selection[0]
|
||||||
|
if not os.access(path, os.W_OK) or not os.access(path, os.R_OK):
|
||||||
|
app.show_error(_("Wallet file not writable"))
|
||||||
|
return
|
||||||
|
app.load_wallet_by_name(path)
|
||||||
|
|
||||||
|
|
|
@ -204,6 +204,8 @@ class ElectrumGui:
|
||||||
opens the wallet and creates a new window for it'''
|
opens the wallet and creates a new window for it'''
|
||||||
try:
|
try:
|
||||||
wallet = self.daemon.load_wallet(path, None)
|
wallet = self.daemon.load_wallet(path, None)
|
||||||
|
if wallet and not wallet.storage.file_writable():
|
||||||
|
raise Exception(_("Wallet file not writable"))
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
traceback.print_exc(file=sys.stdout)
|
traceback.print_exc(file=sys.stdout)
|
||||||
d = QMessageBox(QMessageBox.Warning, _('Error'),
|
d = QMessageBox(QMessageBox.Warning, _('Error'),
|
||||||
|
|
|
@ -91,6 +91,9 @@ class BaseWizard(object):
|
||||||
self.run(action, *args)
|
self.run(action, *args)
|
||||||
|
|
||||||
def new(self):
|
def new(self):
|
||||||
|
if not self.storage.file_writable():
|
||||||
|
self.show_error(_("Wallet file not writable"))
|
||||||
|
return
|
||||||
name = os.path.basename(self.storage.path)
|
name = os.path.basename(self.storage.path)
|
||||||
title = _("Create") + ' ' + name
|
title = _("Create") + ' ' + name
|
||||||
message = '\n'.join([
|
message = '\n'.join([
|
||||||
|
|
|
@ -165,6 +165,15 @@ class WalletStorage(PrintError):
|
||||||
def file_exists(self):
|
def file_exists(self):
|
||||||
return self.path and os.path.exists(self.path)
|
return self.path and os.path.exists(self.path)
|
||||||
|
|
||||||
|
def file_writable(self):
|
||||||
|
if not self.file_exists():
|
||||||
|
if not os.access(os.path.dirname(self.path), os.W_OK):
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
if not os.access(self.path, os.W_OK):
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_eckey_from_password(password):
|
def get_eckey_from_password(password):
|
||||||
secret = pbkdf2.PBKDF2(password, '', iterations=1024, macmodule=hmac, digestmodule=hashlib.sha512).read(64)
|
secret = pbkdf2.PBKDF2(password, '', iterations=1024, macmodule=hmac, digestmodule=hashlib.sha512).read(64)
|
||||||
|
|
Loading…
Add table
Reference in a new issue