diff --git a/base_layer/common_types/src/chain_metadata.rs b/base_layer/common_types/src/chain_metadata.rs index ca08d44753..6c0d444a89 100644 --- a/base_layer/common_types/src/chain_metadata.rs +++ b/base_layer/common_types/src/chain_metadata.rs @@ -24,7 +24,6 @@ use std::fmt::{Display, Error, Formatter}; use primitive_types::U256; use serde::{Deserialize, Serialize}; -use tari_utilities::hex::Hex; use crate::types::{BlockHash, FixedHash}; @@ -145,7 +144,7 @@ impl ChainMetadata { impl Display for ChainMetadata { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { let height = self.height_of_longest_chain; - let best_block = self.best_block.to_hex(); + let best_block = self.best_block; let accumulated_difficulty = self.accumulated_difficulty; writeln!(f, "Height of longest chain: {}", height)?; writeln!(f, "Total accumulated difficulty: {}", accumulated_difficulty)?; diff --git a/base_layer/core/src/base_node/comms_interface/comms_request.rs b/base_layer/core/src/base_node/comms_interface/comms_request.rs index 4aa8033de5..5bd938c90f 100644 --- a/base_layer/core/src/base_node/comms_interface/comms_request.rs +++ b/base_layer/core/src/base_node/comms_interface/comms_request.rs @@ -84,11 +84,11 @@ impl Display for NodeCommsRequest { }, FetchBlocksByKernelExcessSigs(v) => write!(f, "FetchBlocksByKernelExcessSigs (n={})", v.len()), FetchBlocksByUtxos(v) => write!(f, "FetchBlocksByUtxos (n={})", v.len()), - GetHeaderByHash(v) => write!(f, "GetHeaderByHash({})", v.to_hex()), - GetBlockByHash(v) => write!(f, "GetBlockByHash({})", v.to_hex()), + GetHeaderByHash(v) => write!(f, "GetHeaderByHash({})", v), + GetBlockByHash(v) => write!(f, "GetBlockByHash({})", v), GetNewBlockTemplate(v) => write!(f, "GetNewBlockTemplate ({}) with weight {}", v.algo, v.max_weight), GetNewBlock(b) => write!(f, "GetNewBlock (Block Height={})", b.header.height), - GetBlockFromAllChains(v) => write!(f, "GetBlockFromAllChains({})", v.to_hex()), + GetBlockFromAllChains(v) => write!(f, "GetBlockFromAllChains({})", v), FetchKernelByExcessSig(s) => write!( f, "FetchKernelByExcessSig (signature=({}, {}))", diff --git a/base_layer/core/src/blocks/accumulated_data.rs b/base_layer/core/src/blocks/accumulated_data.rs index 1227a419d1..7a9071f5a7 100644 --- a/base_layer/core/src/blocks/accumulated_data.rs +++ b/base_layer/core/src/blocks/accumulated_data.rs @@ -30,7 +30,6 @@ use primitive_types::U256; use serde::{Deserialize, Serialize}; use tari_common_types::types::{Commitment, HashOutput, PrivateKey}; use tari_mmr::{pruned_hashset::PrunedHashSet, ArrayLike}; -use tari_utilities::hex::Hex; use crate::{ blocks::{error::BlockError, Block, BlockHeader}, @@ -198,7 +197,7 @@ impl BlockHeaderAccumulatedData { impl Display for BlockHeaderAccumulatedData { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - writeln!(f, "Hash: {}", self.hash.to_hex())?; + writeln!(f, "Hash: {}", self.hash)?; writeln!(f, "Achieved difficulty: {}", self.achieved_difficulty)?; writeln!(f, "Total accumulated difficulty: {}", self.total_accumulated_difficulty)?; writeln!( diff --git a/base_layer/core/src/blocks/block.rs b/base_layer/core/src/blocks/block.rs index d3ab776313..ccb16c7c81 100644 --- a/base_layer/core/src/blocks/block.rs +++ b/base_layer/core/src/blocks/block.rs @@ -32,7 +32,6 @@ use borsh::{BorshDeserialize, BorshSerialize}; use log::*; use serde::{Deserialize, Serialize}; use tari_common_types::types::{FixedHash, PrivateKey}; -use tari_utilities::hex::Hex; use thiserror::Error; use crate::{ @@ -150,7 +149,7 @@ impl Display for Block { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> { writeln!(f, "----------------- Block -----------------")?; writeln!(f, "--- Header ---")?; - writeln!(f, "Hash: {}", self.header.hash().to_hex())?; + writeln!(f, "Hash: {}", self.header.hash())?; writeln!(f, "{}", self.header)?; writeln!(f, "--- Body ---")?; writeln!(f, "{}", self.body) diff --git a/base_layer/core/src/blocks/block_header.rs b/base_layer/core/src/blocks/block_header.rs index 3a703d3573..5b5704348c 100644 --- a/base_layer/core/src/blocks/block_header.rs +++ b/base_layer/core/src/blocks/block_header.rs @@ -302,17 +302,13 @@ impl Display for BlockHeader { "Version: {}\nBlock height: {}\nPrevious block hash: {}\nTimestamp: {}", self.version, self.height, - self.prev_hash.to_hex(), + self.prev_hash, self.to_chrono_datetime().to_rfc2822() )?; writeln!( fmt, "Merkle roots:\nInputs: {},\nOutputs: {} ({})\n\nKernels: {} ({})", - self.input_mr.to_hex(), - self.output_mr.to_hex(), - self.output_smt_size, - self.kernel_mr.to_hex(), - self.kernel_mmr_size + self.input_mr, self.output_mr, self.output_smt_size, self.kernel_mr, self.kernel_mmr_size )?; writeln!(fmt, "ValidatorNode: {}\n", self.validator_node_mr.to_hex())?; writeln!( diff --git a/base_layer/core/src/blocks/new_blockheader_template.rs b/base_layer/core/src/blocks/new_blockheader_template.rs index 3daaa49be3..b26b6aa7d3 100644 --- a/base_layer/core/src/blocks/new_blockheader_template.rs +++ b/base_layer/core/src/blocks/new_blockheader_template.rs @@ -64,9 +64,7 @@ impl Display for NewBlockHeaderTemplate { fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error> { let msg = format!( "Version: {}\nBlock height: {}\nPrevious block hash: {}\n", - self.version, - self.height, - self.prev_hash.to_hex(), + self.version, self.height, self.prev_hash, ); fmt.write_str(&msg)?; fmt.write_str(&format!( diff --git a/base_layer/core/src/chain_storage/block_add_result.rs b/base_layer/core/src/chain_storage/block_add_result.rs index a76cc1bb07..82890384aa 100644 --- a/base_layer/core/src/chain_storage/block_add_result.rs +++ b/base_layer/core/src/chain_storage/block_add_result.rs @@ -114,7 +114,7 @@ impl fmt::Display for BlockAddResult { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { BlockAddResult::Ok(block) => { - write!(f, "Block {} at height {} added", block.hash().to_hex(), block.height()) + write!(f, "Block {} at height {} added", block.hash(), block.height()) }, BlockAddResult::BlockExists => write!(f, "Block already exists"), BlockAddResult::OrphanBlock => write!(f, "Block added as orphan"), diff --git a/base_layer/core/src/chain_storage/db_transaction.rs b/base_layer/core/src/chain_storage/db_transaction.rs index 3e37c36094..6ca0d7bf52 100644 --- a/base_layer/core/src/chain_storage/db_transaction.rs +++ b/base_layer/core/src/chain_storage/db_transaction.rs @@ -339,16 +339,16 @@ impl fmt::Display for WriteOperation { InsertOrphanBlock(block) => write!( f, "InsertOrphanBlock({}, {})", - block.hash().to_hex(), + block.hash(), block.body.to_counts_string() ), InsertChainHeader { header } => { - write!(f, "InsertChainHeader(#{} {})", header.height(), header.hash().to_hex()) + write!(f, "InsertChainHeader(#{} {})", header.height(), header.hash()) }, InsertTipBlockBody { block } => write!( f, "InsertTipBlockBody({}, {})", - block.accumulated_data().hash.to_hex(), + block.accumulated_data().hash, block.block().body.to_counts_string(), ), InsertKernel { @@ -358,8 +358,8 @@ impl fmt::Display for WriteOperation { } => write!( f, "Insert kernel {} in block:{} position: {}", - kernel.hash().to_hex(), - header_hash.to_hex(), + kernel.hash(), + header_hash, mmr_position ), InsertOutput { @@ -370,27 +370,24 @@ impl fmt::Display for WriteOperation { } => write!( f, "Insert output {} in block({}):{},", - output.hash().to_hex(), + output.hash(), header_height, - header_hash.to_hex(), - ), - DeleteOrphanChainTip(hash) => write!(f, "DeleteOrphanChainTip({})", hash.to_hex()), - InsertOrphanChainTip(hash, total_accumulated_difficulty) => write!( - f, - "InsertOrphanChainTip({}, {})", - hash.to_hex(), - total_accumulated_difficulty + header_hash, ), - DeleteTipBlock(hash) => write!(f, "DeleteTipBlock({})", hash.to_hex()), + DeleteOrphanChainTip(hash) => write!(f, "DeleteOrphanChainTip({})", hash), + InsertOrphanChainTip(hash, total_accumulated_difficulty) => { + write!(f, "InsertOrphanChainTip({}, {})", hash, total_accumulated_difficulty) + }, + DeleteTipBlock(hash) => write!(f, "DeleteTipBlock({})", hash), InsertMoneroSeedHeight(data, height) => { write!(f, "Insert Monero seed string {} for height: {}", data.to_hex(), height) }, - InsertChainOrphanBlock(block) => write!(f, "InsertChainOrphanBlock({})", block.hash().to_hex()), + InsertChainOrphanBlock(block) => write!(f, "InsertChainOrphanBlock({})", block.hash()), UpdateBlockAccumulatedData { header_hash, .. } => { - write!(f, "Update Block data for block {}", header_hash.to_hex()) + write!(f, "Update Block data for block {}", header_hash) }, - PruneOutputsSpentAtHash { block_hash } => write!(f, "Prune output(s) at hash: {}", block_hash.to_hex()), - DeleteAllInputsInBlock { block_hash } => write!(f, "Delete outputs in block {}", block_hash.to_hex()), + PruneOutputsSpentAtHash { block_hash } => write!(f, "Prune output(s) at hash: {}", block_hash), + DeleteAllInputsInBlock { block_hash } => write!(f, "Delete outputs in block {}", block_hash), SetAccumulatedDataForOrphan(accumulated_data) => { write!(f, "Set accumulated data for orphan {}", accumulated_data) }, @@ -403,16 +400,13 @@ impl fmt::Display for WriteOperation { } => write!( f, "Update best block to height:{} ({}) with difficulty: {} and timestamp: {}", - height, - hash.to_hex(), - accumulated_difficulty, - timestamp + height, hash, accumulated_difficulty, timestamp ), SetPruningHorizonConfig(pruning_horizon) => write!(f, "Set config: pruning horizon to {}", pruning_horizon), SetPrunedHeight { height, .. } => write!(f, "Set pruned height to {}", height), DeleteHeader(height) => write!(f, "Delete header at height: {}", height), - DeleteOrphan(hash) => write!(f, "Delete orphan with hash: {}", hash.to_hex()), - InsertBadBlock { hash, height } => write!(f, "Insert bad block #{} {}", height, hash.to_hex()), + DeleteOrphan(hash) => write!(f, "Delete orphan with hash: {}", hash), + InsertBadBlock { hash, height } => write!(f, "Insert bad block #{} {}", height, hash), SetHorizonData { .. } => write!(f, "Set horizon data"), InsertReorg { .. } => write!(f, "Insert reorg"), ClearAllReorgs => write!(f, "Clear all reorgs"), @@ -466,8 +460,8 @@ impl Display for DbKey { fn fmt(&self, f: &mut Formatter) -> Result<(), Error> { match self { DbKey::HeaderHeight(v) => f.write_str(&format!("Header height (#{})", v)), - DbKey::HeaderHash(v) => f.write_str(&format!("Header hash (#{})", v.to_hex())), - DbKey::OrphanBlock(v) => f.write_str(&format!("Orphan block hash ({})", v.to_hex())), + DbKey::HeaderHash(v) => f.write_str(&format!("Header hash (#{})", v)), + DbKey::OrphanBlock(v) => f.write_str(&format!("Orphan block hash ({})", v)), } } } diff --git a/base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs b/base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs index 3b3d24bc42..1895fec9a9 100644 --- a/base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs +++ b/base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs @@ -2477,7 +2477,7 @@ impl fmt::Display for MetadataValue { MetadataValue::AccumulatedWork(d) => write!(f, "Total accumulated work is {}", d), MetadataValue::PruningHorizon(h) => write!(f, "Pruning horizon is {}", h), MetadataValue::PrunedHeight(height) => write!(f, "Effective pruned height is {}", height), - MetadataValue::BestBlock(hash) => write!(f, "Chain tip block hash is {}", hash.to_hex()), + MetadataValue::BestBlock(hash) => write!(f, "Chain tip block hash is {}", hash), MetadataValue::HorizonData(_) => write!(f, "Horizon data"), MetadataValue::BestBlockTimestamp(timestamp) => write!(f, "Chain tip block timestamp is {}", timestamp), MetadataValue::MigrationVersion(n) => write!(f, "Migration version {}", n), diff --git a/base_layer/core/src/covenants/arguments.rs b/base_layer/core/src/covenants/arguments.rs index 7300a51bf6..922b4cb98b 100644 --- a/base_layer/core/src/covenants/arguments.rs +++ b/base_layer/core/src/covenants/arguments.rs @@ -29,10 +29,7 @@ use borsh::{BorshDeserialize, BorshSerialize}; use integer_encoding::VarIntWriter; use tari_common_types::types::{Commitment, FixedHash, PublicKey}; use tari_script::TariScript; -use tari_utilities::{ - hex::{to_hex, Hex}, - ByteArray, -}; +use tari_utilities::{hex::Hex, ByteArray}; use super::decoder::CovenantDecodeError; use crate::{ @@ -237,7 +234,7 @@ impl Display for CovenantArg { #[allow(clippy::enum_glob_use)] use CovenantArg::*; match self { - Hash(hash) => write!(f, "Hash({})", to_hex(&hash[..])), + Hash(hash) => write!(f, "Hash({})", hash), PublicKey(public_key) => write!(f, "PublicKey({})", public_key.to_hex()), Commitment(commitment) => write!(f, "Commitment({})", commitment.to_hex()), TariScript(_) => write!(f, "TariScript(...)"), diff --git a/base_layer/core/src/mempool/service/request.rs b/base_layer/core/src/mempool/service/request.rs index 7e05c8f47f..932e69f6b0 100644 --- a/base_layer/core/src/mempool/service/request.rs +++ b/base_layer/core/src/mempool/service/request.rs @@ -47,11 +47,13 @@ impl Display for MempoolRequest { MempoolRequest::GetTxStateByExcessSig(sig) => { write!(f, "GetTxStateByExcessSig ({})", sig.get_signature().to_hex()) }, - MempoolRequest::SubmitTransaction(tx) => write!( - f, - "SubmitTransaction ({})", - tx.body.kernels()[0].excess_sig.get_signature().to_hex() - ), + MempoolRequest::SubmitTransaction(tx) => { + let sig_hex = tx + .first_kernel_excess_sig() + .map(|sig| sig.get_signature().to_hex()) + .unwrap_or_else(|| "No kernels!".to_string()); + write!(f, "SubmitTransaction ({})", sig_hex) + }, MempoolRequest::GetFeePerGramStats { count, tip_height } => { write!(f, "GetFeePerGramStats(count: {}, tip_height: {})", *count, *tip_height) }, diff --git a/base_layer/core/src/transactions/transaction_components/transaction_input.rs b/base_layer/core/src/transactions/transaction_components/transaction_input.rs index 50fe80a33c..64c56d63e9 100644 --- a/base_layer/core/src/transactions/transaction_components/transaction_input.rs +++ b/base_layer/core/src/transactions/transaction_components/transaction_input.rs @@ -519,7 +519,7 @@ impl TransactionInput { impl Display for TransactionInput { fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), std::fmt::Error> { match self.spent_output { - SpentOutput::OutputHash(ref h) => write!(fmt, "Input spending Output hash: {}", h.to_hex()), + SpentOutput::OutputHash(ref h) => write!(fmt, "Input spending Output hash: {}", h), SpentOutput::OutputData { ref commitment, ref script, @@ -530,12 +530,12 @@ impl Display for TransactionInput { fmt, "({}, {}) [{:?}], Script: ({}), Input_data : ({}), Offset_Pubkey: ({}), Input Hash: {}", commitment.to_hex(), - self.output_hash().to_hex(), + self.output_hash(), features, script, self.input_data.to_hex(), sender_offset_public_key.to_hex(), - self.canonical_hash().to_hex(), + self.canonical_hash(), ), } } diff --git a/base_layer/core/src/transactions/transaction_components/transaction_output.rs b/base_layer/core/src/transactions/transaction_components/transaction_output.rs index 5b4f24fd05..324aa35758 100644 --- a/base_layer/core/src/transactions/transaction_components/transaction_output.rs +++ b/base_layer/core/src/transactions/transaction_components/transaction_output.rs @@ -498,7 +498,7 @@ impl Display for TransactionOutput { "({}, {}) [{:?}], Script: ({}), Offset Pubkey: ({}), Metadata Signature: ({}, {}, {}, {}, {}), Encrypted \ data ({}), Proof: {}", self.commitment.to_hex(), - self.hash().to_hex(), + self.hash(), self.features, self.script, self.sender_offset_public_key.to_hex(), diff --git a/base_layer/wallet/src/base_node_service/handle.rs b/base_layer/wallet/src/base_node_service/handle.rs index 21a1481ad0..b004229394 100644 --- a/base_layer/wallet/src/base_node_service/handle.rs +++ b/base_layer/wallet/src/base_node_service/handle.rs @@ -24,7 +24,6 @@ use std::{fmt, fmt::Formatter, sync::Arc, time::Duration}; use tari_common_types::{chain_metadata::ChainMetadata, types::BlockHash}; use tari_service_framework::reply_channel::SenderService; -use tari_utilities::hex::Hex; use tokio::sync::broadcast; use tower::Service; @@ -57,7 +56,7 @@ impl fmt::Display for BaseNodeEvent { write!(f, "BaseNodeStateChanged: Synced:{:?}", state.is_synced) }, BaseNodeEvent::NewBlockDetected(hash, height) => { - write!(f, "NewBlockDetected: {} ({})", height, hash.to_hex()) + write!(f, "NewBlockDetected: {} ({})", height, hash) }, } } diff --git a/base_layer/wallet/src/output_manager_service/handle.rs b/base_layer/wallet/src/output_manager_service/handle.rs index 12cd02b847..61fcf232ba 100644 --- a/base_layer/wallet/src/output_manager_service/handle.rs +++ b/base_layer/wallet/src/output_manager_service/handle.rs @@ -208,15 +208,12 @@ impl fmt::Display for OutputManagerRequest { CreateClaimShaAtomicSwapTransaction(output, pre_image, fee_per_gram) => write!( f, "ClaimShaAtomicSwap(output hash: {}, pre_image: {}, fee_per_gram: {} )", - output.to_hex(), - pre_image, - fee_per_gram, + output, pre_image, fee_per_gram, ), CreateHtlcRefundTransaction(output, fee_per_gram) => write!( f, "CreateHtlcRefundTransaction(output hash: {}, , fee_per_gram: {} )", - output.to_hex(), - fee_per_gram, + output, fee_per_gram, ), GetOutputStatusesByTxId(t) => write!(f, "GetOutputStatusesByTxId: {}", t),