Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions types/src/model/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub struct GetBlockVerboseOne {
/// The block version.
pub version: block::Version,
/// The merkle root.
pub merkle_root: String,
pub merkle_root: TxMerkleNode,
/// The transaction ids.
pub tx: Vec<Txid>,
/// The block time expressed in UNIX epoch time.
Expand Down Expand Up @@ -103,7 +103,7 @@ pub struct GetBlockVerboseTwo {
/// The block version.
pub version: block::Version,
/// The merkle root.
pub merkle_root: String,
pub merkle_root: TxMerkleNode,
/// The transactions.
pub tx: Vec<GetBlockVerboseTwoTransaction>,
/// The block time expressed in UNIX epoch time.
Expand Down Expand Up @@ -155,7 +155,7 @@ pub struct GetBlockVerboseThree {
/// The block version.
pub version: block::Version,
/// The merkle root.
pub merkle_root: String,
pub merkle_root: TxMerkleNode,
/// The transactions.
pub tx: Vec<GetBlockVerboseThreeTransaction>,
/// The block time expressed in UNIX epoch time.
Expand Down
5 changes: 5 additions & 0 deletions types/src/v17/blockchain/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ pub enum GetBlockVerboseOneError {
Numeric(NumericError),
/// Conversion of the transaction `hash` field failed.
Hash(hex::HexToArrayError),
/// Conversion of the transaction `merkle_root` field failed.
MerkleRoot(hex::HexToArrayError),
/// Conversion of the transaction `hex` field failed.
Tx(encode::FromHexError),
/// Conversion of the transaction `bits` field failed.
Expand All @@ -34,6 +36,8 @@ impl fmt::Display for GetBlockVerboseOneError {
match *self {
Self::Numeric(ref e) => write_err!(f, "numeric"; e),
Self::Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e),
Self::MerkleRoot(ref e) =>
write_err!(f, "conversion of the `merkle_root` field failed"; e),
Self::Tx(ref e) => write_err!(f, "conversion of the `tx` field failed"; e),
Self::Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e),
Self::ChainWork(ref e) =>
Expand All @@ -52,6 +56,7 @@ impl std::error::Error for GetBlockVerboseOneError {
match *self {
Self::Numeric(ref e) => Some(e),
Self::Hash(ref e) => Some(e),
Self::MerkleRoot(ref e) => Some(e),
Self::Tx(ref e) => Some(e),
Self::Bits(ref e) => Some(e),
Self::ChainWork(ref e) => Some(e),
Expand Down
3 changes: 2 additions & 1 deletion types/src/v17/blockchain/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ impl GetBlockVerboseOne {
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::MerkleRoot)?;
let tx = self
.tx
.iter()
Expand Down Expand Up @@ -69,7 +70,7 @@ impl GetBlockVerboseOne {
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
Copy Markdown
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.

merkle_root,
tx,
time: crate::to_u32(self.time, "time")?,
median_time,
Expand Down
15 changes: 15 additions & 0 deletions types/src/v29/blockchain/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ pub enum GetBlockVerboseOneError {
Numeric(NumericError),
/// Conversion of the transaction `hash` field failed.
Hash(hex::HexToArrayError),
/// Conversion of the transaction `merkle_root` field failed.
MerkleRoot(hex::HexToArrayError),
/// Conversion of the transaction `hex` field failed.
Tx(encode::FromHexError),
/// Conversion of the transaction `bits` field failed.
Expand All @@ -38,6 +40,8 @@ impl fmt::Display for GetBlockVerboseOneError {
match *self {
Self::Numeric(ref e) => write_err!(f, "numeric"; e),
Self::Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e),
Self::MerkleRoot(ref e) =>
write_err!(f, "conversion of the `merkle_root` field failed"; e),
Self::Tx(ref e) => write_err!(f, "conversion of the `tx` field failed"; e),
Self::Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e),
Self::Target(ref e) => write_err!(f, "conversion of the `target` field failed"; e),
Expand All @@ -57,6 +61,7 @@ impl std::error::Error for GetBlockVerboseOneError {
match *self {
Self::Numeric(ref e) => Some(e),
Self::Hash(ref e) => Some(e),
Self::MerkleRoot(ref e) => Some(e),
Self::Tx(ref e) => Some(e),
Self::Bits(ref e) => Some(e),
Self::Target(ref e) => Some(e),
Expand All @@ -78,6 +83,8 @@ pub enum GetBlockVerboseTwoError {
Numeric(NumericError),
/// Conversion of the transaction `hash` field failed.
Hash(hex::HexToArrayError),
/// Conversion of the transaction `merkle_root` field failed.
MerkleRoot(hex::HexToArrayError),
/// Conversion of the transaction `bits` field failed.
Bits(UnprefixedHexError),
/// Conversion of the `target` field failed.
Expand All @@ -99,6 +106,8 @@ impl fmt::Display for GetBlockVerboseTwoError {
match *self {
Self::Numeric(ref e) => write_err!(f, "numeric"; e),
Self::Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e),
Self::MerkleRoot(ref e) =>
write_err!(f, "conversion of the `merkle_root` field failed"; e),
Self::Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e),
Self::Target(ref e) => write_err!(f, "conversion of the `target` field failed"; e),
Self::ChainWork(ref e) =>
Expand All @@ -120,6 +129,7 @@ impl std::error::Error for GetBlockVerboseTwoError {
match *self {
Self::Numeric(ref e) => Some(e),
Self::Hash(ref e) => Some(e),
Self::MerkleRoot(ref e) => Some(e),
Self::Bits(ref e) => Some(e),
Self::Target(ref e) => Some(e),
Self::ChainWork(ref e) => Some(e),
Expand All @@ -142,6 +152,8 @@ pub enum GetBlockVerboseThreeError {
Numeric(NumericError),
/// Conversion of the transaction `hash` field failed.
Hash(hex::HexToArrayError),
/// Conversion of the transaction `merkle_root` field failed.
MerkleRoot(hex::HexToArrayError),
/// Conversion of the transaction `bits` field failed.
Bits(UnprefixedHexError),
/// Conversion of the `target` field failed.
Expand Down Expand Up @@ -173,6 +185,8 @@ impl fmt::Display for GetBlockVerboseThreeError {
match *self {
Self::Numeric(ref e) => write_err!(f, "numeric"; e),
Self::Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e),
Self::MerkleRoot(ref e) =>
write_err!(f, "conversion of the `merkle_root` field failed"; e),
Self::Bits(ref e) => write_err!(f, "conversion of the `bits` field failed"; e),
Self::Target(ref e) => write_err!(f, "conversion of the `target` field failed"; e),
Self::ChainWork(ref e) =>
Expand Down Expand Up @@ -204,6 +218,7 @@ impl std::error::Error for GetBlockVerboseThreeError {
match *self {
Self::Numeric(ref e) => Some(e),
Self::Hash(ref e) => Some(e),
Self::MerkleRoot(ref e) => Some(e),
Self::Bits(ref e) => Some(e),
Self::Target(ref e) => Some(e),
Self::ChainWork(ref e) => Some(e),
Expand Down
9 changes: 6 additions & 3 deletions types/src/v29/blockchain/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ impl GetBlockVerboseOne {
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::MerkleRoot)?;
let tx = self
.tx
.iter()
Expand Down Expand Up @@ -51,7 +52,7 @@ impl GetBlockVerboseOne {
weight,
height: crate::to_u32(self.height, "height")?,
version,
merkle_root: self.merkle_root, // TODO: Use hash, which one depends on segwit or not.
merkle_root,
tx,
time: crate::to_u32(self.time, "time")?,
median_time,
Expand All @@ -77,6 +78,7 @@ impl GetBlockVerboseTwo {
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::MerkleRoot)?;
let tx = self
.tx
.into_iter()
Expand Down Expand Up @@ -109,7 +111,7 @@ impl GetBlockVerboseTwo {
weight,
height: crate::to_u32(self.height, "height")?,
version,
merkle_root: self.merkle_root, // TODO: Use hash, which one depends on segwit or not.
merkle_root,
tx,
time: crate::to_u32(self.time, "time")?,
median_time,
Expand Down Expand Up @@ -202,6 +204,7 @@ impl GetBlockVerboseThree {
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::MerkleRoot)?;
let tx = self
.tx
.into_iter()
Expand Down Expand Up @@ -234,7 +237,7 @@ impl GetBlockVerboseThree {
weight,
height: crate::to_u32(self.height, "height")?,
version,
merkle_root: self.merkle_root, // TODO: Use hash, which one depends on segwit or not.
merkle_root,
tx,
time: crate::to_u32(self.time, "time")?,
median_time,
Expand Down