Format subtree roots in little-endian order (#7466)

This commit is contained in:
teor 2023-09-05 22:27:26 +10:00 committed by arya2
parent 243ae9a0c2
commit 99c6dfb23f
2 changed files with 5 additions and 11 deletions

View File

@ -182,12 +182,9 @@ impl Node {
/// Return the node bytes in big-endian byte-order suitable for printing out byte by byte.
///
/// Zebra displays note commitment tree nodes in big-endian byte-order,
/// following the u256 convention set by Bitcoin and zcashd.
/// `zcashd`'s `z_getsubtreesbyindex` does not reverse the byte order of subtree roots.
pub fn bytes_in_display_order(&self) -> [u8; 32] {
let mut reversed_bytes = self.0.to_repr();
reversed_bytes.reverse();
reversed_bytes
self.to_repr()
}
}

View File

@ -190,14 +190,11 @@ impl fmt::Debug for Node {
}
impl Node {
/// Return the node bytes in big-endian byte-order suitable for printing out byte by byte.
/// Return the node bytes in little-endian byte order suitable for printing out byte by byte.
///
/// Zebra displays note commitment tree nodes in big-endian byte-order,
/// following the u256 convention set by Bitcoin and zcashd.
/// `zcashd`'s `z_getsubtreesbyindex` does not reverse the byte order of subtree roots.
pub fn bytes_in_display_order(&self) -> [u8; 32] {
let mut reversed_bytes = self.0;
reversed_bytes.reverse();
reversed_bytes
self.0
}
}