From 5139f9dd7bacae07aa013f7610e3ed37cb5999ab Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Tue, 29 Oct 2024 12:15:04 -0500 Subject: [PATCH] fix(rust): correct tx builder startup --- librustzcash-wrapper/src/lib.rs | 46 ++++++++++++++++----------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/librustzcash-wrapper/src/lib.rs b/librustzcash-wrapper/src/lib.rs index c243aa2..ade568c 100644 --- a/librustzcash-wrapper/src/lib.rs +++ b/librustzcash-wrapper/src/lib.rs @@ -1795,43 +1795,41 @@ pub extern "C" fn rust_wrapper_create_transaction( build: bool, out: *mut u8, out_len: &mut usize){ - //let sap_wit_in: Vec = marshall_from_haskell_var(sap_wit, sap_wit_len, RW); - //let sap_wit_reader = Cursor::new(sap_wit_in); - //let sap_iw = read_commitment_tree::>, SAPLING_DEPTH>(sap_wit_reader); let sap_input: Vec = marshall_from_haskell_var(s_input, s_input_len, RW); let sap_anchor = if sap_input.is_empty() { - None + let sap_wit_in: Vec = marshall_from_haskell_var(sap_wit, sap_wit_len, RW); + let sap_wit_reader = Cursor::new(sap_wit_in); + let sap_iw = read_commitment_tree::>, SAPLING_DEPTH>(sap_wit_reader); + match sap_iw { + Ok(s_iw) => { + Some(SaplingAnchor::from(s_iw.root())) + }, + Err(_e) => { + None + } + } } else { let si = &sap_input[0]; let swit_reader = Cursor::new(&si.iw); let iw: IncrementalWitness = read_incremental_witness(swit_reader).unwrap(); Some(SaplingAnchor::from(iw.root())) }; - //let sap_anchor = match sap_iw { - //Ok(s_iw) => { - //Some(SaplingAnchor::from(s_iw.root())) - //}, - //Err(_e) => { - //None - //} - //}; //println!("{:?}", sap_anchor); - //let orch_wit_in: Vec = marshall_from_haskell_var(orch_wit, orch_wit_len, RW); - //let orch_wit_reader = Cursor::new(orch_wit_in); - //let orch_iw = read_commitment_tree::>, 32>(orch_wit_reader); let orch_input: Vec = marshall_from_haskell_var(o_input, o_input_len, RW); - //let orch_anchor = match orch_iw { - //Ok(o_iw) => { - //Some(OrchardAnchor::from(o_iw.root())) - //}, - //Err(_e) => { - //None - //} - //}; let orch_anchor = if orch_input.is_empty() { - None + let orch_wit_in: Vec = marshall_from_haskell_var(orch_wit, orch_wit_len, RW); + let orch_wit_reader = Cursor::new(orch_wit_in); + let orch_iw = read_commitment_tree::>, 32>(orch_wit_reader); + match orch_iw { + Ok(o_iw) => { + Some(OrchardAnchor::from(o_iw.root())) + }, + Err(_e) => { + None + } + } } else { let oi = &orch_input[0]; let wit_reader = Cursor::new(&oi.iw);