Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
joostjager committed Jan 23, 2025
1 parent 0a5baa4 commit 6b131b1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion bindings/python/src/ldk_node/test_ldk_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def test_channel_full_cycle(self):
print("EVENT:", channel_ready_event_2)
node_2.event_handled()

description = Bolt11InvoiceStringDescription.DIRECT("asdf")
description = Bolt11InvoiceDescription.DIRECT("asdf")
invoice = node_2.bolt11_payment().receive(2500000, description, 9217)
node_1.bolt11_payment().send(invoice, None)

Expand Down
44 changes: 26 additions & 18 deletions src/payment/bolt11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ impl Bolt11Payment {
/// The inbound payment will be automatically claimed upon arrival.
#[cfg(not(feature = "uniffi"))]
pub fn receive(
&self, amount_msat: u64, description: &lightning_invoice::Bolt11InvoiceDescription, expiry_secs: u32,
&self, amount_msat: u64, description: &lightning_invoice::Bolt11InvoiceDescription,
expiry_secs: u32,
) -> Result<Bolt11Invoice, Error> {
self.receive_inner(Some(amount_msat), description, expiry_secs, None)
}
Expand All @@ -416,7 +417,8 @@ impl Bolt11Payment {
pub fn receive(
&self, amount_msat: u64, description: &Bolt11InvoiceDescription, expiry_secs: u32,
) -> Result<Bolt11Invoice, Error> {
let invoice_description = lightning_invoice::Bolt11InvoiceDescription::try_from(description)?;
let invoice_description =
lightning_invoice::Bolt11InvoiceDescription::try_from(description)?;
self.receive_inner(Some(amount_msat), &invoice_description, expiry_secs, None)
}

Expand All @@ -436,8 +438,8 @@ impl Bolt11Payment {
/// [`fail_for_hash`]: Self::fail_for_hash
#[cfg(not(feature = "uniffi"))]
pub fn receive_for_hash(
&self, amount_msat: u64, description: &lightning_invoice::Bolt11InvoiceDescription, expiry_secs: u32,
payment_hash: PaymentHash,
&self, amount_msat: u64, description: &lightning_invoice::Bolt11InvoiceDescription,
expiry_secs: u32, payment_hash: PaymentHash,
) -> Result<Bolt11Invoice, Error> {
self.receive_inner(Some(amount_msat), description, expiry_secs, Some(payment_hash))
}
Expand All @@ -447,7 +449,8 @@ impl Bolt11Payment {
&self, amount_msat: u64, description: &Bolt11InvoiceDescription, expiry_secs: u32,
payment_hash: PaymentHash,
) -> Result<Bolt11Invoice, Error> {
let invoice_description = lightning_invoice::Bolt11InvoiceDescription::try_from(description)?;
let invoice_description =
lightning_invoice::Bolt11InvoiceDescription::try_from(description)?;
self.receive_inner(Some(amount_msat), &invoice_description, expiry_secs, Some(payment_hash))
}

Expand All @@ -466,7 +469,8 @@ impl Bolt11Payment {
pub fn receive_variable_amount(
&self, description: &Bolt11InvoiceDescription, expiry_secs: u32,
) -> Result<Bolt11Invoice, Error> {
let invoice_description = lightning_invoice::Bolt11InvoiceDescription::try_from(description)?;
let invoice_description =
lightning_invoice::Bolt11InvoiceDescription::try_from(description)?;
self.receive_inner(None, &invoice_description, expiry_secs, None)
}

Expand All @@ -486,23 +490,25 @@ impl Bolt11Payment {
/// [`fail_for_hash`]: Self::fail_for_hash
#[cfg(not(feature = "uniffi"))]
pub fn receive_variable_amount_for_hash(
&self, description: &lightning_invoice::Bolt11InvoiceDescription, expiry_secs: u32, payment_hash: PaymentHash,
&self, description: &lightning_invoice::Bolt11InvoiceDescription, expiry_secs: u32,
payment_hash: PaymentHash,
) -> Result<Bolt11Invoice, Error> {
self.receive_inner(None, description, expiry_secs, Some(payment_hash))
}

#[cfg(feature = "uniffi")]
pub fn receive_variable_amount_for_hash(
&self, description: &Bolt11InvoiceDescription, expiry_secs: u32,
payment_hash: PaymentHash,
&self, description: &Bolt11InvoiceDescription, expiry_secs: u32, payment_hash: PaymentHash,
) -> Result<Bolt11Invoice, Error> {
let invoice_description = lightning_invoice::Bolt11InvoiceDescription::try_from(description)?;
let invoice_description =
lightning_invoice::Bolt11InvoiceDescription::try_from(description)?;
self.receive_inner(None, &invoice_description, expiry_secs, Some(payment_hash))
}

pub(crate) fn receive_inner(
&self, amount_msat: Option<u64>, invoice_description: &lightning_invoice::Bolt11InvoiceDescription,
expiry_secs: u32, manual_claim_payment_hash: Option<PaymentHash>,
&self, amount_msat: Option<u64>,
invoice_description: &lightning_invoice::Bolt11InvoiceDescription, expiry_secs: u32,
manual_claim_payment_hash: Option<PaymentHash>,
) -> Result<Bolt11Invoice, Error> {
let invoice = {
let invoice_params = Bolt11InvoiceParameters {
Expand Down Expand Up @@ -569,8 +575,8 @@ impl Bolt11Payment {
/// [LSPS2]: https://github.com/BitcoinAndLightningLayerSpecs/lsp/blob/main/LSPS2/README.md
#[cfg(not(feature = "uniffi"))]
pub fn receive_via_jit_channel(
&self, amount_msat: u64, description: &lightning_invoice::Bolt11InvoiceDescription, expiry_secs: u32,
max_total_lsp_fee_limit_msat: Option<u64>,
&self, amount_msat: u64, description: &lightning_invoice::Bolt11InvoiceDescription,
expiry_secs: u32, max_total_lsp_fee_limit_msat: Option<u64>,
) -> Result<Bolt11Invoice, Error> {
self.receive_via_jit_channel_inner(
Some(amount_msat),
Expand All @@ -586,7 +592,8 @@ impl Bolt11Payment {
&self, amount_msat: u64, description: &Bolt11InvoiceDescription, expiry_secs: u32,
max_total_lsp_fee_limit_msat: Option<u64>,
) -> Result<Bolt11Invoice, Error> {
let invoice_description = lightning_invoice::Bolt11InvoiceDescription::try_from(description)?;
let invoice_description =
lightning_invoice::Bolt11InvoiceDescription::try_from(description)?;
self.receive_via_jit_channel_inner(
Some(amount_msat),
&invoice_description,
Expand Down Expand Up @@ -626,7 +633,8 @@ impl Bolt11Payment {
&self, description: &Bolt11InvoiceDescription, expiry_secs: u32,
max_proportional_lsp_fee_limit_ppm_msat: Option<u64>,
) -> Result<Bolt11Invoice, Error> {
let invoice_description = lightning_invoice::Bolt11InvoiceDescription::try_from(description)?;
let invoice_description =
lightning_invoice::Bolt11InvoiceDescription::try_from(description)?;
self.receive_via_jit_channel_inner(
None,
&invoice_description,
Expand All @@ -637,8 +645,8 @@ impl Bolt11Payment {
}

fn receive_via_jit_channel_inner(
&self, amount_msat: Option<u64>, description: &lightning_invoice::Bolt11InvoiceDescription, expiry_secs: u32,
max_total_lsp_fee_limit_msat: Option<u64>,
&self, amount_msat: Option<u64>, description: &lightning_invoice::Bolt11InvoiceDescription,
expiry_secs: u32, max_total_lsp_fee_limit_msat: Option<u64>,
max_proportional_lsp_fee_limit_ppm_msat: Option<u64>,
) -> Result<Bolt11Invoice, Error> {
let liquidity_source =
Expand Down

0 comments on commit 6b131b1

Please sign in to comment.