From 9d81ac6873feb49cf821ac31eb25382f8a7e5a74 Mon Sep 17 00:00:00 2001 From: Fmt Bot Date: Sun, 1 Feb 2026 02:07:32 +0000 Subject: [PATCH] 2026-02-01 automated rustfmt nightly --- src/payment/pending_payment_store.rs | 186 +++++++++++++-------------- 1 file changed, 93 insertions(+), 93 deletions(-) diff --git a/src/payment/pending_payment_store.rs b/src/payment/pending_payment_store.rs index 580bdcbcc..5fef8d14a 100644 --- a/src/payment/pending_payment_store.rs +++ b/src/payment/pending_payment_store.rs @@ -1,93 +1,93 @@ -// This file is Copyright its original authors, visible in version control history. -// -// This file is licensed under the Apache License, Version 2.0 or the MIT license , at your option. You may not use this file except in -// accordance with one or both of these licenses. - -use bitcoin::Txid; -use lightning::{impl_writeable_tlv_based, ln::channelmanager::PaymentId}; - -use crate::{ - data_store::{StorableObject, StorableObjectUpdate}, - payment::{store::PaymentDetailsUpdate, PaymentDetails}, -}; - -/// Represents a pending payment -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct PendingPaymentDetails { - /// The full payment details - pub details: PaymentDetails, - /// Transaction IDs that have replaced or conflict with this payment. - pub conflicting_txids: Vec, -} - -impl PendingPaymentDetails { - pub(crate) fn new(details: PaymentDetails, conflicting_txids: Vec) -> Self { - Self { details, conflicting_txids } - } - - /// Convert to finalized payment for the main payment store - pub fn into_payment_details(self) -> PaymentDetails { - self.details - } -} - -impl_writeable_tlv_based!(PendingPaymentDetails, { - (0, details, required), - (2, conflicting_txids, optional_vec), -}); - -#[derive(Clone, Debug, PartialEq, Eq)] -pub(crate) struct PendingPaymentDetailsUpdate { - pub id: PaymentId, - pub payment_update: Option, - pub conflicting_txids: Option>, -} - -impl StorableObject for PendingPaymentDetails { - type Id = PaymentId; - type Update = PendingPaymentDetailsUpdate; - - fn id(&self) -> Self::Id { - self.details.id - } - - fn update(&mut self, update: &Self::Update) -> bool { - let mut updated = false; - - // Update the underlying payment details if present - if let Some(payment_update) = &update.payment_update { - updated |= self.details.update(payment_update); - } - - if let Some(new_conflicting_txids) = &update.conflicting_txids { - if &self.conflicting_txids != new_conflicting_txids { - self.conflicting_txids = new_conflicting_txids.clone(); - updated = true; - } - } - - updated - } - - fn to_update(&self) -> Self::Update { - self.into() - } -} - -impl StorableObjectUpdate for PendingPaymentDetailsUpdate { - fn id(&self) -> ::Id { - self.id - } -} - -impl From<&PendingPaymentDetails> for PendingPaymentDetailsUpdate { - fn from(value: &PendingPaymentDetails) -> Self { - Self { - id: value.id(), - payment_update: Some(value.details.to_update()), - conflicting_txids: Some(value.conflicting_txids.clone()), - } - } -} +// This file is Copyright its original authors, visible in version control history. +// +// This file is licensed under the Apache License, Version 2.0 or the MIT license , at your option. You may not use this file except in +// accordance with one or both of these licenses. + +use bitcoin::Txid; +use lightning::impl_writeable_tlv_based; +use lightning::ln::channelmanager::PaymentId; + +use crate::data_store::{StorableObject, StorableObjectUpdate}; +use crate::payment::store::PaymentDetailsUpdate; +use crate::payment::PaymentDetails; + +/// Represents a pending payment +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct PendingPaymentDetails { + /// The full payment details + pub details: PaymentDetails, + /// Transaction IDs that have replaced or conflict with this payment. + pub conflicting_txids: Vec, +} + +impl PendingPaymentDetails { + pub(crate) fn new(details: PaymentDetails, conflicting_txids: Vec) -> Self { + Self { details, conflicting_txids } + } + + /// Convert to finalized payment for the main payment store + pub fn into_payment_details(self) -> PaymentDetails { + self.details + } +} + +impl_writeable_tlv_based!(PendingPaymentDetails, { + (0, details, required), + (2, conflicting_txids, optional_vec), +}); + +#[derive(Clone, Debug, PartialEq, Eq)] +pub(crate) struct PendingPaymentDetailsUpdate { + pub id: PaymentId, + pub payment_update: Option, + pub conflicting_txids: Option>, +} + +impl StorableObject for PendingPaymentDetails { + type Id = PaymentId; + type Update = PendingPaymentDetailsUpdate; + + fn id(&self) -> Self::Id { + self.details.id + } + + fn update(&mut self, update: &Self::Update) -> bool { + let mut updated = false; + + // Update the underlying payment details if present + if let Some(payment_update) = &update.payment_update { + updated |= self.details.update(payment_update); + } + + if let Some(new_conflicting_txids) = &update.conflicting_txids { + if &self.conflicting_txids != new_conflicting_txids { + self.conflicting_txids = new_conflicting_txids.clone(); + updated = true; + } + } + + updated + } + + fn to_update(&self) -> Self::Update { + self.into() + } +} + +impl StorableObjectUpdate for PendingPaymentDetailsUpdate { + fn id(&self) -> ::Id { + self.id + } +} + +impl From<&PendingPaymentDetails> for PendingPaymentDetailsUpdate { + fn from(value: &PendingPaymentDetails) -> Self { + Self { + id: value.id(), + payment_update: Some(value.details.to_update()), + conflicting_txids: Some(value.conflicting_txids.clone()), + } + } +}