From 6323ae0d0fb2726e95a97ceda52b133027297719 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Wed, 9 Nov 2022 10:47:56 +0100 Subject: [PATCH] bitcoind: add time and MTP to BlockStats --- src/bitcoin/d/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/bitcoin/d/mod.rs b/src/bitcoin/d/mod.rs index d3d29ca5..f0157b18 100644 --- a/src/bitcoin/d/mod.rs +++ b/src/bitcoin/d/mod.rs @@ -688,11 +688,23 @@ impl BitcoinD { .and_then(Json::as_i64) .expect("Invalid height in `getblockheader` response: not an i64") as i32; + let time = res + .get("time") + .and_then(Json::as_u64) + .expect("Invalid timestamp in `getblockheader` response: not an u64") + as u32; + let median_time_past = res + .get("mediantime") + .and_then(Json::as_u64) + .expect("Invalid median timestamp in `getblockheader` response: not an u64") + as u32; BlockStats { confirmations, previous_blockhash, height, blockhash, + time, + median_time_past, } } @@ -853,4 +865,6 @@ pub struct BlockStats { pub previous_blockhash: Option, pub blockhash: bitcoin::BlockHash, pub height: i32, + pub time: u32, + pub median_time_past: u32, }