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

Expose LSP fee calculation without network request #1131

Open
gcomte opened this issue Nov 28, 2024 · 1 comment
Open

Expose LSP fee calculation without network request #1131

gcomte opened this issue Nov 28, 2024 · 1 comment

Comments

@gcomte
Copy link

gcomte commented Nov 28, 2024

We'd like the LSP fee calculation for a channel opening to be exposed, such that we can to the calculation ourselves. The calculation happens here, but as part of the function open_channel_fee it always does a network request. This is unnecessary latency for us in some situations, when we already have the LSP info.

Namely our use case is about swapping failed swaps back into lightning. In order to prepare a refund, a network request to retrieve the LSP info is required. However, to calculate the payment amount itself, we need the refund TX to know its fee. So since we already had to receive the LSP info before knowing the payment amount (it is required to learn the payment amount), all we can do to calculate the network amount is start a second network call, just to access the fee calculation, which - since we already have the LSP info - could easily be calculated locally. In fact, this local calculation is exactly what we do, by just copying the calculation logic from the Breez-SDK and do it ourselves. But it would be more maintainable if the Breez-SDK exposed that functionality instead.

@gcomte
Copy link
Author

gcomte commented Dec 3, 2024

To clarify the goal: Ultimately, we aim to fetch the OpeningFeeParams asynchronously in the background and cache them. This way, whenever we need to compute the fees for a specific amount, we can perform the calculation locally without any additional latency caused by a network request.

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

No branches or pull requests

1 participant