mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2026-01-20 06:24:19 +01:00
Fix amountless receiver amount and waiting fee acceptance condition (#670)
This commit is contained in:
@@ -774,7 +774,7 @@ pub(crate) struct ChainSwap {
|
||||
pub(crate) actual_payer_amount_sat: Option<u64>,
|
||||
/// Receiver amount defined at swap creation
|
||||
pub(crate) receiver_amount_sat: u64,
|
||||
/// The final receiver amount, in case of an over/underpayment that has been accepted
|
||||
/// The final receiver amount, in case of an amountless swap for which fees have been accepted
|
||||
pub(crate) accepted_receiver_amount_sat: Option<u64>,
|
||||
pub(crate) claim_fees_sat: u64,
|
||||
/// The [ChainPair] chosen on swap creation
|
||||
@@ -904,15 +904,8 @@ impl ChainSwap {
|
||||
Ok(create_response_json)
|
||||
}
|
||||
|
||||
pub(crate) fn is_amount_mismatch(&self) -> bool {
|
||||
match self.actual_payer_amount_sat {
|
||||
Some(actual_amount) => actual_amount != self.payer_amount_sat,
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn is_waiting_fee_acceptance(&self) -> bool {
|
||||
self.is_amount_mismatch() && self.accepted_receiver_amount_sat.is_none()
|
||||
self.payer_amount_sat == 0 && self.accepted_receiver_amount_sat.is_none()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -597,7 +597,7 @@ impl Persister {
|
||||
maybe_chain_swap_actual_payer_amount_sat,
|
||||
maybe_chain_swap_payer_amount_sat,
|
||||
) {
|
||||
(Some(actual), Some(expected)) if actual != expected => actual, // For over/underpaid chain swaps WaitingFeeAcceptance, show zero fees
|
||||
(Some(actual), Some(0)) => actual, // For amountless chain swaps WaitingFeeAcceptance, show zero fees
|
||||
_ => maybe_chain_swap_receiver_amount_sat.unwrap_or(0),
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user