feat(wallet_ffi): tx status

This commit is contained in:
Pravdyvy 2026-08-07 15:19:12 +03:00
parent cbd10c5bba
commit 45452c80ac
4 changed files with 58 additions and 0 deletions

1
Cargo.lock generated
View File

@ -11574,6 +11574,7 @@ version = "0.1.0"
dependencies = [
"bip39",
"cbindgen",
"common",
"key_protocol",
"lee",
"lee_core",

View File

@ -14,6 +14,7 @@ crate-type = ["rlib", "cdylib", "staticlib"]
wallet.workspace = true
lee.workspace = true
lee_core.workspace = true
common.workspace = true
programs.workspace = true
tokio.workspace = true

View File

@ -3,6 +3,7 @@ use std::{
ffi::{c_char, CString},
};
use common::HashType;
use lee::{privacy_preserving_transaction::circuit::ProgramWithDependencies, program::Program};
use crate::{
@ -390,6 +391,43 @@ pub unsafe extern "C" fn wallet_ffi_send_generic_private_transaction(
}
}
/// Poll transaction for its status.
///
/// # Parameters
/// - `handle`: Valid pointer to wallet handle.
/// - `tx_hash`: Bytes of a transaction hash,
/// - `transaction_status`: Valid pointer into `bool`.
///
/// # Returns
/// - `true` if seen included, `false` othervise.
///
/// # Safety
/// - `handle` must be a valid pointer.
#[no_mangle]
pub unsafe extern "C" fn wallet_ffi_poll_transaction_status(
handle: *mut WalletHandle,
tx_hash: FfiBytes32,
// ToDo: Replace with status enum.
transaction_status: *mut bool,
) -> WalletFfiError {
let wrapper = match get_wallet(handle) {
Ok(w) => w,
Err(e) => return e,
};
let wallet = match wrapper.core.lock() {
Ok(w) => w,
Err(e) => {
print_error(format!("Failed to lock wallet: {e}"));
return WalletFfiError::InternalError;
}
};
*transaction_status = block_on(wallet.poll_transaction(HashType(tx_hash.data))).is_ok();
WalletFfiError::Success
}
/// Free a transaction result returned by `wallet_ffi_send_generic_public_transaction` or
/// `wallet_ffi_send_generic_private_transaction`.
///

View File

@ -668,6 +668,24 @@ enum WalletFfiError wallet_ffi_send_generic_private_transaction(struct WalletHan
const struct FfiProgramWithDependencies *program_with_dependencies,
struct FfiTransactionResult *out_result);
/**
* Poll transaction for its status.
*
* # Parameters
* - `handle`: Valid pointer to wallet handle.
* - `tx_hash`: Bytes of a transaction hash,
* - `transaction_status`: Valid pointer into `bool`.
*
* # Returns
* - `true` if seen included, `false` othervise.
*
* # Safety
* - `handle` must be a valid pointer.
*/
enum WalletFfiError wallet_ffi_poll_transaction_status(struct WalletHandle *handle,
struct FfiBytes32 tx_hash,
bool *transaction_status);
/**
* Free a transaction result returned by `wallet_ffi_send_generic_public_transaction` or
* `wallet_ffi_send_generic_private_transaction`.