diff --git a/core/src/transaction_ffi.rs b/core/src/transaction_ffi.rs index 925f329d88ad49..ec10f014c0f8bc 100644 --- a/core/src/transaction_ffi.rs +++ b/core/src/transaction_ffi.rs @@ -27,6 +27,11 @@ pub unsafe fn create_transaction_interface( transaction.signatures().as_ptr() as *const u8 } + extern "C" fn num_total_signatures(transaction_ptr: TransactionPtr) -> u64 { + let transaction = unsafe { &*(transaction_ptr as *const Tx) }; + transaction.num_total_signatures() + } + extern "C" fn num_write_locks(transaction_ptr: TransactionPtr) -> u64 { let transaction = unsafe { &*(transaction_ptr as *const Tx) }; transaction.num_write_locks() @@ -121,6 +126,7 @@ pub unsafe fn create_transaction_interface( transaction_ptr: transaction as *const Tx as *const core::ffi::c_void, num_signatures_fn: num_signatures::, signatures_fn: signatures::, + num_total_signatures_fn: num_total_signatures::, num_write_locks_fn: num_write_locks::, recent_blockhash_fn: recent_blockhash::, num_instructions_fn: num_instructions::, diff --git a/transaction-ffi/src/lib.rs b/transaction-ffi/src/lib.rs index 309505a4ef3979..b1bae9abe9b71a 100644 --- a/transaction-ffi/src/lib.rs +++ b/transaction-ffi/src/lib.rs @@ -22,6 +22,16 @@ pub type TransactionNumSignaturesFn = pub type TransactionSignaturesFn = unsafe extern "C" fn(transaction_ptr: TransactionPtr) -> *const u8; +/// Returns the total number of signatures in the transaction, including any +/// pre-compile signatures. +/// WARNING: This function should not be used to determine the number of +/// signatures returned by `TransactionSignaturesFn`. Instead, use +/// `TransactionNumSignaturesFn`. +/// # Safety +/// - The transaction pointer must be valid. +pub type TransactionNumTotalSignatures = + unsafe extern "C" fn(transaction_ptr: TransactionPtr) -> u64; + /// Returns the number of requested write-locks in this transaction. /// This does not consider if write-locks are demoted. /// # Safety @@ -159,6 +169,10 @@ pub struct TransactionInterface { /// Returns pointer to the first signature in the transaction. /// See [`TransactionSignaturesFn`]. pub signatures_fn: TransactionSignaturesFn, + /// Returns the total number of signatures in the transaction, including + /// any pre-compile signatures. + /// See [`TransactionNumTotalSignatures`]. + pub num_total_signatures_fn: TransactionNumTotalSignatures, /// Returns the number of requested write-locks in this transaction. /// See [`TransactionNumWriteLocksFn`]. pub num_write_locks_fn: TransactionNumWriteLocksFn,