diff --git a/core/src/apps/base.py b/core/src/apps/base.py index 628bd12f8e..20384a18e1 100644 --- a/core/src/apps/base.py +++ b/core/src/apps/base.py @@ -203,7 +203,7 @@ async def handle_Initialize(msg: Initialize) -> Features: session_id = storage_cache.start_session(msg.session_id) if not utils.BITCOIN_ONLY: - derive_cardano = storage_cache.get(storage_cache.APP_COMMON_DERIVE_CARDANO) + derive_cardano = storage_cache.get_bool(storage_cache.APP_COMMON_DERIVE_CARDANO) have_seed = storage_cache.is_set(storage_cache.APP_COMMON_SEED) if ( @@ -218,9 +218,8 @@ async def handle_Initialize(msg: Initialize) -> Features: have_seed = False if not have_seed: - storage_cache.set( - storage_cache.APP_COMMON_DERIVE_CARDANO, - b"\x01" if msg.derive_cardano else b"", + storage_cache.set_bool( + storage_cache.APP_COMMON_DERIVE_CARDANO, bool(msg.derive_cardano) ) features = get_features() diff --git a/core/src/apps/cardano/seed.py b/core/src/apps/cardano/seed.py index f7b6cfd2ff..06b662c87b 100644 --- a/core/src/apps/cardano/seed.py +++ b/core/src/apps/cardano/seed.py @@ -112,7 +112,7 @@ def is_minting_path(path: Bip32Path) -> bool: def derive_and_store_secrets(passphrase: str) -> None: assert device.is_initialized() - assert cache.get(cache.APP_COMMON_DERIVE_CARDANO) + assert cache.get_bool(cache.APP_COMMON_DERIVE_CARDANO) if not mnemonic.is_bip39(): # nothing to do for SLIP-39, where we can derive the root from the main seed @@ -148,7 +148,7 @@ async def _get_keychain_bip39(derivation_type: CardanoDerivationType) -> Keychai seed = await get_seed() return Keychain(cardano.from_seed_ledger(seed)) - if not cache.get(cache.APP_COMMON_DERIVE_CARDANO): + if not cache.get_bool(cache.APP_COMMON_DERIVE_CARDANO): raise wire.ProcessError("Cardano derivation is not enabled for this session") if derivation_type == CardanoDerivationType.ICARUS: diff --git a/core/src/apps/common/seed.py b/core/src/apps/common/seed.py index d773909b40..58846b4f9d 100644 --- a/core/src/apps/common/seed.py +++ b/core/src/apps/common/seed.py @@ -57,7 +57,7 @@ if not utils.BITCOIN_ONLY: raise wire.NotInitialized("Device is not initialized") need_seed = not storage_cache.is_set(storage_cache.APP_COMMON_SEED) - need_cardano_secret = storage_cache.get( + need_cardano_secret = storage_cache.get_bool( storage_cache.APP_COMMON_DERIVE_CARDANO ) and not storage_cache.is_set(storage_cache.APP_CARDANO_ICARUS_SECRET) diff --git a/core/src/apps/monero/live_refresh.py b/core/src/apps/monero/live_refresh.py index 011b2e2837..90d2dec642 100644 --- a/core/src/apps/monero/live_refresh.py +++ b/core/src/apps/monero/live_refresh.py @@ -64,9 +64,9 @@ async def _init_step( await paths.validate_path(keychain, msg.address_n) - if not storage_cache.get(storage_cache.APP_MONERO_LIVE_REFRESH): + if not storage_cache.get_bool(storage_cache.APP_MONERO_LIVE_REFRESH): await layout.require_confirm_live_refresh() - storage_cache.set(storage_cache.APP_MONERO_LIVE_REFRESH, b"\x01") + storage_cache.set_bool(storage_cache.APP_MONERO_LIVE_REFRESH, True) s.creds = misc.get_creds(keychain, msg.address_n, msg.network_type) diff --git a/core/src/storage/cache.py b/core/src/storage/cache.py index ee36b3e60d..7cfc71424b 100644 --- a/core/src/storage/cache.py +++ b/core/src/storage/cache.py @@ -112,10 +112,10 @@ class SessionCache(DataCache): 2, # APP_COMMON_AUTHORIZATION_TYPE 128, # APP_COMMON_AUTHORIZATION_DATA 32, # APP_COMMON_NONCE - 1, # APP_COMMON_DERIVE_CARDANO + 0, # APP_COMMON_DERIVE_CARDANO 96, # APP_CARDANO_ICARUS_SECRET 96, # APP_CARDANO_ICARUS_TREZOR_SECRET - 1, # APP_MONERO_LIVE_REFRESH + 0, # APP_MONERO_LIVE_REFRESH ) self.last_usage = 0 super().__init__() diff --git a/core/src/storage/common.py b/core/src/storage/common.py index a9f3364af4..649c656d84 100644 --- a/core/src/storage/common.py +++ b/core/src/storage/common.py @@ -31,11 +31,11 @@ def delete( config.delete(app, key, public, writable_locked) -def set_true_or_delete(app: int, key: int, value: bool) -> None: +def set_true_or_delete(app: int, key: int, value: bool, public: bool = False) -> None: if value: - set_bool(app, key, value) + set_bool(app, key, value, public) else: - delete(app, key) + delete(app, key, public) def set_bool(app: int, key: int, value: bool, public: bool = False) -> None: