impl Display for BlockHash and TxId

This commit is contained in:
Jack Grigg
2018-10-11 23:16:48 +01:00
parent 20d5cdc571
commit a1664c6bbc
5 changed files with 29 additions and 0 deletions

View File

@@ -1,5 +1,7 @@
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use hex;
use sapling_crypto::redjubjub::Signature;
use std::fmt;
use std::io::{self, Read, Write};
use std::ops::Deref;
@@ -23,6 +25,14 @@ const SAPLING_TX_VERSION: u32 = 4;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct TxId(pub [u8; 32]);
impl fmt::Display for TxId {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
let mut data = self.0.to_vec();
data.reverse();
formatter.write_str(&hex::encode(data))
}
}
/// A Zcash transaction.
#[derive(Debug)]
pub struct Transaction(TransactionData);