electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 99b83f7527d5ceb8771403d6714bba0f25cd3169
parent a42a773d19afe62fda08cbdedccbeabbfdf33ca1
Author: SomberNight <somber.night@protonmail.com>
Date:   Wed,  4 Sep 2019 13:53:38 +0200

fix #5617

Diffstat:
Melectrum/base_wizard.py | 27+++++++++++++++++++--------
Melectrum/plugins/trustedcoin/trustedcoin.py | 12+++++++++---
2 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/electrum/base_wizard.py b/electrum/base_wizard.py @@ -67,6 +67,13 @@ class WizardStackItem(NamedTuple): storage_data: dict +class WizardWalletPasswordSetting(NamedTuple): + password: Optional[str] + encrypt_storage: bool + storage_enc_version: StorageEncryptionVersion + encrypt_keystore: bool + + class BaseWizard(Logger): def __init__(self, config: SimpleConfig, plugins: Plugins): @@ -75,7 +82,7 @@ class BaseWizard(Logger): self.config = config self.plugins = plugins self.data = {} - self.pw_args = None + self.pw_args = None # type: Optional[WizardWalletPasswordSetting] self._stack = [] # type: List[WizardStackItem] self.plugin = None self.keystores = [] @@ -555,8 +562,9 @@ class BaseWizard(Logger): encrypt_keystore=encrypt_keystore), force_disable_encrypt_cb=not encrypt_keystore) - def on_password(self, password, *, encrypt_storage, - storage_enc_version=StorageEncryptionVersion.USER_PASSWORD, encrypt_keystore): + def on_password(self, password, *, encrypt_storage: bool, + storage_enc_version=StorageEncryptionVersion.USER_PASSWORD, + encrypt_keystore: bool): for k in self.keystores: if k.may_have_password(): k.update_password(None, password) @@ -573,7 +581,10 @@ class BaseWizard(Logger): self.data['keystore'] = keys else: raise Exception('Unknown wallet type') - self.pw_args = password, encrypt_storage, storage_enc_version + self.pw_args = WizardWalletPasswordSetting(password=password, + encrypt_storage=encrypt_storage, + storage_enc_version=storage_enc_version, + encrypt_keystore=encrypt_keystore) self.terminate() def create_storage(self, path): @@ -581,12 +592,12 @@ class BaseWizard(Logger): raise Exception('file already exists at path') if not self.pw_args: return - password, encrypt_storage, storage_enc_version = self.pw_args + pw_args = self.pw_args self.pw_args = None # clean-up so that it can get GC-ed storage = WalletStorage(path) - storage.set_keystore_encryption(bool(password)) - if encrypt_storage: - storage.set_password(password, enc_version=storage_enc_version) + storage.set_keystore_encryption(bool(pw_args.password) and pw_args.encrypt_keystore) + if pw_args.encrypt_storage: + storage.set_password(pw_args.password, enc_version=pw_args.storage_enc_version) for key, value in self.data.items(): storage.put(key, value) storage.write() diff --git a/electrum/plugins/trustedcoin/trustedcoin.py b/electrum/plugins/trustedcoin/trustedcoin.py @@ -47,7 +47,7 @@ from electrum.plugin import BasePlugin, hook from electrum.util import NotEnoughFunds, UserFacingException from electrum.storage import StorageEncryptionVersion from electrum.network import Network -from electrum.base_wizard import BaseWizard +from electrum.base_wizard import BaseWizard, WizardWalletPasswordSetting from electrum.logging import Logger @@ -594,7 +594,10 @@ class TrustedCoinPlugin(BasePlugin): k1.update_password(None, password) wizard.data['x1/'] = k1.dump() wizard.data['x2/'] = k2.dump() - wizard.pw_args = password, encrypt_storage, StorageEncryptionVersion.USER_PASSWORD + wizard.pw_args = WizardWalletPasswordSetting(password=password, + encrypt_storage=encrypt_storage, + storage_enc_version=StorageEncryptionVersion.USER_PASSWORD, + encrypt_keystore=bool(password)) self.go_online_dialog(wizard) def restore_wallet(self, wizard): @@ -642,7 +645,10 @@ class TrustedCoinPlugin(BasePlugin): xpub3 = make_xpub(get_signing_xpub(xtype), long_user_id) k3 = keystore.from_xpub(xpub3) wizard.data['x3/'] = k3.dump() - wizard.pw_args = password, encrypt_storage, StorageEncryptionVersion.USER_PASSWORD + wizard.pw_args = WizardWalletPasswordSetting(password=password, + encrypt_storage=encrypt_storage, + storage_enc_version=StorageEncryptionVersion.USER_PASSWORD, + encrypt_keystore=bool(password)) wizard.terminate() def create_remote_key(self, email, wizard):