mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2025-12-24 01:14:22 +01:00
Send: store preimage on Complete
This commit is contained in:
@@ -63,6 +63,7 @@ typedef struct wire_cst_payment {
|
|||||||
uint32_t timestamp;
|
uint32_t timestamp;
|
||||||
uint64_t amount_sat;
|
uint64_t amount_sat;
|
||||||
uint64_t *fees_sat;
|
uint64_t *fees_sat;
|
||||||
|
struct wire_cst_list_prim_u_8_strict *preimage;
|
||||||
int32_t payment_type;
|
int32_t payment_type;
|
||||||
int32_t status;
|
int32_t status;
|
||||||
} wire_cst_payment;
|
} wire_cst_payment;
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ dictionary Payment {
|
|||||||
u32 timestamp;
|
u32 timestamp;
|
||||||
u64 amount_sat;
|
u64 amount_sat;
|
||||||
u64? fees_sat = null;
|
u64? fees_sat = null;
|
||||||
|
string? preimage = null;
|
||||||
PaymentType payment_type;
|
PaymentType payment_type;
|
||||||
PaymentState status;
|
PaymentState status;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -172,6 +172,7 @@ impl CstDecode<crate::model::Payment> for wire_cst_payment {
|
|||||||
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(),
|
||||||
|
preimage: self.preimage.cst_decode(),
|
||||||
payment_type: self.payment_type.cst_decode(),
|
payment_type: self.payment_type.cst_decode(),
|
||||||
status: self.status.cst_decode(),
|
status: self.status.cst_decode(),
|
||||||
}
|
}
|
||||||
@@ -345,6 +346,7 @@ impl NewWithNullPtr for wire_cst_payment {
|
|||||||
timestamp: Default::default(),
|
timestamp: Default::default(),
|
||||||
amount_sat: Default::default(),
|
amount_sat: Default::default(),
|
||||||
fees_sat: core::ptr::null_mut(),
|
fees_sat: core::ptr::null_mut(),
|
||||||
|
preimage: core::ptr::null_mut(),
|
||||||
payment_type: Default::default(),
|
payment_type: Default::default(),
|
||||||
status: Default::default(),
|
status: Default::default(),
|
||||||
}
|
}
|
||||||
@@ -693,6 +695,7 @@ pub struct wire_cst_payment {
|
|||||||
timestamp: u32,
|
timestamp: u32,
|
||||||
amount_sat: u64,
|
amount_sat: u64,
|
||||||
fees_sat: *mut u64,
|
fees_sat: *mut u64,
|
||||||
|
preimage: *mut wire_cst_list_prim_u_8_strict,
|
||||||
payment_type: i32,
|
payment_type: i32,
|
||||||
status: i32,
|
status: i32,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -592,6 +592,7 @@ impl SseDecode for crate::model::Payment {
|
|||||||
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 = <Option<u64>>::sse_decode(deserializer);
|
let mut var_feesSat = <Option<u64>>::sse_decode(deserializer);
|
||||||
|
let mut var_preimage = <Option<String>>::sse_decode(deserializer);
|
||||||
let mut var_paymentType = <crate::model::PaymentType>::sse_decode(deserializer);
|
let mut var_paymentType = <crate::model::PaymentType>::sse_decode(deserializer);
|
||||||
let mut var_status = <crate::model::PaymentState>::sse_decode(deserializer);
|
let mut var_status = <crate::model::PaymentState>::sse_decode(deserializer);
|
||||||
return crate::model::Payment {
|
return crate::model::Payment {
|
||||||
@@ -600,6 +601,7 @@ impl SseDecode for crate::model::Payment {
|
|||||||
timestamp: var_timestamp,
|
timestamp: var_timestamp,
|
||||||
amount_sat: var_amountSat,
|
amount_sat: var_amountSat,
|
||||||
fees_sat: var_feesSat,
|
fees_sat: var_feesSat,
|
||||||
|
preimage: var_preimage,
|
||||||
payment_type: var_paymentType,
|
payment_type: var_paymentType,
|
||||||
status: var_status,
|
status: var_status,
|
||||||
};
|
};
|
||||||
@@ -936,6 +938,7 @@ impl flutter_rust_bridge::IntoDart for crate::model::Payment {
|
|||||||
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(),
|
||||||
|
self.preimage.into_into_dart().into_dart(),
|
||||||
self.payment_type.into_into_dart().into_dart(),
|
self.payment_type.into_into_dart().into_dart(),
|
||||||
self.status.into_into_dart().into_dart(),
|
self.status.into_into_dart().into_dart(),
|
||||||
]
|
]
|
||||||
@@ -1289,6 +1292,7 @@ impl SseEncode for crate::model::Payment {
|
|||||||
<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);
|
||||||
<Option<u64>>::sse_encode(self.fees_sat, serializer);
|
<Option<u64>>::sse_encode(self.fees_sat, serializer);
|
||||||
|
<Option<String>>::sse_encode(self.preimage, serializer);
|
||||||
<crate::model::PaymentType>::sse_encode(self.payment_type, serializer);
|
<crate::model::PaymentType>::sse_encode(self.payment_type, serializer);
|
||||||
<crate::model::PaymentState>::sse_encode(self.status, serializer);
|
<crate::model::PaymentState>::sse_encode(self.status, serializer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -425,6 +425,8 @@ pub struct PaymentSwapData {
|
|||||||
/// Swap creation timestamp
|
/// Swap creation timestamp
|
||||||
pub created_at: u32,
|
pub created_at: u32,
|
||||||
|
|
||||||
|
pub preimage: Option<String>,
|
||||||
|
|
||||||
/// Amount sent by the swap payer
|
/// Amount sent by the swap payer
|
||||||
pub payer_amount_sat: u64,
|
pub payer_amount_sat: u64,
|
||||||
|
|
||||||
@@ -463,6 +465,9 @@ pub struct Payment {
|
|||||||
/// received.
|
/// received.
|
||||||
pub fees_sat: Option<u64>,
|
pub fees_sat: Option<u64>,
|
||||||
|
|
||||||
|
/// In case of a Send swap, this is the preimage of the paid invoice (proof of payment).
|
||||||
|
pub preimage: Option<String>,
|
||||||
|
|
||||||
pub payment_type: PaymentType,
|
pub payment_type: PaymentType,
|
||||||
|
|
||||||
/// Composite status representing the overall status of the payment.
|
/// Composite status representing the overall status of the payment.
|
||||||
@@ -485,6 +490,7 @@ impl Payment {
|
|||||||
fees_sat: swap
|
fees_sat: swap
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|s| s.payer_amount_sat - s.receiver_amount_sat),
|
.map(|s| s.payer_amount_sat - s.receiver_amount_sat),
|
||||||
|
preimage: swap.as_ref().and_then(|s| s.preimage.clone()),
|
||||||
payment_type: tx.payment_type,
|
payment_type: tx.payment_type,
|
||||||
status: match swap {
|
status: match swap {
|
||||||
Some(swap) => swap.status,
|
Some(swap) => swap.status,
|
||||||
|
|||||||
@@ -13,15 +13,16 @@ pub(crate) fn current_migrations() -> Vec<&'static str> {
|
|||||||
state INTEGER NOT NULL
|
state INTEGER NOT NULL
|
||||||
) STRICT;",
|
) STRICT;",
|
||||||
"CREATE TABLE IF NOT EXISTS send_swaps (
|
"CREATE TABLE IF NOT EXISTS send_swaps (
|
||||||
id TEXT NOT NULL PRIMARY KEY,
|
id TEXT NOT NULL PRIMARY KEY,
|
||||||
invoice TEXT NOT NULL,
|
invoice TEXT NOT NULL,
|
||||||
payer_amount_sat INTEGER NOT NULL,
|
preimage TEXT,
|
||||||
receiver_amount_sat INTEGER NOT NULL,
|
payer_amount_sat INTEGER NOT NULL,
|
||||||
create_response_json TEXT NOT NULL,
|
receiver_amount_sat INTEGER NOT NULL,
|
||||||
lockup_tx_id TEXT,
|
create_response_json TEXT NOT NULL,
|
||||||
refund_tx_id TEXT,
|
lockup_tx_id TEXT,
|
||||||
created_at INTEGER NOT NULL,
|
refund_tx_id TEXT,
|
||||||
state INTEGER NOT NULL
|
created_at INTEGER NOT NULL,
|
||||||
|
state INTEGER NOT NULL
|
||||||
) STRICT;",
|
) STRICT;",
|
||||||
"CREATE TABLE IF NOT EXISTS payment_tx_data (
|
"CREATE TABLE IF NOT EXISTS payment_tx_data (
|
||||||
tx_id TEXT NOT NULL PRIMARY KEY,
|
tx_id TEXT NOT NULL PRIMARY KEY,
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ impl Persister {
|
|||||||
rs.state,
|
rs.state,
|
||||||
ss.id,
|
ss.id,
|
||||||
ss.created_at,
|
ss.created_at,
|
||||||
|
ss.preimage,
|
||||||
ss.payer_amount_sat,
|
ss.payer_amount_sat,
|
||||||
ss.receiver_amount_sat,
|
ss.receiver_amount_sat,
|
||||||
ss.state
|
ss.state
|
||||||
@@ -140,14 +141,16 @@ impl Persister {
|
|||||||
let maybe_receive_swap_receiver_state: Option<PaymentState> = row.get(9)?;
|
let maybe_receive_swap_receiver_state: Option<PaymentState> = row.get(9)?;
|
||||||
let maybe_send_swap_id: Option<String> = row.get(10)?;
|
let maybe_send_swap_id: Option<String> = row.get(10)?;
|
||||||
let maybe_send_swap_created_at: Option<u32> = row.get(11)?;
|
let maybe_send_swap_created_at: Option<u32> = row.get(11)?;
|
||||||
let maybe_send_swap_payer_amount_sat: Option<u64> = row.get(12)?;
|
let maybe_send_swap_preimage: Option<String> = row.get(12)?;
|
||||||
let maybe_send_swap_receiver_amount_sat: Option<u64> = row.get(13)?;
|
let maybe_send_swap_payer_amount_sat: Option<u64> = row.get(13)?;
|
||||||
let maybe_send_swap_state: Option<PaymentState> = row.get(14)?;
|
let maybe_send_swap_receiver_amount_sat: Option<u64> = row.get(14)?;
|
||||||
|
let maybe_send_swap_state: Option<PaymentState> = row.get(15)?;
|
||||||
|
|
||||||
let swap = match maybe_receive_swap_id {
|
let swap = match maybe_receive_swap_id {
|
||||||
Some(receive_swap_id) => Some(PaymentSwapData {
|
Some(receive_swap_id) => Some(PaymentSwapData {
|
||||||
swap_id: receive_swap_id,
|
swap_id: receive_swap_id,
|
||||||
created_at: maybe_receive_swap_created_at.unwrap_or(utils::now()),
|
created_at: maybe_receive_swap_created_at.unwrap_or(utils::now()),
|
||||||
|
preimage: None,
|
||||||
payer_amount_sat: maybe_receive_swap_payer_amount_sat.unwrap_or(0),
|
payer_amount_sat: maybe_receive_swap_payer_amount_sat.unwrap_or(0),
|
||||||
receiver_amount_sat: maybe_receive_swap_receiver_amount_sat.unwrap_or(0),
|
receiver_amount_sat: maybe_receive_swap_receiver_amount_sat.unwrap_or(0),
|
||||||
status: maybe_receive_swap_receiver_state.unwrap_or(PaymentState::Created),
|
status: maybe_receive_swap_receiver_state.unwrap_or(PaymentState::Created),
|
||||||
@@ -155,6 +158,7 @@ impl Persister {
|
|||||||
None => maybe_send_swap_id.map(|send_swap_id| PaymentSwapData {
|
None => maybe_send_swap_id.map(|send_swap_id| PaymentSwapData {
|
||||||
swap_id: send_swap_id,
|
swap_id: send_swap_id,
|
||||||
created_at: maybe_send_swap_created_at.unwrap_or(utils::now()),
|
created_at: maybe_send_swap_created_at.unwrap_or(utils::now()),
|
||||||
|
preimage: maybe_send_swap_preimage,
|
||||||
payer_amount_sat: maybe_send_swap_payer_amount_sat.unwrap_or(0),
|
payer_amount_sat: maybe_send_swap_payer_amount_sat.unwrap_or(0),
|
||||||
receiver_amount_sat: maybe_send_swap_receiver_amount_sat.unwrap_or(0),
|
receiver_amount_sat: maybe_send_swap_receiver_amount_sat.unwrap_or(0),
|
||||||
status: maybe_send_swap_state.unwrap_or(PaymentState::Created),
|
status: maybe_send_swap_state.unwrap_or(PaymentState::Created),
|
||||||
|
|||||||
@@ -160,13 +160,20 @@ impl Persister {
|
|||||||
con: &Connection,
|
con: &Connection,
|
||||||
swap_id: &str,
|
swap_id: &str,
|
||||||
to_state: PaymentState,
|
to_state: PaymentState,
|
||||||
|
preimage: Option<&str>,
|
||||||
lockup_tx_id: Option<&str>,
|
lockup_tx_id: Option<&str>,
|
||||||
refund_tx_id: Option<&str>,
|
refund_tx_id: Option<&str>,
|
||||||
) -> Result<(), PaymentError> {
|
) -> Result<(), PaymentError> {
|
||||||
// Do not overwrite lockup_tx_id, refund_tx_id
|
// Do not overwrite preimage, lockup_tx_id, refund_tx_id
|
||||||
con.execute(
|
con.execute(
|
||||||
"UPDATE send_swaps
|
"UPDATE send_swaps
|
||||||
SET
|
SET
|
||||||
|
preimage =
|
||||||
|
CASE
|
||||||
|
WHEN preimage IS NULL THEN :preimage
|
||||||
|
ELSE preimage
|
||||||
|
END,
|
||||||
|
|
||||||
lockup_tx_id =
|
lockup_tx_id =
|
||||||
CASE
|
CASE
|
||||||
WHEN lockup_tx_id IS NULL THEN :lockup_tx_id
|
WHEN lockup_tx_id IS NULL THEN :lockup_tx_id
|
||||||
@@ -179,11 +186,12 @@ impl Persister {
|
|||||||
ELSE refund_tx_id
|
ELSE refund_tx_id
|
||||||
END,
|
END,
|
||||||
|
|
||||||
state=:state
|
state = :state
|
||||||
WHERE
|
WHERE
|
||||||
id = :id",
|
id = :id",
|
||||||
named_params! {
|
named_params! {
|
||||||
":id": swap_id,
|
":id": swap_id,
|
||||||
|
":preimage": preimage,
|
||||||
":lockup_tx_id": lockup_tx_id,
|
":lockup_tx_id": lockup_tx_id,
|
||||||
":refund_tx_id": refund_tx_id,
|
":refund_tx_id": refund_tx_id,
|
||||||
":state": to_state,
|
":state": to_state,
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ impl LiquidSdk {
|
|||||||
&self,
|
&self,
|
||||||
swap_id: &str,
|
swap_id: &str,
|
||||||
to_state: PaymentState,
|
to_state: PaymentState,
|
||||||
|
preimage: Option<&str>,
|
||||||
lockup_tx_id: Option<&str>,
|
lockup_tx_id: Option<&str>,
|
||||||
refund_tx_id: Option<&str>,
|
refund_tx_id: Option<&str>,
|
||||||
) -> Result<(), PaymentError> {
|
) -> Result<(), PaymentError> {
|
||||||
@@ -209,6 +210,7 @@ impl LiquidSdk {
|
|||||||
&con,
|
&con,
|
||||||
swap_id,
|
swap_id,
|
||||||
to_state,
|
to_state,
|
||||||
|
preimage,
|
||||||
lockup_tx_id,
|
lockup_tx_id,
|
||||||
refund_tx_id,
|
refund_tx_id,
|
||||||
)
|
)
|
||||||
@@ -339,7 +341,7 @@ impl LiquidSdk {
|
|||||||
let refund_tx_id =
|
let refund_tx_id =
|
||||||
self.try_refund(id, &swap_script, &keypair, receiver_amount_sat)?;
|
self.try_refund(id, &swap_script, &keypair, receiver_amount_sat)?;
|
||||||
info!("Broadcast refund tx for Swap-in {id}. Tx id: {refund_tx_id}");
|
info!("Broadcast refund tx for Swap-in {id}. Tx id: {refund_tx_id}");
|
||||||
self.try_handle_send_swap_update(id, Pending, None, Some(&refund_tx_id))?;
|
self.try_handle_send_swap_update(id, Pending, None, None, Some(&refund_tx_id))?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -587,7 +589,13 @@ impl LiquidSdk {
|
|||||||
|
|
||||||
Self::verify_payment_hash(&claim_tx_response.preimage, invoice)?;
|
Self::verify_payment_hash(&claim_tx_response.preimage, invoice)?;
|
||||||
// After we confirm the preimage is correct, we mark this as complete
|
// After we confirm the preimage is correct, we mark this as complete
|
||||||
self.try_handle_send_swap_update(swap_id, Complete, None, None)?;
|
self.try_handle_send_swap_update(
|
||||||
|
swap_id,
|
||||||
|
Complete,
|
||||||
|
Some(&claim_tx_response.preimage),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
)?;
|
||||||
|
|
||||||
let (partial_sig, pub_nonce) =
|
let (partial_sig, pub_nonce) =
|
||||||
refund_tx.submarine_partial_sig(keypair, &claim_tx_response)?;
|
refund_tx.submarine_partial_sig(keypair, &claim_tx_response)?;
|
||||||
@@ -720,7 +728,13 @@ impl LiquidSdk {
|
|||||||
};
|
};
|
||||||
|
|
||||||
lockup_tx_id = self.lockup_funds(swap_id, &create_response)?;
|
lockup_tx_id = self.lockup_funds(swap_id, &create_response)?;
|
||||||
self.try_handle_send_swap_update(swap_id, Pending, Some(&lockup_tx_id), None)?;
|
self.try_handle_send_swap_update(
|
||||||
|
swap_id,
|
||||||
|
Pending,
|
||||||
|
None,
|
||||||
|
Some(&lockup_tx_id),
|
||||||
|
None,
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Boltz has detected the lockup in the mempool, we can speed up
|
// Boltz has detected the lockup in the mempool, we can speed up
|
||||||
@@ -962,7 +976,7 @@ impl LiquidSdk {
|
|||||||
self.try_handle_receive_swap_update(&swap.id, Complete, None)?;
|
self.try_handle_receive_swap_update(&swap.id, Complete, None)?;
|
||||||
}
|
}
|
||||||
if let Some(swap) = pending_send_swaps_by_refund_tx_id.get(&tx_id) {
|
if let Some(swap) = pending_send_swaps_by_refund_tx_id.get(&tx_id) {
|
||||||
self.try_handle_send_swap_update(&swap.id, Failed, None, None)?;
|
self.try_handle_send_swap_update(&swap.id, Failed, None, None, None)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -517,15 +517,16 @@ 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 != 7) throw Exception('unexpected arr length: expect 7 but see ${arr.length}');
|
if (arr.length != 8) throw Exception('unexpected arr length: expect 8 but see ${arr.length}');
|
||||||
return Payment(
|
return Payment(
|
||||||
txId: dco_decode_String(arr[0]),
|
txId: dco_decode_String(arr[0]),
|
||||||
swapId: dco_decode_opt_String(arr[1]),
|
swapId: dco_decode_opt_String(arr[1]),
|
||||||
timestamp: dco_decode_u_32(arr[2]),
|
timestamp: dco_decode_u_32(arr[2]),
|
||||||
amountSat: dco_decode_u_64(arr[3]),
|
amountSat: dco_decode_u_64(arr[3]),
|
||||||
feesSat: dco_decode_opt_box_autoadd_u_64(arr[4]),
|
feesSat: dco_decode_opt_box_autoadd_u_64(arr[4]),
|
||||||
paymentType: dco_decode_payment_type(arr[5]),
|
preimage: dco_decode_opt_String(arr[5]),
|
||||||
status: dco_decode_payment_state(arr[6]),
|
paymentType: dco_decode_payment_type(arr[6]),
|
||||||
|
status: dco_decode_payment_state(arr[7]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -880,6 +881,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
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_opt_box_autoadd_u_64(deserializer);
|
var var_feesSat = sse_decode_opt_box_autoadd_u_64(deserializer);
|
||||||
|
var var_preimage = sse_decode_opt_String(deserializer);
|
||||||
var var_paymentType = sse_decode_payment_type(deserializer);
|
var var_paymentType = sse_decode_payment_type(deserializer);
|
||||||
var var_status = sse_decode_payment_state(deserializer);
|
var var_status = sse_decode_payment_state(deserializer);
|
||||||
return Payment(
|
return Payment(
|
||||||
@@ -888,6 +890,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
timestamp: var_timestamp,
|
timestamp: var_timestamp,
|
||||||
amountSat: var_amountSat,
|
amountSat: var_amountSat,
|
||||||
feesSat: var_feesSat,
|
feesSat: var_feesSat,
|
||||||
|
preimage: var_preimage,
|
||||||
paymentType: var_paymentType,
|
paymentType: var_paymentType,
|
||||||
status: var_status);
|
status: var_status);
|
||||||
}
|
}
|
||||||
@@ -1279,6 +1282,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
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_opt_box_autoadd_u_64(self.feesSat, serializer);
|
sse_encode_opt_box_autoadd_u_64(self.feesSat, serializer);
|
||||||
|
sse_encode_opt_String(self.preimage, serializer);
|
||||||
sse_encode_payment_type(self.paymentType, serializer);
|
sse_encode_payment_type(self.paymentType, serializer);
|
||||||
sse_encode_payment_state(self.status, serializer);
|
sse_encode_payment_state(self.status, serializer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -454,6 +454,7 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
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_opt_box_autoadd_u_64(apiObj.feesSat);
|
wireObj.fees_sat = cst_encode_opt_box_autoadd_u_64(apiObj.feesSat);
|
||||||
|
wireObj.preimage = cst_encode_opt_String(apiObj.preimage);
|
||||||
wireObj.payment_type = cst_encode_payment_type(apiObj.paymentType);
|
wireObj.payment_type = cst_encode_payment_type(apiObj.paymentType);
|
||||||
wireObj.status = cst_encode_payment_state(apiObj.status);
|
wireObj.status = cst_encode_payment_state(apiObj.status);
|
||||||
}
|
}
|
||||||
@@ -1156,6 +1157,8 @@ final class wire_cst_payment extends ffi.Struct {
|
|||||||
|
|
||||||
external ffi.Pointer<ffi.Uint64> fees_sat;
|
external ffi.Pointer<ffi.Uint64> fees_sat;
|
||||||
|
|
||||||
|
external ffi.Pointer<wire_cst_list_prim_u_8_strict> preimage;
|
||||||
|
|
||||||
@ffi.Int32()
|
@ffi.Int32()
|
||||||
external int payment_type;
|
external int payment_type;
|
||||||
|
|
||||||
|
|||||||
@@ -111,6 +111,9 @@ class Payment {
|
|||||||
/// sender. In other words, it's the delta between the amount that was sent and the amount
|
/// sender. In other words, it's the delta between the amount that was sent and the amount
|
||||||
/// received.
|
/// received.
|
||||||
final int? feesSat;
|
final int? feesSat;
|
||||||
|
|
||||||
|
/// In case of a Send swap, this is the preimage of the paid invoice (proof of payment).
|
||||||
|
final String? preimage;
|
||||||
final PaymentType paymentType;
|
final PaymentType paymentType;
|
||||||
|
|
||||||
/// Composite status representing the overall status of the payment.
|
/// Composite status representing the overall status of the payment.
|
||||||
@@ -126,6 +129,7 @@ class Payment {
|
|||||||
required this.timestamp,
|
required this.timestamp,
|
||||||
required this.amountSat,
|
required this.amountSat,
|
||||||
this.feesSat,
|
this.feesSat,
|
||||||
|
this.preimage,
|
||||||
required this.paymentType,
|
required this.paymentType,
|
||||||
required this.status,
|
required this.status,
|
||||||
});
|
});
|
||||||
@@ -137,6 +141,7 @@ class Payment {
|
|||||||
timestamp.hashCode ^
|
timestamp.hashCode ^
|
||||||
amountSat.hashCode ^
|
amountSat.hashCode ^
|
||||||
feesSat.hashCode ^
|
feesSat.hashCode ^
|
||||||
|
preimage.hashCode ^
|
||||||
paymentType.hashCode ^
|
paymentType.hashCode ^
|
||||||
status.hashCode;
|
status.hashCode;
|
||||||
|
|
||||||
@@ -150,6 +155,7 @@ class Payment {
|
|||||||
timestamp == other.timestamp &&
|
timestamp == other.timestamp &&
|
||||||
amountSat == other.amountSat &&
|
amountSat == other.amountSat &&
|
||||||
feesSat == other.feesSat &&
|
feesSat == other.feesSat &&
|
||||||
|
preimage == other.preimage &&
|
||||||
paymentType == other.paymentType &&
|
paymentType == other.paymentType &&
|
||||||
status == other.status;
|
status == other.status;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -454,6 +454,8 @@ final class wire_cst_payment extends ffi.Struct {
|
|||||||
|
|
||||||
external ffi.Pointer<ffi.Uint64> fees_sat;
|
external ffi.Pointer<ffi.Uint64> fees_sat;
|
||||||
|
|
||||||
|
external ffi.Pointer<wire_cst_list_prim_u_8_strict> preimage;
|
||||||
|
|
||||||
@ffi.Int32()
|
@ffi.Int32()
|
||||||
external int payment_type;
|
external int payment_type;
|
||||||
|
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ fun asPayment(payment: ReadableMap): Payment? {
|
|||||||
val timestamp = payment.getInt("timestamp").toUInt()
|
val timestamp = payment.getInt("timestamp").toUInt()
|
||||||
val amountSat = payment.getDouble("amountSat").toULong()
|
val amountSat = payment.getDouble("amountSat").toULong()
|
||||||
val feesSat = if (hasNonNullKey(payment, "feesSat")) payment.getDouble("feesSat").toULong() else null
|
val feesSat = if (hasNonNullKey(payment, "feesSat")) payment.getDouble("feesSat").toULong() else null
|
||||||
|
val preimage = if (hasNonNullKey(payment, "preimage")) payment.getString("preimage") else null
|
||||||
val paymentType = payment.getString("paymentType")?.let { asPaymentType(it) }!!
|
val paymentType = payment.getString("paymentType")?.let { asPaymentType(it) }!!
|
||||||
val status = payment.getString("status")?.let { asPaymentState(it) }!!
|
val status = payment.getString("status")?.let { asPaymentState(it) }!!
|
||||||
return Payment(
|
return Payment(
|
||||||
@@ -148,6 +149,7 @@ fun asPayment(payment: ReadableMap): Payment? {
|
|||||||
timestamp,
|
timestamp,
|
||||||
amountSat,
|
amountSat,
|
||||||
feesSat,
|
feesSat,
|
||||||
|
preimage,
|
||||||
paymentType,
|
paymentType,
|
||||||
status,
|
status,
|
||||||
)
|
)
|
||||||
@@ -160,6 +162,7 @@ fun readableMapOf(payment: Payment): ReadableMap {
|
|||||||
"timestamp" to payment.timestamp,
|
"timestamp" to payment.timestamp,
|
||||||
"amountSat" to payment.amountSat,
|
"amountSat" to payment.amountSat,
|
||||||
"feesSat" to payment.feesSat,
|
"feesSat" to payment.feesSat,
|
||||||
|
"preimage" to payment.preimage,
|
||||||
"paymentType" to payment.paymentType.name.lowercase(),
|
"paymentType" to payment.paymentType.name.lowercase(),
|
||||||
"status" to payment.status.name.lowercase(),
|
"status" to payment.status.name.lowercase(),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -155,6 +155,13 @@ enum BreezLiquidSDKMapper {
|
|||||||
}
|
}
|
||||||
feesSat = feesSatTmp
|
feesSat = feesSatTmp
|
||||||
}
|
}
|
||||||
|
var preimage: String?
|
||||||
|
if hasNonNilKey(data: payment, key: "preimage") {
|
||||||
|
guard let preimageTmp = payment["preimage"] as? String else {
|
||||||
|
throw LiquidSdkError.Generic(message: errUnexpectedValue(fieldName: "preimage"))
|
||||||
|
}
|
||||||
|
preimage = preimageTmp
|
||||||
|
}
|
||||||
guard let paymentTypeTmp = payment["paymentType"] as? String else {
|
guard let paymentTypeTmp = payment["paymentType"] as? String else {
|
||||||
throw LiquidSdkError.Generic(message: errMissingMandatoryField(fieldName: "paymentType", typeName: "Payment"))
|
throw LiquidSdkError.Generic(message: errMissingMandatoryField(fieldName: "paymentType", typeName: "Payment"))
|
||||||
}
|
}
|
||||||
@@ -171,6 +178,7 @@ enum BreezLiquidSDKMapper {
|
|||||||
timestamp: timestamp,
|
timestamp: timestamp,
|
||||||
amountSat: amountSat,
|
amountSat: amountSat,
|
||||||
feesSat: feesSat,
|
feesSat: feesSat,
|
||||||
|
preimage: preimage,
|
||||||
paymentType: paymentType,
|
paymentType: paymentType,
|
||||||
status: status
|
status: status
|
||||||
)
|
)
|
||||||
@@ -183,6 +191,7 @@ enum BreezLiquidSDKMapper {
|
|||||||
"timestamp": payment.timestamp,
|
"timestamp": payment.timestamp,
|
||||||
"amountSat": payment.amountSat,
|
"amountSat": payment.amountSat,
|
||||||
"feesSat": payment.feesSat == nil ? nil : payment.feesSat,
|
"feesSat": payment.feesSat == nil ? nil : payment.feesSat,
|
||||||
|
"preimage": payment.preimage == nil ? nil : payment.preimage,
|
||||||
"paymentType": valueOf(paymentType: payment.paymentType),
|
"paymentType": valueOf(paymentType: payment.paymentType),
|
||||||
"status": valueOf(paymentState: payment.status),
|
"status": valueOf(paymentState: payment.status),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ export interface Payment {
|
|||||||
timestamp: number
|
timestamp: number
|
||||||
amountSat: number
|
amountSat: number
|
||||||
feesSat?: number
|
feesSat?: number
|
||||||
|
preimage?: string
|
||||||
paymentType: PaymentType
|
paymentType: PaymentType
|
||||||
status: PaymentState
|
status: PaymentState
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user