Serialize Amount to bytes using byteorder::LittleEndian

This commit is contained in:
Deirdre Connolly 2020-08-12 02:51:40 -04:00 committed by Deirdre Connolly
parent 646b506e7a
commit 1255cec6a4
2 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,6 @@
//! The LightClientRootHash enum, used for the corresponding block header field.
use crate::note_commitment_tree::SaplingNoteTreeRootHash;
use crate::treestate::note_commitment_tree::SaplingNoteTreeRootHash;
use crate::types::BlockHeight;
use crate::{Network, NetworkUpgrade, NetworkUpgrade::*};

View File

@ -5,6 +5,8 @@ use std::{
ops::RangeInclusive,
};
use byteorder::{ByteOrder, LittleEndian};
type Result<T, E = Error> = std::result::Result<T, E>;
/// A runtime validated type for representing amounts of zatoshis
@ -24,7 +26,9 @@ impl<C> Amount<C> {
/// To little endian byte array
pub fn to_bytes(&self) -> [u8; 8] {
self.0.to_le_bytes()
let mut buf: [u8; 8] = [0; 8];
LittleEndian::write_i64(&mut buf, self.0);
buf
}
}