mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-07-30 20:11:23 +00:00
impl Display for BlockHash and TxId
This commit is contained in:
@@ -8,6 +8,7 @@ authors = [
|
||||
[dependencies]
|
||||
byteorder = "1"
|
||||
ff = { path = "../ff" }
|
||||
hex = "0.3"
|
||||
lazy_static = "1"
|
||||
pairing = { path = "../pairing" }
|
||||
rand = "0.4"
|
||||
|
@@ -1,8 +1,18 @@
|
||||
use hex;
|
||||
use std::fmt;
|
||||
use std::ops::Deref;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct BlockHash(pub [u8; 32]);
|
||||
|
||||
impl fmt::Display for BlockHash {
|
||||
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 block header.
|
||||
pub struct BlockHeader(BlockHeaderData);
|
||||
|
||||
|
@@ -4,6 +4,7 @@ extern crate lazy_static;
|
||||
extern crate blake2_rfc;
|
||||
extern crate byteorder;
|
||||
extern crate ff;
|
||||
extern crate hex;
|
||||
extern crate pairing;
|
||||
extern crate rand;
|
||||
extern crate sapling_crypto;
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user