-
Notifications
You must be signed in to change notification settings - Fork 44
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
Add additional sanity checks before starting a swap #235
Add additional sanity checks before starting a swap #235
Conversation
Since there are similarities with The following may be the scope of #81, but I mention it because I am working on it. I think it would be nice to be able to check I would appreciate your feedback. |
True, there is indeed some room for refactoring and improvement. I will refactor said methods and the interface once I know that the pr fixes @grubles problem with the swap amounts.
We can only ever give an estimate on what is spendable. For cln we can use
I would rather check before we start the swap at all, once we are at the point where we want to pay an invoice we can just do so and act accordingly if it fails. |
Oh sorry, maybe I misunderstood, of course it would be nice to check if we can pay the |
I understood.
Yes, this is what I wanted to tell you. |
Tested with unpatched CLN v23.08 node and patched LND v0.17.0-beta.rc2. Trying an impossible swap-out with unpatched node as initiator:
An impossible swap-in is rejected locally. |
This PR seems to do the right thing.
Here it sounds that Peter will refactor to check
But Yusuke said he can implement it after this is merged. Let's merge this now since it works, then you two discuss who takes the next step? |
Let me clean this up a bit so that we can merge it as is (without Is this okay for you @YusukeShimizu, @wtogami? |
Yes, I am OK. I will implement the following two features.
|
Signed-off-by: Peter Neuroth <[email protected]>
Before we invoke a swap out we check if we have enough local funds in the channel. Signed-off-by: Peter Neuroth <[email protected]>
Before we initiate a swap in, we check that we can receive the given amount via the channel. Signed-off-by: Peter Neuroth <[email protected]>
We are expecting an error message that changed due to the newly introduced sanity checks. Signed-off-by: Peter Neuroth <[email protected]>
Signed-off-by: Peter Neuroth <[email protected]>
Signed-off-by: Peter Neuroth <[email protected]>
Signed-off-by: Peter Neuroth <[email protected]>
fd66be1
to
eab7760
Compare
https://github.com/ElementsProject/peerswap/actions/runs/6177482756/job/16768697864?pr=235 |
|
Don't merge yet. I want to test a little bit more with different configurations (a CLN <> CLN channel and a LND <> LND channel). |
Looks like an impossible swap-out can still occur between two CLN nodes. Run one unpatched PeerSwap and one patched PeerSwap (both with CLN) and initiate a swap-out from the unpatched node that exceeds the channel balance. The opening tx will be broadcasted but since the unpatched node can't actually pay the other side, the swap eventually fails.
|
Successfully tested with two LND nodes (one unpatched, one patched). |
Merging Remaining Tasks
|
We add an additional check that we can spend/receive the swap amount over the desired channel before initiating a swap.