diff --git a/lib/core/src/model.rs b/lib/core/src/model.rs index f7a9167..3fe5f64 100644 --- a/lib/core/src/model.rs +++ b/lib/core/src/model.rs @@ -1271,6 +1271,16 @@ impl Payment { }, } } + + pub(crate) fn get_refund_tx_id(&self) -> Option { + match self.details.clone() { + Some(PaymentDetails::Lightning { refund_tx_id, .. }) => Some(refund_tx_id), + Some(PaymentDetails::Bitcoin { refund_tx_id, .. }) => Some(refund_tx_id), + Some(PaymentDetails::Liquid { .. }) => None, + None => None, + } + .flatten() + } } /// Returned when calling [crate::sdk::LiquidSdk::recommended_fees]. diff --git a/lib/core/src/sdk.rs b/lib/core/src/sdk.rs index 7701abc..9961cfb 100644 --- a/lib/core/src/sdk.rs +++ b/lib/core/src/sdk.rs @@ -1874,9 +1874,16 @@ impl LiquidSdk { .list_payments(&ListPaymentsRequest::default()) .await? .into_iter() - .filter_map(|payment| { - let tx_id = payment.tx_id.clone(); - tx_id.map(|tx_id| (tx_id, payment)) + .flat_map(|payment| { + // Index payments by both tx_id (lockup/claim) and refund_tx_id + let mut res = vec![]; + if let Some(tx_id) = payment.tx_id.clone() { + res.push((tx_id, payment.clone())); + } + if let Some(refund_tx_id) = payment.get_refund_tx_id() { + res.push((refund_tx_id, payment)); + } + res }) .collect(); if with_scan {