diff --git a/librustzcash-wrapper/src/lib.rs b/librustzcash-wrapper/src/lib.rs index e13fffb..563ac5f 100644 --- a/librustzcash-wrapper/src/lib.rs +++ b/librustzcash-wrapper/src/lib.rs @@ -1873,7 +1873,13 @@ pub extern "C" fn rust_wrapper_read_orchard_path_anchor( ){ let path_in: Hpath = marshall_from_haskell_var(path, path_len, RW); let cmx_in: Vec = marshall_from_haskell_var(cmx, cmx_len, RW); - let mk_path = orchard::tree::MerklePath::from_parts(path_in.position, to_array(path_in.path.iter().map(|x| MerkleHashOrchard::from_bytes(&to_array(x.bytes.clone())).unwrap()).collect())); + let mk_path = orchard::tree::MerklePath::from_parts(path_in.position, to_array(path_in.path.iter().map(|x| + if x.bytes.len() > 1 { + MerkleHashOrchard::from_bytes(&to_array(x.bytes.clone())).unwrap() + } else { + MerkleHashOrchard::empty_leaf() + } + ).collect())); let nc = ExtractedNoteCommitment::from_bytes(&to_array(cmx_in)); if nc.is_some().into() { let anchor = mk_path.root(nc.unwrap()); @@ -2152,7 +2158,7 @@ pub extern "C" fn rust_wrapper_create_transaction( } else { None }; - println!("{:?}", sapling_anchor); + //println!("{:?}", sapling_anchor); let orch_input: Vec = marshall_from_haskell_var(o_input, o_input_len, RW); let orch_anchor_in : Vec = marshall_from_haskell_var(orch_wit, orch_wit_len, RW); let orch_anchor = MerkleHashOrchard::from_bytes(&to_array(orch_anchor_in)); @@ -2162,7 +2168,7 @@ pub extern "C" fn rust_wrapper_create_transaction( } else { None }; - println!("{:?}", orchard_anchor); + //println!("{:?}", orchard_anchor); let build_config = BuildConfig::Standard {sapling_anchor, orchard_anchor}; let mut main_builder = Builder::new(MainNetwork, BlockHeight::from(bl_height), build_config); let mut test_builder = Builder::new(TestNetwork, BlockHeight::from(bl_height), build_config); @@ -2248,18 +2254,24 @@ pub extern "C" fn rust_wrapper_create_transaction( let rho = Rho::from_bytes(&to_array(o_in.note.rho)).unwrap(); let rseed = RandomSeed::from_bytes(to_array(o_in.note.rseed.bytes), &rho).unwrap(); let val = NoteValue::from_raw(o_in.note.note); - println!("o inp: {:?}", val); + //println!("o inp: {:?}", val); let note = Note::from_parts(pay_addr, val, rho, rseed).unwrap(); - let merkle_path = orchard::tree::MerklePath::from_parts(o_in.iw.position, to_array(o_in.iw.path.iter().map(|x| MerkleHashOrchard::from_bytes(&to_array(x.bytes.clone())).unwrap()).collect())); + let merkle_path = orchard::tree::MerklePath::from_parts(o_in.iw.position, to_array(o_in.iw.path.iter().map(|x| + if x.bytes.len() > 1 { + MerkleHashOrchard::from_bytes(&to_array(x.bytes.clone())).unwrap() + } else { + MerkleHashOrchard::empty_leaf() + } + ).collect())); if net { let mb = main_builder.add_orchard_spend::(&sp_key, note, merkle_path); match mb { Ok(()) => { - println!("added orchard inp: {:?}", val); + //println!("added orchard inp: {:?}", val); continue; }, Err(e) => { - println!("failed orchard inp: {:?}", e); + //println!("failed orchard inp: {:?}", e); let x = Hhex {bytes: vec![7]}; marshall_to_haskell_var(&x, out, out_len, RW); } @@ -2268,11 +2280,11 @@ pub extern "C" fn rust_wrapper_create_transaction( let tb = test_builder.add_orchard_spend::(&sp_key, note, merkle_path); match tb { Ok(()) => { - println!("added orchard inp: {:?}", val); + //println!("added orchard inp: {:?}", val); continue; }, Err(e) => { - println!("failed orchard inp: {:?}", e); + //println!("failed orchard inp: {:?}", e); let x = Hhex {bytes: vec![7]}; marshall_to_haskell_var(&x, out, out_len, RW); } @@ -2367,7 +2379,7 @@ pub extern "C" fn rust_wrapper_create_transaction( }; let recipient = OrchardAddress::from_raw_address_bytes(&to_array(output.to)).unwrap(); let val = output.amt; - println!("o out: {:?} {:?}", val, output.chg); + //println!("o out: {:?} {:?}", val, output.chg); let memo = MemoBytes::from_bytes(&output.memo).unwrap(); if net { let mb = main_builder.add_orchard_output::(ovk, recipient, val, memo); @@ -2423,7 +2435,7 @@ pub extern "C" fn rust_wrapper_create_transaction( Err(e) => { match e { Error::InsufficientFunds(y) => { - println!("ins funds: {:?}", y); + //println!("ins funds: {:?}", y); let x = Hhex {bytes: vec![0]}; marshall_to_haskell_var(&x, out, out_len, RW); },