From 7fe910a665583b93ce1622769a10053d1acf000f Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Sat, 27 Jun 2020 11:34:08 +0100 Subject: [PATCH] Bugfix: mnemonic extension display in Qt generate Prior to this fix, doing Wallet->Generate in Qt and choosing the mnemonic extension option creates an erroneous error dialog on completion of wallet creation (even though the wallet is created correctly), due to #565 which correctly decoded the binary mnemonic extension for the Wallet->Show Seed function, but this was not correct for the Wallet->Generate case. The cause for this was the difference between the type of the mnemonic extension variable when it was created, and when it is received from storage. This commit ensures consistency between the two cases by making a newly created mnemonic extension variable binary. --- jmclient/jmclient/wallet.py | 6 +++++- jmclient/jmclient/wallet_utils.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/jmclient/jmclient/wallet.py b/jmclient/jmclient/wallet.py index c9b2dc800..59c581a26 100644 --- a/jmclient/jmclient/wallet.py +++ b/jmclient/jmclient/wallet.py @@ -1245,7 +1245,11 @@ def initialize(cls, storage, network, max_mixdepth=2, timestamp=None, storage, network, max_mixdepth, timestamp, entropy, write=False, **kwargs) if entropy_extension: - storage.data[cls._BIP39_EXTENSION_KEY] = entropy_extension + # Note: future reads from storage will retrieve this data + # as binary, so set it as binary on initialization for consistency. + # Note that this is in contrast to the mnemonic wordlist, which is + # handled by the mnemonic package, which returns the words as a string. + storage.data[cls._BIP39_EXTENSION_KEY] = entropy_extension.encode("utf-8") if write: storage.save() diff --git a/jmclient/jmclient/wallet_utils.py b/jmclient/jmclient/wallet_utils.py index e080a114b..6770a9eeb 100644 --- a/jmclient/jmclient/wallet_utils.py +++ b/jmclient/jmclient/wallet_utils.py @@ -562,7 +562,8 @@ def cli_get_wallet_file_name(defaultname="wallet.jmdat"): def cli_display_user_words(words, mnemonic_extension): text = 'Write down this wallet recovery mnemonic\n\n' + words +'\n' if mnemonic_extension: - text += '\nAnd this mnemonic extension: ' + mnemonic_extension + '\n' + text += '\nAnd this mnemonic extension: ' + mnemonic_extension.decode( + 'utf-8') + '\n' jmprint(text, "important") def cli_user_mnemonic_entry():