Skip to content

Commit b0c4d19

Browse files
upbqdnarya2oxarbitragemergify[bot]
authored
fix(rpc): Refactor getrawtransaction & RPC error handling (#9049)
* clean-up: simplify the def of `MapServerError` * Use `HexData` instead of `String` for TXIDs * Remove a redundant test We don't need such a test anymore because the deserialization is handled by Serde now. * Adjust tests for using `HexData` * Make `height` and `confirmations` optional * Use legacy error codes * fmt * Remove unneeded error codes * Remove `zebra-rpc/src/constants.rs` * Rename `MapServerError` to `MapError` * Rename `OkOrServerError` to `OkOrError` * Allow specifying error codes when mapping errors * Allow setting error codes when mapping options * Use the right error code for `getrawtransaction` * fmt * Add docs for the error conversion traits * Refactor the error handling for `getblock` * Refactor error handling in `sendrawtransaction` * Refactor the error handling for `getblock` * Update the error handling for `getrawtransaction` * Refactor error handling for `z_gettreestate` * Refactor the error handling for address parsing * Refactor the error handling for getrawtransaction * Update `z_gettreestate` snapshots * Cosmetics * Refactor error handling in `getblock` * Refactor error handling in `getblockheader` * Simplify `getrawtransaction` * Check errors for `getrawtransaction` * fmt * Simplify proptests * Fix unit tests for `getaddresstxids` * Fix unit tests for `getaddressutxos` * fix docs * Update snapshots for `getrawtransaction` * Update zebra-rpc/src/server/error.rs Co-authored-by: Arya <[email protected]> * Use `transaction::Hash` instead of `HexData` * Simplify error handling * Update zebra-rpc/src/server/error.rs Co-authored-by: Alfredo Garcia <[email protected]> * Move a note on performance * Fix a typo * Use `String` instead of `transaction::Hash` * Adjust and add proptests * Reintroduce snapshots for invalid TXIDs * Don't derive `Serialize` & `Deserialize` for txids Deriving `serde::Serialize` & `serde::Deserialize` for `transaction::Hash` was superfluous, and we didn't need it anywhere in the code. --------- Co-authored-by: Arya <[email protected]> Co-authored-by: Alfredo Garcia <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 568b25e commit b0c4d19

31 files changed

+762
-875
lines changed

zebra-chain/src/transaction/hash.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ use std::{fmt, sync::Arc};
3434
use proptest_derive::Arbitrary;
3535

3636
use hex::{FromHex, ToHex};
37-
use serde::{Deserialize, Serialize};
3837

3938
use crate::serialization::{
4039
ReadZcashExt, SerializationError, WriteZcashExt, ZcashDeserialize, ZcashSerialize,
@@ -56,7 +55,7 @@ use super::{txid::TxIdBuilder, AuthDigest, Transaction};
5655
///
5756
/// [ZIP-244]: https://zips.z.cash/zip-0244
5857
/// [Spec: Transaction Identifiers]: https://zips.z.cash/protocol/protocol.pdf#txnidentifiers
59-
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize, Hash)]
58+
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6059
#[cfg_attr(any(test, feature = "proptest-impl"), derive(Arbitrary))]
6160
pub struct Hash(pub [u8; 32]);
6261

zebra-rpc/src/constants.rs

-44
This file was deleted.

zebra-rpc/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#![doc(html_root_url = "https://docs.rs/zebra_rpc")]
66

77
pub mod config;
8-
pub mod constants;
98
pub mod methods;
109
pub mod queue;
1110
pub mod server;

0 commit comments

Comments
 (0)