wizard: add coldcard
This commit is contained in:
@@ -612,6 +612,32 @@ class ColdcardPlugin(HW_PluginBase):
|
|||||||
keystore.handler.show_error(_('This function is only available for standard wallets when using {}.').format(self.device))
|
keystore.handler.show_error(_('This function is only available for standard wallets when using {}.').format(self.device))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# new wizard
|
||||||
|
|
||||||
|
def wizard_entry_for_device(self, device_info: 'DeviceInfo', *, new_wallet=True) -> str:
|
||||||
|
if new_wallet:
|
||||||
|
return 'coldcard_start' if device_info.initialized else 'coldcard_not_initialized'
|
||||||
|
else:
|
||||||
|
return 'coldcard_unlock'
|
||||||
|
|
||||||
|
# insert coldcard pages in new wallet wizard
|
||||||
|
def extend_wizard(self, wizard: 'NewWalletWizard'):
|
||||||
|
views = {
|
||||||
|
'coldcard_start': {
|
||||||
|
'next': 'coldcard_xpub',
|
||||||
|
},
|
||||||
|
'coldcard_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)
|
||||||
|
},
|
||||||
|
'coldcard_not_initialized': {},
|
||||||
|
'coldcard_unlock': {
|
||||||
|
'last': True
|
||||||
|
},
|
||||||
|
}
|
||||||
|
wizard.navmap_merge(views)
|
||||||
|
|
||||||
|
|
||||||
def xfp_int_from_xfp_bytes(fp_bytes: bytes) -> int:
|
def xfp_int_from_xfp_bytes(fp_bytes: bytes) -> int:
|
||||||
return int.from_bytes(fp_bytes, byteorder="little", signed=False)
|
return int.from_bytes(fp_bytes, byteorder="little", signed=False)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import time, os
|
import time, os
|
||||||
from functools import partial
|
from functools import partial
|
||||||
import copy
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt, pyqtSignal
|
from PyQt5.QtCore import Qt, pyqtSignal
|
||||||
from PyQt5.QtWidgets import QPushButton, QLabel, QVBoxLayout, QWidget, QGridLayout
|
from PyQt5.QtWidgets import QPushButton, QLabel, QVBoxLayout, QWidget, QGridLayout
|
||||||
@@ -18,10 +18,14 @@ from electrum.transaction import PartialTransaction
|
|||||||
from .coldcard import ColdcardPlugin, xfp2str
|
from .coldcard import ColdcardPlugin, xfp2str
|
||||||
from ..hw_wallet.qt import QtHandlerBase, QtPluginBase
|
from ..hw_wallet.qt import QtHandlerBase, QtPluginBase
|
||||||
from ..hw_wallet.plugin import only_hook_if_libraries_available
|
from ..hw_wallet.plugin import only_hook_if_libraries_available
|
||||||
|
from electrum.gui.qt.wizard.wallet import WCScriptAndDerivation, WCHWXPub, WCHWUninitialized, WCHWUnlock
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from electrum.gui.qt.wizard.wallet import QENewWalletWizard
|
||||||
|
|
||||||
CC_DEBUG = False
|
CC_DEBUG = False
|
||||||
|
|
||||||
|
|
||||||
class Plugin(ColdcardPlugin, QtPluginBase):
|
class Plugin(ColdcardPlugin, QtPluginBase):
|
||||||
icon_unpaired = "coldcard_unpaired.png"
|
icon_unpaired = "coldcard_unpaired.png"
|
||||||
icon_paired = "coldcard.png"
|
icon_paired = "coldcard.png"
|
||||||
@@ -82,6 +86,21 @@ class Plugin(ColdcardPlugin, QtPluginBase):
|
|||||||
# - doesn't matter if device not connected, continue
|
# - doesn't matter if device not connected, continue
|
||||||
CKCCSettingsDialog(window, self, keystore).exec_()
|
CKCCSettingsDialog(window, self, keystore).exec_()
|
||||||
|
|
||||||
|
@hook
|
||||||
|
def init_wallet_wizard(self, wizard: 'QENewWalletWizard'):
|
||||||
|
self.extend_wizard(wizard)
|
||||||
|
|
||||||
|
# insert coldcard pages in new wallet wizard
|
||||||
|
def extend_wizard(self, wizard: 'QENewWalletWizard'):
|
||||||
|
super().extend_wizard(wizard)
|
||||||
|
views = {
|
||||||
|
'coldcard_start': {'gui': WCScriptAndDerivation},
|
||||||
|
'coldcard_xpub': {'gui': WCHWXPub},
|
||||||
|
'coldcard_not_initialized': {'gui': WCHWUninitialized},
|
||||||
|
'coldcard_unlock': {'gui': WCHWUnlock}
|
||||||
|
}
|
||||||
|
wizard.navmap_merge(views)
|
||||||
|
|
||||||
|
|
||||||
class Coldcard_Handler(QtHandlerBase):
|
class Coldcard_Handler(QtHandlerBase):
|
||||||
MESSAGE_DIALOG_TITLE = _("Coldcard Status")
|
MESSAGE_DIALOG_TITLE = _("Coldcard Status")
|
||||||
|
|||||||
Reference in New Issue
Block a user