diff --git a/README.md b/README.md index bdcea5bf9..17467860d 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,14 @@ listen_addr = '127.0.0.1:8232' parallel_cpu_threads = 0 ``` +It is recommended to use [adityapk00/lightwalletd](https://github.com/adityapk00/lightwalletd) because that is used in testing. + +If using [zcash/lightwalletd](https://github.com/zcash/lightwalletd.git): +- note that it will require a zcash.conf file: + - `rpcuser` and `rpcpassword` are required by `lightwalletd`, but Zebra ignores them if it receives them from `lightwalletd` + - when using a non-default port, use `rpcport=28232` and `rpcbind=127.0.0.1` + - when using testnet, use `testnet=1` + **WARNING:** This config allows multiple Zebra instances to share the same RPC port. See the [RPC config documentation](https://doc.zebra.zfnd.org/zebra_rpc/config/struct.Config.html) for details. diff --git a/zebra-rpc/src/methods.rs b/zebra-rpc/src/methods.rs index 381fc8ade..4b4fd7288 100644 --- a/zebra-rpc/src/methods.rs +++ b/zebra-rpc/src/methods.rs @@ -30,7 +30,7 @@ use zebra_chain::{ }; use zebra_network::constants::USER_AGENT; use zebra_node_services::mempool; -use zebra_state::{OutputIndex, OutputLocation, TransactionLocation}; +use zebra_state::{HashOrHeight, OutputIndex, OutputLocation, TransactionLocation}; use crate::queue::Queue; @@ -562,18 +562,21 @@ where // - use `height_from_signed_int()` to handle negative heights // (this might be better in the state request, because it needs the state height) // - create a function that handles block hashes or heights, and use it in `z_get_treestate()` - fn get_block(&self, height: String, verbosity: u8) -> BoxFuture> { + fn get_block(&self, hash_or_height: String, verbosity: u8) -> BoxFuture> { let mut state = self.state.clone(); async move { - let height: Height = height.parse().map_err(|error: SerializationError| Error { - code: ErrorCode::ServerError(0), - message: error.to_string(), - data: None, - })?; + let hash_or_height: HashOrHeight = + hash_or_height + .parse() + .map_err(|error: SerializationError| Error { + code: ErrorCode::ServerError(0), + message: error.to_string(), + data: None, + })?; if verbosity == 0 { - let request = zebra_state::ReadRequest::Block(height.into()); + let request = zebra_state::ReadRequest::Block(hash_or_height); let response = state .ready() .and_then(|service| service.call(request)) @@ -596,7 +599,7 @@ where _ => unreachable!("unmatched response to a block request"), } } else if verbosity == 1 { - let request = zebra_state::ReadRequest::TransactionIdsForBlock(height.into()); + let request = zebra_state::ReadRequest::TransactionIdsForBlock(hash_or_height); let response = state .ready() .and_then(|service| service.call(request)) diff --git a/zebra-rpc/src/methods/tests/vectors.rs b/zebra-rpc/src/methods/tests/vectors.rs index 8137e52ae..891c1052f 100644 --- a/zebra-rpc/src/methods/tests/vectors.rs +++ b/zebra-rpc/src/methods/tests/vectors.rs @@ -82,12 +82,21 @@ async fn rpc_getblock() { // Make calls with verbosity=0 and check response for (i, block) in blocks.iter().enumerate() { + let expected_result = GetBlock::Raw(block.clone().into()); + let get_block = rpc .get_block(i.to_string(), 0u8) .await .expect("We should have a GetBlock struct"); - assert_eq!(get_block, GetBlock::Raw(block.clone().into())); + assert_eq!(get_block, expected_result); + + let get_block = rpc + .get_block(block.hash().to_string(), 0u8) + .await + .expect("We should have a GetBlock struct"); + + assert_eq!(get_block, expected_result); } // Make calls with verbosity=1 and check response