Browse Source

qml: properly set keystore password when creating new wallet

patch-4
Sander van Grieken 3 years ago
parent
commit
f83c944f0e
  1. 2
      electrum/gui/qml/qedaemon.py
  2. 6
      electrum/gui/qml/qewalletdb.py

2
electrum/gui/qml/qedaemon.py

@ -150,6 +150,8 @@ class QEDaemon(AuthMixin, QObject):
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._logger.info(f'use single password: {self._use_single_password}') self._logger.info(f'use single password: {self._use_single_password}')
else:
self._logger.info('use single password disabled by config')
self.daemon.config.save_last_wallet(wallet) self.daemon.config.save_last_wallet(wallet)
else: else:

6
electrum/gui/qml/qewalletdb.py

@ -198,8 +198,12 @@ class QEWalletDB(QObject):
derivation = normalize_bip32_derivation(data['derivation_path']) derivation = normalize_bip32_derivation(data['derivation_path'])
script = data['script_type'] if data['script_type'] != 'p2pkh' else 'standard' script = data['script_type'] if data['script_type'] != 'p2pkh' else 'standard'
k = keystore.from_bip43_rootseed(root_seed, derivation, xtype=script) k = keystore.from_bip43_rootseed(root_seed, derivation, xtype=script)
else:
raise Exception('unsupported/unknown seed_type %s' % data['seed_type'])
if data['encrypt']: if data['encrypt']:
if k.may_have_password():
k.update_password(None, data['password'])
storage.set_password(data['password'], enc_version=StorageEncryptionVersion.USER_PASSWORD) storage.set_password(data['password'], enc_version=StorageEncryptionVersion.USER_PASSWORD)
db = WalletDB('', manual_upgrades=False) db = WalletDB('', manual_upgrades=False)
@ -209,7 +213,7 @@ class QEWalletDB(QObject):
db.put('seed_type', data['seed_type']) db.put('seed_type', data['seed_type'])
db.put('keystore', k.dump()) db.put('keystore', k.dump())
if k.can_have_deterministic_lightning_xprv(): if k.can_have_deterministic_lightning_xprv():
db.put('lightning_xprv', k.get_lightning_xprv(None)) db.put('lightning_xprv', k.get_lightning_xprv(data['password'] if data['encrypt'] else None))
db.load_plugins() db.load_plugins()
db.write(storage) db.write(storage)

Loading…
Cancel
Save