synonymdev / bitkit

Self-custodial Bitcoin and Lightning Wallet for Android and iOS.
https://bitkit.to
MIT License
116 stars 23 forks source link

UX improvement to handle when LSP is waiting on previous LN connection close tx to confirm #1910

Open catch-21 opened 4 months ago

catch-21 commented 4 months ago

Blocktank prevents additional LN channel opening that would cause the Bitkit ldk node to exceed the maximum capacity. There is a scenario where, from the Bitkit user's perspective:

It would be good to either: a) prevent establishing a CJIT whilst it is known that Blocktank will prevent this. b) present a useful error to the receiving wallet when the connection is rejected (like "please wait for previous channel close tx to confirm")

See thread: https://synonymworkspace.slack.com/archives/C0726U60V6Y/p1716987787415509

aldertnl commented 3 months ago

Proposal: Once user taps on the toggle in the above scenario, automatically switch the toggle back to the off-state, and show a toast message: Heading: 'Transfer in Progress' Paragraph: 'Please wait for the transfer from your spending balance to your savings to be completed.'

image
pwltr commented 1 month ago

Can't reproduce this, doesn't seem to me like the channel close transaction needs to be confirmed before ordering a new channel.

https://github.com/user-attachments/assets/5890c550-4d4a-4e8a-ac6e-8f969d68a648

Same with a force closed channel:

https://github.com/user-attachments/assets/891c41f2-3ef5-4b38-8756-20aa7bd91360

catch-21 commented 1 month ago

@pwltr Pretty sure this can be reproduced on mainnet. Check the link in description for deets.

catch-21 commented 1 month ago

@pwltr I can reproduce on staging.

From the receiver's perspective, the existing channel is receiving capacity is 1_583_020 (€888.78), close the channel and before confirmation produce a CJIT invoice:

https://github.com/user-attachments/assets/ee86afa7-a3a2-4554-b716-7b76b9218817

The sender cannot pay the CJIT invoice:

Screenshot 2024-08-27 at 15 23 45
pwltr commented 1 month ago

I would to opt to rely on Blocktank to return errors when making the channel order instead of keeping track of channel closing transactions. From Bitkit side the funds are immediately usable (for normal coop closes) so this would need additional logic to track confirmations of closed channels. Also this can depend on the channel size of the new channel so we shouldn't outright block transfers.

Since this is more of an edge case I think it should be handled like this:

JeanlChristophe commented 1 month ago

We can improve the error msg but let's do it later if we hve more issues.