Functions to create and manage Orchard commitment trees #99

Merged
pitmutt merged 30 commits from rav001 into milestone2 2024-11-05 18:28:46 +00:00
Showing only changes of commit 5139f9dd7b - Show all commits

View file

@ -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<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_anchor =
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
}
}
} else {
let si = &sap_input[0];
let swit_reader = Cursor::new(&si.iw);
let iw: IncrementalWitness<Node, SAPLING_DEPTH> = 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<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_anchor = match orch_iw {
//Ok(o_iw) => {
//Some(OrchardAnchor::from(o_iw.root()))
//},
//Err(_e) => {
//None
//}
//};
let orch_anchor =
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
}
}
} else {
let oi = &orch_input[0];
let wit_reader = Cursor::new(&oi.iw);