diff --git a/src/krux/key.py b/src/krux/key.py index 38969e465..1be2b7d71 100644 --- a/src/krux/key.py +++ b/src/krux/key.py @@ -34,6 +34,7 @@ DER_SINGLE = "m/84h/%dh/0h" DER_MULTI = "m/48h/%dh/0h/2h" +HARDENED_STR_REPLACE = "'" class Key: @@ -77,9 +78,11 @@ def fingerprint_hex_str(self, pretty=False): return formatted_txt % hexlify(self.fingerprint).decode("utf-8") def derivation_str(self, pretty=False): - """Returns the derivation path for the Hierarchical Deterministic Wallet""" + """Returns the derivation path for the Hierarchical Deterministic Wallet to + be displayed as string + """ formatted_txt = t("Derivation: %s") if pretty else "%s" - return formatted_txt % self.derivation + return (formatted_txt % self.derivation).replace("h", HARDENED_STR_REPLACE) def sign(self, message_hash): """Signs a message with the extended master private key""" @@ -104,3 +107,12 @@ def pick_final_word(entropy, words): def get_default_derivation(multisig, network): """Return the Krux default derivation path for single-sig or multisig""" return (DER_MULTI if multisig else DER_SINGLE) % network["bip32"] + + @staticmethod + def get_default_derivation_str(multisig, network): + """Return the Krux default derivation path for single-sig or multisig to + be displayd as string + """ + return Key.get_default_derivation(multisig, network).replace( + "h", HARDENED_STR_REPLACE + ) diff --git a/src/krux/pages/home.py b/src/krux/pages/home.py index dc9de8f34..236fe4a09 100644 --- a/src/krux/pages/home.py +++ b/src/krux/pages/home.py @@ -229,6 +229,18 @@ def _load_wallet(self): % self.ctx.wallet.descriptor.to_string() ) self.ctx.display.flash_text(t("Wallet output descriptor loaded!")) + + # BlueWallet single sig descriptor without fingerprint + if ( + self.ctx.wallet.descriptor.key + and not self.ctx.wallet.descriptor.key.origin + ): + self.ctx.display.clear() + self.ctx.display.draw_centered_text( + t("Warning:\nIncomplete output descriptor"), theme.error_color + ) + self.ctx.input.wait_for_button() + except Exception as e: self.ctx.log.exception("Exception occurred loading wallet") self.ctx.display.clear() @@ -236,14 +248,7 @@ def _load_wallet(self): t("Invalid wallet:\n%s") % repr(e), theme.error_color ) self.ctx.input.wait_for_button() - if self.ctx.wallet.descriptor.key: # If single sig - if not self.ctx.wallet.descriptor.key.origin: - # Blue exports descriptors without a fingerprint - self.ctx.display.clear() - self.ctx.display.draw_centered_text( - t("Warning:\nIncomplete output descriptor"), theme.error_color - ) - self.ctx.input.wait_for_button() + return MENU_CONTINUE def addresses_menu(self): diff --git a/src/krux/pages/login.py b/src/krux/pages/login.py index eb0560ac4..6ba4f85fe 100644 --- a/src/krux/pages/login.py +++ b/src/krux/pages/login.py @@ -310,6 +310,13 @@ def _load_key_from_words(self, words): return MENU_CONTINUE self.ctx.display.clear() + # Test mnemonic Checksum verification before asking for passphrase + temp_key = Key( + mnemonic, + False, + NETWORKS[Settings().bitcoin.network], + ) + while True: submenu = Menu( self.ctx, @@ -354,7 +361,7 @@ def _load_key_from_words(self, words): ( t("Single-sig") + "\n" - + Key.get_default_derivation( + + Key.get_default_derivation_str( False, NETWORKS[Settings().bitcoin.network] ), lambda: MENU_EXIT, @@ -362,7 +369,7 @@ def _load_key_from_words(self, words): ( t("Multisig") + "\n" - + Key.get_default_derivation( + + Key.get_default_derivation_str( True, NETWORKS[Settings().bitcoin.network] ), lambda: MENU_EXIT,