Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanity check channel balance prior to swap #81

Closed
wtogami opened this issue Jun 27, 2022 · 2 comments · Fixed by #246
Closed

Sanity check channel balance prior to swap #81

wtogami opened this issue Jun 27, 2022 · 2 comments · Fixed by #246

Comments

@wtogami
Copy link
Contributor

wtogami commented Jun 27, 2022

Prior to starting a swap, and again prior to sending, check the channel's max htlc limit to verify that the requested swap would actually be possible. Print informative error messages otherwise.

Related: #73

@wtogami wtogami added this to the v0.3.0 milestone Jun 27, 2022
@nepet nepet self-assigned this Jul 11, 2022
@nepet
Copy link
Contributor

nepet commented Sep 29, 2022

Why

So this issue is a little bit paranoid but we want to do everything we can to avoid canceled swaps, especially swap-out swaps as the responder is in charge of the on-chain part.
The following assumes a swap-out but same applies symmetrically for a swap-in:
Currently we only check that we have enough local balance (our_amount_msat) to perform the swap. This check is not strong enough as we could have set a htlc_maximum_msat that is below our local balance.

Solution

We want to check that min(htlc_maximum_msat, our_amount_msat) > swap_amt_msat + fees
Best place to check that would be after we received the swap_out_agreement that contains the "fee_invoice". We may still want to perform the same check without the fees before we initiate a swap.

@nepet nepet removed their assignment Sep 29, 2022
@wtogami wtogami removed this from the v0.3.0 milestone Jul 14, 2023
@wtogami
Copy link
Contributor Author

wtogami commented Jul 14, 2023

It would be nice to fix this because it would prevent guaranteed-to-fail onchain transactions and spamming the swap database.

@wtogami wtogami changed the title Channel sanity checks Sanity check channel balance prior to swap Sep 5, 2023
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 a pull request may close this issue.

2 participants