Skip to content

Conversation

@galt-tr
Copy link
Contributor

@galt-tr galt-tr commented Nov 25, 2025

This pull request improves the handling of Merkle proofs for trees with an odd number of leaves, ensuring correct behavior and preventing potential panics when a leaf node does not have a sibling. It also adds comprehensive tests to verify this behavior and updates dependencies.

Merkle proof logic improvements

  • Updated the getLeafSiblingHash function in subtree.go to correctly handle cases where a leaf node has no sibling by duplicating the last node's hash, following Bitcoin convention. This prevents panics when generating proofs for odd numbers of leaves.

Testing enhancements

  • Added TestGetMerkleProofOddLeaves in subtree_test.go with multiple sub-tests to verify Merkle proof correctness for trees with odd and even numbers of leaves, including large trees. These tests ensure the new logic works as intended and prevent regressions.

Dependency updates

  • Updated the Go version in go.mod from 1.24.3 to 1.24.6 and bumped the golang.org/x/exp dependency to a newer version.

@galt-tr galt-tr requested a review from mrz1836 as a code owner November 25, 2025 13:14
@github-actions github-actions bot added fork-pr PR originated from a forked repository requires-manual-review PR or issue requires manual review by a maintainer or security team labels Nov 25, 2025
@github-actions
Copy link
Contributor

👋 Thanks, @galt-tr!

This pull request comes from a fork. For security, our CI runs in a restricted mode.
A maintainer will triage this shortly and run any additional checks as needed.

  • 🏷️ Labeled: fork-pr, requires-manual-review
  • 👀 We'll review and follow up here if anything else is needed.

Thanks for contributing to bsv-blockchain/go-subtree! 🚀

@sonarqubecloud
Copy link

@galt-tr galt-tr merged commit 4bd35d9 into bsv-blockchain:master Nov 25, 2025
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork-pr PR originated from a forked repository requires-manual-review PR or issue requires manual review by a maintainer or security team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants