From 817835302b9e03a69d962f4bd59ffbe57ff4d359 Mon Sep 17 00:00:00 2001 From: Alan Szepieniec Date: Sat, 23 Aug 2025 00:57:00 +0200 Subject: [PATCH] fix(RPC): Encode hashmap as list for transmission In commit 1096a293 on neptune-core, the return type of RPC endpoint `addition_records_for_block` changes from `HashMap` to `Vec`. This commit applies the matching change on the side of the client, including building the original hashmap from the transmitted list. These commits (the present one and the one referenced) fix the issue that transparent transaction info could not be transferred across the RPC layer. --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/html/page/announcement.rs | 19 +++++++++++++------ src/neptune_rpc.rs | 5 ++--- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a4887b7..5f9f613 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1737,7 +1737,7 @@ dependencies = [ [[package]] name = "neptune-cash" version = "0.3.0" -source = "git+https://github.com/Neptune-Crypto/neptune-core.git?branch=asz%2Ftransparent-transactions#cece8dab9db0334b07a2112a9163e3882ab71a55" +source = "git+https://github.com/Neptune-Crypto/neptune-core.git?branch=master#1096a2935af9c023a3a737638c09195f4801881b" dependencies = [ "aead", "aes-gcm", diff --git a/Cargo.toml b/Cargo.toml index 373ede9..03d64ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,7 @@ arbitrary = "1.4.1" proptest-arbitrary-interop = "0.1.0" [patch.crates-io] -neptune-cash = { git = "https://github.com/Neptune-Crypto/neptune-core.git", branch = "asz/transparent-transactions" } +neptune-cash = { git = "https://github.com/Neptune-Crypto/neptune-core.git", branch = "master" } [features] mock = ["dep:blake3", "dep:rand"] \ No newline at end of file diff --git a/src/html/page/announcement.rs b/src/html/page/announcement.rs index d14cf10..a9a5ed7 100644 --- a/src/html/page/announcement.rs +++ b/src/html/page/announcement.rs @@ -84,12 +84,19 @@ pub async fn announcement_page( .iter() .map(|output| output.addition_record()) .collect::>(); - addition_record_indices = state.rpc_client.addition_record_indices_for_block(context::current(), state.token(), block_selector, &addition_records).await - .map_err(|e| not_found_html_response(state, Some(e.to_string())))? - .map_err(rpc_method_err)? - .expect( - "block guaranteed to exist because we got here; getting its announcements should work", - ); + addition_record_indices = state + .rpc_client + .addition_record_indices_for_block( + context::current(), + state.token(), + block_selector, + &addition_records, + ) + .await + .map_err(|e| not_found_html_response(state, Some(e.to_string())))? + .map_err(rpc_method_err)? + .into_iter() + .collect::>(); let mut transparent_utxos_cache = state.transparent_utxos_cache.lock().await; diff --git a/src/neptune_rpc.rs b/src/neptune_rpc.rs index 46748f5..fb5227c 100644 --- a/src/neptune_rpc.rs +++ b/src/neptune_rpc.rs @@ -19,7 +19,6 @@ use neptune_cash::rpc_server::error::RpcError; use neptune_cash::rpc_server::RPCClient; use neptune_cash::rpc_server::RpcResult; use neptune_cash::util_types::mutator_set::addition_record::AdditionRecord; -use std::collections::HashMap; use std::net::Ipv4Addr; use std::net::SocketAddr; use std::sync::Arc; @@ -195,7 +194,7 @@ impl AuthenticatedClient { block_selector: BlockSelector, _addition_records: &[AdditionRecord], ) -> ::core::result::Result< - RpcResult>>>, + RpcResult)>>, ::tarpc::client::RpcError, > { let rpc_result = self @@ -204,7 +203,7 @@ impl AuthenticatedClient { .await; // if the RPC call was successful, return that - if let Ok(Ok(Some(_))) = rpc_result { + if let Ok(Ok(_)) = rpc_result { return rpc_result; }