Merge pull request #545 from nuttycom/feature/wallet_orchard-anchor_depth

Update incrementalmerkletree & orchard dependency versions.
This commit is contained in:
ebfull 2022-05-04 11:06:11 -06:00 committed by GitHub
commit 68cbc2bb17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 9 deletions

View File

@ -19,6 +19,10 @@ panic = 'abort'
codegen-units = 1
[patch.crates-io]
halo2_gadgets = { git = "https://github.com/zcash/halo2.git", rev = "0c33fa4e6e41464884765c8fb4cefebafd300ca2" }
halo2_proofs = { git = "https://github.com/zcash/halo2.git", rev = "0c33fa4e6e41464884765c8fb4cefebafd300ca2" }
hdwallet = { git = "https://github.com/nuttycom/hdwallet", rev = "9b4c1bdbe0517e3a7a8f285d6048a37d472ba3bc" }
incrementalmerkletree = { git = "https://github.com/zcash/incrementalmerkletree", rev = "f23e3d89507849a24543121839eea6f40b141aff" }
orchard = { git = "https://github.com/zcash/orchard", rev = "a30caec124aa6c6e7818b5100293204425c49de3" }
zcash_encoding = { path = "components/zcash_encoding" }
zcash_note_encryption = { path = "components/zcash_note_encryption" }

View File

@ -114,15 +114,24 @@ impl Vector {
/// Reads a CompactSize-prefixed series of elements into a collection, assuming the encoding
/// written by [`Vector::write`], using the provided function to decode each element.
pub fn read_collected<R: Read, E, F, O: FromIterator<E>>(
pub fn read_collected<R: Read, E, F, O: FromIterator<E>>(reader: R, func: F) -> io::Result<O>
where
F: Fn(&mut R) -> io::Result<E>,
{
Self::read_collected_mut(reader, func)
}
/// Reads a CompactSize-prefixed series of elements into a collection, assuming the encoding
/// written by [`Vector::write`], using the provided function to decode each element.
pub fn read_collected_mut<R: Read, E, F, O: FromIterator<E>>(
mut reader: R,
func: F,
) -> io::Result<O>
where
F: Fn(&mut R) -> io::Result<E>,
F: FnMut(&mut R) -> io::Result<E>,
{
let count: usize = CompactSize::read_t(&mut reader)?;
Array::read_collected(reader, count, func)
Array::read_collected_mut(reader, count, func)
}
/// Writes a slice of values by writing [`CompactSize`]-encoded integer specifying the length
@ -185,12 +194,25 @@ impl Array {
/// Reads `count` elements into a collection, assuming the encoding written by
/// [`Array::write`], using the provided function to decode each element.
pub fn read_collected<R: Read, E, F, O: FromIterator<E>>(
mut reader: R,
reader: R,
count: usize,
func: F,
) -> io::Result<O>
where
F: Fn(&mut R) -> io::Result<E>,
{
Self::read_collected_mut(reader, count, func)
}
/// Reads `count` elements into a collection, assuming the encoding written by
/// [`Array::write`], using the provided function to decode each element.
pub fn read_collected_mut<R: Read, E, F, O: FromIterator<E>>(
mut reader: R,
count: usize,
mut func: F,
) -> io::Result<O>
where
F: FnMut(&mut R) -> io::Result<E>,
{
(0..count).map(|_| func(&mut reader)).collect()
}

View File

@ -14,6 +14,7 @@ use zcash_encoding::{Optional, Vector};
use super::{CommitmentTree, HashSer};
pub const SER_V1: u8 = 1;
pub const SER_V2: u8 = 2;
impl HashSer for MerkleHashOrchard {
fn read<R: Read>(mut reader: R) -> io::Result<Self>

View File

@ -5,11 +5,11 @@ use std::io::{self, Read, Write};
use byteorder::{ReadBytesExt, WriteBytesExt};
use nonempty::NonEmpty;
use orchard::{
bundle::{Action, Authorization, Authorized, Flags},
bundle::{Authorization, Authorized, Flags},
note::{ExtractedNoteCommitment, Nullifier, TransmittedNoteCiphertext},
primitives::redpallas::{self, SigType, Signature, SpendAuth, VerificationKey},
value::ValueCommitment,
Anchor,
Action, Anchor,
};
use zcash_encoding::{Array, CompactSize, Vector};
@ -156,7 +156,12 @@ pub fn read_action_without_auth<R: Read>(mut reader: R) -> io::Result<Action<()>
pub fn read_flags<R: Read>(mut reader: R) -> io::Result<Flags> {
let mut byte = [0u8; 1];
reader.read_exact(&mut byte)?;
Flags::from_byte(byte[0])
Flags::from_byte(byte[0]).ok_or_else(|| {
io::Error::new(
io::ErrorKind::InvalidInput,
"invalid Orchard flags".to_owned(),
)
})
}
pub fn read_anchor<R: Read>(mut reader: R) -> io::Result<Anchor> {

View File

@ -1,6 +1,6 @@
//! Types and functions for building Sapling transaction components.
use std::fmt;
use core::fmt;
use std::sync::mpsc::Sender;
use ff::Field;

View File

@ -437,7 +437,7 @@ impl<A: Authorization> TransactionData<A> {
sprout_bundle: self.sprout_bundle,
sapling_bundle: self.sapling_bundle.map(|b| b.map_authorization(f_sapling)),
orchard_bundle: self.orchard_bundle.map(|b| {
b.authorize(
b.map_authorization(
&mut f_orchard,
|f, _, s| f.map_spend_auth(s),
|f, a| f.map_authorization(a),