Functions to handle commitment tree nodes for Sapling and Orchard #100

Merged
pitmutt merged 50 commits from rav001 into milestone2 2024-11-15 18:48:36 +00:00
Showing only changes of commit 20851a4e48 - Show all commits

View file

@ -1694,7 +1694,12 @@ pub extern "C" fn rust_wrapper_read_sapling_path_anchor(
){ ){
let path_in: Hpath = marshall_from_haskell_var(path, path_len, RW); let path_in: Hpath = marshall_from_haskell_var(path, path_len, RW);
let cmx_in: Vec<u8> = marshall_from_haskell_var(cmx, cmx_len, RW); let cmx_in: Vec<u8> = marshall_from_haskell_var(cmx, cmx_len, RW);
let mk_path = sapling_crypto::MerklePath::from_parts(path_in.path.iter().map(|x| Node::from_bytes(to_array(x.bytes.clone())).unwrap()).collect(), Position::from(u64::from(path_in.position))); let mk_path = sapling_crypto::MerklePath::from_parts(path_in.path.iter().map(|x|
if x.bytes.len() > 1 {
Node::from_bytes(to_array(x.bytes.clone())).unwrap()
} else {
Node::empty_leaf()
}).collect(), Position::from(u64::from(path_in.position)));
match mk_path { match mk_path {
Ok(mp1) => { Ok(mp1) => {
let nc = SaplingNoteCommitment::from_bytes(&to_array(cmx_in)); let nc = SaplingNoteCommitment::from_bytes(&to_array(cmx_in));