mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2026-02-23 06:54:20 +01:00
sync: correctly detect payment by refund tx ID (#470)
* sync: correctly detect payment by refund tx ID * Payment: extract get_refund_tx_id() as own method
This commit is contained in:
@@ -1271,6 +1271,16 @@ impl Payment {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn get_refund_tx_id(&self) -> Option<String> {
|
||||
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].
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user