coldcard: factor out manipulate_keystore_dict_during_wizard_setup
This commit is contained in:
committed by
Sander van Grieken
parent
d2c7df3180
commit
1a91da67ea
@@ -87,15 +87,14 @@ class CKCCClient(HardwareClientBase):
|
|||||||
self.label())
|
self.label())
|
||||||
|
|
||||||
@runs_in_hwd_thread
|
@runs_in_hwd_thread
|
||||||
def verify_connection(self, expected_xfp: int, expected_xpub=None):
|
def verify_connection(self, expected_xfp: int, expected_xpub: str):
|
||||||
ex = (expected_xfp, expected_xpub)
|
ex = (expected_xfp, expected_xpub)
|
||||||
|
|
||||||
if self._expected_device == ex:
|
if self._expected_device == ex:
|
||||||
# all is as expected
|
# all is as expected
|
||||||
return
|
return
|
||||||
|
|
||||||
if expected_xpub is None:
|
assert expected_xpub
|
||||||
expected_xpub = self.dev.master_xpub
|
|
||||||
|
|
||||||
if ((self._expected_device is not None)
|
if ((self._expected_device is not None)
|
||||||
or (self.dev.master_fingerprint != expected_xfp)
|
or (self.dev.master_fingerprint != expected_xfp)
|
||||||
@@ -114,9 +113,6 @@ class CKCCClient(HardwareClientBase):
|
|||||||
|
|
||||||
self._expected_device = ex
|
self._expected_device = ex
|
||||||
|
|
||||||
if not getattr(self, 'ckcc_xpub', None):
|
|
||||||
self.ckcc_xpub = expected_xpub
|
|
||||||
|
|
||||||
_logger.info("Successfully verified against MiTM")
|
_logger.info("Successfully verified against MiTM")
|
||||||
|
|
||||||
def is_pairable(self):
|
def is_pairable(self):
|
||||||
@@ -146,7 +142,7 @@ class CKCCClient(HardwareClientBase):
|
|||||||
|
|
||||||
return lab
|
return lab
|
||||||
|
|
||||||
def manipulate_keystore_dict_during_wizard_setup(self, d: dict):
|
def _get_ckcc_master_xpub_from_device(self):
|
||||||
master_xpub = self.dev.master_xpub
|
master_xpub = self.dev.master_xpub
|
||||||
if master_xpub is not None:
|
if master_xpub is not None:
|
||||||
try:
|
try:
|
||||||
@@ -156,7 +152,7 @@ class CKCCClient(HardwareClientBase):
|
|||||||
_('Invalid xpub magic. Make sure your {} device is set to the correct chain.').format(self.device) + ' ' +
|
_('Invalid xpub magic. Make sure your {} device is set to the correct chain.').format(self.device) + ' ' +
|
||||||
_('You might have to unplug and plug it in again.')
|
_('You might have to unplug and plug it in again.')
|
||||||
) from None
|
) from None
|
||||||
d['ckcc_xpub'] = master_xpub
|
return master_xpub
|
||||||
|
|
||||||
@runs_in_hwd_thread
|
@runs_in_hwd_thread
|
||||||
def has_usable_connection_with_device(self):
|
def has_usable_connection_with_device(self):
|
||||||
@@ -273,6 +269,12 @@ class Coldcard_KeyStore(Hardware_KeyStore):
|
|||||||
assert xfp is not None
|
assert xfp is not None
|
||||||
return xfp_int_from_xfp_bytes(bfh(xfp))
|
return xfp_int_from_xfp_bytes(bfh(xfp))
|
||||||
|
|
||||||
|
def opportunistically_fill_in_missing_info_from_device(self, client: 'CKCCClient'):
|
||||||
|
super().opportunistically_fill_in_missing_info_from_device(client)
|
||||||
|
if self.ckcc_xpub is None:
|
||||||
|
self.ckcc_xpub = client._get_ckcc_master_xpub_from_device()
|
||||||
|
self.is_requesting_to_be_rewritten_to_wallet_file = True
|
||||||
|
|
||||||
def get_client(self, *args, **kwargs):
|
def get_client(self, *args, **kwargs):
|
||||||
# called when user tries to do something like view address, sign somthing.
|
# called when user tries to do something like view address, sign somthing.
|
||||||
# - not called during probing/setup
|
# - not called during probing/setup
|
||||||
|
|||||||
@@ -268,14 +268,6 @@ class HardwareClientBase(ABC):
|
|||||||
"""
|
"""
|
||||||
return self.plugin.name
|
return self.plugin.name
|
||||||
|
|
||||||
def manipulate_keystore_dict_during_wizard_setup(self, d: dict) -> None: # noqa: B027
|
|
||||||
"""Called during wallet creation in the wizard, before the keystore
|
|
||||||
is constructed for the first time. 'd' is the dict that will be
|
|
||||||
passed to the keystore constructor.
|
|
||||||
"""
|
|
||||||
# TODO: this is only used by coldcard. determine if this needs to stay generalized
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class HardwareHandlerBase:
|
class HardwareHandlerBase:
|
||||||
"""An interface between the GUI and the device handling logic for handling I/O."""
|
"""An interface between the GUI and the device handling logic for handling I/O."""
|
||||||
|
|||||||
Reference in New Issue
Block a user