From 5fd33e7e43f8ef78c82d82655936ca24528903c1 Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Thu, 2 May 2024 07:22:12 -0500 Subject: [PATCH] Add debuggin for create transaction --- librustzcash-wrapper/src/lib.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/librustzcash-wrapper/src/lib.rs b/librustzcash-wrapper/src/lib.rs index c4f3316..f9a144d 100644 --- a/librustzcash-wrapper/src/lib.rs +++ b/librustzcash-wrapper/src/lib.rs @@ -1656,6 +1656,7 @@ pub extern "C" fn rust_wrapper_create_transaction( 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: Option> = read_incremental_witness(orch_wit_reader).ok(); @@ -1667,16 +1668,19 @@ pub extern "C" fn rust_wrapper_create_transaction( None } }; + println!(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 test_builder = Builder::new(TestNetwork, BlockHeight::from(bl_height), build_config); let trans_input: Vec = marshall_from_haskell_var(t_input, t_input_len, RW); + println!(trans_input); for t_in in trans_input { if t_in.sk.len() > 1 { let k = SecretKey::from_slice(&t_in.sk).unwrap(); if net { match main_builder.add_transparent_input(k, t_in.utxo.unpack(), t_in.coin.unpack()) { Ok(()) => { + println!("added t-input in main"); continue; }, Err(_e) => { println!("Error reading transparent input"); } @@ -1684,6 +1688,7 @@ pub extern "C" fn rust_wrapper_create_transaction( } else { match test_builder.add_transparent_input(k, t_in.utxo.unpack(), t_in.coin.unpack()) { Ok(()) => { + println!("added t-input in test"); continue; }, Err(_e) => { println!("Error reading transparent input"); } @@ -1692,6 +1697,7 @@ pub extern "C" fn rust_wrapper_create_transaction( } } let sap_input: Vec = marshall_from_haskell_var(s_input, s_input_len, RW); + println!(sap_input); for s_in in sap_input { if s_in.sk.len() > 1 { let sp_key = ExtendedSpendingKey::from_bytes(&s_in.sk); @@ -1720,6 +1726,7 @@ pub extern "C" fn rust_wrapper_create_transaction( } } let orch_input: Vec = marshall_from_haskell_var(o_input, o_input_len, RW); + println!(orch_input); for o_in in orch_input { if o_in.sk.len() > 1 { let sp_key = SpendingKey::from_bytes(o_in.sk[0..32].try_into().unwrap()).unwrap(); @@ -1739,6 +1746,7 @@ pub extern "C" fn rust_wrapper_create_transaction( } } let outputs: Vec = marshall_from_haskell_var(out_list, out_list_len, RW); + println!(outputs); for output in outputs { match output.kind { 1 => { @@ -1782,8 +1790,10 @@ pub extern "C" fn rust_wrapper_create_transaction( let memo = MemoBytes::from_bytes(&output.memo).unwrap(); if net { let _mb = main_builder.add_orchard_output::(ovk, recipient, val, memo); + println!("added o-input to main"); } else { let _tb = test_builder.add_orchard_output::(ovk, recipient, val, memo); + println!("added o-input to test"); } }, _ => { @@ -1797,9 +1807,12 @@ pub extern "C" fn rust_wrapper_create_transaction( let output_params_in: Vec = marshall_from_haskell_var(sapoutput, sapoutput_len, RW); let output_params_reader = Cursor::new(output_params_in); let output_prover = OutputParameters::read(output_params_reader, true).unwrap(); + println!("loaded params"); let result = if net { + println!("started main build"); main_builder.build(OsRng, &spend_prover, &output_prover, &FeeRule::standard()) } else { + println!("started test build"); test_builder.build(OsRng, &spend_prover, &output_prover, &FeeRule::standard()) }; match result {