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

feat(ln-client): make LN gateway known upfront #3882

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

elsirion
Copy link
Contributor

@elsirion elsirion commented Dec 8, 2023

Otherwise, fees that will be paid cannot be shown to users upfront.

Comment on lines 1007 to 1028
/// Pays a LN invoice with our available funds using the supplied `gateway`.
///
/// The `gateway` can be acquired by calling
/// [`LightningClientModule::select_active_gateway`].
pub async fn pay_bolt11_invoice<M: Serialize + MaybeSend + MaybeSync>(
&self,
gateway: LightningGateway,
invoice: Bolt11Invoice,
extra_meta: M,
) -> anyhow::Result<OutgoingLightningPayment> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the important part, everything else is just fixing up tests.

justinmoon
justinmoon previously approved these changes Dec 8, 2023
Copy link
Contributor

@justinmoon justinmoon 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, but seems like a lightning test is failing

Should we do the same thing to create_bolt11_invoice?

Copy link

codecov bot commented Dec 9, 2023

Codecov Report

Attention: 20 lines in your changes are missing coverage. Please review.

Comparison is base (b891544) 57.09% compared to head (12d572f) 57.04%.
Report is 29 commits behind head on master.

Files Patch % Lines
fedimint-load-test-tool/src/main.rs 0.00% 10 Missing ⚠️
fedimint-cli/src/client.rs 0.00% 4 Missing ⚠️
fedimint-load-test-tool/src/common.rs 0.00% 4 Missing ⚠️
fedimint-wasm-tests/src/lib.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3882      +/-   ##
==========================================
- Coverage   57.09%   57.04%   -0.06%     
==========================================
  Files         193      193              
  Lines       42649    42929     +280     
==========================================
+ Hits        24351    24488     +137     
- Misses      18298    18441     +143     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@elsirion
Copy link
Contributor Author

Turns out we have tests for being able to pay internal invoices even if no LN GW is present (which is probably good). I'm trying a new, minimal approach, but longer term we need to think about how to best pull that pay fn apart so that users can be better informed.

@elsirion elsirion marked this pull request as ready for review December 10, 2023 14:25
@elsirion elsirion requested review from a team as code owners December 10, 2023 14:25
let OutgoingLightningPayment {
payment_type,
contract_id,
fee: _,
} = user_lightning_module
.pay_bolt11_invoice(invoice.clone(), ())
.pay_bolt11_invoice(gateway, invoice.clone(), ())
Copy link
Contributor

Choose a reason for hiding this comment

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

why not call pay_invoice here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I got tired of repeating the same code after a while, introduced the fn but forgot that one.

@@ -254,11 +254,14 @@ pub async fn handle_command(
let lightning_module = client.get_first_module::<LightningClientModule>();
lightning_module.select_active_gateway().await?;

let gateway = lightning_module.select_active_gateway().await.ok();
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like that you're ignoring the error everywhere. Perhaps create a opt_select_active_gateway that returns an Option but also logs as a warning the error returned by select_active_gateway?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was a bit unsure about this, the reason why it's an option in the first place is that we currently have support for internal payments without a gateway being present. So it wasn't entirely clear to me if thats something we'd want to warn about till it's an actual problem. But you are right that it makes debugging the root cause harder, so will add it.

Otherwise, fees that will be paid cannot be
shown to users upfront.
@elsirion elsirion added this pull request to the merge queue Dec 13, 2023
Merged via the queue into fedimint:master with commit 9b906d2 Dec 13, 2023
20 checks passed
@elsirion elsirion deleted the 2023-12-selectable-gw branch December 13, 2023 14:30
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.

None yet

4 participants