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.plugin import run_hook
|
||||||
from electrum.i18n import _
|
from electrum.i18n import _
|
||||||
from electrum.wallet import Multisig_Wallet
|
from electrum.wallet import Multisig_Wallet
|
||||||
|
from electrum.wizard import WizardViewState
|
||||||
|
|
||||||
from .main_window import protected
|
from .main_window import protected
|
||||||
from electrum.gui.qt.wizard.wallet import QEKeystoreWizard
|
from electrum.gui.qt.wizard.wallet import QEKeystoreWizard
|
||||||
@@ -192,7 +193,9 @@ class WalletInfoDialog(WindowModalDialog):
|
|||||||
self.window.gui_object.reload_windows()
|
self.window.gui_object.reload_windows()
|
||||||
|
|
||||||
def enable_keystore(self, b: bool):
|
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()
|
result = dialog.run()
|
||||||
if not result:
|
if not result:
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ from .wizard import QEAbstractWizard, WizardComponent
|
|||||||
from electrum.logging import get_logger, Logger
|
from electrum.logging import get_logger, Logger
|
||||||
from electrum import WalletStorage, mnemonic, keystore
|
from electrum import WalletStorage, mnemonic, keystore
|
||||||
from electrum.wallet_db import WalletDB
|
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.bip39_recovery_dialog import Bip39RecoveryDialog
|
||||||
from electrum.gui.qt.password_dialog import PasswordLayout, PW_NEW, MSG_ENTER_PASSWORD, PasswordLayoutForHW
|
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):
|
class QEKeystoreWizard(KeystoreWizard, QEAbstractWizard, MessageBoxMixin):
|
||||||
_logger = get_logger(__name__)
|
_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)
|
QEAbstractWizard.__init__(self, config, app, start_viewstate=start_viewstate)
|
||||||
KeystoreWizard.__init__(self, plugins)
|
KeystoreWizard.__init__(self, plugins)
|
||||||
self._wallet_type = wallet_type
|
|
||||||
self.window_title = _('Extend wallet keystore')
|
self.window_title = _('Extend wallet keystore')
|
||||||
# attach gui classes to views
|
# attach gui classes to views
|
||||||
self.navmap_merge({
|
self.navmap_merge({
|
||||||
@@ -417,9 +425,7 @@ class WCKeystoreType(WalletWizardComponent):
|
|||||||
self.wizard_data['keystore_type'] = self.choice_w.selected_key
|
self.wizard_data['keystore_type'] = self.choice_w.selected_key
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class WCExtendKeystore(WalletWizardComponent):
|
class WCExtendKeystore(WalletWizardComponent):
|
||||||
|
|
||||||
def __init__(self, parent, wizard):
|
def __init__(self, parent, wizard):
|
||||||
WalletWizardComponent.__init__(self, parent, wizard, title=_('Keystore'))
|
WalletWizardComponent.__init__(self, parent, wizard, title=_('Keystore'))
|
||||||
message = _('What type of signing method do you want to add?')
|
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().addWidget(self.choice_w)
|
||||||
self.layout().addStretch(1)
|
self.layout().addStretch(1)
|
||||||
self._valid = True
|
self._valid = True
|
||||||
self.wizard_data['wallet_type'] = self._wallet_type = wizard._wallet_type
|
|
||||||
|
|
||||||
def apply(self):
|
def apply(self):
|
||||||
self.wizard_data['wallet_type'] = self._wallet_type
|
|
||||||
self.wizard_data['keystore_type'] = self.choice_w.selected_key
|
self.wizard_data['keystore_type'] = self.choice_w.selected_key
|
||||||
if multisig_type(self._wallet_type):
|
if multisig_type(self.wizard_data['wallet_type']):
|
||||||
self.wizard_data['wallet_type'] = self._wallet_type = 'multisig'
|
|
||||||
self.wizard_data['multisig_participants'] = 2
|
self.wizard_data['multisig_participants'] = 2
|
||||||
self.wizard_data['multisig_signatures'] = 2
|
self.wizard_data['multisig_signatures'] = 2
|
||||||
self.wizard_data['multisig_cosigner_data'] = {}
|
self.wizard_data['multisig_cosigner_data'] = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user