From 9390c65283bf10eeebaafd28be647d44f6937c05 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Fri, 5 Sep 2025 11:41:30 -0600 Subject: [PATCH 1/2] Revert "Align to dependencies" This reverts commit d492338c2a18a21b6b4f13f39bdbde3d8add0b15. This crate specifically parses zcashd wallets using `zcash_primitives 0.19` and its dependencies; introducing a second version of the `incrementalmerkletree` crates breaks compatibility with the `zcash_primitives` version. --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d9721dd..6a9fb31 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,8 +27,8 @@ zcash_protocol = "0.4" zip32 = "0.1" orchard = "0.10" sapling = { package = "sapling-crypto", version = "0.3", features = ["temporary-zcashd"] } -incrementalmerkletree = "0.8" -bridgetree = "0.7" +incrementalmerkletree = "0.7" +bridgetree = "0.6" [dev-dependencies] bc-rand = "^0.4.0" From 4673aa59c9e23a6a563e6950dc48b2820cbeb4e8 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Fri, 5 Sep 2025 11:44:02 -0600 Subject: [PATCH 2/2] Fix incorrect parsing of `CWalletTx::mapSaplingNoteData` In `zcashd`, `mapSaplingNoteData` is always parsed if the transaction version supports sapling; the implementation in `wallet_tx` parsing incorrectly parsed it instead as a value wrapped in `std::optional`. This causes an off-by-one error in the remainder of `CWalletTx` parsing, but that error only appears sometimes because the `0x00` and `0x01` discriminants for optional values are also valid vector lengths, so transactions that did not include a Sapling component would not have a parse error here. --- src/zcashd_wallet/wallet_tx.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/zcashd_wallet/wallet_tx.rs b/src/zcashd_wallet/wallet_tx.rs index 8972901..354033e 100644 --- a/src/zcashd_wallet/wallet_tx.rs +++ b/src/zcashd_wallet/wallet_tx.rs @@ -144,13 +144,14 @@ impl Parse for WalletTx { let mut sapling_note_data = None; if transaction.version().has_sapling() { - sapling_note_data = parse!(p, "sapling_note_data")?; + let value = parse!(p, "sapling_note_data")?; + sapling_note_data = Some(value); } let mut orchard_tx_meta: Option = None; if transaction.version().has_orchard() { - let meta = parse!(p, "orchard_tx_meta")?; - orchard_tx_meta = Some(meta); + let value = parse!(p, "orchard_tx_meta")?; + orchard_tx_meta = Some(value); } let unparsed_data = p.rest();