Skip to content

Commit

Permalink
fix: additional check for cancelled transactions (#3369)
Browse files Browse the repository at this point in the history
Description
---
Check if a transaction has already been received and cancelled on accept transaction.

Motivation and Context
---

How Has This Been Tested?
---
cargo test --all
  • Loading branch information
StriderDM committed Sep 20, 2021
1 parent 8d4e258 commit ac5f26e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion base_layer/wallet/src/transaction_service/service.rs
Expand Up @@ -1217,8 +1217,21 @@ where
traced_message_tag
);

// Check if this transaction has already been received and cancelled.
if let Ok(inbound_tx) = self.db.get_cancelled_pending_inbound_transaction(data.tx_id).await {
if inbound_tx.source_public_key != source_pubkey {
return Err(TransactionServiceError::InvalidSourcePublicKey);
}
trace!(
target: LOG_TARGET,
"A repeated Transaction (TxId: {}) has been received but has been previously cancelled",
inbound_tx.tx_id
);
return Ok(());
}

// Check if this transaction has already been received.
if let Ok(inbound_tx) = self.db.get_pending_inbound_transaction(data.tx_id).await {
if let Ok(inbound_tx) = self.db.get_pending_inbound_transaction(data.clone().tx_id).await {
// Check that it is from the same person
if inbound_tx.source_public_key != source_pubkey {
return Err(TransactionServiceError::InvalidSourcePublicKey);
Expand Down

0 comments on commit ac5f26e

Please sign in to comment.