Functions to handle commitment tree nodes for Sapling and Orchard #100

Merged
pitmutt merged 50 commits from rav001 into milestone2 2024-11-15 18:48:36 +00:00
Showing only changes of commit 1492f3b6ad - Show all commits

View file

@ -1844,6 +1844,7 @@ pub extern "C" fn rust_wrapper_create_transaction(
let trans_input: Vec<HtransparentInput> = marshall_from_haskell_var(t_input, t_input_len, RW);
for t_in in trans_input {
if t_in.sk.len() > 1 {
println!("t inp: {:?}", t_in);
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()) {
@ -1866,6 +1867,7 @@ pub extern "C" fn rust_wrapper_create_transaction(
}
for s_in in sap_input {
if s_in.sk.len() > 1 {
println!("s inp: {:?}", s_in);
let sp_key = ExtendedSpendingKey::from_bytes(&s_in.sk);
match sp_key {
Ok(sk) => {
@ -1912,6 +1914,7 @@ pub extern "C" fn rust_wrapper_create_transaction(
}
for o_in in orch_input {
if o_in.sk.len() > 1 {
println!("o inp: {:?}", o_in);
let sp_key = SpendingKey::from_bytes(o_in.sk[0..32].try_into().unwrap()).unwrap();
let pay_addr = OrchardAddress::from_raw_address_bytes(&to_array(o_in.note.recipient)).unwrap();
let rho = Rho::from_bytes(&to_array(o_in.note.rho)).unwrap();
@ -1952,6 +1955,7 @@ pub extern "C" fn rust_wrapper_create_transaction(
1 => {
let recipient = TransparentAddress::PublicKeyHash(to_array(output.to));
let val = NonNegativeAmount::from_u64(output.amt).unwrap();
println!("t out: {:?} {:?}", val, output.chg);
if net {
let _mb = main_builder.add_transparent_output(&recipient, val);
} else {
@ -1961,6 +1965,7 @@ pub extern "C" fn rust_wrapper_create_transaction(
2 => {
let recipient = TransparentAddress::ScriptHash(to_array(output.to));
let val = NonNegativeAmount::from_u64(output.amt).unwrap();
println!("t out: {:?} {:?}", val, output.chg);
if net {
let _mb = main_builder.add_transparent_output(&recipient, val);
} else {
@ -1972,6 +1977,7 @@ pub extern "C" fn rust_wrapper_create_transaction(
let recipient = PaymentAddress::from_bytes(&to_array(output.to)).unwrap();
let val = NonNegativeAmount::from_u64(output.amt).unwrap();
let memo = MemoBytes::from_bytes(&output.memo).unwrap();
println!("s out: {:?} {:?}", val, output.chg);
if net {
let _mb = main_builder.add_sapling_output::<String>(ovk, recipient, val, memo);
} else {
@ -1987,6 +1993,7 @@ pub extern "C" fn rust_wrapper_create_transaction(
};
let recipient = OrchardAddress::from_raw_address_bytes(&to_array(output.to)).unwrap();
let val = output.amt;
println!("o out: {:?} {:?}", val, output.chg);
let memo = MemoBytes::from_bytes(&output.memo).unwrap();
if net {
let _mb = main_builder.add_orchard_output::<String>(ovk, recipient, val, memo);