Transaction creation updates #78

Merged
pitmutt merged 10 commits from rav001 into dev040 2024-05-02 19:59:26 +00:00
Showing only changes of commit c144a6d624 - Show all commits

View file

@ -170,7 +170,7 @@ use bech32::{
pub enum RW {}
pub const RW: PhantomData<RW> = PhantomData;
#[derive(BorshSerialize, BorshDeserialize)]
#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub struct RawData {
hrp: Vec<u8>,
bytes: Vec<u8>
@ -190,7 +190,7 @@ impl<RW> ToHaskell<RW> for RawData {
//}
//}
#[derive(BorshSerialize, BorshDeserialize)]
#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub struct HrawTx {
bytes: Vec<u8>,
s: bool,
@ -204,7 +204,7 @@ impl<RW> ToHaskell<RW> for HrawTx {
}
}
#[derive(BorshSerialize, BorshDeserialize)]
#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub struct HshieldedOutput {
pub cv: Hhex,
cmu: Hhex,
@ -248,7 +248,7 @@ impl HshieldedOutput {
}
}
#[derive(BorshSerialize, BorshDeserialize)]
#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub struct Hhex {
bytes: Vec<u8>
}
@ -261,7 +261,7 @@ impl<RW> ToHaskell<RW> for Hhex {
}
#[derive(BorshSerialize, BorshDeserialize)]
#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub struct Haction {
nf: Hhex,
rk: Hhex,
@ -290,7 +290,7 @@ impl Haction {
}
}
#[derive(BorshSerialize, BorshDeserialize)]
#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub struct Hnote {
note: u64,
recipient: Vec<u8>,
@ -307,7 +307,7 @@ impl<RW> ToHaskell<RW> for Hnote {
}
}
#[derive(BorshSerialize, BorshDeserialize)]
#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub struct Hrseed {
kind: u8,
bytes: Vec<u8>
@ -328,7 +328,7 @@ impl<RW> ToHaskell<RW> for Hrseed {
}
}
#[derive(BorshSerialize, BorshDeserialize)]
#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub struct Hua {
net: u8,
o_rec: Vec<u8>,
@ -361,7 +361,7 @@ impl Hua {
}
}
#[derive(BorshSerialize, BorshDeserialize)]
#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub struct Htx {
txid: Vec<u8>,
locktime: u32,
@ -379,7 +379,7 @@ impl<RW> ToHaskell<RW> for Htx {
}
#[derive(BorshSerialize, BorshDeserialize)]
#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub struct HTBundle {
empty: bool,
vin: Vec<HTxIn>,
@ -400,7 +400,7 @@ impl HTBundle {
}
}
#[derive(BorshSerialize, BorshDeserialize)]
#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub struct HTxIn {
outpoint: Houtpoint,
script: Vec<u8>,
@ -420,7 +420,7 @@ impl HTxIn {
}
}
#[derive(BorshSerialize, BorshDeserialize)]
#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub struct HTxOut {
amt: i64,
script: Vec<u8>
@ -449,7 +449,7 @@ impl HTxOut {
}
}
#[derive(BorshSerialize, BorshDeserialize)]
#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub struct Houtpoint {
hash: Vec<u8>,
index: u32
@ -479,7 +479,7 @@ impl Houtpoint {
}
}
#[derive(BorshSerialize, BorshDeserialize)]
#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub struct HtransparentInput {
sk: Vec<u8>,
utxo: Houtpoint,
@ -500,7 +500,7 @@ impl<RW> ToHaskell<RW> for HtransparentInput {
}
}
#[derive(BorshSerialize, BorshDeserialize)]
#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub struct HSBundle {
empty: bool,
spends: Vec<Hspend>,
@ -523,7 +523,7 @@ impl HSBundle {
}
}
#[derive(BorshSerialize, BorshDeserialize)]
#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub struct Hspend {
cv: Hhex,
anchor: Hhex,
@ -552,7 +552,7 @@ impl Hspend {
}
}
#[derive(BorshSerialize, BorshDeserialize)]
#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub struct HsaplingInput {
sk: Vec<u8>,
note: Hnote,
@ -567,7 +567,7 @@ impl<RW> FromHaskell<RW> for HsaplingInput {
}
#[derive(BorshSerialize, BorshDeserialize)]
#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub struct HorchardInput {
sk: Vec<u8>,
note: Hnote,
@ -581,7 +581,7 @@ impl<RW> FromHaskell<RW> for HorchardInput {
}
}
#[derive(BorshSerialize, BorshDeserialize)]
#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub struct Houtput {
kind: u8,
ovk: Vec<u8>,
@ -598,7 +598,7 @@ impl<RW> FromHaskell<RW> for Houtput {
}
}
#[derive(BorshSerialize, BorshDeserialize)]
#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub struct HOBundle {
empty: bool,
actions: Vec<Haction>,
@ -623,7 +623,7 @@ impl HOBundle {
}
#[derive(BorshSerialize, BorshDeserialize)]
#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub struct Hflags {
spends: bool,
outputs: bool
@ -642,7 +642,7 @@ impl Hflags {
}
}
#[derive(BorshSerialize, BorshDeserialize)]
#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub struct Hufvk {
net: u8,
orchard: Vec<u8>,
@ -671,7 +671,7 @@ impl Hufvk {
}
}
#[derive(BorshSerialize, BorshDeserialize)]
#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub struct Hsvk {
vk: Vec<u8>,
ovk: Vec<u8>
@ -795,7 +795,7 @@ pub extern "C" fn rust_wrapper_svk_decode(
true
}
Err(e) => {
print!("{}", e);
print!("{:?}", e);
false
}
}
@ -1656,7 +1656,7 @@ pub extern "C" fn rust_wrapper_create_transaction(
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: Option<IncrementalWitness<MerkleHashOrchard, 32>> = read_incremental_witness(orch_wit_reader).ok();
@ -1668,12 +1668,12 @@ pub extern "C" fn rust_wrapper_create_transaction(
None
}
};
println!(orch_anchor);
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<HtransparentInput> = marshall_from_haskell_var(t_input, t_input_len, RW);
println!(trans_input);
println!("{:?}", trans_input);
for t_in in trans_input {
if t_in.sk.len() > 1 {
let k = SecretKey::from_slice(&t_in.sk).unwrap();
@ -1697,7 +1697,7 @@ pub extern "C" fn rust_wrapper_create_transaction(
}
}
let sap_input: Vec<HsaplingInput> = marshall_from_haskell_var(s_input, s_input_len, RW);
println!(sap_input);
println!("{:?}", sap_input);
for s_in in sap_input {
if s_in.sk.len() > 1 {
let sp_key = ExtendedSpendingKey::from_bytes(&s_in.sk);
@ -1726,7 +1726,7 @@ pub extern "C" fn rust_wrapper_create_transaction(
}
}
let orch_input: Vec<HorchardInput> = marshall_from_haskell_var(o_input, o_input_len, RW);
println!(orch_input);
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();
@ -1746,7 +1746,7 @@ pub extern "C" fn rust_wrapper_create_transaction(
}
}
let outputs: Vec<Houtput> = marshall_from_haskell_var(out_list, out_list_len, RW);
println!(outputs);
println!("{:?}", outputs);
for output in outputs {
match output.kind {
1 => {