Skip to content

fix(UX): Alert users about anchor-reserve when they try to use their max on-chain balance#1748

Merged
rolznz merged 5 commits intogetAlby:masterfrom
krrish-sehgal:fix/notify-user-about-anchor-reserve
Sep 20, 2025
Merged

fix(UX): Alert users about anchor-reserve when they try to use their max on-chain balance#1748
rolznz merged 5 commits intogetAlby:masterfrom
krrish-sehgal:fix/notify-user-about-anchor-reserve

Conversation

@krrish-sehgal
Copy link
Copy Markdown
Contributor

@krrish-sehgal krrish-sehgal commented Sep 20, 2025

Fixes #1695

Screen.Recording.2025-09-20.at.8.50.16.AM.mov

With reference to this comment, I found the Anchor reserve alert componet , whiich get triggered when user tries to use the onchain balance, that leaves less than 50k sats on-chain and not 25k , Let me know if that needs to be changed or this works.

Thanks!

@rolznz
Copy link
Copy Markdown
Contributor

rolznz commented Sep 20, 2025

@krrish-sehgal thanks for the PR, and cool you reused an existing alert. But in this case we do not show the button to allow the user to use their on-chain wallet if it would use anchor reserve funds.

I think if we remove the subtracted 25,000 at https://github.com/getAlby/hub/blob/master/frontend/src/screens/wallet/swap/SwapInStatus.tsx#L197 this will fix it.

And we should update the anchor reserve alert copy

From

You have channels open and this withdrawal may deplete your anchor
        reserves which may make it harder to close channels without depositing
        additional onchain funds to your savings balance. To avoid this, set
        aside at least {new Intl.NumberFormat().format(channels.length * 25000)}{" "}
        sats on-chain.

To

        You have channels open and by spending your entire on-chain balance including your anchor
        reserves may put your node at risk of unable to reclaim funds in your channel after a force-closure.
        To prevent this, set
        aside at least {new Intl.NumberFormat().format(channels.length * 25000)}{" "}
        sats on-chain.

@rolznz
Copy link
Copy Markdown
Contributor

rolznz commented Sep 20, 2025

Edit: I wonder if we should use a different alert instead. Because then we can also say that the user must use an external wallet since they do not have enough balance in their hub's on-chain wallet (only applicable to swaps).

@krrish-sehgal
Copy link
Copy Markdown
Contributor Author

krrish-sehgal commented Sep 20, 2025

okay, I see what you are talking about @rolznz , but this page appears after the swap in is clicked at /wallet/swap , so both "Open in External Wallet" and "Use Hub On-Chain Funds" buttons are visible, It would require to go through the boltz.exchange api , thus my regtest was failing...

In order to test it , i would either have to setup boltz-regtest(Tried and failed,cz of space constraints) or use the testnet (I am gonna try to set it up without having to sync the node)...

Any other way to bypass it?

@krrish-sehgal
Copy link
Copy Markdown
Contributor Author

krrish-sehgal commented Sep 20, 2025

Also instead of making a new component, I was thinking this could be a much better approach:

<AlertDescription>
  {isSwap ? (
    <>
      You have channels open and by spending your entire on-chain balance including your anchor
      reserves may put your node at risk of being unable to reclaim funds in your channel after a force-closure.
      You must use an external wallet since you do not have enough balance in your hub's on-chain wallet.
      To prevent this, set aside at least {new Intl.NumberFormat().format(channels.length * 25000)}{" "}
      sats on-chain.
    </>
  ) : (
    <>
      You have channels open and this withdrawal may deplete your anchor
      reserves which may make it harder to close channels without depositing
      additional onchain funds to your savings balance. To avoid this, set
      aside at least {new Intl.NumberFormat().format(channels.length * 25000)}{" "}
      sats on-chain.
    </>
  )}
</AlertDescription>

@rolznz
Copy link
Copy Markdown
Contributor

rolznz commented Sep 20, 2025

@krrish-sehgal testnet3 is basically unusable unfortunately. Boltz Regtest works well but I don't think we need to have it running for this task as we show the alert on the page beforehand.

I will change the copy a bit and also add this alert to the wallet receive (via onchain swap) page.

image image

Copy link
Copy Markdown
Contributor

@rolznz rolznz left a comment

Choose a reason for hiding this comment

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

tACK

@rolznz
Copy link
Copy Markdown
Contributor

rolznz commented Sep 20, 2025

@krrish-sehgal thanks for the initial changes, please let me know if this sounds good to you, and I'll merge the PR.

@krrish-sehgal
Copy link
Copy Markdown
Contributor Author

This seems good.. but you mentioned that we needed to remove 25k from here "https://github.com/getAlby/hub/blob/master/frontend/src/screens/wallet/swap/SwapInStatus.tsx#L197 " so that button stays visible and users get a chance to spend all the funds even tho it depletes the anchor reserve.. .

Do we not want it anymore?

@rolznz
Copy link
Copy Markdown
Contributor

rolznz commented Sep 20, 2025

This seems good.. but you mentioned that we needed to remove 25k from here "https://github.com/getAlby/hub/blob/master/frontend/src/screens/wallet/swap/SwapInStatus.tsx#L197 " so that button stays visible and users get a chance to spend all the funds even tho it depletes the anchor reserve.. .

Do we not want it anymore?

True, I guess we should remove that, then it's consistent with how the on-chain withdrawal/send works.

@rolznz
Copy link
Copy Markdown
Contributor

rolznz commented Sep 20, 2025

One thing I don't like about the current implementation is we show this warning even if the user did not plan to use their hub wallet (they planned to use an external wallet). This warning will always show if they enter an amount bigger than their current on-chain balance. But if we instead only show the warning when the user clicks the button to transfer with the hub's on-chain funds, then the user has to abort the swap and go back to change the amount and they can't see how much they can actually safely send. So I guess it's ok. At least the user sees something which is better than now where the button just disappears without warning

@krrish-sehgal
Copy link
Copy Markdown
Contributor Author

krrish-sehgal commented Sep 20, 2025

@rolznz , this surely is much better than navigating users to abort the swap and go back to square 1. Also , I have fixed the 25k condition.

Thanks!

@rolznz
Copy link
Copy Markdown
Contributor

rolznz commented Sep 20, 2025

@krrish-sehgal thank you!

@rolznz rolznz merged commit fe93d7e into getAlby:master Sep 20, 2025
6 of 10 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.

Notify the user who wants to swap-in the max on-chain balance

2 participants