From 0b75360d8d9ee691e9f7f1a3967d0f3703a7292d Mon Sep 17 00:00:00 2001 From: Ross Savage Date: Fri, 29 Nov 2024 12:00:36 +0100 Subject: [PATCH] Store unblinding data for the tx --- .../include/breez_sdk_liquid.h | 1 + lib/bindings/src/breez_sdk_liquid.udl | 1 + lib/core/src/chain_swap.rs | 2 + lib/core/src/frb_generated.rs | 7 ++ lib/core/src/model.rs | 10 +++ lib/core/src/persist/migrations.rs | 1 + lib/core/src/persist/mod.rs | 84 ++++++++++--------- lib/core/src/receive_swap.rs | 1 + lib/core/src/sdk.rs | 1 + lib/core/src/send_swap.rs | 1 + lib/core/src/test_utils/persist.rs | 1 + packages/dart/lib/src/frb_generated.dart | 20 +++-- packages/dart/lib/src/frb_generated.io.dart | 3 + packages/dart/lib/src/model.dart | 7 ++ ...utter_breez_liquid_bindings_generated.dart | 2 + .../breezsdkliquid/BreezSDKLiquidMapper.kt | 4 +- .../ios/BreezSDKLiquidMapper.swift | 10 ++- packages/react-native/src/index.ts | 1 + 18 files changed, 109 insertions(+), 48 deletions(-) diff --git a/lib/bindings/langs/flutter/breez_sdk_liquid/include/breez_sdk_liquid.h b/lib/bindings/langs/flutter/breez_sdk_liquid/include/breez_sdk_liquid.h index 676ea503b..41d52c7f4 100644 --- a/lib/bindings/langs/flutter/breez_sdk_liquid/include/breez_sdk_liquid.h +++ b/lib/bindings/langs/flutter/breez_sdk_liquid/include/breez_sdk_liquid.h @@ -442,6 +442,7 @@ typedef struct wire_cst_payment_details { typedef struct wire_cst_payment { struct wire_cst_list_prim_u_8_strict *destination; struct wire_cst_list_prim_u_8_strict *tx_id; + struct wire_cst_list_prim_u_8_strict *unblinding_data; uint32_t timestamp; uint64_t amount_sat; uint64_t fees_sat; diff --git a/lib/bindings/src/breez_sdk_liquid.udl b/lib/bindings/src/breez_sdk_liquid.udl index db8f02c70..b5eb5e52d 100644 --- a/lib/bindings/src/breez_sdk_liquid.udl +++ b/lib/bindings/src/breez_sdk_liquid.udl @@ -553,6 +553,7 @@ dictionary Payment { u64? swapper_fees_sat = null; string? destination = null; string? tx_id = null; + string? unblinding_data = null; }; enum PaymentType { diff --git a/lib/core/src/chain_swap.rs b/lib/core/src/chain_swap.rs index 4145b7d24..75d0b2cda 100644 --- a/lib/core/src/chain_swap.rs +++ b/lib/core/src/chain_swap.rs @@ -483,6 +483,7 @@ impl ChainSwapHandler { fees_sat: lockup_tx_fees_sat + swap.claim_fees_sat, payment_type: PaymentType::Send, is_confirmed: false, + unblinding_data: None, }, None, None)?; self.update_swap_info(&ChainSwapUpdate { @@ -836,6 +837,7 @@ impl ChainSwapHandler { fees_sat: 0, payment_type: PaymentType::Receive, is_confirmed: false, + unblinding_data: None, }, None, None, diff --git a/lib/core/src/frb_generated.rs b/lib/core/src/frb_generated.rs index e87495cf5..571c08775 100644 --- a/lib/core/src/frb_generated.rs +++ b/lib/core/src/frb_generated.rs @@ -3455,6 +3455,7 @@ impl SseDecode for crate::model::Payment { fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { let mut var_destination = >::sse_decode(deserializer); let mut var_txId = >::sse_decode(deserializer); + let mut var_unblindingData = >::sse_decode(deserializer); let mut var_timestamp = ::sse_decode(deserializer); let mut var_amountSat = ::sse_decode(deserializer); let mut var_feesSat = ::sse_decode(deserializer); @@ -3465,6 +3466,7 @@ impl SseDecode for crate::model::Payment { return crate::model::Payment { destination: var_destination, tx_id: var_txId, + unblinding_data: var_unblindingData, timestamp: var_timestamp, amount_sat: var_amountSat, fees_sat: var_feesSat, @@ -5472,6 +5474,7 @@ impl flutter_rust_bridge::IntoDart for crate::model::Payment { [ self.destination.into_into_dart().into_dart(), self.tx_id.into_into_dart().into_dart(), + self.unblinding_data.into_into_dart().into_dart(), self.timestamp.into_into_dart().into_dart(), self.amount_sat.into_into_dart().into_dart(), self.fees_sat.into_into_dart().into_dart(), @@ -7447,6 +7450,7 @@ impl SseEncode for crate::model::Payment { fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { >::sse_encode(self.destination, serializer); >::sse_encode(self.tx_id, serializer); + >::sse_encode(self.unblinding_data, serializer); ::sse_encode(self.timestamp, serializer); ::sse_encode(self.amount_sat, serializer); ::sse_encode(self.fees_sat, serializer); @@ -9396,6 +9400,7 @@ mod io { crate::model::Payment { destination: self.destination.cst_decode(), tx_id: self.tx_id.cst_decode(), + unblinding_data: self.unblinding_data.cst_decode(), timestamp: self.timestamp.cst_decode(), amount_sat: self.amount_sat.cst_decode(), fees_sat: self.fees_sat.cst_decode(), @@ -10607,6 +10612,7 @@ mod io { Self { destination: core::ptr::null_mut(), tx_id: core::ptr::null_mut(), + unblinding_data: core::ptr::null_mut(), timestamp: Default::default(), amount_sat: Default::default(), fees_sat: Default::default(), @@ -12724,6 +12730,7 @@ mod io { pub struct wire_cst_payment { destination: *mut wire_cst_list_prim_u_8_strict, tx_id: *mut wire_cst_list_prim_u_8_strict, + unblinding_data: *mut wire_cst_list_prim_u_8_strict, timestamp: u32, amount_sat: u64, fees_sat: u64, diff --git a/lib/core/src/model.rs b/lib/core/src/model.rs index 8e5c798d8..4ab8ed059 100644 --- a/lib/core/src/model.rs +++ b/lib/core/src/model.rs @@ -1187,6 +1187,10 @@ pub struct PaymentTxData { /// Onchain tx status pub is_confirmed: bool, + + /// Data to use in the `blinded` param when unblinding the transaction in an explorer. + /// See: https://docs.liquid.net/docs/unblinding-transactions + pub unblinding_data: Option, } #[derive(Debug, Clone, Serialize)] @@ -1320,6 +1324,10 @@ pub struct Payment { pub tx_id: Option, + /// Data to use in the `blinded` param when unblinding the transaction in an explorer. + /// See: https://docs.liquid.net/docs/unblinding-transactions + pub unblinding_data: Option, + /// Composite timestamp that can be used for sorting or displaying the payment. /// /// If this payment has an associated swap, it is the swap creation time. Otherwise, the point @@ -1375,6 +1383,7 @@ impl Payment { Payment { destination: swap.bolt11.clone(), tx_id: None, + unblinding_data: None, timestamp: swap.created_at, amount_sat, fees_sat: swap.payer_amount_sat - swap.receiver_amount_sat, @@ -1401,6 +1410,7 @@ impl Payment { ) -> Payment { Payment { tx_id: Some(tx.tx_id), + unblinding_data: tx.unblinding_data, // When the swap is present and of type send and receive, we retrieve the destination from the invoice. // If it's a chain swap instead, we use the `claim_address` field from the swap data (either pure Bitcoin or Liquid address). // Otherwise, we specify the Liquid address (BIP21 or pure), set in `payment_details.address`. diff --git a/lib/core/src/persist/migrations.rs b/lib/core/src/persist/migrations.rs index 6e0d8708b..69d050414 100644 --- a/lib/core/src/persist/migrations.rs +++ b/lib/core/src/persist/migrations.rs @@ -213,5 +213,6 @@ pub(crate) fn current_migrations() -> Vec<&'static str> { data BLOB NOT NULL ) STRICT;", "ALTER TABLE receive_swaps DROP COLUMN mrh_script_pubkey;", + "ALTER TABLE payment_tx_data ADD COLUMN unblinding_data TEXT;", ] } diff --git a/lib/core/src/persist/mod.rs b/lib/core/src/persist/mod.rs index bc84fb910..ba1a5cbee 100644 --- a/lib/core/src/persist/mod.rs +++ b/lib/core/src/persist/mod.rs @@ -108,6 +108,9 @@ impl Persister { .iter() .find(|output| output.is_some()) .and_then(|output| output.clone().map(|o| o.script_pubkey.to_hex())); + let unblinding_data = tx + .unblinded_url("") + .replace(&format!("tx/{}#blinded=", tx_id), ""); self.insert_or_update_payment( PaymentTxData { tx_id: tx_id.clone(), @@ -119,6 +122,7 @@ impl Persister { false => PaymentType::Send, }, is_confirmed: is_tx_confirmed, + unblinding_data: Some(unblinding_data), }, maybe_script_pubkey, None, @@ -139,9 +143,10 @@ impl Persister { amount_sat, fees_sat, payment_type, - is_confirmed + is_confirmed, + unblinding_data ) - VALUES (?, ?, ?, ?, ?, ?) + VALUES (?, ?, ?, ?, ?, ?, ?) ", ( &ptx.tx_id, @@ -150,6 +155,7 @@ impl Persister { ptx.fees_sat, ptx.payment_type, ptx.is_confirmed, + ptx.unblinding_data, ), )?; @@ -208,6 +214,7 @@ impl Persister { ptx.fees_sat, ptx.payment_type, ptx.is_confirmed, + ptx.unblinding_data, rs.id, rs.created_at, rs.invoice, @@ -284,56 +291,57 @@ impl Persister { fees_sat: row.get(3)?, payment_type: row.get(4)?, is_confirmed: row.get(5)?, + unblinding_data: row.get(6)?, }), _ => None, }; - let maybe_receive_swap_id: Option = row.get(6)?; - let maybe_receive_swap_created_at: Option = row.get(7)?; - let maybe_receive_swap_invoice: Option = row.get(8)?; - let maybe_receive_swap_payment_hash: Option = row.get(9)?; - let maybe_receive_swap_description: Option = row.get(10)?; - let maybe_receive_swap_preimage: Option = row.get(11)?; - let maybe_receive_swap_payer_amount_sat: Option = row.get(12)?; - let maybe_receive_swap_receiver_amount_sat: Option = row.get(13)?; - let maybe_receive_swap_receiver_state: Option = row.get(14)?; - let maybe_receive_swap_pair_fees_json: Option = row.get(15)?; + let maybe_receive_swap_id: Option = row.get(7)?; + let maybe_receive_swap_created_at: Option = row.get(8)?; + let maybe_receive_swap_invoice: Option = row.get(9)?; + let maybe_receive_swap_payment_hash: Option = row.get(10)?; + let maybe_receive_swap_description: Option = row.get(11)?; + let maybe_receive_swap_preimage: Option = row.get(12)?; + let maybe_receive_swap_payer_amount_sat: Option = row.get(13)?; + let maybe_receive_swap_receiver_amount_sat: Option = row.get(14)?; + let maybe_receive_swap_receiver_state: Option = row.get(15)?; + let maybe_receive_swap_pair_fees_json: Option = row.get(16)?; let maybe_receive_swap_pair_fees: Option = maybe_receive_swap_pair_fees_json.and_then(|pair| serde_json::from_str(&pair).ok()); - let maybe_send_swap_id: Option = row.get(16)?; - let maybe_send_swap_created_at: Option = row.get(17)?; - let maybe_send_swap_invoice: Option = row.get(18)?; - let maybe_send_swap_bolt12_offer: Option = row.get(19)?; - let maybe_send_swap_payment_hash: Option = row.get(20)?; - let maybe_send_swap_description: Option = row.get(21)?; - let maybe_send_swap_preimage: Option = row.get(22)?; - let maybe_send_swap_refund_tx_id: Option = row.get(23)?; - let maybe_send_swap_payer_amount_sat: Option = row.get(24)?; - let maybe_send_swap_receiver_amount_sat: Option = row.get(25)?; - let maybe_send_swap_state: Option = row.get(26)?; - let maybe_send_swap_pair_fees_json: Option = row.get(27)?; + let maybe_send_swap_id: Option = row.get(17)?; + let maybe_send_swap_created_at: Option = row.get(18)?; + let maybe_send_swap_invoice: Option = row.get(19)?; + let maybe_send_swap_bolt12_offer: Option = row.get(20)?; + let maybe_send_swap_payment_hash: Option = row.get(21)?; + let maybe_send_swap_description: Option = row.get(22)?; + let maybe_send_swap_preimage: Option = row.get(23)?; + let maybe_send_swap_refund_tx_id: Option = row.get(24)?; + let maybe_send_swap_payer_amount_sat: Option = row.get(25)?; + let maybe_send_swap_receiver_amount_sat: Option = row.get(26)?; + let maybe_send_swap_state: Option = row.get(27)?; + let maybe_send_swap_pair_fees_json: Option = row.get(28)?; let maybe_send_swap_pair_fees: Option = maybe_send_swap_pair_fees_json.and_then(|pair| serde_json::from_str(&pair).ok()); - let maybe_chain_swap_id: Option = row.get(28)?; - let maybe_chain_swap_created_at: Option = row.get(29)?; - let maybe_chain_swap_direction: Option = row.get(30)?; - let maybe_chain_swap_preimage: Option = row.get(31)?; - let maybe_chain_swap_description: Option = row.get(32)?; - let maybe_chain_swap_refund_tx_id: Option = row.get(33)?; - let maybe_chain_swap_payer_amount_sat: Option = row.get(34)?; - let maybe_chain_swap_receiver_amount_sat: Option = row.get(35)?; - let maybe_chain_swap_claim_address: Option = row.get(36)?; - let maybe_chain_swap_state: Option = row.get(37)?; - let maybe_chain_swap_pair_fees_json: Option = row.get(38)?; + let maybe_chain_swap_id: Option = row.get(29)?; + let maybe_chain_swap_created_at: Option = row.get(30)?; + let maybe_chain_swap_direction: Option = row.get(31)?; + let maybe_chain_swap_preimage: Option = row.get(32)?; + let maybe_chain_swap_description: Option = row.get(33)?; + let maybe_chain_swap_refund_tx_id: Option = row.get(34)?; + let maybe_chain_swap_payer_amount_sat: Option = row.get(35)?; + let maybe_chain_swap_receiver_amount_sat: Option = row.get(36)?; + let maybe_chain_swap_claim_address: Option = row.get(37)?; + let maybe_chain_swap_state: Option = row.get(38)?; + let maybe_chain_swap_pair_fees_json: Option = row.get(39)?; let maybe_chain_swap_pair_fees: Option = maybe_chain_swap_pair_fees_json.and_then(|pair| serde_json::from_str(&pair).ok()); - let maybe_swap_refund_tx_amount_sat: Option = row.get(39)?; + let maybe_swap_refund_tx_amount_sat: Option = row.get(40)?; - let maybe_payment_details_destination: Option = row.get(40)?; - let maybe_payment_details_description: Option = row.get(41)?; + let maybe_payment_details_destination: Option = row.get(41)?; + let maybe_payment_details_description: Option = row.get(42)?; let (swap, payment_type) = match maybe_receive_swap_id { Some(receive_swap_id) => { diff --git a/lib/core/src/receive_swap.rs b/lib/core/src/receive_swap.rs index 2e10ce1ff..db29d4bc1 100644 --- a/lib/core/src/receive_swap.rs +++ b/lib/core/src/receive_swap.rs @@ -353,6 +353,7 @@ impl ReceiveSwapHandler { fees_sat: 0, payment_type: PaymentType::Receive, is_confirmed: false, + unblinding_data: None, }, None, None, diff --git a/lib/core/src/sdk.rs b/lib/core/src/sdk.rs index 0523fcac2..1f3c084a1 100644 --- a/lib/core/src/sdk.rs +++ b/lib/core/src/sdk.rs @@ -1221,6 +1221,7 @@ impl LiquidSdk { fees_sat, payment_type: PaymentType::Send, is_confirmed: false, + unblinding_data: None, }; let destination = address_data.to_uri().unwrap_or(address_data.address); diff --git a/lib/core/src/send_swap.rs b/lib/core/src/send_swap.rs index 63d071dba..ea32c4576 100644 --- a/lib/core/src/send_swap.rs +++ b/lib/core/src/send_swap.rs @@ -231,6 +231,7 @@ impl SendSwapHandler { fees_sat: lockup_tx_fees_sat, payment_type: PaymentType::Send, is_confirmed: false, + unblinding_data: None, }, None, None, diff --git a/lib/core/src/test_utils/persist.rs b/lib/core/src/test_utils/persist.rs index 6bdf1927b..8e632b4be 100644 --- a/lib/core/src/test_utils/persist.rs +++ b/lib/core/src/test_utils/persist.rs @@ -162,5 +162,6 @@ pub(crate) fn new_payment_tx_data(payment_type: PaymentType) -> PaymentTxData { fees_sat: 0, payment_type, is_confirmed: false, + unblinding_data: None, } } diff --git a/packages/dart/lib/src/frb_generated.dart b/packages/dart/lib/src/frb_generated.dart index bd23b2c3b..0742c31b6 100644 --- a/packages/dart/lib/src/frb_generated.dart +++ b/packages/dart/lib/src/frb_generated.dart @@ -2482,17 +2482,18 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { Payment dco_decode_payment(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs final arr = raw as List; - if (arr.length != 9) throw Exception('unexpected arr length: expect 9 but see ${arr.length}'); + if (arr.length != 10) throw Exception('unexpected arr length: expect 10 but see ${arr.length}'); return Payment( destination: dco_decode_opt_String(arr[0]), txId: dco_decode_opt_String(arr[1]), - timestamp: dco_decode_u_32(arr[2]), - amountSat: dco_decode_u_64(arr[3]), - feesSat: dco_decode_u_64(arr[4]), - swapperFeesSat: dco_decode_opt_box_autoadd_u_64(arr[5]), - paymentType: dco_decode_payment_type(arr[6]), - status: dco_decode_payment_state(arr[7]), - details: dco_decode_payment_details(arr[8]), + unblindingData: dco_decode_opt_String(arr[2]), + timestamp: dco_decode_u_32(arr[3]), + amountSat: dco_decode_u_64(arr[4]), + feesSat: dco_decode_u_64(arr[5]), + swapperFeesSat: dco_decode_opt_box_autoadd_u_64(arr[6]), + paymentType: dco_decode_payment_type(arr[7]), + status: dco_decode_payment_state(arr[8]), + details: dco_decode_payment_details(arr[9]), ); } @@ -4477,6 +4478,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { // Codec=Sse (Serialization based), see doc to use other codecs var var_destination = sse_decode_opt_String(deserializer); var var_txId = sse_decode_opt_String(deserializer); + var var_unblindingData = sse_decode_opt_String(deserializer); var var_timestamp = sse_decode_u_32(deserializer); var var_amountSat = sse_decode_u_64(deserializer); var var_feesSat = sse_decode_u_64(deserializer); @@ -4487,6 +4489,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return Payment( destination: var_destination, txId: var_txId, + unblindingData: var_unblindingData, timestamp: var_timestamp, amountSat: var_amountSat, feesSat: var_feesSat, @@ -6362,6 +6365,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { // Codec=Sse (Serialization based), see doc to use other codecs sse_encode_opt_String(self.destination, serializer); sse_encode_opt_String(self.txId, serializer); + sse_encode_opt_String(self.unblindingData, serializer); sse_encode_u_32(self.timestamp, serializer); sse_encode_u_64(self.amountSat, serializer); sse_encode_u_64(self.feesSat, serializer); diff --git a/packages/dart/lib/src/frb_generated.io.dart b/packages/dart/lib/src/frb_generated.io.dart index 005325d96..02922bdea 100644 --- a/packages/dart/lib/src/frb_generated.io.dart +++ b/packages/dart/lib/src/frb_generated.io.dart @@ -2697,6 +2697,7 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { void cst_api_fill_to_wire_payment(Payment apiObj, wire_cst_payment wireObj) { wireObj.destination = cst_encode_opt_String(apiObj.destination); wireObj.tx_id = cst_encode_opt_String(apiObj.txId); + wireObj.unblinding_data = cst_encode_opt_String(apiObj.unblindingData); wireObj.timestamp = cst_encode_u_32(apiObj.timestamp); wireObj.amount_sat = cst_encode_u_64(apiObj.amountSat); wireObj.fees_sat = cst_encode_u_64(apiObj.feesSat); @@ -5894,6 +5895,8 @@ final class wire_cst_payment extends ffi.Struct { external ffi.Pointer tx_id; + external ffi.Pointer unblinding_data; + @ffi.Uint32() external int timestamp; diff --git a/packages/dart/lib/src/model.dart b/packages/dart/lib/src/model.dart index 763aaf885..5a604abff 100644 --- a/packages/dart/lib/src/model.dart +++ b/packages/dart/lib/src/model.dart @@ -531,6 +531,10 @@ class Payment { final String? destination; final String? txId; + /// Data to use in the `blinded` param when unblinding the transaction in an explorer. + /// See: https://docs.liquid.net/docs/unblinding-transactions + final String? unblindingData; + /// Composite timestamp that can be used for sorting or displaying the payment. /// /// If this payment has an associated swap, it is the swap creation time. Otherwise, the point @@ -579,6 +583,7 @@ class Payment { const Payment({ this.destination, this.txId, + this.unblindingData, required this.timestamp, required this.amountSat, required this.feesSat, @@ -592,6 +597,7 @@ class Payment { int get hashCode => destination.hashCode ^ txId.hashCode ^ + unblindingData.hashCode ^ timestamp.hashCode ^ amountSat.hashCode ^ feesSat.hashCode ^ @@ -607,6 +613,7 @@ class Payment { runtimeType == other.runtimeType && destination == other.destination && txId == other.txId && + unblindingData == other.unblindingData && timestamp == other.timestamp && amountSat == other.amountSat && feesSat == other.feesSat && diff --git a/packages/flutter/lib/flutter_breez_liquid_bindings_generated.dart b/packages/flutter/lib/flutter_breez_liquid_bindings_generated.dart index 29b3ca24d..c70fbe516 100644 --- a/packages/flutter/lib/flutter_breez_liquid_bindings_generated.dart +++ b/packages/flutter/lib/flutter_breez_liquid_bindings_generated.dart @@ -4463,6 +4463,8 @@ final class wire_cst_payment extends ffi.Struct { external ffi.Pointer tx_id; + external ffi.Pointer unblinding_data; + @ffi.Uint32() external int timestamp; diff --git a/packages/react-native/android/src/main/java/com/breezsdkliquid/BreezSDKLiquidMapper.kt b/packages/react-native/android/src/main/java/com/breezsdkliquid/BreezSDKLiquidMapper.kt index a7a5a5b48..91308475e 100644 --- a/packages/react-native/android/src/main/java/com/breezsdkliquid/BreezSDKLiquidMapper.kt +++ b/packages/react-native/android/src/main/java/com/breezsdkliquid/BreezSDKLiquidMapper.kt @@ -1378,7 +1378,8 @@ fun asPayment(payment: ReadableMap): Payment? { val swapperFeesSat = if (hasNonNullKey(payment, "swapperFeesSat")) payment.getDouble("swapperFeesSat").toULong() else null val destination = if (hasNonNullKey(payment, "destination")) payment.getString("destination") else null val txId = if (hasNonNullKey(payment, "txId")) payment.getString("txId") else null - return Payment(timestamp, amountSat, feesSat, paymentType, status, details, swapperFeesSat, destination, txId) + val unblindingData = if (hasNonNullKey(payment, "unblindingData")) payment.getString("unblindingData") else null + return Payment(timestamp, amountSat, feesSat, paymentType, status, details, swapperFeesSat, destination, txId, unblindingData) } fun readableMapOf(payment: Payment): ReadableMap = @@ -1392,6 +1393,7 @@ fun readableMapOf(payment: Payment): ReadableMap = "swapperFeesSat" to payment.swapperFeesSat, "destination" to payment.destination, "txId" to payment.txId, + "unblindingData" to payment.unblindingData, ) fun asPaymentList(arr: ReadableArray): List { diff --git a/packages/react-native/ios/BreezSDKLiquidMapper.swift b/packages/react-native/ios/BreezSDKLiquidMapper.swift index 9f56c2d1f..d8cdcca65 100644 --- a/packages/react-native/ios/BreezSDKLiquidMapper.swift +++ b/packages/react-native/ios/BreezSDKLiquidMapper.swift @@ -1646,8 +1646,15 @@ enum BreezSDKLiquidMapper { } txId = txIdTmp } + var unblindingData: String? + if hasNonNilKey(data: payment, key: "unblindingData") { + guard let unblindingDataTmp = payment["unblindingData"] as? String else { + throw SdkError.Generic(message: errUnexpectedValue(fieldName: "unblindingData")) + } + unblindingData = unblindingDataTmp + } - return Payment(timestamp: timestamp, amountSat: amountSat, feesSat: feesSat, paymentType: paymentType, status: status, details: details, swapperFeesSat: swapperFeesSat, destination: destination, txId: txId) + return Payment(timestamp: timestamp, amountSat: amountSat, feesSat: feesSat, paymentType: paymentType, status: status, details: details, swapperFeesSat: swapperFeesSat, destination: destination, txId: txId, unblindingData: unblindingData) } static func dictionaryOf(payment: Payment) -> [String: Any?] { @@ -1661,6 +1668,7 @@ enum BreezSDKLiquidMapper { "swapperFeesSat": payment.swapperFeesSat == nil ? nil : payment.swapperFeesSat, "destination": payment.destination == nil ? nil : payment.destination, "txId": payment.txId == nil ? nil : payment.txId, + "unblindingData": payment.unblindingData == nil ? nil : payment.unblindingData, ] } diff --git a/packages/react-native/src/index.ts b/packages/react-native/src/index.ts index f49f91ddf..0d39d5e90 100644 --- a/packages/react-native/src/index.ts +++ b/packages/react-native/src/index.ts @@ -257,6 +257,7 @@ export interface Payment { swapperFeesSat?: number destination?: string txId?: string + unblindingData?: string } export interface PrepareBuyBitcoinRequest {