Compare commits
No commits in common. "22c0fe374976d9f2323a8b7cd42f941423d45111" and "8dbcf58a93853d3ec7f03d73e68cb029646f8266" have entirely different histories.
22c0fe3749
...
8dbcf58a93
2 changed files with 50 additions and 54 deletions
|
@ -170,7 +170,7 @@ use bech32::{
|
|||
pub enum RW {}
|
||||
pub const RW: PhantomData<RW> = PhantomData;
|
||||
|
||||
#[derive(Debug, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(BorshSerialize, BorshDeserialize)]
|
||||
pub struct RawData {
|
||||
hrp: Vec<u8>,
|
||||
bytes: Vec<u8>
|
||||
|
@ -190,7 +190,7 @@ impl<RW> ToHaskell<RW> for RawData {
|
|||
//}
|
||||
//}
|
||||
|
||||
#[derive(Debug, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(BorshSerialize, BorshDeserialize)]
|
||||
pub struct HrawTx {
|
||||
bytes: Vec<u8>,
|
||||
s: bool,
|
||||
|
@ -204,7 +204,7 @@ impl<RW> ToHaskell<RW> for HrawTx {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(BorshSerialize, BorshDeserialize)]
|
||||
pub struct HshieldedOutput {
|
||||
pub cv: Hhex,
|
||||
cmu: Hhex,
|
||||
|
@ -248,7 +248,7 @@ impl HshieldedOutput {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(BorshSerialize, BorshDeserialize)]
|
||||
pub struct Hhex {
|
||||
bytes: Vec<u8>
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ impl<RW> ToHaskell<RW> for Hhex {
|
|||
}
|
||||
|
||||
|
||||
#[derive(Debug, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(BorshSerialize, BorshDeserialize)]
|
||||
pub struct Haction {
|
||||
nf: Hhex,
|
||||
rk: Hhex,
|
||||
|
@ -290,7 +290,7 @@ impl Haction {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(BorshSerialize, BorshDeserialize)]
|
||||
pub struct Hnote {
|
||||
note: u64,
|
||||
recipient: Vec<u8>,
|
||||
|
@ -307,7 +307,7 @@ impl<RW> ToHaskell<RW> for Hnote {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(BorshSerialize, BorshDeserialize)]
|
||||
pub struct Hrseed {
|
||||
kind: u8,
|
||||
bytes: Vec<u8>
|
||||
|
@ -328,7 +328,7 @@ impl<RW> ToHaskell<RW> for Hrseed {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(BorshSerialize, BorshDeserialize)]
|
||||
pub struct Hua {
|
||||
net: u8,
|
||||
o_rec: Vec<u8>,
|
||||
|
@ -361,7 +361,7 @@ impl Hua {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(BorshSerialize, BorshDeserialize)]
|
||||
pub struct Htx {
|
||||
txid: Vec<u8>,
|
||||
locktime: u32,
|
||||
|
@ -379,7 +379,7 @@ impl<RW> ToHaskell<RW> for Htx {
|
|||
}
|
||||
|
||||
|
||||
#[derive(Debug, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(BorshSerialize, BorshDeserialize)]
|
||||
pub struct HTBundle {
|
||||
empty: bool,
|
||||
vin: Vec<HTxIn>,
|
||||
|
@ -400,7 +400,7 @@ impl HTBundle {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(BorshSerialize, BorshDeserialize)]
|
||||
pub struct HTxIn {
|
||||
outpoint: Houtpoint,
|
||||
script: Vec<u8>,
|
||||
|
@ -420,7 +420,7 @@ impl HTxIn {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(BorshSerialize, BorshDeserialize)]
|
||||
pub struct HTxOut {
|
||||
amt: i64,
|
||||
script: Vec<u8>
|
||||
|
@ -449,7 +449,7 @@ impl HTxOut {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(BorshSerialize, BorshDeserialize)]
|
||||
pub struct Houtpoint {
|
||||
hash: Vec<u8>,
|
||||
index: u32
|
||||
|
@ -479,7 +479,7 @@ impl Houtpoint {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(BorshSerialize, BorshDeserialize)]
|
||||
pub struct HtransparentInput {
|
||||
sk: Vec<u8>,
|
||||
utxo: Houtpoint,
|
||||
|
@ -500,7 +500,7 @@ impl<RW> ToHaskell<RW> for HtransparentInput {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(BorshSerialize, BorshDeserialize)]
|
||||
pub struct HSBundle {
|
||||
empty: bool,
|
||||
spends: Vec<Hspend>,
|
||||
|
@ -523,7 +523,7 @@ impl HSBundle {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(BorshSerialize, BorshDeserialize)]
|
||||
pub struct Hspend {
|
||||
cv: Hhex,
|
||||
anchor: Hhex,
|
||||
|
@ -552,7 +552,7 @@ impl Hspend {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(BorshSerialize, BorshDeserialize)]
|
||||
pub struct HsaplingInput {
|
||||
sk: Vec<u8>,
|
||||
note: Hnote,
|
||||
|
@ -567,7 +567,7 @@ impl<RW> FromHaskell<RW> for HsaplingInput {
|
|||
}
|
||||
|
||||
|
||||
#[derive(Debug, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(BorshSerialize, BorshDeserialize)]
|
||||
pub struct HorchardInput {
|
||||
sk: Vec<u8>,
|
||||
note: Hnote,
|
||||
|
@ -581,7 +581,7 @@ impl<RW> FromHaskell<RW> for HorchardInput {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(BorshSerialize, BorshDeserialize)]
|
||||
pub struct Houtput {
|
||||
kind: u8,
|
||||
ovk: Vec<u8>,
|
||||
|
@ -598,7 +598,7 @@ impl<RW> FromHaskell<RW> for Houtput {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(BorshSerialize, BorshDeserialize)]
|
||||
pub struct HOBundle {
|
||||
empty: bool,
|
||||
actions: Vec<Haction>,
|
||||
|
@ -623,7 +623,7 @@ impl HOBundle {
|
|||
}
|
||||
|
||||
|
||||
#[derive(Debug, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(BorshSerialize, BorshDeserialize)]
|
||||
pub struct Hflags {
|
||||
spends: bool,
|
||||
outputs: bool
|
||||
|
@ -642,7 +642,7 @@ impl Hflags {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(BorshSerialize, BorshDeserialize)]
|
||||
pub struct Hufvk {
|
||||
net: u8,
|
||||
orchard: Vec<u8>,
|
||||
|
@ -671,7 +671,7 @@ impl Hufvk {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, BorshSerialize, BorshDeserialize)]
|
||||
#[derive(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
|
||||
}
|
||||
}
|
||||
|
@ -1647,24 +1647,23 @@ pub extern "C" fn rust_wrapper_create_transaction(
|
|||
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_iw: Option<IncrementalWitness<Node, SAPLING_DEPTH>> = read_incremental_witness(sap_wit_reader).ok();
|
||||
let sap_anchor = match sap_iw {
|
||||
Ok(s_iw) => {
|
||||
Some(s_iw) => {
|
||||
Some(SaplingAnchor::from(s_iw.root()))
|
||||
},
|
||||
Err(_e) => {
|
||||
None => {
|
||||
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_iw: Option<IncrementalWitness<MerkleHashOrchard, 32>> = read_incremental_witness(orch_wit_reader).ok();
|
||||
let orch_anchor = match orch_iw {
|
||||
Ok(o_iw) => {
|
||||
Some(o_iw) => {
|
||||
Some(OrchardAnchor::from(o_iw.root()))
|
||||
},
|
||||
Err(_e) => {
|
||||
None => {
|
||||
None
|
||||
}
|
||||
};
|
||||
|
@ -1678,7 +1677,6 @@ pub extern "C" fn rust_wrapper_create_transaction(
|
|||
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"); }
|
||||
|
@ -1686,7 +1684,6 @@ 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"); }
|
||||
|
@ -1774,13 +1771,12 @@ pub extern "C" fn rust_wrapper_create_transaction(
|
|||
}
|
||||
},
|
||||
4 => {
|
||||
//let sk = SpendingKey::from_bytes(output.ovk[0..32].try_into().unwrap()).unwrap();
|
||||
//let ovk = if output.chg {
|
||||
//Some(FullViewingKey::from(&sk).to_ovk(Scope::Internal))
|
||||
//} else {
|
||||
//Some(FullViewingKey::from(&sk).to_ovk(Scope::External))
|
||||
//};
|
||||
let ovk = None;
|
||||
let sk = SpendingKey::from_bytes(output.ovk[0..32].try_into().unwrap()).unwrap();
|
||||
let ovk = if output.chg {
|
||||
Some(FullViewingKey::from(&sk).to_ovk(Scope::Internal))
|
||||
}else {
|
||||
Some(FullViewingKey::from(&sk).to_ovk(Scope::External))
|
||||
};
|
||||
let recipient = OrchardAddress::from_raw_address_bytes(&to_array(output.to)).unwrap();
|
||||
let val = output.amt;
|
||||
let memo = MemoBytes::from_bytes(&output.memo).unwrap();
|
||||
|
@ -1797,10 +1793,10 @@ pub extern "C" fn rust_wrapper_create_transaction(
|
|||
}
|
||||
let spend_params_in: Vec<u8> = marshall_from_haskell_var(sapspend, sapspend_len, RW);
|
||||
let spend_params_reader = Cursor::new(spend_params_in);
|
||||
let spend_prover = SpendParameters::read(spend_params_reader, false).unwrap();
|
||||
let spend_prover = SpendParameters::read(spend_params_reader, true).unwrap();
|
||||
let output_params_in: Vec<u8> = 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, false).unwrap();
|
||||
let output_prover = OutputParameters::read(output_params_reader, true).unwrap();
|
||||
let result = if net {
|
||||
main_builder.build(OsRng, &spend_prover, &output_prover, &FeeRule::standard())
|
||||
} else {
|
||||
|
@ -1815,11 +1811,11 @@ pub extern "C" fn rust_wrapper_create_transaction(
|
|||
},
|
||||
Err(e) => {
|
||||
match e {
|
||||
Error::InsufficientFunds(y) => {
|
||||
Error::InsufficientFunds(_y) => {
|
||||
let x = Hhex {bytes: vec![0]};
|
||||
marshall_to_haskell_var(&x, out, out_len, RW);
|
||||
},
|
||||
Error::ChangeRequired(y1) => {
|
||||
Error::ChangeRequired(_y1) => {
|
||||
let x = Hhex {bytes: vec![1]};
|
||||
marshall_to_haskell_var(&x, out, out_len, RW);
|
||||
},
|
||||
|
@ -1827,27 +1823,27 @@ pub extern "C" fn rust_wrapper_create_transaction(
|
|||
let x = Hhex {bytes: vec![2]};
|
||||
marshall_to_haskell_var(&x, out, out_len, RW);
|
||||
},
|
||||
Error::Balance(y3) => {
|
||||
Error::Balance(x) => {
|
||||
let x = Hhex {bytes: vec![3]};
|
||||
marshall_to_haskell_var(&x, out, out_len, RW);
|
||||
},
|
||||
Error::TransparentBuild(y4) => {
|
||||
Error::TransparentBuild(x) => {
|
||||
let x = Hhex {bytes: vec![4]};
|
||||
marshall_to_haskell_var(&x, out, out_len, RW);
|
||||
},
|
||||
Error::SaplingBuild(y5) => {
|
||||
Error::SaplingBuild(x) => {
|
||||
let x = Hhex {bytes: vec![5]};
|
||||
marshall_to_haskell_var(&x, out, out_len, RW);
|
||||
},
|
||||
Error::OrchardBuild(y7) => {
|
||||
Error::OrchardBuild(x) => {
|
||||
let x = Hhex {bytes: vec![6]};
|
||||
marshall_to_haskell_var(&x, out, out_len, RW);
|
||||
},
|
||||
Error::OrchardSpend(y8) => {
|
||||
Error::OrchardSpend(x) => {
|
||||
let x = Hhex {bytes: vec![7]};
|
||||
marshall_to_haskell_var(&x, out, out_len, RW);
|
||||
},
|
||||
Error::OrchardRecipient(y9) => {
|
||||
Error::OrchardRecipient(x) => {
|
||||
let x = Hhex {bytes: vec![8]};
|
||||
marshall_to_haskell_var(&x, out, out_len, RW);
|
||||
},
|
||||
|
|
|
@ -123,8 +123,8 @@ readZebraTransaction hex =
|
|||
rawTx = (withPureBorshVarBuffer . rustWrapperTxRead) $ hexBytes hex
|
||||
|
||||
createTransaction ::
|
||||
Maybe SaplingCommitmentTree -- ^ to obtain the Sapling anchor
|
||||
-> Maybe OrchardCommitmentTree -- ^ to obtain the Orchard anchor
|
||||
Maybe SaplingWitness -- ^ to obtain the Sapling anchor
|
||||
-> Maybe OrchardWitness -- ^ to obtain the Orchard anchor
|
||||
-> [TransparentTxSpend] -- ^ the list of transparent notes to spend
|
||||
-> [SaplingTxSpend] -- ^ the list of Sapling notes to spend
|
||||
-> [OrchardTxSpend] -- ^ the list of Orchard notes to spend
|
||||
|
@ -156,10 +156,10 @@ createTransaction sapAnchor orchAnchor tSpend sSpend oSpend outgoing sParams oPa
|
|||
rustWrapperCreateTx
|
||||
(case sapAnchor of
|
||||
Nothing -> "0"
|
||||
Just sA -> toBytes $ sapTree sA)
|
||||
Just sA -> toBytes $ sapWit sA)
|
||||
(case orchAnchor of
|
||||
Nothing -> "0"
|
||||
Just oA -> toBytes $ orchTree oA)
|
||||
Just oA -> toBytes $ orchWit oA)
|
||||
tSpend
|
||||
sSpend
|
||||
oSpend
|
||||
|
|
Loading…
Reference in a new issue