1
0

wizard: add keepkey to new wizard

This commit is contained in:
Sander van Grieken
2023-08-23 12:30:20 +02:00
parent 48fb4911a3
commit d70831392d
8 changed files with 52 additions and 7 deletions

View File

@@ -731,7 +731,7 @@ class BitBox02Plugin(HW_PluginBase):
else:
return 'bitbox02_unlock'
# insert trezor pages in new wallet wizard
# insert bitbox02 pages in new wallet wizard
def extend_wizard(self, wizard: 'NewWalletWizard'):
views = {
'bitbox02_start': {

View File

@@ -73,7 +73,7 @@ class Plugin(BitBox02Plugin, QtPluginBase):
def init_wallet_wizard(self, wizard: 'QENewWalletWizard'):
self.extend_wizard(wizard)
# insert trezor pages in new wallet wizard
# insert bitbox02 pages in new wallet wizard
def extend_wizard(self, wizard: 'QENewWalletWizard'):
super().extend_wizard(wizard)
views = {

View File

@@ -780,7 +780,7 @@ class DigitalBitboxPlugin(HW_PluginBase):
else:
return 'dbitbox_unlock'
# insert trezor pages in new wallet wizard
# insert digitalbitbox pages in new wallet wizard
def extend_wizard(self, wizard: 'NewWalletWizard'):
views = {
'dbitbox_start': {

View File

@@ -47,7 +47,7 @@ class Plugin(DigitalBitboxPlugin, QtPluginBase):
def init_wallet_wizard(self, wizard: 'QENewWalletWizard'):
self.extend_wizard(wizard)
# insert trezor pages in new wallet wizard
# insert digitalbitbox pages in new wallet wizard
def extend_wizard(self, wizard: 'QENewWalletWizard'):
super().extend_wizard(wizard)
views = {

View File

@@ -488,7 +488,7 @@ class JadePlugin(HW_PluginBase):
else:
return 'jade_unlock'
# insert trezor pages in new wallet wizard
# insert jade pages in new wallet wizard
def extend_wizard(self, wizard: 'NewWalletWizard'):
views = {
'jade_start': {

View File

@@ -39,7 +39,7 @@ class Plugin(JadePlugin, QtPluginBase):
def init_wallet_wizard(self, wizard: 'QENewWalletWizard'):
self.extend_wizard(wizard)
# insert trezor pages in new wallet wizard
# insert jade pages in new wallet wizard
def extend_wizard(self, wizard: 'QENewWalletWizard'):
super().extend_wizard(wizard)
views = {

View File

@@ -488,3 +488,29 @@ class KeepKeyPlugin(HW_PluginBase):
def get_tx(self, tx_hash):
tx = self.prev_tx[tx_hash]
return self.electrum_tx_to_txtype(tx)
# new wizard
def wizard_entry_for_device(self, device_info: 'DeviceInfo', *, new_wallet=True) -> str:
if new_wallet:
return 'keepkey_start' if device_info.initialized else 'keepkey_not_initialized'
else:
return 'keepkey_unlock'
# insert keepkey pages in new wallet wizard
def extend_wizard(self, wizard: 'NewWalletWizard'):
views = {
'keepkey_start': {
'next': 'keepkey_xpub',
},
'keepkey_xpub': {
'next': lambda d: wizard.wallet_password_view(d) if wizard.last_cosigner(d) else 'multisig_cosigner_keystore',
'accept': wizard.maybe_master_pubkey,
'last': lambda d: wizard.is_single_password() and wizard.last_cosigner(d)
},
'keepkey_not_initialized': {},
'keepkey_unlock': {
'last': True
},
}
wizard.navmap_merge(views)

View File

@@ -1,5 +1,5 @@
from functools import partial
import threading
from typing import TYPE_CHECKING
from PyQt5.QtCore import Qt, QEventLoop, pyqtSignal, QRegExp
from PyQt5.QtGui import QRegExpValidator
@@ -17,6 +17,10 @@ from ..hw_wallet.qt import QtHandlerBase, QtPluginBase
from ..hw_wallet.plugin import only_hook_if_libraries_available
from .keepkey import KeepKeyPlugin, TIM_NEW, TIM_RECOVER, TIM_MNEMONIC
from electrum.gui.qt.wizard.wallet import WCScriptAndDerivation, WCHWUninitialized, WCHWUnlock, WCHWXPub
if TYPE_CHECKING:
from electrum.gui.qt.wizard.wallet import QENewWalletWizard
PASSPHRASE_HELP_SHORT =_(
"Passphrases allow you to access new wallets, each "
@@ -310,6 +314,21 @@ class Plugin(KeepKeyPlugin, QtPlugin):
from keepkeylib.qt.pinmatrix import PinMatrixWidget
return PinMatrixWidget
@hook
def init_wallet_wizard(self, wizard: 'QENewWalletWizard'):
self.extend_wizard(wizard)
# insert keepkey pages in new wallet wizard
def extend_wizard(self, wizard: 'QENewWalletWizard'):
super().extend_wizard(wizard)
views = {
'keepkey_start': {'gui': WCScriptAndDerivation},
'keepkey_xpub': {'gui': WCHWXPub},
'keepkey_not_initialized': {'gui': WCHWUninitialized},
'keepkey_unlock': {'gui': WCHWUnlock}
}
wizard.navmap_merge(views)
class SettingsDialog(WindowModalDialog):
'''This dialog doesn't require a device be paired with a wallet.