diff --git a/integration_tests/tests/wallet_ffi.rs b/integration_tests/tests/wallet_ffi.rs index a19bc355..d421291f 100644 --- a/integration_tests/tests/wallet_ffi.rs +++ b/integration_tests/tests/wallet_ffi.rs @@ -284,6 +284,12 @@ unsafe extern "C" { ) -> LabelList; fn wallet_ffi_free_label_list(label_list: *mut LabelList) -> error::WalletFfiError; + + fn wallet_ffi_poll_transaction_status( + handle: *mut WalletHandle, + tx_hash: FfiBytes32, + transaction_status: *mut bool, + ) -> error::WalletFfiError; } fn new_wallet_ffi_with_test_context_config( @@ -987,6 +993,17 @@ fn test_wallet_ffi_transfer_public() -> Result<()> { assert_eq!(from_balance, 9900); assert_eq!(to_balance, 20100); + // Also check for transaction inclusion + let hash_bytes = unsafe { transfer_result.tx_hash_bytes() }; + let mut is_included = false; + + unsafe { + wallet_ffi_poll_transaction_status(wallet_ffi_handle, hash_bytes, &raw mut is_included) + .unwrap(); + } + + assert!(is_included); + unsafe { wallet_ffi_free_transfer_result(&raw mut transfer_result); wallet_ffi_destroy(wallet_ffi_handle); diff --git a/lez/wallet-ffi/src/types.rs b/lez/wallet-ffi/src/types.rs index 3779ba01..cf872338 100644 --- a/lez/wallet-ffi/src/types.rs +++ b/lez/wallet-ffi/src/types.rs @@ -7,6 +7,7 @@ use std::{ str::FromStr as _, }; +use common::HashType; use lee::{Data, ProgramId, SharedSecretKey}; use lee_core::{encryption::MlKem768EncapsulationKey, program::PdaSeed, NullifierPublicKey}; use wallet::{account::AccountIdWithPrivacy, AccountIdentity}; @@ -173,6 +174,22 @@ impl Default for FfiTransferResult { } } +impl FfiTransferResult { + #[must_use] + /// Casting valid results hash into bytes. + /// + /// # Safety + /// Field `tx_hash` must be a valid pointer into transaction hash. + pub unsafe fn tx_hash_bytes(&self) -> FfiBytes32 { + let cstring = unsafe { CString::from_raw(self.tx_hash) }; + let rstring = cstring.into_string().expect("Must be a valid Rust string"); + + let hash_val = HashType::from_str(&rstring).expect("Must be a valid hex string"); + + FfiBytes32 { data: hash_val.0 } + } +} + // Helper functions to convert between Rust and FFI types impl FfiBytes32 {