fix(rust): correct tx builder startup

This commit is contained in:
Rene Vergara 2024-10-29 12:15:04 -05:00
parent a21642baee
commit 5139f9dd7b
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2

View file

@ -1795,43 +1795,41 @@ pub extern "C" fn rust_wrapper_create_transaction(
build: bool, build: bool,
out: *mut u8, out: *mut u8,
out_len: &mut usize){ out_len: &mut usize){
//let sap_wit_in: Vec<u8> = 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::<Node, Cursor<Vec<u8>>, SAPLING_DEPTH>(sap_wit_reader);
let sap_input: Vec<HsaplingInput> = marshall_from_haskell_var(s_input, s_input_len, RW); let sap_input: Vec<HsaplingInput> = marshall_from_haskell_var(s_input, s_input_len, RW);
let sap_anchor = let sap_anchor =
if sap_input.is_empty() { if sap_input.is_empty() {
let sap_wit_in: Vec<u8> = 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::<Node, Cursor<Vec<u8>>, SAPLING_DEPTH>(sap_wit_reader);
match sap_iw {
Ok(s_iw) => {
Some(SaplingAnchor::from(s_iw.root()))
},
Err(_e) => {
None None
}
}
} else { } else {
let si = &sap_input[0]; let si = &sap_input[0];
let swit_reader = Cursor::new(&si.iw); let swit_reader = Cursor::new(&si.iw);
let iw: IncrementalWitness<Node, SAPLING_DEPTH> = read_incremental_witness(swit_reader).unwrap(); let iw: IncrementalWitness<Node, SAPLING_DEPTH> = read_incremental_witness(swit_reader).unwrap();
Some(SaplingAnchor::from(iw.root())) 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); //println!("{:?}", sap_anchor);
//let orch_wit_in: Vec<u8> = 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::<MerkleHashOrchard, Cursor<Vec<u8>>, 32>(orch_wit_reader);
let orch_input: Vec<HorchardInput> = marshall_from_haskell_var(o_input, o_input_len, RW); let orch_input: Vec<HorchardInput> = 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 = let orch_anchor =
if orch_input.is_empty() { if orch_input.is_empty() {
let orch_wit_in: Vec<u8> = 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::<MerkleHashOrchard, Cursor<Vec<u8>>, 32>(orch_wit_reader);
match orch_iw {
Ok(o_iw) => {
Some(OrchardAnchor::from(o_iw.root()))
},
Err(_e) => {
None None
}
}
} else { } else {
let oi = &orch_input[0]; let oi = &orch_input[0];
let wit_reader = Cursor::new(&oi.iw); let wit_reader = Cursor::new(&oi.iw);