Fix unnecessary delay before sending signed transaction in nbgl
Closed this issue · 0 comments
Description
In the final screen after signing a transaction on a Ledger Stax (or Flex), the "Transaction Approved" popup appears for 3 seconds before the signed transaction is sent to the client.
Your environment
- Windows 11
- develop
- Ledger Stax
Steps to reproduce
- Send a transaction request via Metamask
- Finalize signature flow on Stax
- Note 3 second delay before Metamask responds
Expected behaviour
The expected behavior is that the signed transaction is immediately sent to the client. The final apdu isn't sent until the Transaction Approved popup is closed, so this is independent of any particular PC client.
Actual behaviour
The PC client hangs for 3 seconds or until the user manually dismisses the "Transaction Approved" popup on the Ledger.
Proposed solution
The issue stems from use of nbgl_useCaseReviewStatus
in src/nbgl/ui_approve_tx.c in the reviewChoice
function (line 48). The callback to this function is not executed until after the popup is dismissed, which is confirmTransation
[sic] (line 41) in the confirmation case, which sends the confirmed transaction to the client.
The fix is to factor io_seproxyhal_touch_tx_ok
(ui_common_signTx.c line 10) into two phases,:one that signs the transaction and sends it, and one that resets the app contexts and returns to the idle screen. In reviewChoice
in the confirm
case, the transaction should then be signed and sent to the client, and then the callback is only used to reset the app context.