Skip to content

fix: use Buffer.slice() instead of subarray() in getPrevoutTaprootKey#2326

Open
lindsey-comet wants to merge 2 commits intobitcoinjs:masterfrom
lindsey-comet:fix/2249-buffer-slice
Open

fix: use Buffer.slice() instead of subarray() in getPrevoutTaprootKey#2326
lindsey-comet wants to merge 2 commits intobitcoinjs:masterfrom
lindsey-comet:fix/2249-buffer-slice

Conversation

@lindsey-comet
Copy link
Copy Markdown

Summary

  • Fixes issue Buffer.equals() requires Buffer, not Uint8Array #2249 where Buffer.equals() requires Buffer, not Uint8Array
  • Changed script.subarray(2, 34) to script.slice(2, 34) in getPrevoutTaprootKey()
  • Node.js Buffer.subarray() returns Uint8Array, while Buffer.slice() returns Buffer
  • This ensures the returned value can be compared using .equals() with other Buffer values

Test Plan

  • All 2660 existing tests pass
  • Build completes successfully

🤖 Generated with Claude Code

Lindsey Comet and others added 2 commits March 17, 2026 22:10
Updated README.md and JSDoc comments to reflect that v7 APIs are
Uint8Array-first. Buffer input is still accepted (as it is a
Uint8Array subclass), but the canonical public type is now Uint8Array.

Changes:
- README.md: Updated project description to mention Uint8Array
- JSDoc comments: Changed 'as a Buffer' to 'as a Uint8Array' or
  clarified Buffer compatibility notes

Fixes bitcoinjs#2321
This fixes issue bitcoinjs#2249 where Buffer.equals() requires Buffer, not Uint8Array.
Node.js Buffer.subarray() returns Uint8Array, while Buffer.slice() returns Buffer.
The getPrevoutTaprootKey function now uses .slice(2, 34) to ensure
the returned value can be compared using .equals() with other Buffer values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jvgelder
Copy link
Copy Markdown

should use #2322 as a base for now ?

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.

2 participants