Fix darkside v5 txid computation and tree state nil dereference#548
Open
zmanian wants to merge 2 commits intozcash:masterfrom
Open
Fix darkside v5 txid computation and tree state nil dereference#548zmanian wants to merge 2 commits intozcash:masterfrom
zmanian wants to merge 2 commits intozcash:masterfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ParseFromSlicecomputes v5 txids via ZIP 244, skip the SHA256d override for v5 transactions.Closes #456
Closes #466
Depends on #547 (ZIP 244 txid computation) -- this PR is based on that branch.
Test plan
go build ./...passesgo test ./parser/...passes (16 tests including v5 txid validation)DarksideRemoveTreeStatewith non-existent height/hash and verify error instead of crashGenerated with Claude Code