diff --git a/base_layer/wallet/src/transaction_service/handle.rs b/base_layer/wallet/src/transaction_service/handle.rs index 8311773404..720de8ce7f 100644 --- a/base_layer/wallet/src/transaction_service/handle.rs +++ b/base_layer/wallet/src/transaction_service/handle.rs @@ -165,11 +165,7 @@ pub enum TransactionEvent { num_confirmations: u64, is_valid: bool, }, - TransactionValidationTimedOut(u64), TransactionValidationStateChanged(u64), - TransactionValidationFailure(u64), - TransactionValidationAborted(u64), - TransactionValidationDelayed(u64), Error(String), } diff --git a/base_layer/wallet_ffi/src/callback_handler.rs b/base_layer/wallet_ffi/src/callback_handler.rs index 4f7b57eb64..3661cd23f5 100644 --- a/base_layer/wallet_ffi/src/callback_handler.rs +++ b/base_layer/wallet_ffi/src/callback_handler.rs @@ -258,19 +258,10 @@ where TBackend: TransactionBackend + 'static self.receive_transaction_mined_unconfirmed_event(tx_id, num_confirmations).await; self.trigger_balance_refresh().await; }, - TransactionEvent::TransactionValidationStateChanged(tx_id) => { - self.transaction_validation_complete_event(tx_id, CallbackValidationResults::Success); + TransactionEvent::TransactionValidationStateChanged(request_key) => { + self.transaction_validation_complete_event(request_key); self.trigger_balance_refresh().await; }, - TransactionEvent::TransactionValidationFailure(tx_id) => { - self.transaction_validation_complete_event(tx_id, CallbackValidationResults::Failure); - }, - TransactionEvent::TransactionValidationAborted(tx_id) => { - self.transaction_validation_complete_event(tx_id, CallbackValidationResults::Aborted); - }, - TransactionEvent::TransactionValidationDelayed(tx_id) => { - self.transaction_validation_complete_event(tx_id, CallbackValidationResults::BaseNodeNotInSync); - }, TransactionEvent::TransactionMinedRequestTimedOut(_tx_id) | TransactionEvent::TransactionImported(_tx_id) | TransactionEvent::TransactionCompletedImmediately(_tx_id) @@ -505,29 +496,13 @@ where TBackend: TransactionBackend + 'static } } - fn transaction_validation_complete_event(&mut self, request_key: u64, result: CallbackValidationResults) { + fn transaction_validation_complete_event(&mut self, request_key: u64) { debug!( target: LOG_TARGET, - "Calling Transaction Validation Complete callback function for Request Key: {} with result {:?}", - request_key, - result as u8, + "Calling Transaction Validation Complete callback function for Request Key: {}", request_key, ); - match result { - CallbackValidationResults::Success => unsafe { - (self.callback_transaction_validation_complete)(request_key, CallbackValidationResults::Success as u8); - }, - CallbackValidationResults::Aborted => unsafe { - (self.callback_transaction_validation_complete)(request_key, CallbackValidationResults::Aborted as u8); - }, - CallbackValidationResults::Failure => unsafe { - (self.callback_transaction_validation_complete)(request_key, CallbackValidationResults::Failure as u8); - }, - CallbackValidationResults::BaseNodeNotInSync => unsafe { - (self.callback_transaction_validation_complete)( - request_key, - CallbackValidationResults::BaseNodeNotInSync as u8, - ); - }, + unsafe { + (self.callback_transaction_validation_complete)(request_key, CallbackValidationResults::Success as u8); } } diff --git a/base_layer/wallet_ffi/src/callback_handler_tests.rs b/base_layer/wallet_ffi/src/callback_handler_tests.rs index 75e233d158..9d3a140a88 100644 --- a/base_layer/wallet_ffi/src/callback_handler_tests.rs +++ b/base_layer/wallet_ffi/src/callback_handler_tests.rs @@ -65,6 +65,7 @@ mod test { use crate::{callback_handler::CallbackHandler, output_manager_service_mock::MockOutputManagerService}; use tari_wallet::transaction_service::protocols::TxRejection; + #[derive(Debug)] struct CallbackState { pub received_tx_callback_called: bool, pub received_tx_reply_callback_called: bool, @@ -194,9 +195,9 @@ mod test { Box::from_raw(balance); } - unsafe extern "C" fn transaction_validation_complete_callback(_tx_id: u64, result: u8) { + unsafe extern "C" fn transaction_validation_complete_callback(request_key: u64, _result: u8) { let mut lock = CALLBACK_STATE.lock().unwrap(); - lock.callback_transaction_validation_complete += result as u32; + lock.callback_transaction_validation_complete += request_key as u32; drop(lock); } @@ -492,7 +493,7 @@ mod test { .unwrap(); transaction_event_sender - .send(Arc::new(TransactionEvent::TransactionValidationFailure(1u64))) + .send(Arc::new(TransactionEvent::TransactionValidationStateChanged(2u64))) .unwrap(); oms_event_sender @@ -508,7 +509,7 @@ mod test { .unwrap(); transaction_event_sender - .send(Arc::new(TransactionEvent::TransactionValidationAborted(1u64))) + .send(Arc::new(TransactionEvent::TransactionValidationStateChanged(3u64))) .unwrap(); oms_event_sender @@ -524,7 +525,7 @@ mod test { .unwrap(); transaction_event_sender - .send(Arc::new(TransactionEvent::TransactionValidationDelayed(1u64))) + .send(Arc::new(TransactionEvent::TransactionValidationStateChanged(4u64))) .unwrap(); dht_event_sender @@ -548,7 +549,7 @@ mod test { assert!(lock.saf_messages_received); assert_eq!(lock.callback_txo_validation_complete, 18); assert_eq!(lock.callback_balance_updated, 5); - assert_eq!(lock.callback_transaction_validation_complete, 6); + assert_eq!(lock.callback_transaction_validation_complete, 10); drop(lock); }