Browse Source

qml: skip wallet password entry when single_password and password is known

patch-4
Sander van Grieken 3 years ago
parent
commit
63fed38305
  1. 22
      electrum/gui/qml/components/NewWalletWizard.qml
  2. 10
      electrum/gui/qml/qedaemon.py
  3. 8
      electrum/gui/qml/qewalletdb.py

22
electrum/gui/qml/components/NewWalletWizard.qml

@ -44,6 +44,8 @@ Wizard {
case 'haveseed':
page = _loadNextComponent(components.haveseed, wizard_data)
page.next.connect(function() {haveseedDone()})
if (wizard_data['seed_type'] != 'bip39' && Daemon.singlePassword)
page.last = true
break
// case 'masterkey'
// case 'hardware'
@ -53,13 +55,15 @@ Wizard {
function createseedDone(d) {
console.log('create seed done')
var page = _loadNextComponent(components.confirmseed, wizard_data)
page.next.connect(function() {confirmseedDone()})
if (Daemon.singlePassword)
page.last = true
else
page.next.connect(function() {confirmseedDone()})
}
function confirmseedDone(d) {
console.log('confirm seed done')
var page = _loadNextComponent(components.walletpassword, wizard_data)
page.next.connect(function() {walletpasswordDone()})
page.last = true
}
@ -67,10 +71,12 @@ Wizard {
console.log('have seed done')
if (wizard_data['seed_type'] == 'bip39') {
var page = _loadNextComponent(components.bip39refine, wizard_data)
page.next.connect(function() {bip39refineDone()})
if (Daemon.singlePassword)
page.last = true
else
page.next.connect(function() {bip39refineDone()})
} else {
var page = _loadNextComponent(components.walletpassword, wizard_data)
page.next.connect(function() {walletpasswordDone()})
page.last = true
}
}
@ -78,15 +84,9 @@ Wizard {
function bip39refineDone(d) {
console.log('bip39 refine done')
var page = _loadNextComponent(components.walletpassword, wizard_data)
page.next.connect(function() {walletpasswordDone()})
page.last = true
}
function walletpasswordDone(d) {
console.log('walletpassword done')
var page = _loadNextComponent(components.walletpassword, wizard_data)
}
WizardComponents {
id: components
}
@ -99,7 +99,7 @@ Wizard {
onAccepted: {
console.log('Finished new wallet wizard')
walletdb.create_storage(wizard_data)
walletdb.create_storage(wizard_data, Daemon.singlePasswordEnabled, Daemon.singlePassword)
}
WalletDB {

10
electrum/gui/qml/qedaemon.py

@ -155,6 +155,7 @@ class QEDaemon(AuthMixin, QObject):
if self.daemon.config.get('single_password'):
self._use_single_password = self.daemon.update_password_for_directory(old_password=password, new_password=password)
self._password = password
self.singlePasswordChanged.emit()
self._logger.info(f'use single password: {self._use_single_password}')
else:
self._logger.info('use single password disabled by config')
@ -203,6 +204,15 @@ class QEDaemon(AuthMixin, QObject):
def fx(self):
return self.qefx
singlePasswordChanged = pyqtSignal()
@pyqtProperty(bool, notify=singlePasswordChanged)
def singlePasswordEnabled(self):
return self._use_single_password
@pyqtProperty(str, notify=singlePasswordChanged)
def singlePassword(self):
return self._password
@pyqtSlot(result=str)
def suggestWalletName(self):
i = 1

8
electrum/gui/qml/qewalletdb.py

@ -172,12 +172,16 @@ class QEWalletDB(QObject):
self._ready = True
self.readyChanged.emit()
@pyqtSlot('QJSValue')
def create_storage(self, js_data):
@pyqtSlot('QJSValue',bool,str)
def create_storage(self, js_data, single_password_enabled, single_password):
self._logger.info('Creating wallet from wizard data')
data = js_data.toVariant()
self._logger.debug(str(data))
if single_password_enabled and single_password:
data['encrypt'] = True
data['password'] = single_password
try:
path = os.path.join(os.path.dirname(self.daemon.config.get_wallet_path()), data['wallet_name'])
if os.path.exists(path):

Loading…
Cancel
Save