fix(rust): account for empty leaf in sapling path

This commit is contained in:
Rene Vergara 2024-11-07 12:54:22 -06:00
parent 8244ffa1ce
commit 20851a4e48
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2

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 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 {
Ok(mp1) => {
let nc = SaplingNoteCommitment::from_bytes(&to_array(cmx_in));