-
Notifications
You must be signed in to change notification settings - Fork 153
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
UI to balance LN channels #859
Conversation
I need some help here. After fixing the mentioned bug, I can add tests and finish the remaining work in the PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to auto-balance the channel I got the error
Insufficient balance
, but this should not happen since the source has more than enough funds to pay the target and that can be confirmed by logging the amounts in the console.
I tested this PR and it's working fine for me. I'm not sure why you're getting that error on your end. Can you share more of the LND logs from one of the nodes?
Since it works for me, I left some feedback on the code.
f473d7a
to
01e3f8c
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #859 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 154 156 +2
Lines 5571 5694 +123
Branches 1129 1095 -34
==========================================
+ Hits 5571 5694 +123 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@jamaljsr I addressed nearly all issues except the dropdown menu. I can implement tests for the added functionality, but I stil get the following error:
You said it worked on your side, so I ask you to test again. I'll try to figure out why it is not working on my machine. Actually, I'm getting some buggy behavior unrelated to the PR: sometimes I can't click on anything, which I suppose not to be a polar bug but a bug with electron due to my window manager. |
I'll be back to it in a few days. |
Hey @uwla are you planning to continue to work on this PR? I took a look at your latest changes and noticed what is causing the promisesToAwait.push(
createInvoice({ node: target, amount }).then(invoice =>
payInvoice({ node: source, amount, invoice }),
),
); |
Thanks @jamaljsr ! I am back to the PR, working on it today |
I got some problems:
After playing a bit, I found out I am also getting the same behavior when generating and paying invoices manually with the mentioned implementations: Create invoice -> Copy and Close -> Pay invoices. The only which works pretty well is LND to LND. |
Thanks for the details on the issues your facing. I think I've found solutions to your outstanding problems.
I had to dive pretty deep into the weeds to figure this one out. I was able to reproduce the behavior on my end as well. The problem is essentially a configuration issue on the Eclair side. By default, it won't let you make a single payment that is more than 45% of the channel capacity. Check the reference.conf for a more detailed explanation. It would be nice if Eclair logged a clearer error message, but it doesn't. When I changed this to 100%, then Eclair began behaving correctly.
Copy this config value into the default Eclair startup flags in constants.ts.
This error is actually saying that you should not provide the The API Docs state: "The pay RPC command attempts to find a route to the given destination, and send the funds it asks for. If the bolt11 does not contain an amount, amount_msat is required, otherwise if it is specified it must be null." I also saw this error in my testing and remove the |
After testing this a bit more, I feel like immediately balancing the channels when the button is clicked can be a bit unexpected. It would be very cool if it instead displayed a modal with the details of the payments that will be made on each channel. Then when the Submit button in the modal is clicked, the channels would get balanced. What do you think about this idea? |
@jamaljsr I think it is a good idea. So, we show a modal and for each channel:
After all channels, we add a button on the bottom "auto balance all channels", which will autobalance the preview values. Finally, at the very bottom, a CONFIRM button an a CANCEL button. If user confirms, each channel will be updated in batch if needed. Otherwise the modal is hidden and its state reset. What about it now? |
I can create the modal and add some tests for the coverage not to drop. However, I have been facing an weird issue while developing polar locally: after launching the live Electron app, a lot of times I can not click on buttons, and the cursor icon does not alter (it is the same as normal, instead of a click pointer). This has been the most headache thing, because I have to open the devtools and do something like |
After writing the above response, I did a quick google search and found the cause of the issue. It is the |
@jamaljsr I have sync my fork and now the bug is fixed. I'm working on the dropdown menu and the modal. |
Hey @jamaljsr, when creating a 250,000 sats channels, which is the default, I noticed if the implementation is LND, then the source starts with 246530 sats and the target 0 sats. Where are the missing sats? |
01e3f8c
to
cb98bbe
Compare
I have not finished the PR, but I pushed it anyway so you can see how it is going. I added the dropdown and the modal. I still need to: implement business logic, add tests, code styling refactoring. |
Thanks for the update. I will check it out over the next few days. |
I'll add business logic today. The laast PR added UI, but it did not implement any logic |
Sorry, I forgot to answer this question. The balance is decreased by the fee for the commitment transaction and the amount allocated to the anchor output, since Anchor channels are created by default in LND. You can use For example, here's the output for one 250K sat channel I just created.
The balance breakdown is as follows:
|
cb98bbe
to
4cd78dd
Compare
Thanks @jamaljsr for the updates. My last push had some UI improvements. I will implement business logic tomorrow, by adding a new store action. Things are working pretty well now that I can click buttons and test things with hot-reload, after fixing the react overlay bug. |
With the last push, it is WORKING! At least with LND nodes. It stills does not work well with Clightning and Eclair due to the mentioned bugs, which we were discussing previously. Now, what remains:
@jamaljsr I need your help with (1), since you know what is causing it. I also need your opinion with (4), because I am not familiar with Polar's preferences for code style, where the added functions and interfaces should be placed. |
Did you apply the fixes I mentioned in this prior comment? This resolved the Core Lightning and Eclair issues for me.
I will review your latest changes by tomorrow for sure. |
I'll solve the issues with Eclair and Clightning as you explained before @jamaljsr |
Some updates here. So, I have changed the
I created a new network with 1 LND, 1 Clightning and 1 Eclair. Still got 3 types of errors, specially when trying to transact the whole amount:
The Eclair node is unable to find a "route" to a node it is directly connected? And the Clightning too. Also, even though I have passed the flags to the default Eclair flags, it still says "balance is too low" when the remaining balance is 0. When leaving each channel with at least around 1000 satoshis it works and the "too low" error does not show up, but sometimes the "route not found" error does happen. The Eclair and Clightning implementation are not good compared to LND |
4cd78dd
to
49be98d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @uwla thanks for updating this. Apologies for taking so long to review.
I tested the functionality and it works great! I also reviewed all of the code and don't have any further suggestions there.
The only thing left to do is to get the tests passing and coverage back up to 100%. Are you able to work on this in order to get this PR merged?
Hi @jamaljsr I'll try to find some free time on the coming weeks and attempt to get the tests passing. I hope I'll be able to get coverage back to 100% and will post updates here if help is needed |
Hi @jamaljsr . It's been over 1 month and I have been very busy, so unfortunately I won't be able to work on adding tests soon ( Can you delegate/assign the commit which adds tests to somebody else? But please, let me have the credits in the git history for the commit which adds the feature itself. |
Hey @uwla, I appreciate the update. I'll work on adding the tests when time permits. I will retain your existing commits in the git history. |
Hey @Jem256, yes please feel free to add the tests. Thank you 🙏 |
Hey @uwla I added tests for this feature. Please check out my PR on your branch |
thanks @Jem256 for the contribution, I had forgotten about this. Let us make this feature done. While I have not used Polar for a while, tt is likely I will need this software soon. So, if anything is needed from my side, I will be glad to help and potentially make more contributions to this software 👍 |
We have got it passed @jamaljsr Nonethless, I have not manually tested the UI for the last commits. |
The modal has slicers to manually balance LN channels. It also has a button to evenly balance the channels.
In this commit we add a role to the balance channel button so we can target it in the next commit and test.
This commit then tests the button and its intended functionlities
In this commit we did a little refactor to the BalanceChannelsModal component to make it easier to test, which we will do in the next commit.
In this commit we test the refactored BalanceChannelsModal component, to cover for the function call.
Since channelsInfo is always an array and we loop through it before anything means if it's empty we just do nothing. Also this makes it easier to test.
This commit tests for when resetChannelsInfo was called on a channel with invalid id or a node withing the channel that has no valid id for its 'to' node.
In this commit we test for when we try to manually try to update the channel balance but passed in invalid index.
ff813a2
to
e390da4
Compare
Thanks for wrapping this up @uwla @Jem256 @Abdulkbk 🙏 I have rebased this on This now looks good to merge. 🚀 |
Solves #831.
NOTE: work in progress, implementation not ready yet.
Done
To do
Help needed here.
Trying to auto-balance the channel I got the error
Insufficient balance
, but this should not happen since the source has more than enough funds to pay the target and that can be confirmed by logging the amounts in the console.I decided to open the PR anyway, so I can get help with the bug.