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