zcash_client_backend: Treat protobuf default as the empty tree.
Fixes #1280
This commit is contained in:
parent
97651a6d4b
commit
5f1d75937b
|
@ -263,6 +263,9 @@ impl service::TreeState {
|
|||
pub fn sapling_tree(
|
||||
&self,
|
||||
) -> io::Result<CommitmentTree<Node, { sapling::NOTE_COMMITMENT_TREE_DEPTH }>> {
|
||||
if self.sapling_tree.is_empty() {
|
||||
Ok(CommitmentTree::empty())
|
||||
} else {
|
||||
let sapling_tree_bytes = hex::decode(&self.sapling_tree).map_err(|e| {
|
||||
io::Error::new(
|
||||
io::ErrorKind::InvalidData,
|
||||
|
@ -273,6 +276,7 @@ impl service::TreeState {
|
|||
&sapling_tree_bytes[..],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Deserializes and returns the Sapling note commitment tree field of the tree state.
|
||||
#[cfg(feature = "orchard")]
|
||||
|
@ -280,15 +284,21 @@ impl service::TreeState {
|
|||
&self,
|
||||
) -> io::Result<CommitmentTree<MerkleHashOrchard, { orchard::NOTE_COMMITMENT_TREE_DEPTH as u8 }>>
|
||||
{
|
||||
if self.orchard_tree.is_empty() {
|
||||
Ok(CommitmentTree::empty())
|
||||
} else {
|
||||
let orchard_tree_bytes = hex::decode(&self.orchard_tree).map_err(|e| {
|
||||
io::Error::new(
|
||||
io::ErrorKind::InvalidData,
|
||||
format!("Hex decoding of Orchard tree bytes failed: {:?}", e),
|
||||
)
|
||||
})?;
|
||||
read_commitment_tree::<MerkleHashOrchard, _, { orchard::NOTE_COMMITMENT_TREE_DEPTH as u8 }>(
|
||||
&orchard_tree_bytes[..],
|
||||
)
|
||||
read_commitment_tree::<
|
||||
MerkleHashOrchard,
|
||||
_,
|
||||
{ orchard::NOTE_COMMITMENT_TREE_DEPTH as u8 },
|
||||
>(&orchard_tree_bytes[..])
|
||||
}
|
||||
}
|
||||
|
||||
/// Parses this tree state into a [`ChainState`] for use with [`scan_cached_blocks`].
|
||||
|
|
Loading…
Reference in New Issue