@@ -263,31 +263,51 @@ def _build_tx(self, from_pubkey, accounts, program_id, instr_data, extra_account
263263 # ================================================================
264264
265265 def test_solana_sign_token_transfer (self ):
266- """SPL Token transfer — OLED shows 'Send [amount] tokens to [address]'."""
266+ """Unchecked SPL Transfer has no signed mint (the token being moved is
267+ not provable), so it now requires AdvancedMode (blind-sign); only the
268+ TransferChecked variant clear-signs."""
267269 self .requires_fullFeature ()
268270 self .setup_mnemonic_allallall ()
271+ from keepkeylib .client import CallException
269272 from_pubkey = self ._get_from_pubkey ()
270273 to_account = b'\x33 ' * 32 # destination token account
271- owner = from_pubkey # token owner = signer
272274 # SPL Token Transfer instruction: opcode=3 (u8) + amount (LE u64)
273275 instr_data = bytes ([3 ]) + struct .pack ('<Q' , 50000000 ) # 50M tokens
274276 raw_tx = self ._build_tx (from_pubkey , [to_account ], self .TOKEN_PROGRAM , instr_data )
275- resp = self .client .call (messages .SolanaSignTx (
276- address_n = parse_path ("m/44'/501'/0'/0'" ), raw_tx = raw_tx ))
277+ tx = messages .SolanaSignTx (
278+ address_n = parse_path ("m/44'/501'/0'/0'" ), raw_tx = raw_tx )
279+
280+ self .client .apply_policy ('AdvancedMode' , False )
281+ with self .assertRaises (CallException ):
282+ self .client .call (tx )
283+
284+ self .client .apply_policy ('AdvancedMode' , True )
285+ resp = self .client .call (tx )
277286 self .assertEqual (len (resp .signature ), 64 )
287+ self .client .apply_policy ('AdvancedMode' , False )
278288
279289 def test_solana_sign_token_approve (self ):
280- """SPL Token approve — OLED shows 'Approve [amount] tokens to [delegate]'."""
290+ """Unchecked SPL Approve hides the delegated token's mint, so it now
291+ requires AdvancedMode (blind-sign)."""
281292 self .requires_fullFeature ()
282293 self .setup_mnemonic_allallall ()
294+ from keepkeylib .client import CallException
283295 from_pubkey = self ._get_from_pubkey ()
284296 delegate = b'\x44 ' * 32
285297 # SPL Token Approve: opcode=4 (u8) + amount (LE u64)
286298 instr_data = bytes ([4 ]) + struct .pack ('<Q' , 100000000 )
287299 raw_tx = self ._build_tx (from_pubkey , [delegate ], self .TOKEN_PROGRAM , instr_data )
288- resp = self .client .call (messages .SolanaSignTx (
289- address_n = parse_path ("m/44'/501'/0'/0'" ), raw_tx = raw_tx ))
300+ tx = messages .SolanaSignTx (
301+ address_n = parse_path ("m/44'/501'/0'/0'" ), raw_tx = raw_tx )
302+
303+ self .client .apply_policy ('AdvancedMode' , False )
304+ with self .assertRaises (CallException ):
305+ self .client .call (tx )
306+
307+ self .client .apply_policy ('AdvancedMode' , True )
308+ resp = self .client .call (tx )
290309 self .assertEqual (len (resp .signature ), 64 )
310+ self .client .apply_policy ('AdvancedMode' , False )
291311
292312 def test_solana_sign_stake_delegate (self ):
293313 """Stake delegate — OLED shows 'Delegate stake?'."""
@@ -542,9 +562,12 @@ def test_solana_sign_multi_instruction_transfer_and_memo(self):
542562 # ================================================================
543563
544564 def test_solana_sign_token_transfer_with_metadata (self ):
545- """SPL Token transfer with SolanaTokenInfo for OLED display of symbol + decimals."""
565+ """Host SolanaTokenInfo does NOT make an unchecked transfer clear-signable:
566+ the mint is not signed, so the metadata is unauthenticated and the tx
567+ still requires AdvancedMode. (TransferChecked binds the mint on-chain.)"""
546568 self .requires_fullFeature ()
547569 self .setup_mnemonic_allallall ()
570+ from keepkeylib .client import CallException
548571
549572 from_pubkey = self ._get_from_pubkey ()
550573 to_account = b'\x33 ' * 32 # destination token account
@@ -567,13 +590,20 @@ def test_solana_sign_token_transfer_with_metadata(self):
567590 decimals = 6 ,
568591 )
569592
570- resp = self . client . call ( messages .SolanaSignTx (
593+ tx = messages .SolanaSignTx (
571594 address_n = parse_path ("m/44'/501'/0'/0'" ),
572595 raw_tx = raw_tx ,
573596 token_info = [token_info ],
574- ))
597+ )
598+ self .client .apply_policy ('AdvancedMode' , False )
599+ with self .assertRaises (CallException ):
600+ self .client .call (tx )
601+
602+ self .client .apply_policy ('AdvancedMode' , True )
603+ resp = self .client .call (tx )
575604 self .assertEqual (len (resp .signature ), 64 )
576605 self .assertFalse (all (b == 0 for b in resp .signature ))
606+ self .client .apply_policy ('AdvancedMode' , False )
577607
578608 # ================================================================
579609 # Path edge-case tests
0 commit comments