qml: wip single password
This commit is contained in:
@@ -108,6 +108,7 @@ Pane {
|
||||
unlockButton.enabled = false
|
||||
_unlockClicked = true
|
||||
wallet_db.password = password.text
|
||||
wallet_db.verify()
|
||||
openwalletdialog.forceActiveFocus()
|
||||
}
|
||||
|
||||
@@ -132,6 +133,7 @@ Pane {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
wallet_db.verify()
|
||||
password.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import QtQuick.Layouts 1.0
|
||||
import QtQuick.Controls 2.1
|
||||
|
||||
WizardComponent {
|
||||
valid: password1.text === password2.text
|
||||
valid: password1.text === password2.text && password1.text.length > 4
|
||||
|
||||
onAccept: {
|
||||
wizard_data['password'] = password1.text
|
||||
|
||||
@@ -90,12 +90,14 @@ class QEConfig(AuthMixin, QObject):
|
||||
def pinCode(self, pin_code):
|
||||
if pin_code == '':
|
||||
self.pinCodeRemoveAuth()
|
||||
self.config.set_key('pin_code', pin_code, True)
|
||||
self.pinCodeChanged.emit()
|
||||
else:
|
||||
self.config.set_key('pin_code', pin_code, True)
|
||||
self.pinCodeChanged.emit()
|
||||
|
||||
@auth_protect(method='wallet')
|
||||
def pinCodeRemoveAuth(self):
|
||||
pass # no-op
|
||||
self.config.set_key('pin_code', '', True)
|
||||
self.pinCodeChanged.emit()
|
||||
|
||||
useGossipChanged = pyqtSignal()
|
||||
@pyqtProperty(bool, notify=useGossipChanged)
|
||||
|
||||
@@ -4,7 +4,7 @@ from decimal import Decimal
|
||||
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject, QUrl
|
||||
from PyQt5.QtCore import Qt, QAbstractListModel, QModelIndex
|
||||
|
||||
from electrum.util import register_callback, get_new_wallet_name, WalletFileException
|
||||
from electrum.util import register_callback, get_new_wallet_name, WalletFileException, standardize_path
|
||||
from electrum.logging import get_logger
|
||||
from electrum.wallet import Wallet, Abstract_Wallet
|
||||
from electrum.storage import WalletStorage, StorageReadWriteError
|
||||
@@ -130,12 +130,17 @@ class QEDaemon(AuthMixin, QObject):
|
||||
if self._path is None:
|
||||
return
|
||||
|
||||
self._path = standardize_path(self._path)
|
||||
self._logger.debug('load wallet ' + str(self._path))
|
||||
|
||||
if path not in self.daemon._wallets:
|
||||
if not password:
|
||||
password = self._password
|
||||
|
||||
if self._path not in self.daemon._wallets:
|
||||
# pre-checks, let walletdb trigger any necessary user interactions
|
||||
self._walletdb.path = self._path
|
||||
self._walletdb.password = password
|
||||
self._walletdb.verify()
|
||||
if not self._walletdb.ready:
|
||||
return
|
||||
|
||||
@@ -144,6 +149,7 @@ class QEDaemon(AuthMixin, QObject):
|
||||
if wallet != None:
|
||||
self._loaded_wallets.add_wallet(wallet=wallet)
|
||||
self._current_wallet = QEWallet.getInstanceFor(wallet)
|
||||
self._current_wallet.password = password
|
||||
self.walletLoaded.emit()
|
||||
|
||||
if self.daemon.config.get('single_password'):
|
||||
@@ -218,3 +224,5 @@ class QEDaemon(AuthMixin, QObject):
|
||||
assert self._use_single_password
|
||||
self._logger.debug('about to set password to %s for ALL wallets' % password)
|
||||
self.daemon.update_password_for_directory(old_password=self._password, new_password=password)
|
||||
self._password = password
|
||||
|
||||
|
||||
@@ -545,10 +545,10 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
||||
if storage.is_encrypted_with_hw_device():
|
||||
return
|
||||
|
||||
self._logger.debug('Ok to set password for wallet with path %s' % storage.path)
|
||||
if password:
|
||||
enc_version = StorageEncryptionVersion.USER_PASSWORD
|
||||
else:
|
||||
enc_version = StorageEncryptionVersion.PLAINTEXT
|
||||
storage.set_password(password, enc_version=enc_version)
|
||||
self.wallet.save_db()
|
||||
self._logger.debug(f'Ok to set password from {self.password} to {password} for wallet with path {storage.path}')
|
||||
|
||||
try:
|
||||
self.wallet.update_password(self.password, password, encrypt_storage=True)
|
||||
self.password = password
|
||||
except InvalidPassword as e:
|
||||
self._logger.exception(repr(e))
|
||||
|
||||
@@ -59,10 +59,6 @@ class QEWalletDB(QObject):
|
||||
self.reset()
|
||||
self._path = wallet_path
|
||||
|
||||
self.load_storage()
|
||||
if self._storage:
|
||||
self.load_db()
|
||||
|
||||
self.pathChanged.emit(self._ready)
|
||||
|
||||
@pyqtProperty(bool, notify=needsPasswordChanged)
|
||||
@@ -101,12 +97,6 @@ class QEWalletDB(QObject):
|
||||
self._password = wallet_password
|
||||
self.passwordChanged.emit()
|
||||
|
||||
self.load_storage()
|
||||
|
||||
if self._storage:
|
||||
self.needsPassword = False
|
||||
self.load_db()
|
||||
|
||||
@pyqtProperty(bool, notify=requiresSplitChanged)
|
||||
def requiresSplit(self):
|
||||
return self._requiresSplit
|
||||
@@ -125,6 +115,11 @@ class QEWalletDB(QObject):
|
||||
def ready(self):
|
||||
return self._ready
|
||||
|
||||
@pyqtSlot()
|
||||
def verify(self):
|
||||
self.load_storage()
|
||||
if self._storage:
|
||||
self.load_db()
|
||||
|
||||
@pyqtSlot()
|
||||
def doSplit(self):
|
||||
@@ -226,5 +221,3 @@ class QEWalletDB(QObject):
|
||||
except Exception as e:
|
||||
self._logger.error(str(e))
|
||||
self.createError.emit(str(e))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user