feat: Use the notes to determine anchors

This commit is contained in:
Rene Vergara 2024-09-30 14:50:54 -05:00
parent 38e4131daa
commit 3969490283
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2

View file

@ -1702,14 +1702,24 @@ pub extern "C" fn rust_wrapper_create_transaction(
let orch_wit_in: Vec<u8> = marshall_from_haskell_var(orch_wit, orch_wit_len, RW); 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_wit_reader = Cursor::new(orch_wit_in);
let orch_iw = read_commitment_tree::<MerkleHashOrchard, Cursor<Vec<u8>>, 32>(orch_wit_reader); let orch_iw = read_commitment_tree::<MerkleHashOrchard, Cursor<Vec<u8>>, 32>(orch_wit_reader);
let orch_anchor = match orch_iw { let orch_input: Vec<HorchardInput> = marshall_from_haskell_var(o_input, o_input_len, RW);
Ok(o_iw) => { //let orch_anchor = match orch_iw {
Some(OrchardAnchor::from(o_iw.root())) //Ok(o_iw) => {
}, //Some(OrchardAnchor::from(o_iw.root()))
Err(_e) => { //},
//Err(_e) => {
//None
//}
//};
let orch_anchor =
if orch_input.is_empty() {
None None
} } else {
}; let oi = &orch_input[0];
let wit_reader = Cursor::new(&oi.iw);
let iw: IncrementalWitness<MerkleHashOrchard, 32> = read_incremental_witness(wit_reader).unwrap();
Some(OrchardAnchor::from(iw.root()))
};
let build_config = BuildConfig::Standard {sapling_anchor: sap_anchor, orchard_anchor: orch_anchor}; let build_config = BuildConfig::Standard {sapling_anchor: sap_anchor, orchard_anchor: orch_anchor};
let mut main_builder = Builder::new(MainNetwork, BlockHeight::from(bl_height), build_config); 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); let mut test_builder = Builder::new(TestNetwork, BlockHeight::from(bl_height), build_config);
@ -1764,7 +1774,6 @@ pub extern "C" fn rust_wrapper_create_transaction(
} }
} }
} }
let orch_input: Vec<HorchardInput> = marshall_from_haskell_var(o_input, o_input_len, RW);
for o_in in orch_input { for o_in in orch_input {
if o_in.sk.len() > 1 { if o_in.sk.len() > 1 {
let sp_key = SpendingKey::from_bytes(o_in.sk[0..32].try_into().unwrap()).unwrap(); let sp_key = SpendingKey::from_bytes(o_in.sk[0..32].try_into().unwrap()).unwrap();