def get_xpub(self, device_id, derivation, xtype, wizard): if xtype not in self.SUPPORTED_XTYPES: raise ScriptTypeNotSupported(_('This type of script is not supported with {}.').format(self.device)) if is_all_public_derivation(derivation): raise Exception(f"The {self.device} does not reveal xpubs corresponding to non-hardened paths. (path: {derivation})") client = self.scan_and_create_client_for_device(device_id=device_id, wizard=wizard) client.check_device_dialog() xpub = client.get_xpub(derivation, xtype) return xpub
def test_is_all_public_derivation(self): self.assertFalse(is_all_public_derivation("m/0/1'/1'")) self.assertFalse(is_all_public_derivation("m/0/2/1'")) self.assertFalse(is_all_public_derivation("m/0/1'/1'/5")) self.assertTrue(is_all_public_derivation("m")) self.assertTrue(is_all_public_derivation("m/0")) self.assertTrue(is_all_public_derivation("m/75/22/3"))