From a565aa201aa134f61fe7e3ef2c60e1c565f3e4e8 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Fri, 13 Mar 2026 23:06:17 +0000 Subject: [PATCH] feat: add transaction history stub methods to UniFFI bridge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add `get_transactions`, `get_transaction`, and `get_transaction_count` methods to `SpvClient` in the UniFFI bridge. All three return stub/empty data for now — real transaction history will be wired to wallet data in a future PR. Closes #40 Co-authored-by: Kevin Rombach --- dash-spv/src/bridge/mod.rs | 92 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/dash-spv/src/bridge/mod.rs b/dash-spv/src/bridge/mod.rs index b18d78a0f..a52f1ca10 100644 --- a/dash-spv/src/bridge/mod.rs +++ b/dash-spv/src/bridge/mod.rs @@ -769,6 +769,45 @@ impl SpvClient { } } +// ============ Transaction history methods ============ + +#[uniffi::export] +impl SpvClient { + /// Returns a paginated list of transactions from the wallet's transaction history. + /// + /// Transaction history sync is not yet implemented in the SPV client, so this + /// method always returns an empty `Vec`. It is exported so foreign-language + /// bindings can be generated and call-sites can be wired up in advance. + /// + /// # Parameters + /// + /// * `limit` – maximum number of transactions to return. + /// * `offset` – number of transactions to skip before returning results. + pub async fn get_transactions(&self, limit: u32, offset: u32) -> Vec { + let _ = (limit, offset); + vec![] + } + + /// Looks up a single transaction by its transaction ID. + /// + /// Transaction history sync is not yet implemented in the SPV client, so this + /// method always returns `None`. It is exported so foreign-language bindings + /// can be generated and call-sites can be wired up in advance. + pub async fn get_transaction(&self, txid: String) -> Option { + let _ = txid; + None + } + + /// Returns the total number of transactions in the wallet's transaction history. + /// + /// Transaction history sync is not yet implemented in the SPV client, so this + /// method always returns `0`. It is exported so foreign-language bindings can + /// be generated and call-sites can be wired up in advance. + pub async fn get_transaction_count(&self) -> u32 { + 0 + } +} + // ============ Stub functions ============ /// Returns a greeting string (sanity-check export). @@ -1590,4 +1629,57 @@ mod tests { "get_governance_proposal should return None (stub)" ); } + + // ---- get_transactions / get_transaction / get_transaction_count stub tests ---- + + /// `get_transaction_count` always returns 0 (transaction history not yet implemented). + #[tokio::test] + async fn test_get_transaction_count_returns_zero() { + let temp_dir = TempDir::new().expect("Failed to create temp dir"); + let config = ClientConfig::regtest().without_filters().with_storage_path(temp_dir.path()); + + let client = SpvClient::new(config).await.expect("SpvClient construction must succeed"); + assert_eq!( + client.get_transaction_count().await, + 0, + "get_transaction_count should return 0 (stub)" + ); + } + + /// `get_transactions` always returns an empty vec (transaction history not yet implemented). + #[tokio::test] + async fn test_get_transactions_returns_empty() { + let temp_dir = TempDir::new().expect("Failed to create temp dir"); + let config = ClientConfig::regtest().without_filters().with_storage_path(temp_dir.path()); + + let client = SpvClient::new(config).await.expect("SpvClient construction must succeed"); + assert!( + client.get_transactions(10, 0).await.is_empty(), + "get_transactions should return empty vec (stub)" + ); + } + + /// `get_transactions` with various limit/offset values always returns empty (stub). + #[tokio::test] + async fn test_get_transactions_with_limit_and_offset() { + let temp_dir = TempDir::new().expect("Failed to create temp dir"); + let config = ClientConfig::regtest().without_filters().with_storage_path(temp_dir.path()); + + let client = SpvClient::new(config).await.expect("SpvClient construction must succeed"); + assert!(client.get_transactions(0, 0).await.is_empty()); + assert!(client.get_transactions(100, 50).await.is_empty()); + } + + /// `get_transaction` always returns `None` (transaction history not yet implemented). + #[tokio::test] + async fn test_get_transaction_returns_none() { + let temp_dir = TempDir::new().expect("Failed to create temp dir"); + let config = ClientConfig::regtest().without_filters().with_storage_path(temp_dir.path()); + + let client = SpvClient::new(config).await.expect("SpvClient construction must succeed"); + assert!( + client.get_transaction("abcd1234".to_string()).await.is_none(), + "get_transaction should return None (stub)" + ); + } }