diff --git a/mm2src/coins/utxo/rpc_clients.rs b/mm2src/coins/utxo/rpc_clients.rs index 716ba891e9..4921056a7b 100644 --- a/mm2src/coins/utxo/rpc_clients.rs +++ b/mm2src/coins/utxo/rpc_clients.rs @@ -31,7 +31,7 @@ use http::Uri; use http::{Request, StatusCode}; use keys::Address; #[cfg(test)] use mocktopus::macros::*; -use rpc::v1::types::{Bytes as BytesJson, Transaction as RpcTransaction, VerboseBlockClient, H256 as H256Json}; +use rpc::v1::types::{Bytes as BytesJson, Transaction as RpcTransaction, H256 as H256Json}; #[cfg(feature = "native")] use rustls::{self}; use script::Builder; use serde_json::{self as json, Value as Json}; @@ -356,6 +356,54 @@ pub enum EstimateFeeMethod { SmartFee, } +#[derive(Debug, Deserialize)] +#[serde(untagged)] +pub enum BlockNonce { + String(String), + U64(u64), +} + +#[derive(Debug, Deserialize)] +pub struct VerboseBlock { + /// Block hash + pub hash: H256Json, + /// Number of confirmations. -1 if block is on the side chain + pub confirmations: i64, + /// Block size + pub size: u32, + /// Block size, excluding witness data + pub strippedsize: Option, + /// Block weight + pub weight: Option, + /// Block height + pub height: Option, + /// Block version + pub version: u32, + /// Block version as hex + #[serde(rename = "versionHex")] + pub version_hex: Option, + /// Merkle root of this block + pub merkleroot: H256Json, + /// Transactions ids + pub tx: Vec, + /// Block time in seconds since epoch (Jan 1 1970 GMT) + pub time: u32, + /// Median block time in seconds since epoch (Jan 1 1970 GMT) + pub mediantime: Option, + /// Block nonce + pub nonce: BlockNonce, + /// Block nbits + pub bits: String, + /// Block difficulty + pub difficulty: f64, + /// Expected number of hashes required to produce the chain up to this block (in hex) + pub chainwork: H256Json, + /// Hash of previous block + pub previousblockhash: Option, + /// Hash of next block + pub nextblockhash: Option, +} + pub type RpcReqSub = async_oneshot::Sender>; /// RPC client for UTXO based coins @@ -574,7 +622,8 @@ impl UtxoRpcClientOps for NativeClient { ) -> Box + Send> { let selfi = self.clone(); let fut = async move { - let starting_block_data = try_s!(selfi.get_block(starting_block.to_string()).compat().await); + let starting_block_hash = try_s!(selfi.get_block_hash(starting_block).compat().await); + let starting_block_data = try_s!(selfi.get_block(starting_block_hash).compat().await); if let Some(median) = starting_block_data.mediantime { return Ok(median); } @@ -586,7 +635,8 @@ impl UtxoRpcClientOps for NativeClient { starting_block - count.get() + 1 }; for block_n in from..starting_block { - let block_data = try_s!(selfi.get_block(block_n.to_string()).compat().await); + let block_hash = try_s!(selfi.get_block_hash(block_n).compat().await); + let block_data = try_s!(selfi.get_block(block_hash).compat().await); block_timestamps.push(block_data.time); } // can unwrap because count is non zero @@ -660,11 +710,14 @@ impl NativeClientImpl { /// https://developer.bitcoin.org/reference/rpc/getblock.html /// Always returns verbose block - pub fn get_block(&self, height: String) -> RpcRes { + pub fn get_block(&self, hash: H256Json) -> RpcRes { let verbose = true; - rpc_func!(self, "getblock", height, verbose) + rpc_func!(self, "getblock", hash, verbose) } + /// https://developer.bitcoin.org/reference/rpc/getblockhash.html + pub fn get_block_hash(&self, height: u64) -> RpcRes { rpc_func!(self, "getblockhash", height) } + /// https://developer.bitcoin.org/reference/rpc/getblockcount.html pub fn get_block_count(&self) -> RpcRes { rpc_func!(self, "getblockcount") } @@ -762,11 +815,6 @@ impl NativeClientImpl { ) } - /// https://developer.bitcoin.org/reference/rpc/getblockhash.html - pub fn get_block_hash(&self, block_number: u64) -> RpcRes { - rpc_func!(self, "getblockhash", block_number) - } - /// https://developer.bitcoin.org/reference/rpc/sendtoaddress.html pub fn send_to_address(&self, addr: &str, amount: &BigDecimal) -> RpcRes { rpc_func!(self, "sendtoaddress", addr, amount) diff --git a/mm2src/coins/utxo/utxo_tests.rs b/mm2src/coins/utxo/utxo_tests.rs index c2cbe52a7e..97a1eba424 100644 --- a/mm2src/coins/utxo/utxo_tests.rs +++ b/mm2src/coins/utxo/utxo_tests.rs @@ -1,6 +1,6 @@ use super::rpc_clients::{ElectrumProtocol, ListSinceBlockRes, NetworkInfo}; use super::*; -use crate::utxo::rpc_clients::{GetAddressInfoRes, UtxoRpcClientOps, ValidateAddressRes}; +use crate::utxo::rpc_clients::{GetAddressInfoRes, UtxoRpcClientOps, ValidateAddressRes, VerboseBlock}; use crate::utxo::utxo_common::{generate_transaction, UtxoArcBuilder}; use crate::utxo::utxo_standard::{utxo_standard_coin_from_conf_and_request, UtxoStandardCoin}; use crate::{SwapOps, TradePreimageValue, WithdrawFee}; @@ -12,7 +12,7 @@ use common::{block_on, OrdRange, DEX_FEE_ADDR_RAW_PUBKEY}; use futures::future::join_all; use gstuff::now_ms; use mocktopus::mocking::*; -use rpc::v1::types::{VerboseBlockClient, H256 as H256Json}; +use rpc::v1::types::H256 as H256Json; use serialization::deserialize; use std::collections::HashMap; use std::thread; @@ -1022,8 +1022,15 @@ fn test_get_median_time_past_from_electrum_btc() { #[test] fn test_get_median_time_past_from_native_has_median_in_get_block() { let client = native_client_for_test(); - NativeClientImpl::get_block.mock_safe(|_, block_num| { - assert_eq!(block_num, "632858".to_string()); + NativeClientImpl::get_block_hash.mock_safe(|_, block_num| { + assert_eq!(block_num, 632858); + MockResult::Return(Box::new(futures01::future::ok( + "00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695e3".into(), + ))) + }); + + NativeClientImpl::get_block.mock_safe(|_, block_hash| { + assert_eq!(block_hash, "00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695e3".into()); let block_data_str = r#"{"hash":"00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695e3","confirmations":1,"strippedsize":833287,"size":1493229,"weight":3993090,"height":632858,"version":549453824,"versionHex":"20c00000","merkleroot":"7e20760d227465d2a84fbb2617b2962f77364daa66f06b48d1010fa27923b940","tx":[],"time":1591174568,"mediantime":1591173041,"nonce":"1594651477","bits":"171297f6","difficulty":15138043247082.88,"chainwork":"00000000000000000000000000000000000000000fff2e35384d3c16f53adda4","nTx":1601,"previousblockhash":"00000000000000000009a54084d9f4eafa3ca07af646ff8fa9031d0ac72a92aa"}"#; let block_data = json::from_str(block_data_str).unwrap(); MockResult::Return( @@ -1040,27 +1047,34 @@ fn test_get_median_time_past_from_native_does_not_have_median_in_get_block() { let blocks_json_str = r#" [ {"hash":"00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695e3","confirmations":1,"strippedsize":833287,"size":1493229,"weight":3993090,"height":632858,"version":549453824,"versionHex":"20c00000","merkleroot":"7e20760d227465d2a84fbb2617b2962f77364daa66f06b48d1010fa27923b940","tx":[],"time":1591173090,"nonce":"1594651477","bits":"171297f6","difficulty":15138043247082.88,"chainwork":"00000000000000000000000000000000000000000fff2e35384d3c16f53adda4","nTx":1601,"previousblockhash":"00000000000000000009a54084d9f4eafa3ca07af646ff8fa9031d0ac72a92aa"}, - {"hash":"00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695e3","confirmations":1,"strippedsize":833287,"size":1493229,"weight":3993090,"height":632857,"version":549453824,"versionHex":"20c00000","merkleroot":"7e20760d227465d2a84fbb2617b2962f77364daa66f06b48d1010fa27923b940","tx":[],"time":1591173080,"nonce":"1594651477","bits":"171297f6","difficulty":15138043247082.88,"chainwork":"00000000000000000000000000000000000000000fff2e35384d3c16f53adda4","nTx":1601,"previousblockhash":"00000000000000000009a54084d9f4eafa3ca07af646ff8fa9031d0ac72a92aa"}, - {"hash":"00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695e3","confirmations":1,"strippedsize":833287,"size":1493229,"weight":3993090,"height":632856,"version":549453824,"versionHex":"20c00000","merkleroot":"7e20760d227465d2a84fbb2617b2962f77364daa66f06b48d1010fa27923b940","tx":[],"time":1591173070,"nonce":"1594651477","bits":"171297f6","difficulty":15138043247082.88,"chainwork":"00000000000000000000000000000000000000000fff2e35384d3c16f53adda4","nTx":1601,"previousblockhash":"00000000000000000009a54084d9f4eafa3ca07af646ff8fa9031d0ac72a92aa"}, - {"hash":"00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695e3","confirmations":1,"strippedsize":833287,"size":1493229,"weight":3993090,"height":632855,"version":549453824,"versionHex":"20c00000","merkleroot":"7e20760d227465d2a84fbb2617b2962f77364daa66f06b48d1010fa27923b940","tx":[],"time":1591173058,"nonce":"1594651477","bits":"171297f6","difficulty":15138043247082.88,"chainwork":"00000000000000000000000000000000000000000fff2e35384d3c16f53adda4","nTx":1601,"previousblockhash":"00000000000000000009a54084d9f4eafa3ca07af646ff8fa9031d0ac72a92aa"}, - {"hash":"00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695e3","confirmations":1,"strippedsize":833287,"size":1493229,"weight":3993090,"height":632854,"version":549453824,"versionHex":"20c00000","merkleroot":"7e20760d227465d2a84fbb2617b2962f77364daa66f06b48d1010fa27923b940","tx":[],"time":1591173050,"nonce":"1594651477","bits":"171297f6","difficulty":15138043247082.88,"chainwork":"00000000000000000000000000000000000000000fff2e35384d3c16f53adda4","nTx":1601,"previousblockhash":"00000000000000000009a54084d9f4eafa3ca07af646ff8fa9031d0ac72a92aa"}, - {"hash":"00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695e3","confirmations":1,"strippedsize":833287,"size":1493229,"weight":3993090,"height":632853,"version":549453824,"versionHex":"20c00000","merkleroot":"7e20760d227465d2a84fbb2617b2962f77364daa66f06b48d1010fa27923b940","tx":[],"time":1591173041,"nonce":"1594651477","bits":"171297f6","difficulty":15138043247082.88,"chainwork":"00000000000000000000000000000000000000000fff2e35384d3c16f53adda4","nTx":1601,"previousblockhash":"00000000000000000009a54084d9f4eafa3ca07af646ff8fa9031d0ac72a92aa"}, - {"hash":"00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695e3","confirmations":1,"strippedsize":833287,"size":1493229,"weight":3993090,"height":632852,"version":549453824,"versionHex":"20c00000","merkleroot":"7e20760d227465d2a84fbb2617b2962f77364daa66f06b48d1010fa27923b940","tx":[],"time":1591173040,"nonce":"1594651477","bits":"171297f6","difficulty":15138043247082.88,"chainwork":"00000000000000000000000000000000000000000fff2e35384d3c16f53adda4","nTx":1601,"previousblockhash":"00000000000000000009a54084d9f4eafa3ca07af646ff8fa9031d0ac72a92aa"}, - {"hash":"00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695e3","confirmations":1,"strippedsize":833287,"size":1493229,"weight":3993090,"height":632851,"version":549453824,"versionHex":"20c00000","merkleroot":"7e20760d227465d2a84fbb2617b2962f77364daa66f06b48d1010fa27923b940","tx":[],"time":1591173039,"nonce":"1594651477","bits":"171297f6","difficulty":15138043247082.88,"chainwork":"00000000000000000000000000000000000000000fff2e35384d3c16f53adda4","nTx":1601,"previousblockhash":"00000000000000000009a54084d9f4eafa3ca07af646ff8fa9031d0ac72a92aa"}, - {"hash":"00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695e3","confirmations":1,"strippedsize":833287,"size":1493229,"weight":3993090,"height":632850,"version":549453824,"versionHex":"20c00000","merkleroot":"7e20760d227465d2a84fbb2617b2962f77364daa66f06b48d1010fa27923b940","tx":[],"time":1591173038,"nonce":"1594651477","bits":"171297f6","difficulty":15138043247082.88,"chainwork":"00000000000000000000000000000000000000000fff2e35384d3c16f53adda4","nTx":1601,"previousblockhash":"00000000000000000009a54084d9f4eafa3ca07af646ff8fa9031d0ac72a92aa"}, - {"hash":"00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695e3","confirmations":1,"strippedsize":833287,"size":1493229,"weight":3993090,"height":632849,"version":549453824,"versionHex":"20c00000","merkleroot":"7e20760d227465d2a84fbb2617b2962f77364daa66f06b48d1010fa27923b940","tx":[],"time":1591173037,"nonce":"1594651477","bits":"171297f6","difficulty":15138043247082.88,"chainwork":"00000000000000000000000000000000000000000fff2e35384d3c16f53adda4","nTx":1601,"previousblockhash":"00000000000000000009a54084d9f4eafa3ca07af646ff8fa9031d0ac72a92aa"}, - {"hash":"00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695e3","confirmations":1,"strippedsize":833287,"size":1493229,"weight":3993090,"height":632848,"version":549453824,"versionHex":"20c00000","merkleroot":"7e20760d227465d2a84fbb2617b2962f77364daa66f06b48d1010fa27923b940","tx":[],"time":1591173030,"nonce":"1594651477","bits":"171297f6","difficulty":15138043247082.88,"chainwork":"00000000000000000000000000000000000000000fff2e35384d3c16f53adda4","nTx":1601,"previousblockhash":"00000000000000000009a54084d9f4eafa3ca07af646ff8fa9031d0ac72a92aa"} + {"hash":"00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695e4","confirmations":1,"strippedsize":833287,"size":1493229,"weight":3993090,"height":632857,"version":549453824,"versionHex":"20c00000","merkleroot":"7e20760d227465d2a84fbb2617b2962f77364daa66f06b48d1010fa27923b940","tx":[],"time":1591173080,"nonce":"1594651477","bits":"171297f6","difficulty":15138043247082.88,"chainwork":"00000000000000000000000000000000000000000fff2e35384d3c16f53adda4","nTx":1601,"previousblockhash":"00000000000000000009a54084d9f4eafa3ca07af646ff8fa9031d0ac72a92aa"}, + {"hash":"00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695e5","confirmations":1,"strippedsize":833287,"size":1493229,"weight":3993090,"height":632856,"version":549453824,"versionHex":"20c00000","merkleroot":"7e20760d227465d2a84fbb2617b2962f77364daa66f06b48d1010fa27923b940","tx":[],"time":1591173070,"nonce":"1594651477","bits":"171297f6","difficulty":15138043247082.88,"chainwork":"00000000000000000000000000000000000000000fff2e35384d3c16f53adda4","nTx":1601,"previousblockhash":"00000000000000000009a54084d9f4eafa3ca07af646ff8fa9031d0ac72a92aa"}, + {"hash":"00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695e6","confirmations":1,"strippedsize":833287,"size":1493229,"weight":3993090,"height":632855,"version":549453824,"versionHex":"20c00000","merkleroot":"7e20760d227465d2a84fbb2617b2962f77364daa66f06b48d1010fa27923b940","tx":[],"time":1591173058,"nonce":"1594651477","bits":"171297f6","difficulty":15138043247082.88,"chainwork":"00000000000000000000000000000000000000000fff2e35384d3c16f53adda4","nTx":1601,"previousblockhash":"00000000000000000009a54084d9f4eafa3ca07af646ff8fa9031d0ac72a92aa"}, + {"hash":"00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695e7","confirmations":1,"strippedsize":833287,"size":1493229,"weight":3993090,"height":632854,"version":549453824,"versionHex":"20c00000","merkleroot":"7e20760d227465d2a84fbb2617b2962f77364daa66f06b48d1010fa27923b940","tx":[],"time":1591173050,"nonce":"1594651477","bits":"171297f6","difficulty":15138043247082.88,"chainwork":"00000000000000000000000000000000000000000fff2e35384d3c16f53adda4","nTx":1601,"previousblockhash":"00000000000000000009a54084d9f4eafa3ca07af646ff8fa9031d0ac72a92aa"}, + {"hash":"00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695e8","confirmations":1,"strippedsize":833287,"size":1493229,"weight":3993090,"height":632853,"version":549453824,"versionHex":"20c00000","merkleroot":"7e20760d227465d2a84fbb2617b2962f77364daa66f06b48d1010fa27923b940","tx":[],"time":1591173041,"nonce":"1594651477","bits":"171297f6","difficulty":15138043247082.88,"chainwork":"00000000000000000000000000000000000000000fff2e35384d3c16f53adda4","nTx":1601,"previousblockhash":"00000000000000000009a54084d9f4eafa3ca07af646ff8fa9031d0ac72a92aa"}, + {"hash":"00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695e9","confirmations":1,"strippedsize":833287,"size":1493229,"weight":3993090,"height":632852,"version":549453824,"versionHex":"20c00000","merkleroot":"7e20760d227465d2a84fbb2617b2962f77364daa66f06b48d1010fa27923b940","tx":[],"time":1591173040,"nonce":"1594651477","bits":"171297f6","difficulty":15138043247082.88,"chainwork":"00000000000000000000000000000000000000000fff2e35384d3c16f53adda4","nTx":1601,"previousblockhash":"00000000000000000009a54084d9f4eafa3ca07af646ff8fa9031d0ac72a92aa"}, + {"hash":"00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695f0","confirmations":1,"strippedsize":833287,"size":1493229,"weight":3993090,"height":632851,"version":549453824,"versionHex":"20c00000","merkleroot":"7e20760d227465d2a84fbb2617b2962f77364daa66f06b48d1010fa27923b940","tx":[],"time":1591173039,"nonce":"1594651477","bits":"171297f6","difficulty":15138043247082.88,"chainwork":"00000000000000000000000000000000000000000fff2e35384d3c16f53adda4","nTx":1601,"previousblockhash":"00000000000000000009a54084d9f4eafa3ca07af646ff8fa9031d0ac72a92aa"}, + {"hash":"00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695f1","confirmations":1,"strippedsize":833287,"size":1493229,"weight":3993090,"height":632850,"version":549453824,"versionHex":"20c00000","merkleroot":"7e20760d227465d2a84fbb2617b2962f77364daa66f06b48d1010fa27923b940","tx":[],"time":1591173038,"nonce":"1594651477","bits":"171297f6","difficulty":15138043247082.88,"chainwork":"00000000000000000000000000000000000000000fff2e35384d3c16f53adda4","nTx":1601,"previousblockhash":"00000000000000000009a54084d9f4eafa3ca07af646ff8fa9031d0ac72a92aa"}, + {"hash":"00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695f2","confirmations":1,"strippedsize":833287,"size":1493229,"weight":3993090,"height":632849,"version":549453824,"versionHex":"20c00000","merkleroot":"7e20760d227465d2a84fbb2617b2962f77364daa66f06b48d1010fa27923b940","tx":[],"time":1591173037,"nonce":"1594651477","bits":"171297f6","difficulty":15138043247082.88,"chainwork":"00000000000000000000000000000000000000000fff2e35384d3c16f53adda4","nTx":1601,"previousblockhash":"00000000000000000009a54084d9f4eafa3ca07af646ff8fa9031d0ac72a92aa"}, + {"hash":"00000000000000000002eb7892b8fdfd7b8e0f089e5cdf96436de680b7e695f3","confirmations":1,"strippedsize":833287,"size":1493229,"weight":3993090,"height":632848,"version":549453824,"versionHex":"20c00000","merkleroot":"7e20760d227465d2a84fbb2617b2962f77364daa66f06b48d1010fa27923b940","tx":[],"time":1591173030,"nonce":1594651477,"bits":"171297f6","difficulty":15138043247082.88,"chainwork":"00000000000000000000000000000000000000000fff2e35384d3c16f53adda4","nTx":1601,"previousblockhash":"00000000000000000009a54084d9f4eafa3ca07af646ff8fa9031d0ac72a92aa"} ] "#; - let blocks: Vec = json::from_str(blocks_json_str).unwrap(); - let mut blocks: HashMap<_, _> = blocks - .into_iter() - .map(|block| (block.height.unwrap().to_string(), block)) + let blocks: Vec = json::from_str(blocks_json_str).unwrap(); + let mut block_hashes: HashMap<_, _> = blocks + .iter() + .map(|block| (block.height.unwrap() as u64, block.hash.clone())) .collect(); + let mut blocks: HashMap<_, _> = blocks.into_iter().map(|block| (block.hash.clone(), block)).collect(); let client = native_client_for_test(); - NativeClientImpl::get_block.mock_safe(move |_, block_num| { - let block = blocks.remove(&block_num).unwrap(); + + NativeClientImpl::get_block_hash.mock_safe(move |_, block_num| { + let hash = block_hashes.remove(&block_num).unwrap(); + MockResult::Return(Box::new(futures01::future::ok(hash))) + }); + + NativeClientImpl::get_block.mock_safe(move |_, block_hash| { + let block = blocks.remove(&block_hash).unwrap(); MockResult::Return(Box::new(futures01::future::ok(block))) }); @@ -2159,6 +2173,49 @@ fn test_validate_fee_min_block() { assert!(validate_err.contains("confirmed before min_block")); } +#[test] +fn firo_verbose_block_deserialize() { + let json = json!({ + "hash":"e21ea157b142270ba479a0aeb5571144b2a06f66a693c20675c624a6f211de0a", + "confirmations":1, + "strippedsize":234913, + "size":234913, + "weight":234913, + "height":348355, + "version":536875008, + "versionHex":"20001000", + "merkleroot":"b7fa3ce26f5b493397302c260905ca6f8c9ade56cab7cb314dc6f8a1d4c69245", + "tx":[ + "166d2e6c6b8e1f29192737be5b0df79f7ccb286a898a3bf7253aa091e1002756", + "f0bcbf10f2aa20d6891c14fdf64eb336df2d4466ebbc6bd5349c61478be77bd3", + "0305f0fed2286b4504907bd2588dec5205f0807f11d003489b6748437728b6dc", + "17f69f35b125de65e140de9bffe873702a4550379fb0ae4fe371f703c739e268", + "ca60309ee4f846f607295aabcea2d0680ca23a7fbb8699ad1b597255ad6c5a73", + "5aec101f7b2452d293c1a1c3889861bc8e96081f3ecd328859bc005c14d2737e", + "bd9a8a2fdbad3db6c38e6472fd2e50d452a98553c8a105cb10afc85b5eaadee0", + "0a52a67bf6ca3784f81b828616cda6bdca314402cded278d98f94b546784a58d", + "55e6f918b2e7af2886499919b1c4a2ba341180934a4691a1a7166d6dadfcf8b9", + "7a2d8b10b3bfc3037ee884699ca4770d96575b2d39179801d760d1c86377ff58", + "ded160f1ec3e978daa2d8adb0b611223946db1c1155522cf9f0796e6f6c081fe" + ], + "cbTx":{ + "version":2, + "height":348355, + "merkleRootMNList":"5bd9041001ba65e1aea7a8d3982bb7fc2a8a561a1898d4e176a2cc4d242107b0", + "merkleRootQuorums":"bfe0f35ec169f3b96eb66097138e70d1e52a66a2fc31a057df6298bbbc790fce" + }, + "time":1614002775, + "mediantime":1614001062, + "nonce":43516489, + "bits":"1b6d4183", + "difficulty":599.8302783653238, + "chainwork":"000000000000000000000000000000000000000000000000bb39407cfc6d253a", + "previousblockhash":"71b81ff345f062e5c6eacbda63f64295590667a8d72428e4e71011675fe531e1", + "chainlock":true + }); + let _block: VerboseBlock = json::from_value(json).unwrap(); +} + #[test] fn test_generate_tx_doge_fee() { // A tx below 1kb is always 1 doge fee yes.