Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions client-sdk/src/client/fee_payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use super::{
pub const WITHDRAWAL_FEE_MEMO: &str = "withdrawal_fee_memo";
pub const CLAIM_FEE_MEMO: &str = "claim_fee_memo";
pub const USED_OR_INVALID_MEMO: &str = "used_or_invalid_memo";
pub const TX_TIMEOUT_BUFFER_SECS: u64 = 600;

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum FeeType {
Expand Down Expand Up @@ -302,16 +303,23 @@ pub async fn select_unused_fees(
collected_total_fee += transfer.amount;
}
Err(ReceiveValidationError::TxIsNotSettled(timestamp)) => {
if timestamp + tx_timeout < chrono::Utc::now().timestamp() as u64 {
if timestamp + tx_timeout + TX_TIMEOUT_BUFFER_SECS
< chrono::Utc::now().timestamp() as u64
{
consume_payment(store_vault_server, view_pair, &memo, "tx is timeout").await?;
}
log::info!("fee: {} is not settled yet", memo.meta.digest);
continue;
}
Err(e) => {
Err(ReceiveValidationError::ValidationError(e)) => {
log::warn!("invalid fee: {} reason: {}", memo.meta.digest, e,);
consume_payment(store_vault_server, view_pair, &memo, &e.to_string()).await?;
}
Err(e) => {
return Err(SyncError::FeeError(format!(
"failed to validate fee memo: {e}",
)));
}
}
if collected_total_fee >= fee.amount {
break;
Expand Down
8 changes: 4 additions & 4 deletions client-sdk/src/client/receive_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ pub async fn validate_receive(
) -> Result<Transfer, ReceiveValidationError> {
transfer_data
.validate()
.map_err(|e| StrategyError::ValidationError(e.to_string()))?;
.map_err(|e| ReceiveValidationError::ValidationError(e.to_string()))?;

let recipient = transfer_data.transfer.recipient;
if recipient != recipient_spend_pub.0.into() {
return Err(ReceiveValidationError::GeneralError(
return Err(ReceiveValidationError::ValidationError(
"Recipient is not the same as the key".to_string(),
));
}
Expand All @@ -80,15 +80,15 @@ pub async fn validate_receive(
ReceiveValidationError::ValidationError(format!("Failed to decompress spent proof: {e}"))
})?;
if spent_pis.tx != transfer_data.tx {
return Err(ReceiveValidationError::GeneralError(
return Err(ReceiveValidationError::ValidationError(
"Tx in spent proof is not the same as transfer witness tx".to_string(),
));
}
let insufficient_flag = spent_pis
.insufficient_flags
.random_access(transfer_data.transfer_index as usize);
if insufficient_flag {
return Err(ReceiveValidationError::GeneralError(
return Err(ReceiveValidationError::ValidationError(
"Insufficient flag is on in spent proof".to_string(),
));
}
Expand Down
Loading