synonymdev / bitkit

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

[Bug]: Impossible to get a 2nd lightning connection #1924

Closed mattcrv closed 4 months ago

mattcrv commented 4 months ago

Describe the bug

I have one channel whose total size is at $498.71. Trying to receive my current receiving capacity + 1 sat ($448.54) doesn't trigger the CJIT flow. Adding connection doesn't work due to the 2nd channel being too big, despite both totaling $947,25.

Reproduce

  1. Try getting a 2nd channel at current bitcoin prices

Screenshots / Recording

https://github.com/synonymdev/bitkit/assets/93796166/6cac3e9b-b00c-4c5d-8363-7f5bdc168b96

Operating system

iOS 17.5.1

Bitkit version

49d1359

Log output

No response

catch-21 commented 4 months ago

I think the same occurs with self-funded LN connections:

  1. I have a existing connection with ₿713_054 inbound ($492.73 currently) (orderid: 6f4e78ba-cbc3-4ab8-a077-3b2ebd84ac1a)
  2. I attempt to create a new connection with similar inbound
  3. New connection is stuck pending with status 'Payment successful'. ₿721_553 inbound ($498.60 currently) (oriderid: 02f0c3fd-3636-4038-b584-2d89f4250f4b). Blocktank logs:
    "message":"Node capacity is above our capacity limit. Contact us for more information.","type":"CHANNEL_REJECTED_BY_LSP"
SeverinAlexB commented 4 months ago

$590.50 + $567.44 > $999

Bitkit channel calculation bug?

catch-21 commented 4 months ago

@JeanlChristophe This still needs addressing on BK side

pwltr commented 4 months ago

You have an existing channel with size 731 837 ₿. Trying to receive > 600 000 ₿ puts you over the max node capacity of (currently) 1 397 634 ₿ since total channel size must be at 2 times the client balance.

So you can't receive that amount over Lightning and we can't give you another channel for that size. Currently the UI falls back to onchain only.

mattcrv commented 4 months ago

You have an existing channel with size 731 837 ₿. Trying to receive > 600 000 ₿ puts you over the max node capacity of (currently) 1 397 634 ₿ since total channel size must be at 2 times the client balance.

So you can't receive that amount over Lightning and we can't give you another channel for that size. Currently the UI falls back to onchain only.

Hmm, gotcha. So it is possible to get a 2nd channel and receive >600 000 ₿ in total, but just as long as I don't try to receive it all at once? That is, if I first receive 590 000 ₿ and then 10 000 ₿, it should work because the 2nd channel size would be 20 000 ₿?

Fwiw I never run into these issues when receiving similar amounts on Phoenix given that they set the remote balance of new JIT channels to a fixed amount rather than 2x the local client balance.

pwltr commented 4 months ago

if I first receive 590 000 ₿ and then 10 000 ₿, it should work because the 2nd channel size would be 20 000 ₿?

Right, your first channel's size is 731 837 so that leaves you with 665 797 capacity for your node to open new channels. Since the UI only opens the CJIT flow if you try to create an invoice larger than your current remote balance, you have to receive some payments first. (In your case you could receive ~330 000, that would allow you to create another CJIT order for >328 205 client balance that is still small enough)

fixed amount rather than 2x the local client balance

that is a requirement by Blocktank