qt: wizard: pass wallet_type to Keystore wizard via initial viewstate
This commit is contained in:
@@ -14,6 +14,7 @@ from PyQt6.QtWidgets import (
|
||||
from electrum.plugin import run_hook
|
||||
from electrum.i18n import _
|
||||
from electrum.wallet import Multisig_Wallet
|
||||
from electrum.wizard import WizardViewState
|
||||
|
||||
from .main_window import protected
|
||||
from electrum.gui.qt.wizard.wallet import QEKeystoreWizard
|
||||
@@ -192,7 +193,9 @@ class WalletInfoDialog(WindowModalDialog):
|
||||
self.window.gui_object.reload_windows()
|
||||
|
||||
def enable_keystore(self, b: bool):
|
||||
dialog = QEKeystoreWizard(self.window.config, self.window.wallet.wallet_type, self.window.gui_object.app, self.window.gui_object.plugins)
|
||||
v = WizardViewState('keystore_type', {'wallet_type': self.window.wallet.wallet_type}, {})
|
||||
dialog = QEKeystoreWizard(config=self.window.config, app=self.window.gui_object.app,
|
||||
plugins=self.window.gui_object.plugins, start_viewstate=v)
|
||||
result = dialog.run()
|
||||
if not result:
|
||||
return
|
||||
|
||||
@@ -23,7 +23,7 @@ from .wizard import QEAbstractWizard, WizardComponent
|
||||
from electrum.logging import get_logger, Logger
|
||||
from electrum import WalletStorage, mnemonic, keystore
|
||||
from electrum.wallet_db import WalletDB
|
||||
from electrum.wizard import NewWalletWizard, KeystoreWizard
|
||||
from electrum.wizard import NewWalletWizard, KeystoreWizard, WizardViewState
|
||||
|
||||
from electrum.gui.qt.bip39_recovery_dialog import Bip39RecoveryDialog
|
||||
from electrum.gui.qt.password_dialog import PasswordLayout, PW_NEW, MSG_ENTER_PASSWORD, PasswordLayoutForHW
|
||||
@@ -51,10 +51,18 @@ MSG_HW_STORAGE_ENCRYPTION = _("Set wallet file encryption.") + '\n'\
|
||||
class QEKeystoreWizard(KeystoreWizard, QEAbstractWizard, MessageBoxMixin):
|
||||
_logger = get_logger(__name__)
|
||||
|
||||
def __init__(self, config: 'SimpleConfig', wallet_type: str, app: 'QElectrumApplication', plugins: 'Plugins', *, start_viewstate=None):
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
config: 'SimpleConfig',
|
||||
app: 'QElectrumApplication',
|
||||
plugins: 'Plugins',
|
||||
start_viewstate: WizardViewState = None
|
||||
):
|
||||
assert 'wallet_type' in start_viewstate.wizard_data, 'wallet_type required'
|
||||
|
||||
QEAbstractWizard.__init__(self, config, app, start_viewstate=start_viewstate)
|
||||
KeystoreWizard.__init__(self, plugins)
|
||||
self._wallet_type = wallet_type
|
||||
self.window_title = _('Extend wallet keystore')
|
||||
# attach gui classes to views
|
||||
self.navmap_merge({
|
||||
@@ -417,9 +425,7 @@ class WCKeystoreType(WalletWizardComponent):
|
||||
self.wizard_data['keystore_type'] = self.choice_w.selected_key
|
||||
|
||||
|
||||
|
||||
class WCExtendKeystore(WalletWizardComponent):
|
||||
|
||||
def __init__(self, parent, wizard):
|
||||
WalletWizardComponent.__init__(self, parent, wizard, title=_('Keystore'))
|
||||
message = _('What type of signing method do you want to add?')
|
||||
@@ -431,13 +437,10 @@ class WCExtendKeystore(WalletWizardComponent):
|
||||
self.layout().addWidget(self.choice_w)
|
||||
self.layout().addStretch(1)
|
||||
self._valid = True
|
||||
self.wizard_data['wallet_type'] = self._wallet_type = wizard._wallet_type
|
||||
|
||||
def apply(self):
|
||||
self.wizard_data['wallet_type'] = self._wallet_type
|
||||
self.wizard_data['keystore_type'] = self.choice_w.selected_key
|
||||
if multisig_type(self._wallet_type):
|
||||
self.wizard_data['wallet_type'] = self._wallet_type = 'multisig'
|
||||
if multisig_type(self.wizard_data['wallet_type']):
|
||||
self.wizard_data['multisig_participants'] = 2
|
||||
self.wizard_data['multisig_signatures'] = 2
|
||||
self.wizard_data['multisig_cosigner_data'] = {}
|
||||
|
||||
Reference in New Issue
Block a user