@@ -252,17 +252,9 @@ async def handle_Initialize(
252252 else :
253253 storage .cache .delete (storage .cache .APP_COMMON_CLIENT_CONTAINS_ATTACH )
254254
255- prev_session_id = storage .cache .get_session_id ()
256-
257- from apps .common import passphrase
258-
259- passphrase_pin_enabled = passphrase .is_passphrase_pin_enabled ()
260255 if (
261- device_is_unlocked ()
262- and prev_session_id != msg .session_id
263- and hasattr (msg , "passphrase_state" )
256+ hasattr (msg , "passphrase_state" )
264257 and msg .passphrase_state is not None
265- and passphrase_pin_enabled
266258 and msg .passphrase_state != ""
267259 and se_thd89 .check_passphrase_btc_test_address (
268260 msg .passphrase_state
@@ -271,8 +263,17 @@ async def handle_Initialize(
271263 )
272264 ):
273265 session_id = storage .cache .start_session ()
266+ elif msg .session_id is not None :
267+ if (
268+ not hasattr (msg , "passphrase_state" )
269+ or msg .passphrase_state is None
270+ or msg .passphrase_state == ""
271+ ):
272+ session_id = storage .cache .start_session ()
273+ else :
274+ session_id = storage .cache .start_session (msg .session_id )
274275 else :
275- session_id = storage .cache .start_session (msg . session_id )
276+ session_id = storage .cache .start_session ()
276277 if not utils .BITCOIN_ONLY :
277278 if utils .USE_THD89 :
278279 if msg .derive_cardano is not None and msg .derive_cardano :
@@ -664,7 +665,6 @@ def get_pinlocked_handler(
664665
665666 async def wrapper (ctx : wire .Context , msg : wire .Msg ) -> protobuf .MessageType :
666667 await unlock_device (ctx )
667- storage .cache .start_session ()
668668 return await orig_handler (ctx , msg )
669669
670670 return wrapper
@@ -756,7 +756,6 @@ async def handle_UnLockDevice(
756756 """Handle UnLockDevice message to unlock the device if needed."""
757757 if not config .is_unlocked ():
758758 await unlock_device (ctx , pin_use_type = PinType .USER_AND_PASSPHRASE_PIN )
759- storage .cache .start_session ()
760759
761760 # Get current device state after unlock attempt
762761 from apps .common import passphrase
0 commit comments