From d830cac76ddde821a0fea382c366f483d9352e14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Granh=C3=A3o?= Date: Tue, 10 Oct 2023 10:41:20 +0100 Subject: [PATCH 1/4] Remove `latest_state_change_at` from `Payment` --- examples/3l-node/cli.rs | 8 -------- src/lib.rs | 2 -- src/lipalightninglib.udl | 1 - 3 files changed, 11 deletions(-) diff --git a/examples/3l-node/cli.rs b/examples/3l-node/cli.rs index 7a13ae10..b347a1f8 100644 --- a/examples/3l-node/cli.rs +++ b/examples/3l-node/cli.rs @@ -662,19 +662,11 @@ fn list_payments(node: &LightningNode) -> Result<(), String> { let timezone = FixedOffset::east_opt(payment.created_at.timezone_utc_offset_secs).unwrap(); let created_at = created_at.with_timezone(&timezone); - let latest_change_at: DateTime = payment.latest_state_change_at.time.into(); - let timezone = - FixedOffset::east_opt(payment.latest_state_change_at.timezone_utc_offset_secs).unwrap(); - let latest_change_at = latest_change_at.with_timezone(&timezone); println!( "{} payment created at {created_at} {}", payment_type.bold(), payment.created_at.timezone_id ); - println!( - "and with latest state change at {latest_change_at} {}", - payment.latest_state_change_at.timezone_id - ); println!(" State: {:?}", payment.payment_state); if payment.payment_state == PaymentState::Failed { println!(" Fail reason: {:?}", payment.fail_reason); diff --git a/src/lib.rs b/src/lib.rs index affce956..c7b89a7a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -135,7 +135,6 @@ pub struct Payment { pub amount: Amount, pub invoice_details: InvoiceDetails, pub created_at: TzTime, - pub latest_state_change_at: TzTime, pub description: String, pub preimage: Option, pub network_fees: Option, @@ -681,7 +680,6 @@ impl LightningNode { amount, invoice_details, created_at: time.clone(), - latest_state_change_at: time, // TODO: remove this field from interface description, preimage: Some(payment_details.payment_preimage), network_fees, diff --git a/src/lipalightninglib.udl b/src/lipalightninglib.udl index 9e0e33e0..7d5dd3e4 100644 --- a/src/lipalightninglib.udl +++ b/src/lipalightninglib.udl @@ -363,7 +363,6 @@ dictionary Payment { Amount amount; // Nominal amount specified in the invoice InvoiceDetails invoice_details; TzTime created_at; - TzTime latest_state_change_at; string description; // The description embedded in the invoice. Given the length limit of this data, // it is possible that a hex hash of the description is provided instead, but that is uncommon. string? preimage; // Hex representation of the preimage. Will only be present on successful payments. From c2a8d50507a632e1e41eb6dd32476bf95cd4ec18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Granh=C3=A3o?= Date: Tue, 10 Oct 2023 10:41:49 +0100 Subject: [PATCH 2/4] Update TODO comment for `fail_reason` --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index c7b89a7a..f1419002 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -675,7 +675,7 @@ impl LightningNode { Ok(Payment { payment_type, payment_state, - fail_reason: None, // TODO: Request SDK to store and provide failed payment attempts + fail_reason: None, // TODO: Request SDK to store and provide reason for failed payments hash: payment_details.payment_hash, amount, invoice_details, From bb2976fc01f9f6254d723828f60d631243d7d369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Granh=C3=A3o?= Date: Tue, 10 Oct 2023 10:42:12 +0100 Subject: [PATCH 3/4] Add doc comment to `fail_reason` --- src/lipalightninglib.udl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lipalightninglib.udl b/src/lipalightninglib.udl index 7d5dd3e4..afd9dd9e 100644 --- a/src/lipalightninglib.udl +++ b/src/lipalightninglib.udl @@ -358,7 +358,7 @@ interface MaxRoutingFeeMode { dictionary Payment { PaymentType payment_type; PaymentState payment_state; - PayErrorCode? fail_reason; + PayErrorCode? fail_reason; // For now, will always be empty string hash; // Hex representation of payment hash Amount amount; // Nominal amount specified in the invoice InvoiceDetails invoice_details; From 0fc409f579f3e036bfbb79c93a262c4a029c618a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Granh=C3=A3o?= Date: Tue, 10 Oct 2023 11:02:31 +0100 Subject: [PATCH 4/4] Fix clippy warning --- src/invoice_details.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/invoice_details.rs b/src/invoice_details.rs index 079a480f..2b05a89e 100644 --- a/src/invoice_details.rs +++ b/src/invoice_details.rs @@ -26,7 +26,7 @@ impl InvoiceDetails { amount: ln_invoice .amount_msat .map(|a| a.to_amount_down(exchange_rate)), - description: ln_invoice.description.unwrap_or(String::new()), + description: ln_invoice.description.unwrap_or_default(), payment_hash: ln_invoice.payment_hash, payee_pub_key: ln_invoice.payee_pubkey, creation_timestamp: unix_timestamp_to_system_time(ln_invoice.timestamp),