From ab44fe29a6d9cb36f3d964484e8fb98274e489d8 Mon Sep 17 00:00:00 2001 From: octobocto Date: Sat, 19 Sep 2026 05:00:52 -0700 Subject: [PATCH 1/2] types: nest the block header and body in JSON --- lib/types/mod.rs | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/lib/types/mod.rs b/lib/types/mod.rs index 5797bb66..cba340da 100644 --- a/lib/types/mod.rs +++ b/lib/types/mod.rs @@ -627,9 +627,7 @@ pub trait Verify { #[derive(Clone, Debug, Deserialize, Serialize, ToSchema)] pub struct Block { - #[serde(flatten)] pub header: Header, - #[serde(flatten)] pub body: Body, pub height: u32, } @@ -842,3 +840,38 @@ mod withdrawal_bundle_order_regression { } } } + +#[cfg(test)] +mod block_json_tests { + use bitcoin::hashes::Hash as _; + + use super::{Block, Body, Header, MerkleRoot}; + + #[test] + fn block_json_nests_the_header_and_the_body() { + let block = Block { + header: Header { + merkle_root: MerkleRoot::from([1; 32]), + prev_side_hash: None, + prev_main_hash: bitcoin::BlockHash::from_byte_array([2; 32]), + }, + body: Body { + coinbase: Vec::new(), + transactions: Vec::new(), + authorizations: Vec::new(), + actor_proofs: Vec::new(), + }, + height: 7, + }; + let json = serde_json::to_value(&block).unwrap(); + assert_eq!( + json["header"]["prev_main_hash"], + serde_json::to_value(block.header.prev_main_hash).unwrap() + ); + assert!(json["body"]["transactions"].is_array()); + assert_eq!(json["height"], 7); + assert!(json.get("prev_main_hash").is_none()); + let decoded: Block = serde_json::from_value(json.clone()).unwrap(); + assert_eq!(serde_json::to_value(&decoded).unwrap(), json); + } +} From 6209da6162ff7b09f3e06c106a587abc8cde9bb3 Mon Sep 17 00:00:00 2001 From: octobocto Date: Sat, 19 Sep 2026 05:01:20 -0700 Subject: [PATCH 2/2] workspace: bump version to 0.18.0 --- Cargo.lock | 10 +++++----- Cargo.toml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2c457cdc..9c923f93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7683,7 +7683,7 @@ dependencies = [ [[package]] name = "truthcoin_dc" -version = "0.17.0" +version = "0.18.0" dependencies = [ "addr", "anyhow", @@ -7759,7 +7759,7 @@ dependencies = [ [[package]] name = "truthcoin_dc_app" -version = "0.17.0" +version = "0.18.0" dependencies = [ "anyhow", "base64 0.22.1", @@ -7810,7 +7810,7 @@ dependencies = [ [[package]] name = "truthcoin_dc_app_cli" -version = "0.17.0" +version = "0.18.0" dependencies = [ "anyhow", "bitcoin", @@ -7834,7 +7834,7 @@ dependencies = [ [[package]] name = "truthcoin_dc_app_rpc_api" -version = "0.17.0" +version = "0.18.0" dependencies = [ "anyhow", "bitcoin", @@ -7850,7 +7850,7 @@ dependencies = [ [[package]] name = "truthcoin_dc_integration_tests" -version = "0.17.0" +version = "0.18.0" dependencies = [ "anyhow", "bip300301_enforcer_integration_tests", diff --git a/Cargo.toml b/Cargo.toml index 54e96f34..ff40fced 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ authors = ["Ash Manning ", edition = "2024" license-file = "LICENSE.txt" publish = false -version = "0.17.0" +version = "0.18.0" [workspace.dependencies] anyhow = "1.0.72"