Skip to content

Model merkle_root as TxMerkleNode#519

Merged
tcharding merged 1 commit intorust-bitcoin:masterfrom
jamillambert:0225-merkle-root-model
Feb 27, 2026
Merged

Model merkle_root as TxMerkleNode#519
tcharding merged 1 commit intorust-bitcoin:masterfrom
jamillambert:0225-merkle-root-model

Conversation

@jamillambert
Copy link
Collaborator

Some of the modelled types used a String for merkle_root. But it has a rust-bitcoin type TxMerkleNode.

Change them all to TxMerkleNode, and update the into_model() functions.

self.stripped_size.map(|size| crate::to_u32(size, "stripped_size")).transpose()?;
let weight = Weight::from_wu(self.weight);
let version = block::Version::from_consensus(self.version);
let merkle_root = self.merkle_root.parse::<TxMerkleNode>().map_err(E::Hash)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not 100% correct. It made me look if we do this elsewhere and we do. Created: #521

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the error variant for merkle_root. Will have a look at the rest in a separate PR.

Some of the modelled types used a String for merkle_root. But it has a
rust-bitcoin type TxMerkleNode.

Change them all to TxMerkleNode, add the required error variant, and
update the into_model() functions.
@jamillambert jamillambert force-pushed the 0225-merkle-root-model branch from 81b5686 to 162a2df Compare February 26, 2026 10:35
Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 162a2df

weight,
height: crate::to_u32(self.height, "height")?,
version,
merkle_root: self.merkle_root, // TODO: Use hash, which one depends on segwit or not.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FTR I don't know what this comment is meaning referring to segwit? Perhaps I was confused when I wrote it.

@tcharding tcharding merged commit 054608c into rust-bitcoin:master Feb 27, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants