Skip to content

Commit 201561d

Browse files
committed
fix(core/sol): handle the situation where the signer is missing in the memo program
1 parent 601c6ff commit 201561d

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

core/src/apps/solana/sign_tx.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ async def sign_tx(
6262
# verify fee payer
6363
if not multiple_signers:
6464
if fee_payer.get() != signer_pub_key_bytes:
65+
if __debug__:
66+
print(
67+
f"Invalid signer used: {PublicKey(fee_payer.get())} != {PublicKey(signer_pub_key_bytes)}"
68+
)
6569
raise wire.DataError("Invalid signer used")
6670
else:
6771
if PublicKey(signer_pub_key_bytes) not in accounts_keys[:sigs_count]:
@@ -100,7 +104,7 @@ async def sign_tx(
100104
elif program_id == SPL_MEMO_PROGRAM_ID:
101105
from .spl.memo.memo_program import parse
102106

103-
await parse(ctx, accounts, i.data)
107+
await parse(ctx, accounts if len(accounts) > 0 else [fee_payer], i.data)
104108
# elif program_id == COMPUTE_BUDGET_PROGRAM_ID:
105109
# pass
106110
# # elif program_id == STAKE_PROGRAM_ID:

core/src/apps/solana/spl/memo/memo_program.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ async def parse(ctx: wire.Context, accounts: list[PublicKey], data: bytes) -> No
1818
"""Parse memo instruction params."""
1919
from trezor.lvglui.i18n import gettext as _, keys as i18n_keys
2020

21-
params = MemoParams(signer=accounts[0], message=data)
22-
memo = params.message.decode("utf-8")
21+
signer = accounts[0]
22+
params = MemoParams(signer=signer, message=data)
23+
from apps.common.signverify import decode_message
24+
25+
memo = decode_message(params.message)
2326
from trezor.ui.layouts.lvgl import confirm_sol_memo
2427

25-
await confirm_sol_memo(
26-
ctx, _(i18n_keys.TITLE__MEMO), _(i18n_keys.LIST_KEY__MESSAGE__COLON), memo
27-
)
28+
await confirm_sol_memo(ctx, _(i18n_keys.TITLE__MEMO), memo, str(signer))

core/src/trezor/ui/layouts/lvgl/__init__.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,11 +1235,19 @@ async def confirm_sol_token_transfer(
12351235

12361236

12371237
async def confirm_sol_memo(
1238-
ctx: wire.GenericContext, title: str, description: str, memo: str
1238+
ctx: wire.GenericContext, title: str, memo: str, signer: str
12391239
) -> None:
1240-
from trezor.lvglui.scrs.template import BlobDisPlay
1240+
from trezor.lvglui.scrs.template import Message
12411241

1242-
screen = BlobDisPlay(title, description, memo, None)
1242+
screen = Message(
1243+
title,
1244+
signer,
1245+
memo,
1246+
ctx.primary_color,
1247+
ctx.icon_path,
1248+
False,
1249+
item_addr_title=_(i18n_keys.LIST_KEY__SIGNER__COLON),
1250+
)
12431251
await raise_if_cancelled(
12441252
interact(ctx, screen, "sol_memo", ButtonRequestType.ProtectCall)
12451253
)

0 commit comments

Comments
 (0)