Skip to content

Commit e2698a9

Browse files
committed
Revert "Add consensus::deserialize_hex function
As this function won't be included in `rust-bitcoin v0.31.0` release according to rust-bitcoin/rust-bitcoincore-rpc#308 (comment)
1 parent 1a774ea commit e2698a9

File tree

1 file changed

+0
-51
lines changed

1 file changed

+0
-51
lines changed

bitcoin/src/consensus/mod.rs

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ pub mod params;
1111
#[cfg(feature = "bitcoinconsensus")]
1212
pub mod validation;
1313

14-
use core::fmt;
15-
16-
use hex::{HexToBytesError, HexToBytesIter};
17-
use internals::write_err;
18-
1914
pub use self::encode::{
2015
deserialize, deserialize_partial, serialize, Decodable, Encodable, ReadExt, WriteExt,
2116
};
@@ -25,51 +20,5 @@ pub use self::validation::{
2520
verify_script, verify_script_with_flags, verify_transaction, verify_transaction_with_flags,
2621
};
2722

28-
/// Deserialize any decodable type from a hex string.
29-
pub fn deserialize_hex<T: Decodable>(hex: &str) -> Result<T, DecodeHexError> {
30-
let mut decoder = HexToBytesIter::new(hex)?;
31-
let rv = Decodable::consensus_decode_from_finite_reader(&mut decoder)?;
32-
Ok(rv)
33-
}
34-
35-
/// Hex decoding error.
36-
#[derive(Debug)]
37-
pub enum DecodeHexError {
38-
/// Hex decoding error.
39-
Decode(HexToBytesError),
40-
/// Consensus deserialization error.
41-
Deser(encode::Error),
42-
}
43-
44-
impl fmt::Display for DecodeHexError {
45-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
46-
use DecodeHexError::*;
47-
48-
match *self {
49-
Decode(ref e) => write_err!(f, "hex decoding erorr"; e),
50-
Deser(ref e) => write_err!(f, "consensus deserialization error"; e),
51-
}
52-
}
53-
}
54-
55-
#[cfg(feature = "std")]
56-
impl std::error::Error for DecodeHexError {
57-
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
58-
use DecodeHexError::*;
59-
60-
match *self {
61-
Decode(_) | Deser(_) => None,
62-
}
63-
}
64-
}
65-
66-
impl From<HexToBytesError> for DecodeHexError {
67-
fn from(e: HexToBytesError) -> Self { Self::Decode(e) }
68-
}
69-
70-
impl From<encode::Error> for DecodeHexError {
71-
fn from(e: encode::Error) -> Self { Self::Deser(e) }
72-
}
73-
7423
#[cfg(feature = "serde")]
7524
pub mod serde;

0 commit comments

Comments
 (0)