diff --git a/libs/sdk-bindings/src/breez_sdk.udl b/libs/sdk-bindings/src/breez_sdk.udl index fa821055b..b188a841a 100644 --- a/libs/sdk-bindings/src/breez_sdk.udl +++ b/libs/sdk-bindings/src/breez_sdk.udl @@ -331,6 +331,7 @@ dictionary LogEntry { dictionary InvoicePaidDetails { string payment_hash; string bolt11; + Payment? payment; }; dictionary PaymentFailedData { diff --git a/libs/sdk-core/src/breez_services.rs b/libs/sdk-core/src/breez_services.rs index 0c29259a5..6d622cc8a 100644 --- a/libs/sdk-core/src/breez_services.rs +++ b/libs/sdk-core/src/breez_services.rs @@ -106,6 +106,7 @@ pub struct PaymentFailedData { pub struct InvoicePaidDetails { pub payment_hash: String, pub bolt11: String, + pub payment: Option, } pub trait LogStream: Send + Sync { @@ -1134,7 +1135,7 @@ impl BreezServices { if payment.is_some() { let res = cloned .persister - .insert_or_update_payments(&vec![payment.unwrap()]); + .insert_or_update_payments(&vec![payment.clone().unwrap()]); debug!("paid invoice was added to payments list {:?}", res); } if let Err(e) = cloned.do_sync(true).await { @@ -1144,6 +1145,7 @@ impl BreezServices { details: InvoicePaidDetails { payment_hash: hex::encode(p.payment_hash), bolt11: p.bolt11, + payment, }, }).await; } diff --git a/libs/sdk-core/src/bridge_generated.rs b/libs/sdk-core/src/bridge_generated.rs index b2e1f9a3e..49ff7fcc3 100644 --- a/libs/sdk-core/src/bridge_generated.rs +++ b/libs/sdk-core/src/bridge_generated.rs @@ -1117,6 +1117,7 @@ impl support::IntoDart for InvoicePaidDetails { vec![ self.payment_hash.into_into_dart().into_dart(), self.bolt11.into_into_dart().into_dart(), + self.payment.into_dart(), ] .into_dart() } diff --git a/libs/sdk-core/src/swap_in/swap.rs b/libs/sdk-core/src/swap_in/swap.rs index 160161157..371cf5a48 100644 --- a/libs/sdk-core/src/swap_in/swap.rs +++ b/libs/sdk-core/src/swap_in/swap.rs @@ -910,6 +910,7 @@ mod tests { details: crate::InvoicePaidDetails { payment_hash: hex::encode(swap_info.payment_hash.clone()), bolt11: "".to_string(), + payment: None, }, }) .await?; diff --git a/libs/sdk-flutter/lib/bridge_generated.dart b/libs/sdk-flutter/lib/bridge_generated.dart index 31adc4c60..712cf1054 100644 --- a/libs/sdk-flutter/lib/bridge_generated.dart +++ b/libs/sdk-flutter/lib/bridge_generated.dart @@ -583,10 +583,12 @@ sealed class InputType with _$InputType { class InvoicePaidDetails { final String paymentHash; final String bolt11; + final Payment? payment; const InvoicePaidDetails({ required this.paymentHash, required this.bolt11, + this.payment, }); } @@ -2802,10 +2804,11 @@ class BreezSdkCoreImpl implements BreezSdkCore { InvoicePaidDetails _wire2api_invoice_paid_details(dynamic raw) { final arr = raw as List; - if (arr.length != 2) throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); + if (arr.length != 3) throw Exception('unexpected arr length: expect 3 but see ${arr.length}'); return InvoicePaidDetails( paymentHash: _wire2api_String(arr[0]), bolt11: _wire2api_String(arr[1]), + payment: _wire2api_opt_box_autoadd_payment(arr[2]), ); } diff --git a/libs/sdk-react-native/android/src/main/java/com/breezsdk/BreezSDKMapper.kt b/libs/sdk-react-native/android/src/main/java/com/breezsdk/BreezSDKMapper.kt index b5da1d145..9bca21a38 100644 --- a/libs/sdk-react-native/android/src/main/java/com/breezsdk/BreezSDKMapper.kt +++ b/libs/sdk-react-native/android/src/main/java/com/breezsdk/BreezSDKMapper.kt @@ -633,9 +633,11 @@ fun asInvoicePaidDetails(invoicePaidDetails: ReadableMap): InvoicePaidDetails? { } val paymentHash = invoicePaidDetails.getString("paymentHash")!! val bolt11 = invoicePaidDetails.getString("bolt11")!! + val payment = if (hasNonNullKey(invoicePaidDetails, "payment")) invoicePaidDetails.getMap("payment")?.let { asPayment(it) } else null return InvoicePaidDetails( paymentHash, bolt11, + payment, ) } @@ -643,6 +645,7 @@ fun readableMapOf(invoicePaidDetails: InvoicePaidDetails): ReadableMap { return readableMapOf( "paymentHash" to invoicePaidDetails.paymentHash, "bolt11" to invoicePaidDetails.bolt11, + "payment" to invoicePaidDetails.payment?.let { readableMapOf(it) }, ) } diff --git a/libs/sdk-react-native/ios/BreezSDKMapper.swift b/libs/sdk-react-native/ios/BreezSDKMapper.swift index 099b49069..637825638 100644 --- a/libs/sdk-react-native/ios/BreezSDKMapper.swift +++ b/libs/sdk-react-native/ios/BreezSDKMapper.swift @@ -565,10 +565,15 @@ class BreezSDKMapper { static func asInvoicePaidDetails(invoicePaidDetails: [String: Any?]) throws -> InvoicePaidDetails { guard let paymentHash = invoicePaidDetails["paymentHash"] as? String else { throw SdkError.Generic(message: "Missing mandatory field paymentHash for type InvoicePaidDetails") } guard let bolt11 = invoicePaidDetails["bolt11"] as? String else { throw SdkError.Generic(message: "Missing mandatory field bolt11 for type InvoicePaidDetails") } + var payment: Payment? + if let paymentTmp = invoicePaidDetails["payment"] as? [String: Any?] { + payment = try asPayment(payment: paymentTmp) + } return InvoicePaidDetails( paymentHash: paymentHash, - bolt11: bolt11 + bolt11: bolt11, + payment: payment ) } @@ -576,6 +581,7 @@ class BreezSDKMapper { return [ "paymentHash": invoicePaidDetails.paymentHash, "bolt11": invoicePaidDetails.bolt11, + "payment": invoicePaidDetails.payment == nil ? nil : dictionaryOf(payment: invoicePaidDetails.payment!), ] } diff --git a/libs/sdk-react-native/src/index.ts b/libs/sdk-react-native/src/index.ts index 9df023e59..6b6cf01b9 100644 --- a/libs/sdk-react-native/src/index.ts +++ b/libs/sdk-react-native/src/index.ts @@ -109,6 +109,7 @@ export type GreenlightNodeConfig = { export type InvoicePaidDetails = { paymentHash: string bolt11: string + payment?: Payment } export type LnInvoice = {