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

10
electrum/gui/qml/qedaemon.py

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

8
electrum/gui/qml/qewalletdb.py

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

Loading…
Cancel
Save