Skip to content

Fix darkside v5 txid computation and tree state nil dereference#548

Open
zmanian wants to merge 2 commits intozcash:masterfrom
zmanian:fix-darkside-txid-and-treestate
Open

Fix darkside v5 txid computation and tree state nil dereference#548
zmanian wants to merge 2 commits intozcash:masterfrom
zmanian:fix-darkside-txid-and-treestate

Conversation

@zmanian
Copy link

@zmanian zmanian commented Feb 11, 2026

Summary

  • darksideSetTxID applied SHA256d to all transactions including v5, producing incorrect txids. Now that ParseFromSlice computes v5 txids via ZIP 244, skip the SHA256d override for v5 transactions.
  • DarksideRemoveTreeState crashed with a nil pointer dereference when removing a tree state at a non-existent height or hash. Add nil checks to return an error instead of panicking.

Closes #456
Closes #466

Depends on #547 (ZIP 244 txid computation) -- this PR is based on that branch.

Test plan

  • go build ./... passes
  • go test ./parser/... passes (16 tests including v5 txid validation)
  • Darkside integration tests with v5 transactions verify correct txids
  • Call DarksideRemoveTreeState with non-existent height/hash and verify error instead of crash

Generated with Claude Code

zmanian and others added 2 commits February 11, 2026 11:32
lightwalletd has returned incorrect txids for v5 transactions since
NU5 activation (issue zcash#392). The workaround fetches txids from zcashd
via a verbose getblock RPC call. This commit implements the ZIP 244
BLAKE2b-256 hash tree so v5 txids are computed during parsing.

The core blocker was that Go's golang.org/x/crypto/blake2b package
lacks personalization support. This is resolved by vendoring the
pure-Go BLAKE2b implementation into an internal package and adding
the ~3 lines needed for personalization parameter injection.

The ZIP 244 hash tree re-parses Transaction.rawBytes to feed fields
into 18 personalized BLAKE2b-256 digests. The v5 shared sapling
anchor is buffered and replayed per-spend in the noncompact digest.

All 10 test vectors from testdata/tx_v5.json now validate txids.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
darksideSetTxID applied SHA256d to all transactions including v5, producing
incorrect txids. Now that ParseFromSlice computes v5 txids via ZIP 244,
skip the SHA256d override for v5 transactions. (fixes zcash#456)

DarksideRemoveTreeState crashed with a nil pointer dereference when
removing a tree state at a non-existent height or hash. Add nil checks
to return an error instead of panicking. (fixes zcash#466)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: (low-priority) darkside: RemoveTreeState on non-existent height crashes lightwalletd Darkside TXIDs are incorrect

1 participant