Skip to content

Commit 73ce9dc

Browse files
committed
Merge remote-tracking branch 'RCasatta/deser_header'
2 parents 60321b9 + e27d82d commit 73ce9dc

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/types.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ where
107107
Ok(answer)
108108
}
109109

110+
fn from_hex_header<'de, D>(deserializer: D) -> Result<block::BlockHeader, D::Error>
111+
where
112+
D: de::Deserializer<'de>,
113+
{
114+
use bitcoin::consensus::deserialize;
115+
116+
let vec: Vec<u8> = from_hex(deserializer)?;
117+
deserialize(&vec).map_err(de::Error::custom)
118+
}
119+
110120
/// Response to a [`script_get_history`](../client/struct.Client.html#method.script_get_history) request.
111121
#[derive(Debug, Deserialize)]
112122
pub struct GetHistoryRes {
@@ -189,8 +199,8 @@ pub struct GetMerkleRes {
189199
pub struct HeaderNotification {
190200
/// New block height.
191201
pub height: usize,
192-
#[serde(rename(serialize = "hex"))]
193202
/// Newly added header.
203+
#[serde(rename = "hex", deserialize_with = "from_hex_header")]
194204
pub header: block::BlockHeader,
195205
}
196206

0 commit comments

Comments
 (0)