Skip to content

Comments

feat(gui): Approve dialog before publishing Bitcoin lock transaction#291

Merged
binarybaron merged 13 commits intomasterfrom
gui/accept-final-rate
Apr 17, 2025
Merged

feat(gui): Approve dialog before publishing Bitcoin lock transaction#291
binarybaron merged 13 commits intomasterfrom
gui/accept-final-rate

Conversation

@binarybaron
Copy link

@binarybaron binarybaron commented Apr 16, 2025

This diff introduces a new "approvals" mechanism that alters the swap flow by requiring explicit user intervention before the Bitcoin lock transaction is broadcast. Previously, the Bitcoin lock was executed automatically without any user prompt. Now, the backend defines ApprovalRequestType (e.g. a PreBtcLock variant with details like btc_lock_amount, btc_network_fee, and xmr_receive_amount) and ApprovalEvent (with statuses such as Pending, Resolved, and Rejected). The method request_approval() in the TauriHandle struct uses a oneshot channel and concurrent timeout handling via tokio::select! to wait for the user's decision. Based on the outcome—explicit approval or timeout/rejection—the approval event is emitted through the emit_approval() helper, thereby gating the subsequent broadcast of the Bitcoin lock transaction.

On the UI side, changes have been made to reflect the new flow; the modal (for example, in SwapSetupInflightPage.tsx) now displays the swap details along with explicit action buttons that call resolveApproval() via RPC when clicked. The Redux store, selectors, and hooks like usePendingPreBtcLockApproval() have been updated to track and display these approval events. As a result, the overall functionality now requires the user to explicitly approve the swap offer before proceeding, ensuring they are aware of the swap's key parameters and that the locking of funds occurs only after their confirmation.

OfferAcceptFlow.mov

@binarybaron binarybaron marked this pull request as draft April 16, 2025 17:19
@Einliterflasche
Copy link

this one is forked off asb/cache-quotes i think, we should rebase before merging

@binarybaron
Copy link
Author

this one is forked off asb/cache-quotes i think, we should rebase before merging

will do but let's merge #288 first. I don't want to deal with merge conflicts.

@binarybaron binarybaron force-pushed the gui/accept-final-rate branch 3 times, most recently from b15ce25 to 35e58dc Compare April 17, 2025 17:43
@binarybaron binarybaron force-pushed the gui/accept-final-rate branch from b2abd72 to 5fc1c6c Compare April 17, 2025 22:38
@binarybaron binarybaron marked this pull request as ready for review April 17, 2025 22:42
@binarybaron
Copy link
Author

@Einliterflasche @b-enedict @delta1 This is ready for review. I think the changes are mostly fine. Unless there any objections I'm going to merge this.

@binarybaron binarybaron changed the title feat(gui): Accept dialog for final exchange rate feat(gui): Approve dialog before publishing Bitcoin lock transaction Apr 17, 2025
@binarybaron binarybaron merged commit 9ddf2da into master Apr 17, 2025
0 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants