diff --git a/libs/sdk-bindings/src/breez_sdk.udl b/libs/sdk-bindings/src/breez_sdk.udl index 9a3bd1ecc..98c11b249 100644 --- a/libs/sdk-bindings/src/breez_sdk.udl +++ b/libs/sdk-bindings/src/breez_sdk.udl @@ -86,7 +86,7 @@ enum SendPaymentError { "RouteNotFound", "RouteTooExpensive", "ServiceConnectivity", - "OfferAmountChanged", + "OfferChanged", }; enum EnvironmentType { diff --git a/libs/sdk-core/src/breez_services.rs b/libs/sdk-core/src/breez_services.rs index ed035f82c..ab9761604 100644 --- a/libs/sdk-core/src/breez_services.rs +++ b/libs/sdk-core/src/breez_services.rs @@ -1391,8 +1391,8 @@ impl BreezServices { }) .await?; - if let Some(new_amount) = fetch_invoice_response.new_amount_msat { - return Err(SendPaymentError::OfferAmountChanged { new_amount }); + if let Some(changes) = fetch_invoice_response.changes { + return Err(SendPaymentError::OfferChanged { changes }); } Ok(self.send_payment(SendPaymentRequest { diff --git a/libs/sdk-core/src/error.rs b/libs/sdk-core/src/error.rs index d36fa4fc9..5813b3692 100644 --- a/libs/sdk-core/src/error.rs +++ b/libs/sdk-core/src/error.rs @@ -4,7 +4,7 @@ use thiserror::Error; use crate::{ invoice::InvoiceError, lnurl::error::LnUrlError, node_api::NodeError, - persist::error::PersistError, swap_in::error::SwapError, swap_out::error::ReverseSwapError, + persist::error::PersistError, swap_in::error::SwapError, swap_out::error::ReverseSwapError, FetchInvoiceChanges, }; pub type SdkResult = Result; @@ -589,8 +589,8 @@ pub enum SendPaymentError { #[error("Service connectivity: {err}")] ServiceConnectivity { err: String }, - #[error("Amount has changed: {new_amount}")] - OfferAmountChanged { new_amount: u64 }, + #[error("Offer has changed: {changes:?}")] + OfferChanged { changes: FetchInvoiceChanges }, } impl From for SendPaymentError { diff --git a/libs/sdk-core/src/greenlight/node_api.rs b/libs/sdk-core/src/greenlight/node_api.rs index 1f4a1ba69..9be653768 100644 --- a/libs/sdk-core/src/greenlight/node_api.rs +++ b/libs/sdk-core/src/greenlight/node_api.rs @@ -1007,10 +1007,11 @@ impl NodeAPI for Greenlight { Ok(FetchInvoiceResponse { bolt12: response.invoice, - new_amount_msat: match response.changes { - Some(changes) => changes.amount_msat.map(|amount| amount.msat), - None => None - }, + changes: response.changes.map(|changes| FetchInvoiceChanges { + amount: changes.amount_msat.map(|amount| amount.msat), + vendor: changes.vendor, + description: changes.description + }) }) } diff --git a/libs/sdk-core/src/models.rs b/libs/sdk-core/src/models.rs index 996f76b1a..a63dffb2d 100644 --- a/libs/sdk-core/src/models.rs +++ b/libs/sdk-core/src/models.rs @@ -824,10 +824,17 @@ pub struct FetchInvoiceRequest { pub(crate) payer_note: Option, } +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct FetchInvoiceChanges { + pub(crate) vendor: Option, + pub(crate) description: Option, + pub(crate) amount: Option, +} + #[derive(Clone, Debug, Serialize, Deserialize)] pub struct FetchInvoiceResponse { pub(crate) bolt12: String, - pub(crate) new_amount_msat: Option, + pub(crate) changes: Option, } #[derive(Clone, Debug, Serialize, Deserialize)] 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 a77aabbb4..95d70094e 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 @@ -457,12 +457,10 @@ fun asCreateOfferRequest(createOfferRequest: ReadableMap): CreateOfferRequest? { } else { null } - val issuer = if (hasNonNullKey(createOfferRequest, "issuer")) createOfferRequest.getString("issuer") else null return CreateOfferRequest( amountMsat, description, absoluteExpiry, - issuer, ) } @@ -471,7 +469,6 @@ fun readableMapOf(createOfferRequest: CreateOfferRequest): ReadableMap { "amountMsat" to createOfferRequest.amountMsat, "description" to createOfferRequest.description, "absoluteExpiry" to createOfferRequest.absoluteExpiry, - "issuer" to createOfferRequest.issuer, ) } diff --git a/libs/sdk-react-native/ios/BreezSDKMapper.swift b/libs/sdk-react-native/ios/BreezSDKMapper.swift index 85b7d69e0..4192ef7b1 100644 --- a/libs/sdk-react-native/ios/BreezSDKMapper.swift +++ b/libs/sdk-react-native/ios/BreezSDKMapper.swift @@ -497,19 +497,11 @@ enum BreezSDKMapper { } absoluteExpiry = absoluteExpiryTmp } - var issuer: String? - if hasNonNilKey(data: createOfferRequest, key: "issuer") { - guard let issuerTmp = createOfferRequest["issuer"] as? String else { - throw SdkError.Generic(message: errUnexpectedValue(fieldName: "issuer")) - } - issuer = issuerTmp - } return CreateOfferRequest( amountMsat: amountMsat, description: description, - absoluteExpiry: absoluteExpiry, - issuer: issuer + absoluteExpiry: absoluteExpiry ) } @@ -518,7 +510,6 @@ enum BreezSDKMapper { "amountMsat": createOfferRequest.amountMsat == nil ? nil : createOfferRequest.amountMsat, "description": createOfferRequest.description, "absoluteExpiry": createOfferRequest.absoluteExpiry == nil ? nil : createOfferRequest.absoluteExpiry, - "issuer": createOfferRequest.issuer == nil ? nil : createOfferRequest.issuer, ] } diff --git a/libs/sdk-react-native/src/index.ts b/libs/sdk-react-native/src/index.ts index 4d9fb162e..d68072027 100644 --- a/libs/sdk-react-native/src/index.ts +++ b/libs/sdk-react-native/src/index.ts @@ -85,7 +85,6 @@ export type CreateOfferRequest = { amountMsat?: number description: string absoluteExpiry?: number - issuer?: string } export type CurrencyInfo = {