Skip to content

fix(swaps): Allow redeem flow for restored reverse swaps in transaction.claimed#3707

Draft
a-khushal wants to merge 1 commit intoZeusLN:masterfrom
a-khushal:fix/reverse-swap-claimed-redeem
Draft

fix(swaps): Allow redeem flow for restored reverse swaps in transaction.claimed#3707
a-khushal wants to merge 1 commit intoZeusLN:masterfrom
a-khushal:fix/reverse-swap-claimed-redeem

Conversation

@a-khushal
Copy link
Copy Markdown
Contributor

@a-khushal a-khushal commented Feb 15, 2026

Description

Relates to issue: ZEUS-3701

This pull request is categorized as a:

  • New feature
  • Bug fix
  • Code refactor
  • Configuration change
  • Locales update
  • Quality assurance
  • Other

Checklist

  • I’ve run yarn run tsc and made sure my code compiles correctly
  • I’ve run yarn run lint and made sure my code didn’t contain any problematic patterns
  • I’ve run yarn run prettier and made sure my code is formatted correctly
  • I’ve run yarn run test and made sure all of the tests pass

Testing

If you modified or added a utility file, did you add new unit tests?

  • No, I’m a fool
  • Yes
  • N/A

I have tested this PR on the following platforms (please specify OS version and phone model/VM):

  • Android
  • iOS

I have tested this PR with the following types of nodes (please specify node version and API version where appropriate):

  • Embedded LND
  • LND (REST)
  • LND (Lightning Node Connect)
  • Core Lightning (CLNRest)
  • Nostr Wallet Connect
  • LndHub

Locales

  • I’ve added new locale text that requires translations
  • I’m aware that new translations should be made on the ZEUS Transfix page and not directly to this repo

Third Party Dependencies and Packages

  • Contributors will need to run yarn after this PR is merged in
  • 3rd party dependencies have been modified:
    • verify that package.json and yarn.lock have been properly updated
    • verify that dependencies are installed for both iOS and Android platforms

Other:

  • Changes were made that require an update to the README
  • Changes were made that require an update to onboarding

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @a-khushal, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a bug where users were unable to redeem funds for reverse swaps that had been restored and were in a claimed state. It introduces the necessary backend logic and UI components to facilitate the redemption process for these specific reverse swaps, improving the overall user experience and reliability of swap operations.

Highlights

  • Reverse Swap Redeem Flow: Implemented the functionality to allow users to redeem funds for restored reverse swaps that are in a 'claimed' state. This involves new logic to derive private keys, fetch transaction hexes, and retrieve preimages for reverse swaps.
  • Dynamic Refund/Redeem Button: The 'Refund' button in the swap details view now dynamically changes to 'Redeem' for reverse swaps and triggers the appropriate createReverseClaimTransaction function.
  • UI/UX Enhancements: The 'uncooperative' switch is now hidden for reverse swaps, and a new 'Redeem' button is displayed in the SwapDetails screen when a reverse swap reaches the TransactionClaimed state, directing users to the RefundSwap screen.
  • Status Handling Improvement: Refactored swap status display logic to ensure consistency by using a currentStatus variable that prioritizes real-time updates but falls back to the stored swap data status.
Changelog
  • views/Swaps/Refund.tsx
    • Added ReactNativeBlobUtil import for fetching swap data.
    • Introduced createReverseClaimTransaction function to handle the redemption of reverse swaps.
    • Implemented helper functions getPrivateKey, getReverseTransactionHex, and getReversePreimageHex to assist in reverse swap claim logic.
    • Modified the createRefundTransaction call to correctly use refundPubKey for reverse swaps.
    • Updated the main action button to dynamically display 'Redeem' for reverse swaps and trigger the new claim transaction logic.
    • Conditionally rendered the 'uncooperative' switch, hiding it for reverse swaps.
  • views/Swaps/SwapDetails.tsx
    • Refactored status display logic to use a currentStatus variable, ensuring consistent status updates.
    • Added a new showReverseRedeemButton flag to control the visibility of the redeem button.
    • Implemented a conditional 'Redeem' button that navigates to the RefundSwap screen for claimed reverse swaps.
Activity
  • The author marked this as a bug fix.
  • The author confirmed that tsc, lint, prettier, and test commands were run successfully.
  • The author confirmed that unit tests were not applicable for this change.
  • The author tested the PR on Android with Embedded LND.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements a bug fix to allow redeeming restored reverse swaps that are in the transaction.claimed state. The changes introduce a "Redeem" button in the swap details view, which leads to a new flow within the existing RefundSwap component. New helper methods are added to facilitate the creation of a reverse claim transaction. The logic appears sound and correctly handles both the existing refund flow and the new redeem flow. I've kept the suggestion to improve code robustness by replacing non-null assertions with explicit checks, which will make the code safer and more maintainable.

Comment thread views/Swaps/Refund.tsx
@a-khushal a-khushal force-pushed the fix/reverse-swap-claimed-redeem branch 2 times, most recently from c046bac to 22d9e2a Compare February 15, 2026 11:29
@a-khushal a-khushal force-pushed the fix/reverse-swap-claimed-redeem branch from 22d9e2a to 9234b16 Compare February 26, 2026 09:32
@a-khushal a-khushal force-pushed the fix/reverse-swap-claimed-redeem branch 3 times, most recently from 9dd68d7 to 0ede049 Compare March 24, 2026 04:21
@a-khushal
Copy link
Copy Markdown
Contributor Author

@gemini-code-assist /review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the functionality to redeem funds from restored reverse swaps, which is a great addition for improving user fund recovery. The changes are well-structured, introducing new helper functions to handle key derivation and data fetching for restored swaps, and reusing the RefundSwap screen for the new redemption flow. The logic in SwapDetails.tsx to show the redeem button at the correct swap state is also sound.

I've found one critical issue that needs to be addressed and one suggestion for improving code quality. The critical issue is a missing await which will cause the redemption flow to fail. Please see my detailed comments below.

Comment thread views/Swaps/Refund.tsx Outdated
Comment thread views/Swaps/Refund.tsx Outdated
@a-khushal a-khushal force-pushed the fix/reverse-swap-claimed-redeem branch from 0ede049 to 9dea230 Compare March 24, 2026 05:46
@a-khushal
Copy link
Copy Markdown
Contributor Author

@gemini-code-assist /review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request introduces support for reverse swaps, including updates to the Swap model for flexible preimage types and new methods in Refund.tsx to handle reverse claim transactions, such as deriving private keys, fetching transaction hex, and deriving preimage hex. The UI in Refund.tsx and SwapDetails.tsx has been updated to conditionally display options and actions relevant to reverse swaps, such as a "Redeem" button and dynamic button titles, and to use a consistent status variable for displaying swap progress. Review comments suggest simplifying the private key reconstruction logic in Refund.tsx for better readability and replacing the magic number 2 for the default fee rate with a named constant.

Comment thread views/Swaps/Refund.tsx Outdated
Comment thread views/Swaps/Refund.tsx Outdated
@a-khushal a-khushal force-pushed the fix/reverse-swap-claimed-redeem branch from 9dea230 to 026ee49 Compare March 24, 2026 05:59
@a-khushal a-khushal force-pushed the fix/reverse-swap-claimed-redeem branch from 026ee49 to 17e6355 Compare April 4, 2026 06:28
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.

1 participant