Skip to content

Commit

Permalink
Merge pull request #682 from getlipa/feature/breez/address-fix-todos
Browse files Browse the repository at this point in the history
Address & Fix todos
  • Loading branch information
danielgranhao authored Oct 10, 2023
2 parents eec4347 + 0fc409f commit ddc123e
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 14 deletions.
8 changes: 0 additions & 8 deletions examples/3l-node/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Utc> = 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);
Expand Down
2 changes: 1 addition & 1 deletion src/invoice_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 1 addition & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
pub network_fees: Option<Amount>,
Expand Down Expand Up @@ -676,12 +675,11 @@ 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,
created_at: time.clone(),
latest_state_change_at: time, // TODO: remove this field from interface
description,
preimage: Some(payment_details.payment_preimage),
network_fees,
Expand Down
3 changes: 1 addition & 2 deletions src/lipalightninglib.udl
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,11 @@ 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;
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.
Expand Down

0 comments on commit ddc123e

Please sign in to comment.