Store unblinding data for the tx (#584)

This commit is contained in:
Ross Savage
2025-01-02 09:03:01 +01:00
committed by GitHub
parent d3a3b2b171
commit 9253caa388
18 changed files with 115 additions and 51 deletions

View File

@@ -507,6 +507,7 @@ typedef struct wire_cst_payment_details {
typedef struct wire_cst_payment { typedef struct wire_cst_payment {
struct wire_cst_list_prim_u_8_strict *destination; 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 *tx_id;
struct wire_cst_list_prim_u_8_strict *unblinding_data;
uint32_t timestamp; uint32_t timestamp;
uint64_t amount_sat; uint64_t amount_sat;
uint64_t fees_sat; uint64_t fees_sat;

View File

@@ -568,6 +568,7 @@ dictionary Payment {
u64? swapper_fees_sat = null; u64? swapper_fees_sat = null;
string? destination = null; string? destination = null;
string? tx_id = null; string? tx_id = null;
string? unblinding_data = null;
}; };
enum PaymentType { enum PaymentType {

View File

@@ -485,6 +485,7 @@ impl ChainSwapHandler {
fees_sat: lockup_tx_fees_sat + swap.claim_fees_sat, fees_sat: lockup_tx_fees_sat + swap.claim_fees_sat,
payment_type: PaymentType::Send, payment_type: PaymentType::Send,
is_confirmed: false, is_confirmed: false,
unblinding_data: None,
}, None, false)?; }, None, false)?;
self.update_swap_info(&ChainSwapUpdate { self.update_swap_info(&ChainSwapUpdate {
@@ -817,6 +818,7 @@ impl ChainSwapHandler {
fees_sat: 0, fees_sat: 0,
payment_type: PaymentType::Receive, payment_type: PaymentType::Receive,
is_confirmed: false, is_confirmed: false,
unblinding_data: None,
}, },
None, None,
false, false,

View File

@@ -3590,6 +3590,7 @@ impl SseDecode for crate::model::Payment {
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
let mut var_destination = <Option<String>>::sse_decode(deserializer); let mut var_destination = <Option<String>>::sse_decode(deserializer);
let mut var_txId = <Option<String>>::sse_decode(deserializer); let mut var_txId = <Option<String>>::sse_decode(deserializer);
let mut var_unblindingData = <Option<String>>::sse_decode(deserializer);
let mut var_timestamp = <u32>::sse_decode(deserializer); let mut var_timestamp = <u32>::sse_decode(deserializer);
let mut var_amountSat = <u64>::sse_decode(deserializer); let mut var_amountSat = <u64>::sse_decode(deserializer);
let mut var_feesSat = <u64>::sse_decode(deserializer); let mut var_feesSat = <u64>::sse_decode(deserializer);
@@ -3600,6 +3601,7 @@ impl SseDecode for crate::model::Payment {
return crate::model::Payment { return crate::model::Payment {
destination: var_destination, destination: var_destination,
tx_id: var_txId, tx_id: var_txId,
unblinding_data: var_unblindingData,
timestamp: var_timestamp, timestamp: var_timestamp,
amount_sat: var_amountSat, amount_sat: var_amountSat,
fees_sat: var_feesSat, fees_sat: var_feesSat,
@@ -5663,6 +5665,7 @@ impl flutter_rust_bridge::IntoDart for crate::model::Payment {
[ [
self.destination.into_into_dart().into_dart(), self.destination.into_into_dart().into_dart(),
self.tx_id.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.timestamp.into_into_dart().into_dart(),
self.amount_sat.into_into_dart().into_dart(), self.amount_sat.into_into_dart().into_dart(),
self.fees_sat.into_into_dart().into_dart(), self.fees_sat.into_into_dart().into_dart(),
@@ -7726,6 +7729,7 @@ impl SseEncode for crate::model::Payment {
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
<Option<String>>::sse_encode(self.destination, serializer); <Option<String>>::sse_encode(self.destination, serializer);
<Option<String>>::sse_encode(self.tx_id, serializer); <Option<String>>::sse_encode(self.tx_id, serializer);
<Option<String>>::sse_encode(self.unblinding_data, serializer);
<u32>::sse_encode(self.timestamp, serializer); <u32>::sse_encode(self.timestamp, serializer);
<u64>::sse_encode(self.amount_sat, serializer); <u64>::sse_encode(self.amount_sat, serializer);
<u64>::sse_encode(self.fees_sat, serializer); <u64>::sse_encode(self.fees_sat, serializer);
@@ -9739,6 +9743,7 @@ mod io {
crate::model::Payment { crate::model::Payment {
destination: self.destination.cst_decode(), destination: self.destination.cst_decode(),
tx_id: self.tx_id.cst_decode(), tx_id: self.tx_id.cst_decode(),
unblinding_data: self.unblinding_data.cst_decode(),
timestamp: self.timestamp.cst_decode(), timestamp: self.timestamp.cst_decode(),
amount_sat: self.amount_sat.cst_decode(), amount_sat: self.amount_sat.cst_decode(),
fees_sat: self.fees_sat.cst_decode(), fees_sat: self.fees_sat.cst_decode(),
@@ -10988,6 +10993,7 @@ mod io {
Self { Self {
destination: core::ptr::null_mut(), destination: core::ptr::null_mut(),
tx_id: core::ptr::null_mut(), tx_id: core::ptr::null_mut(),
unblinding_data: core::ptr::null_mut(),
timestamp: Default::default(), timestamp: Default::default(),
amount_sat: Default::default(), amount_sat: Default::default(),
fees_sat: Default::default(), fees_sat: Default::default(),
@@ -13174,6 +13180,7 @@ mod io {
pub struct wire_cst_payment { pub struct wire_cst_payment {
destination: *mut wire_cst_list_prim_u_8_strict, destination: *mut wire_cst_list_prim_u_8_strict,
tx_id: *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, timestamp: u32,
amount_sat: u64, amount_sat: u64,
fees_sat: u64, fees_sat: u64,

View File

@@ -1220,6 +1220,10 @@ pub struct PaymentTxData {
/// Onchain tx status /// Onchain tx status
pub is_confirmed: bool, 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<String>,
} }
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
@@ -1369,6 +1373,10 @@ pub struct Payment {
pub tx_id: Option<String>, pub tx_id: Option<String>,
/// 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<String>,
/// Composite timestamp that can be used for sorting or displaying the payment. /// 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 /// If this payment has an associated swap, it is the swap creation time. Otherwise, the point
@@ -1428,6 +1436,7 @@ impl Payment {
Payment { Payment {
destination: swap.bolt11.clone(), destination: swap.bolt11.clone(),
tx_id: None, tx_id: None,
unblinding_data: None,
timestamp: swap.created_at, timestamp: swap.created_at,
amount_sat, amount_sat,
fees_sat: swap.payer_amount_sat - swap.receiver_amount_sat, fees_sat: swap.payer_amount_sat - swap.receiver_amount_sat,
@@ -1445,6 +1454,7 @@ impl Payment {
) -> Payment { ) -> Payment {
Payment { Payment {
tx_id: Some(tx.tx_id), 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. // 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). // 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`. // Otherwise, we specify the Liquid address (BIP21 or pure), set in `payment_details.address`.

View File

@@ -214,5 +214,6 @@ pub(crate) fn current_migrations() -> Vec<&'static str> {
) STRICT;", ) STRICT;",
"ALTER TABLE receive_swaps DROP COLUMN mrh_script_pubkey;", "ALTER TABLE receive_swaps DROP COLUMN mrh_script_pubkey;",
"ALTER TABLE payment_details ADD COLUMN lnurl_info_json TEXT;", "ALTER TABLE payment_details ADD COLUMN lnurl_info_json TEXT;",
"ALTER TABLE payment_tx_data ADD COLUMN unblinding_data TEXT;",
] ]
} }

View File

@@ -123,6 +123,9 @@ impl Persister {
.iter() .iter()
.find(|output| output.is_some()) .find(|output| output.is_some())
.and_then(|output| output.clone().map(|o| o.script_pubkey.to_hex())); .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( self.insert_or_update_payment(
PaymentTxData { PaymentTxData {
tx_id: tx_id.clone(), tx_id: tx_id.clone(),
@@ -134,6 +137,7 @@ impl Persister {
false => PaymentType::Send, false => PaymentType::Send,
}, },
is_confirmed: is_tx_confirmed, is_confirmed: is_tx_confirmed,
unblinding_data: Some(unblinding_data),
}, },
maybe_script_pubkey.map(|destination| PaymentTxDetails { maybe_script_pubkey.map(|destination| PaymentTxDetails {
tx_id, tx_id,
@@ -152,7 +156,8 @@ impl Persister {
amount_sat, amount_sat,
fees_sat, fees_sat,
payment_type, payment_type,
is_confirmed is_confirmed,
unblinding_data
FROM payment_tx_data FROM payment_tx_data
WHERE is_confirmed = 0", WHERE is_confirmed = 0",
)?; )?;
@@ -165,6 +170,7 @@ impl Persister {
fees_sat: row.get(3)?, fees_sat: row.get(3)?,
payment_type: row.get(4)?, payment_type: row.get(4)?,
is_confirmed: row.get(5)?, is_confirmed: row.get(5)?,
unblinding_data: row.get(6)?,
}) })
})? })?
.map(|i| i.unwrap()) .map(|i| i.unwrap())
@@ -187,15 +193,17 @@ impl Persister {
amount_sat, amount_sat,
fees_sat, fees_sat,
payment_type, payment_type,
is_confirmed is_confirmed,
unblinding_data
) )
VALUES (?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?)
ON CONFLICT (tx_id) ON CONFLICT (tx_id)
DO UPDATE SET timestamp = CASE WHEN excluded.is_confirmed = 1 THEN excluded.timestamp ELSE timestamp END, DO UPDATE SET timestamp = CASE WHEN excluded.is_confirmed = 1 THEN excluded.timestamp ELSE timestamp END,
amount_sat = excluded.amount_sat, amount_sat = excluded.amount_sat,
fees_sat = excluded.fees_sat, fees_sat = excluded.fees_sat,
payment_type = excluded.payment_type, payment_type = excluded.payment_type,
is_confirmed = excluded.is_confirmed is_confirmed = excluded.is_confirmed,
unblinding_data = excluded.unblinding_data
", ",
( (
&ptx.tx_id, &ptx.tx_id,
@@ -204,6 +212,7 @@ impl Persister {
ptx.fees_sat, ptx.fees_sat,
ptx.payment_type, ptx.payment_type,
ptx.is_confirmed, ptx.is_confirmed,
ptx.unblinding_data,
), ),
)?; )?;
@@ -357,6 +366,7 @@ impl Persister {
ptx.fees_sat, ptx.fees_sat,
ptx.payment_type, ptx.payment_type,
ptx.is_confirmed, ptx.is_confirmed,
ptx.unblinding_data,
rs.id, rs.id,
rs.created_at, rs.created_at,
rs.invoice, rs.invoice,
@@ -441,57 +451,58 @@ impl Persister {
fees_sat: row.get(3)?, fees_sat: row.get(3)?,
payment_type: row.get(4)?, payment_type: row.get(4)?,
is_confirmed: row.get(5)?, is_confirmed: row.get(5)?,
unblinding_data: row.get(6)?,
}), }),
_ => None, _ => None,
}; };
let maybe_receive_swap_id: Option<String> = row.get(6)?; let maybe_receive_swap_id: Option<String> = row.get(7)?;
let maybe_receive_swap_created_at: Option<u32> = row.get(7)?; let maybe_receive_swap_created_at: Option<u32> = row.get(8)?;
let maybe_receive_swap_invoice: Option<String> = row.get(8)?; let maybe_receive_swap_invoice: Option<String> = row.get(9)?;
let maybe_receive_swap_payment_hash: Option<String> = row.get(9)?; let maybe_receive_swap_payment_hash: Option<String> = row.get(10)?;
let maybe_receive_swap_description: Option<String> = row.get(10)?; let maybe_receive_swap_description: Option<String> = row.get(11)?;
let maybe_receive_swap_preimage: Option<String> = row.get(11)?; let maybe_receive_swap_preimage: Option<String> = row.get(12)?;
let maybe_receive_swap_payer_amount_sat: Option<u64> = row.get(12)?; let maybe_receive_swap_payer_amount_sat: Option<u64> = row.get(13)?;
let maybe_receive_swap_receiver_amount_sat: Option<u64> = row.get(13)?; let maybe_receive_swap_receiver_amount_sat: Option<u64> = row.get(14)?;
let maybe_receive_swap_receiver_state: Option<PaymentState> = row.get(14)?; let maybe_receive_swap_receiver_state: Option<PaymentState> = row.get(15)?;
let maybe_receive_swap_pair_fees_json: Option<String> = row.get(15)?; let maybe_receive_swap_pair_fees_json: Option<String> = row.get(16)?;
let maybe_receive_swap_pair_fees: Option<ReversePair> = let maybe_receive_swap_pair_fees: Option<ReversePair> =
maybe_receive_swap_pair_fees_json.and_then(|pair| serde_json::from_str(&pair).ok()); maybe_receive_swap_pair_fees_json.and_then(|pair| serde_json::from_str(&pair).ok());
let maybe_send_swap_id: Option<String> = row.get(16)?; let maybe_send_swap_id: Option<String> = row.get(17)?;
let maybe_send_swap_created_at: Option<u32> = row.get(17)?; let maybe_send_swap_created_at: Option<u32> = row.get(18)?;
let maybe_send_swap_invoice: Option<String> = row.get(18)?; let maybe_send_swap_invoice: Option<String> = row.get(19)?;
let maybe_send_swap_bolt12_offer: Option<String> = row.get(19)?; let maybe_send_swap_bolt12_offer: Option<String> = row.get(20)?;
let maybe_send_swap_payment_hash: Option<String> = row.get(20)?; let maybe_send_swap_payment_hash: Option<String> = row.get(21)?;
let maybe_send_swap_description: Option<String> = row.get(21)?; let maybe_send_swap_description: Option<String> = row.get(22)?;
let maybe_send_swap_preimage: Option<String> = row.get(22)?; let maybe_send_swap_preimage: Option<String> = row.get(23)?;
let maybe_send_swap_refund_tx_id: Option<String> = row.get(23)?; let maybe_send_swap_refund_tx_id: Option<String> = row.get(24)?;
let maybe_send_swap_payer_amount_sat: Option<u64> = row.get(24)?; let maybe_send_swap_payer_amount_sat: Option<u64> = row.get(25)?;
let maybe_send_swap_receiver_amount_sat: Option<u64> = row.get(25)?; let maybe_send_swap_receiver_amount_sat: Option<u64> = row.get(26)?;
let maybe_send_swap_state: Option<PaymentState> = row.get(26)?; let maybe_send_swap_state: Option<PaymentState> = row.get(27)?;
let maybe_send_swap_pair_fees_json: Option<String> = row.get(27)?; let maybe_send_swap_pair_fees_json: Option<String> = row.get(28)?;
let maybe_send_swap_pair_fees: Option<SubmarinePair> = let maybe_send_swap_pair_fees: Option<SubmarinePair> =
maybe_send_swap_pair_fees_json.and_then(|pair| serde_json::from_str(&pair).ok()); maybe_send_swap_pair_fees_json.and_then(|pair| serde_json::from_str(&pair).ok());
let maybe_chain_swap_id: Option<String> = row.get(28)?; let maybe_chain_swap_id: Option<String> = row.get(29)?;
let maybe_chain_swap_created_at: Option<u32> = row.get(29)?; let maybe_chain_swap_created_at: Option<u32> = row.get(30)?;
let maybe_chain_swap_direction: Option<Direction> = row.get(30)?; let maybe_chain_swap_direction: Option<Direction> = row.get(31)?;
let maybe_chain_swap_preimage: Option<String> = row.get(31)?; let maybe_chain_swap_preimage: Option<String> = row.get(32)?;
let maybe_chain_swap_description: Option<String> = row.get(32)?; let maybe_chain_swap_description: Option<String> = row.get(33)?;
let maybe_chain_swap_refund_tx_id: Option<String> = row.get(33)?; let maybe_chain_swap_refund_tx_id: Option<String> = row.get(34)?;
let maybe_chain_swap_payer_amount_sat: Option<u64> = row.get(34)?; let maybe_chain_swap_payer_amount_sat: Option<u64> = row.get(35)?;
let maybe_chain_swap_receiver_amount_sat: Option<u64> = row.get(35)?; let maybe_chain_swap_receiver_amount_sat: Option<u64> = row.get(36)?;
let maybe_chain_swap_claim_address: Option<String> = row.get(36)?; let maybe_chain_swap_claim_address: Option<String> = row.get(37)?;
let maybe_chain_swap_state: Option<PaymentState> = row.get(37)?; let maybe_chain_swap_state: Option<PaymentState> = row.get(38)?;
let maybe_chain_swap_pair_fees_json: Option<String> = row.get(38)?; let maybe_chain_swap_pair_fees_json: Option<String> = row.get(39)?;
let maybe_chain_swap_pair_fees: Option<ChainPair> = let maybe_chain_swap_pair_fees: Option<ChainPair> =
maybe_chain_swap_pair_fees_json.and_then(|pair| serde_json::from_str(&pair).ok()); maybe_chain_swap_pair_fees_json.and_then(|pair| serde_json::from_str(&pair).ok());
let maybe_swap_refund_tx_amount_sat: Option<u64> = row.get(39)?; let maybe_swap_refund_tx_amount_sat: Option<u64> = row.get(40)?;
let maybe_payment_details_destination: Option<String> = row.get(40)?; let maybe_payment_details_destination: Option<String> = row.get(41)?;
let maybe_payment_details_description: Option<String> = row.get(41)?; let maybe_payment_details_description: Option<String> = row.get(42)?;
let maybe_payment_details_lnurl_info_json: Option<String> = row.get(42)?; let maybe_payment_details_lnurl_info_json: Option<String> = row.get(43)?;
let maybe_payment_details_lnurl_info: Option<LnUrlInfo> = let maybe_payment_details_lnurl_info: Option<LnUrlInfo> =
maybe_payment_details_lnurl_info_json.and_then(|info| serde_json::from_str(&info).ok()); maybe_payment_details_lnurl_info_json.and_then(|info| serde_json::from_str(&info).ok());

View File

@@ -337,6 +337,7 @@ impl ReceiveSwapHandler {
fees_sat: 0, fees_sat: 0,
payment_type: PaymentType::Receive, payment_type: PaymentType::Receive,
is_confirmed: false, is_confirmed: false,
unblinding_data: None,
}, },
None, None,
false, false,

View File

@@ -1228,6 +1228,7 @@ impl LiquidSdk {
fees_sat, fees_sat,
payment_type: PaymentType::Send, payment_type: PaymentType::Send,
is_confirmed: false, is_confirmed: false,
unblinding_data: None,
}; };
let description = address_data.message; let description = address_data.message;

View File

@@ -235,6 +235,7 @@ impl SendSwapHandler {
fees_sat: lockup_tx_fees_sat, fees_sat: lockup_tx_fees_sat,
payment_type: PaymentType::Send, payment_type: PaymentType::Send,
is_confirmed: false, is_confirmed: false,
unblinding_data: None,
}, },
None, None,
false, false,

View File

@@ -162,5 +162,6 @@ pub(crate) fn new_payment_tx_data(payment_type: PaymentType) -> PaymentTxData {
fees_sat: 0, fees_sat: 0,
payment_type, payment_type,
is_confirmed: false, is_confirmed: false,
unblinding_data: None,
} }
} }

View File

@@ -2554,17 +2554,18 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
Payment dco_decode_payment(dynamic raw) { Payment dco_decode_payment(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs // Codec=Dco (DartCObject based), see doc to use other codecs
final arr = raw as List<dynamic>; final arr = raw as List<dynamic>;
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( return Payment(
destination: dco_decode_opt_String(arr[0]), destination: dco_decode_opt_String(arr[0]),
txId: dco_decode_opt_String(arr[1]), txId: dco_decode_opt_String(arr[1]),
timestamp: dco_decode_u_32(arr[2]), unblindingData: dco_decode_opt_String(arr[2]),
amountSat: dco_decode_u_64(arr[3]), timestamp: dco_decode_u_32(arr[3]),
feesSat: dco_decode_u_64(arr[4]), amountSat: dco_decode_u_64(arr[4]),
swapperFeesSat: dco_decode_opt_box_autoadd_u_64(arr[5]), feesSat: dco_decode_u_64(arr[5]),
paymentType: dco_decode_payment_type(arr[6]), swapperFeesSat: dco_decode_opt_box_autoadd_u_64(arr[6]),
status: dco_decode_payment_state(arr[7]), paymentType: dco_decode_payment_type(arr[7]),
details: dco_decode_payment_details(arr[8]), status: dco_decode_payment_state(arr[8]),
details: dco_decode_payment_details(arr[9]),
); );
} }
@@ -4651,6 +4652,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
var var_destination = sse_decode_opt_String(deserializer); var var_destination = sse_decode_opt_String(deserializer);
var var_txId = 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_timestamp = sse_decode_u_32(deserializer);
var var_amountSat = sse_decode_u_64(deserializer); var var_amountSat = sse_decode_u_64(deserializer);
var var_feesSat = sse_decode_u_64(deserializer); var var_feesSat = sse_decode_u_64(deserializer);
@@ -4661,6 +4663,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
return Payment( return Payment(
destination: var_destination, destination: var_destination,
txId: var_txId, txId: var_txId,
unblindingData: var_unblindingData,
timestamp: var_timestamp, timestamp: var_timestamp,
amountSat: var_amountSat, amountSat: var_amountSat,
feesSat: var_feesSat, feesSat: var_feesSat,
@@ -6621,6 +6624,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_opt_String(self.destination, serializer); sse_encode_opt_String(self.destination, serializer);
sse_encode_opt_String(self.txId, 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_32(self.timestamp, serializer);
sse_encode_u_64(self.amountSat, serializer); sse_encode_u_64(self.amountSat, serializer);
sse_encode_u_64(self.feesSat, serializer); sse_encode_u_64(self.feesSat, serializer);

View File

@@ -2823,6 +2823,7 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
void cst_api_fill_to_wire_payment(Payment apiObj, wire_cst_payment wireObj) { void cst_api_fill_to_wire_payment(Payment apiObj, wire_cst_payment wireObj) {
wireObj.destination = cst_encode_opt_String(apiObj.destination); wireObj.destination = cst_encode_opt_String(apiObj.destination);
wireObj.tx_id = cst_encode_opt_String(apiObj.txId); 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.timestamp = cst_encode_u_32(apiObj.timestamp);
wireObj.amount_sat = cst_encode_u_64(apiObj.amountSat); wireObj.amount_sat = cst_encode_u_64(apiObj.amountSat);
wireObj.fees_sat = cst_encode_u_64(apiObj.feesSat); wireObj.fees_sat = cst_encode_u_64(apiObj.feesSat);
@@ -6175,6 +6176,8 @@ final class wire_cst_payment extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> tx_id; external ffi.Pointer<wire_cst_list_prim_u_8_strict> tx_id;
external ffi.Pointer<wire_cst_list_prim_u_8_strict> unblinding_data;
@ffi.Uint32() @ffi.Uint32()
external int timestamp; external int timestamp;

View File

@@ -595,6 +595,10 @@ class Payment {
final String? destination; final String? destination;
final String? txId; 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. /// 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 /// If this payment has an associated swap, it is the swap creation time. Otherwise, the point
@@ -643,6 +647,7 @@ class Payment {
const Payment({ const Payment({
this.destination, this.destination,
this.txId, this.txId,
this.unblindingData,
required this.timestamp, required this.timestamp,
required this.amountSat, required this.amountSat,
required this.feesSat, required this.feesSat,
@@ -656,6 +661,7 @@ class Payment {
int get hashCode => int get hashCode =>
destination.hashCode ^ destination.hashCode ^
txId.hashCode ^ txId.hashCode ^
unblindingData.hashCode ^
timestamp.hashCode ^ timestamp.hashCode ^
amountSat.hashCode ^ amountSat.hashCode ^
feesSat.hashCode ^ feesSat.hashCode ^
@@ -671,6 +677,7 @@ class Payment {
runtimeType == other.runtimeType && runtimeType == other.runtimeType &&
destination == other.destination && destination == other.destination &&
txId == other.txId && txId == other.txId &&
unblindingData == other.unblindingData &&
timestamp == other.timestamp && timestamp == other.timestamp &&
amountSat == other.amountSat && amountSat == other.amountSat &&
feesSat == other.feesSat && feesSat == other.feesSat &&

View File

@@ -4596,6 +4596,8 @@ final class wire_cst_payment extends ffi.Struct {
external ffi.Pointer<wire_cst_list_prim_u_8_strict> tx_id; external ffi.Pointer<wire_cst_list_prim_u_8_strict> tx_id;
external ffi.Pointer<wire_cst_list_prim_u_8_strict> unblinding_data;
@ffi.Uint32() @ffi.Uint32()
external int timestamp; external int timestamp;

View File

@@ -1512,7 +1512,8 @@ fun asPayment(payment: ReadableMap): Payment? {
val swapperFeesSat = if (hasNonNullKey(payment, "swapperFeesSat")) payment.getDouble("swapperFeesSat").toULong() else null val swapperFeesSat = if (hasNonNullKey(payment, "swapperFeesSat")) payment.getDouble("swapperFeesSat").toULong() else null
val destination = if (hasNonNullKey(payment, "destination")) payment.getString("destination") else null val destination = if (hasNonNullKey(payment, "destination")) payment.getString("destination") else null
val txId = if (hasNonNullKey(payment, "txId")) payment.getString("txId") 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 = fun readableMapOf(payment: Payment): ReadableMap =
@@ -1526,6 +1527,7 @@ fun readableMapOf(payment: Payment): ReadableMap =
"swapperFeesSat" to payment.swapperFeesSat, "swapperFeesSat" to payment.swapperFeesSat,
"destination" to payment.destination, "destination" to payment.destination,
"txId" to payment.txId, "txId" to payment.txId,
"unblindingData" to payment.unblindingData,
) )
fun asPaymentList(arr: ReadableArray): List<Payment> { fun asPaymentList(arr: ReadableArray): List<Payment> {

View File

@@ -1779,8 +1779,15 @@ enum BreezSDKLiquidMapper {
} }
txId = txIdTmp 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?] { static func dictionaryOf(payment: Payment) -> [String: Any?] {
@@ -1794,6 +1801,7 @@ enum BreezSDKLiquidMapper {
"swapperFeesSat": payment.swapperFeesSat == nil ? nil : payment.swapperFeesSat, "swapperFeesSat": payment.swapperFeesSat == nil ? nil : payment.swapperFeesSat,
"destination": payment.destination == nil ? nil : payment.destination, "destination": payment.destination == nil ? nil : payment.destination,
"txId": payment.txId == nil ? nil : payment.txId, "txId": payment.txId == nil ? nil : payment.txId,
"unblindingData": payment.unblindingData == nil ? nil : payment.unblindingData,
] ]
} }

View File

@@ -276,6 +276,7 @@ export interface Payment {
swapperFeesSat?: number swapperFeesSat?: number
destination?: string destination?: string
txId?: string txId?: string
unblindingData?: string
} }
export interface PrepareBuyBitcoinRequest { export interface PrepareBuyBitcoinRequest {