mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 04:18:10 +00:00
fix(core/ui): don't send ButtonRequest when displaying GetAddress QR code
[no changelog]
This commit is contained in:
parent
6e0c2578f8
commit
c100358ce2
@ -384,25 +384,30 @@ async def show_address(
|
|||||||
multisig_index: int | None = None,
|
multisig_index: int | None = None,
|
||||||
xpubs: Sequence[str] = (),
|
xpubs: Sequence[str] = (),
|
||||||
) -> None:
|
) -> None:
|
||||||
|
send_button_request = True
|
||||||
while True:
|
while True:
|
||||||
title = (
|
title = (
|
||||||
"RECEIVE ADDRESS\n(MULTISIG)"
|
"RECEIVE ADDRESS\n(MULTISIG)"
|
||||||
if multisig_index is not None
|
if multisig_index is not None
|
||||||
else "RECEIVE ADDRESS"
|
else "RECEIVE ADDRESS"
|
||||||
)
|
)
|
||||||
result = await interact(
|
layout = RustLayout(
|
||||||
ctx,
|
|
||||||
RustLayout(
|
|
||||||
trezorui2.confirm_address(
|
trezorui2.confirm_address(
|
||||||
title=title,
|
title=title,
|
||||||
data=address,
|
data=address,
|
||||||
description=network or "",
|
description=network or "",
|
||||||
extra=None,
|
extra=None,
|
||||||
)
|
)
|
||||||
),
|
)
|
||||||
|
if send_button_request:
|
||||||
|
send_button_request = False
|
||||||
|
await button_request(
|
||||||
|
ctx,
|
||||||
"show_address",
|
"show_address",
|
||||||
ButtonRequestType.Address,
|
ButtonRequestType.Address,
|
||||||
|
pages=layout.page_count(),
|
||||||
)
|
)
|
||||||
|
result = await ctx.wait(layout)
|
||||||
|
|
||||||
# User pressed right button.
|
# User pressed right button.
|
||||||
if result is CONFIRMED:
|
if result is CONFIRMED:
|
||||||
@ -416,8 +421,7 @@ async def show_address(
|
|||||||
result += "(YOURS)" if i == multisig_index else "(COSIGNER)"
|
result += "(YOURS)" if i == multisig_index else "(COSIGNER)"
|
||||||
return result
|
return result
|
||||||
|
|
||||||
result = await interact(
|
result = await ctx.wait(
|
||||||
ctx,
|
|
||||||
RustLayout(
|
RustLayout(
|
||||||
trezorui2.show_address_details(
|
trezorui2.show_address_details(
|
||||||
address=address if address_qr is None else address_qr,
|
address=address if address_qr is None else address_qr,
|
||||||
@ -426,19 +430,12 @@ async def show_address(
|
|||||||
path=path,
|
path=path,
|
||||||
xpubs=[(xpub_title(i), xpub) for i, xpub in enumerate(xpubs)],
|
xpubs=[(xpub_title(i), xpub) for i, xpub in enumerate(xpubs)],
|
||||||
)
|
)
|
||||||
),
|
)
|
||||||
"show_address_details",
|
|
||||||
ButtonRequestType.Address,
|
|
||||||
)
|
)
|
||||||
assert result is CANCELLED
|
assert result is CANCELLED
|
||||||
|
|
||||||
else:
|
else:
|
||||||
result = await interact(
|
result = await ctx.wait(RustLayout(trezorui2.show_mismatch()))
|
||||||
ctx,
|
|
||||||
RustLayout(trezorui2.show_mismatch()),
|
|
||||||
"warning_address_mismatch",
|
|
||||||
ButtonRequestType.Warning,
|
|
||||||
)
|
|
||||||
assert result in (CONFIRMED, CANCELLED)
|
assert result in (CONFIRMED, CANCELLED)
|
||||||
# Right button aborts action, left goes back to showing address.
|
# Right button aborts action, left goes back to showing address.
|
||||||
if result is CONFIRMED:
|
if result is CONFIRMED:
|
||||||
|
@ -368,14 +368,14 @@ class DebugLink:
|
|||||||
x, y = click
|
x, y = click
|
||||||
return self.input(x=x, y=y, wait=wait)
|
return self.input(x=x, y=y, wait=wait)
|
||||||
|
|
||||||
def press_yes(self) -> None:
|
def press_yes(self, wait: bool = False) -> None:
|
||||||
self.input(button=messages.DebugButton.YES)
|
self.input(button=messages.DebugButton.YES, wait=wait)
|
||||||
|
|
||||||
def press_no(self) -> None:
|
def press_no(self, wait: bool = False) -> None:
|
||||||
self.input(button=messages.DebugButton.NO)
|
self.input(button=messages.DebugButton.NO, wait=wait)
|
||||||
|
|
||||||
def press_info(self) -> None:
|
def press_info(self, wait: bool = False) -> None:
|
||||||
self.input(button=messages.DebugButton.INFO)
|
self.input(button=messages.DebugButton.INFO, wait=wait)
|
||||||
|
|
||||||
def swipe_up(self, wait: bool = False) -> None:
|
def swipe_up(self, wait: bool = False) -> None:
|
||||||
self.input(swipe=messages.DebugSwipeDirection.UP, wait=wait)
|
self.input(swipe=messages.DebugSwipeDirection.UP, wait=wait)
|
||||||
|
@ -78,20 +78,16 @@ def test_show_tt(
|
|||||||
):
|
):
|
||||||
def input_flow():
|
def input_flow():
|
||||||
yield
|
yield
|
||||||
client.debug.click(CORNER_BUTTON)
|
client.debug.click(CORNER_BUTTON, wait=True)
|
||||||
yield
|
|
||||||
# synchronize; TODO get rid of this once we have single-global-layout
|
# synchronize; TODO get rid of this once we have single-global-layout
|
||||||
client.debug.synchronize_at("HorizontalPage")
|
client.debug.synchronize_at("HorizontalPage")
|
||||||
|
|
||||||
client.debug.swipe_left(wait=True)
|
client.debug.swipe_left(wait=True)
|
||||||
client.debug.swipe_right(wait=True)
|
client.debug.swipe_right(wait=True)
|
||||||
client.debug.swipe_left(wait=True)
|
client.debug.swipe_left(wait=True)
|
||||||
client.debug.click(CORNER_BUTTON)
|
client.debug.click(CORNER_BUTTON, wait=True)
|
||||||
yield
|
client.debug.press_no(wait=True)
|
||||||
client.debug.press_no()
|
client.debug.press_no(wait=True)
|
||||||
yield
|
|
||||||
client.debug.press_no()
|
|
||||||
yield
|
|
||||||
client.debug.press_yes()
|
client.debug.press_yes()
|
||||||
|
|
||||||
with client:
|
with client:
|
||||||
@ -115,16 +111,13 @@ def test_show_cancel(
|
|||||||
):
|
):
|
||||||
def input_flow():
|
def input_flow():
|
||||||
yield
|
yield
|
||||||
client.debug.click(CORNER_BUTTON)
|
client.debug.click(CORNER_BUTTON, wait=True)
|
||||||
yield
|
|
||||||
# synchronize; TODO get rid of this once we have single-global-layout
|
# synchronize; TODO get rid of this once we have single-global-layout
|
||||||
client.debug.synchronize_at("HorizontalPage")
|
client.debug.synchronize_at("HorizontalPage")
|
||||||
|
|
||||||
client.debug.swipe_left(wait=True)
|
client.debug.swipe_left(wait=True)
|
||||||
client.debug.click(CORNER_BUTTON)
|
client.debug.click(CORNER_BUTTON, wait=True)
|
||||||
yield
|
client.debug.press_no(wait=True)
|
||||||
client.debug.press_no()
|
|
||||||
yield
|
|
||||||
client.debug.press_yes()
|
client.debug.press_yes()
|
||||||
|
|
||||||
with client, pytest.raises(Cancelled):
|
with client, pytest.raises(Cancelled):
|
||||||
@ -285,7 +278,6 @@ def test_show_multisig_xpubs(
|
|||||||
assert layout.get_content().replace(" ", "") == address
|
assert layout.get_content().replace(" ", "") == address
|
||||||
|
|
||||||
client.debug.click(CORNER_BUTTON)
|
client.debug.click(CORNER_BUTTON)
|
||||||
yield # show QR code
|
|
||||||
assert "Qr" in client.debug.wait_layout().text
|
assert "Qr" in client.debug.wait_layout().text
|
||||||
|
|
||||||
layout = client.debug.swipe_left(wait=True)
|
layout = client.debug.swipe_left(wait=True)
|
||||||
@ -302,12 +294,12 @@ def test_show_multisig_xpubs(
|
|||||||
content = layout.get_content().replace(" ", "")
|
content = layout.get_content().replace(" ", "")
|
||||||
assert xpubs[xpub_num] in content
|
assert xpubs[xpub_num] in content
|
||||||
|
|
||||||
client.debug.click(CORNER_BUTTON)
|
client.debug.click(CORNER_BUTTON, wait=True)
|
||||||
yield # show address
|
# show address
|
||||||
client.debug.press_no()
|
client.debug.press_no(wait=True)
|
||||||
yield # address mismatch
|
# address mismatch
|
||||||
client.debug.press_no()
|
client.debug.press_no(wait=True)
|
||||||
yield # show address
|
# show address
|
||||||
client.debug.press_yes()
|
client.debug.press_yes()
|
||||||
|
|
||||||
with client:
|
with client:
|
||||||
|
Loading…
Reference in New Issue
Block a user