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

Liquid/Lightning drain #553

Merged
merged 6 commits into from
Nov 11, 2024
Merged

Liquid/Lightning drain #553

merged 6 commits into from
Nov 11, 2024

Conversation

dangeross
Copy link
Collaborator

@dangeross dangeross commented Nov 7, 2024

This PR:

  • fixes drain tx (drain tx fee estimate) to use the lowball fee
  • estimate fees for liquid/mrh/lightning with fallback to drain fees
  • attempt to fallback to drain txs for paying to liquid or send swap lockup
  • blocks draining while there are pending payments

It's difficult to add a drain option to the PrepareLnUrlPayRequest because at the point when preparing we don't know if the LNURL invoice response will contain an MRH or not for a direct Liquid tx. Because of this we can't calculate an invoice amount to drain for both options. See #559

TODO

  • Add drain option to to prepare_send_payment 80830de

Fixes #543
Fixes #550

Copy link
Contributor

@ok300 ok300 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

lib/core/src/model.rs Outdated Show resolved Hide resolved
lib/core/src/sdk.rs Outdated Show resolved Hide resolved
@roeierez
Copy link
Member

It's difficult to add a drain option to the PrepareLnUrlPayRequest because at the point when preparing we don't know if the LNURL invoice response will contain an MRH or not for a direct Liquid tx. Because of this we can't calculate an invoice amount to drain for both options.

Do you think it is reasonable to calculate for one case (let's say without routing hints) and if we get one with routing hints fetch again?

@@ -373,7 +373,7 @@ dictionary LnUrlPayRequest {

dictionary PrepareSendRequest {
string destination;
u64? amount_sat = null;
PayOnchainAmount? amount = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is a bit confusing because we use onchain for bitcoin.
do you think it makes sense to use amount_sat as before and add the drain option default to false?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the drain option should be an explicit opt-in and would be more consistent with the drain to Bitcoin. I would rather rename the PayOnchainAmount to something like DrainableAmount. Happy to revert to use the amount_sat if you prefer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps rename to SendPaymentAmount or PayAmount ?

@dangeross
Copy link
Collaborator Author

Do you think it is reasonable to calculate for one case (let's say without routing hints) and if we get one with routing hints fetch again?

I think it's a reasonable solution. I thought about just sending the drain amount to the MRH of the first invoice also, but this way seems cleaner

@dangeross dangeross merged commit 4da57e3 into main Nov 11, 2024
8 checks passed
@dangeross dangeross deleted the savage-send-payment-drain branch November 11, 2024 20:50
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

Successfully merging this pull request may close these issues.

Draining all funds with Lightning/Liquid payments Not able to send full balance via Liquid
3 participants