Support for Zebra 2.1.0 #102
3 changed files with 7 additions and 8 deletions
|
@ -1548,9 +1548,10 @@ pub extern "C" fn rust_wrapper_read_orchard_witness(
|
||||||
out: *mut u8,
|
out: *mut u8,
|
||||||
out_len: &mut usize
|
out_len: &mut usize
|
||||||
){
|
){
|
||||||
let tree_in: Vec<u8> = marshall_from_haskell_var(tree, tree_len, RW);
|
let tree_in: Hfrontier = marshall_from_haskell_var(tree, tree_len, RW);
|
||||||
let tree_reader = Cursor::new(tree_in);
|
let leaf = MerkleHashOrchard::from_bytes(&to_array(tree_in.leaf.bytes)).unwrap();
|
||||||
let ct: CommitmentTree<MerkleHashOrchard, 32> = read_commitment_tree(tree_reader).unwrap();
|
let frontier: Frontier<MerkleHashOrchard, 32> = Frontier::from_parts(Position::from(tree_in.position), leaf, tree_in.ommers.iter().map(|x| MerkleHashOrchard::from_bytes(&to_array(x.clone())).unwrap() ).collect()).unwrap();
|
||||||
|
let ct: CommitmentTree<MerkleHashOrchard, 32> = CommitmentTree::from_frontier(&frontier);
|
||||||
let inc_wit = IncrementalWitness::from_tree(ct);
|
let inc_wit = IncrementalWitness::from_tree(ct);
|
||||||
let mut out_bytes: Vec<u8> = Vec::new();
|
let mut out_bytes: Vec<u8> = Vec::new();
|
||||||
let result = write_incremental_witness(&inc_wit, &mut out_bytes);
|
let result = write_incremental_witness(&inc_wit, &mut out_bytes);
|
||||||
|
|
|
@ -255,7 +255,7 @@ import ZcashHaskell.Types
|
||||||
#}
|
#}
|
||||||
|
|
||||||
{# fun unsafe rust_wrapper_read_orchard_witness as rustWrapperReadOrchardWitness
|
{# fun unsafe rust_wrapper_read_orchard_witness as rustWrapperReadOrchardWitness
|
||||||
{ toBorshVar* `BS.ByteString'&
|
{ toBorshVar* `OrchardFrontier'&
|
||||||
, getVarBuffer `Buffer HexString'&
|
, getVarBuffer `Buffer HexString'&
|
||||||
}
|
}
|
||||||
-> `()'
|
-> `()'
|
||||||
|
|
|
@ -220,15 +220,13 @@ updateOrchardCommitmentTree tree cmx =
|
||||||
rustWrapperReadOrchardCommitmentTree tree (hexBytes cmx)
|
rustWrapperReadOrchardCommitmentTree tree (hexBytes cmx)
|
||||||
|
|
||||||
-- | Get the Orchard incremental witness from a commitment tree
|
-- | Get the Orchard incremental witness from a commitment tree
|
||||||
getOrchardWitness :: OrchardCommitmentTree -> Maybe OrchardWitness
|
getOrchardWitness :: OrchardFrontier -> Maybe OrchardWitness
|
||||||
getOrchardWitness tree =
|
getOrchardWitness tree =
|
||||||
if BS.length (hexBytes wit) > 1
|
if BS.length (hexBytes wit) > 1
|
||||||
then Just $ OrchardWitness wit
|
then Just $ OrchardWitness wit
|
||||||
else Nothing
|
else Nothing
|
||||||
where
|
where
|
||||||
wit =
|
wit = withPureBorshVarBuffer $ rustWrapperReadOrchardWitness tree
|
||||||
withPureBorshVarBuffer $
|
|
||||||
rustWrapperReadOrchardWitness (hexBytes $ orchTree tree)
|
|
||||||
|
|
||||||
-- | Get the Sapling note position from a witness
|
-- | Get the Sapling note position from a witness
|
||||||
getOrchardNotePosition :: OrchardWitness -> Integer
|
getOrchardNotePosition :: OrchardWitness -> Integer
|
||||||
|
|
Loading…
Reference in a new issue