Skip to content

CSHLD-886: Fix incorrect hashbytes padding in sBTC withdraw builder#8830

Merged
abhi-bitgo merged 1 commit into
masterfrom
CSHLD-886-fix-hashbytes-padding
May 22, 2026
Merged

CSHLD-886: Fix incorrect hashbytes padding in sBTC withdraw builder#8830
abhi-bitgo merged 1 commit into
masterfrom
CSHLD-886-fix-hashbytes-padding

Conversation

@abhi-bitgo
Copy link
Copy Markdown
Contributor

Summary

Remove incorrect 32-byte zero-padding of BTC address hash bytes in the sBTC withdraw builder. P2PKH, P2SH, and P2WPKH addresses have 20-byte hashes and were being incorrectly padded to 32 bytes.

Linear: CSHLD-886

Changes

  • Remove HASHBYTES_BUFFER_LENGTH constant and 32-byte zero-padding logic from withdrawParamsToFunctionArgs in sbtcWithdrawBuilder.ts
  • Pass decoded.hashBytes directly to bufferCV instead of padding
  • Add unit test assertions verifying correct hashbyte buffer lengths:
    • 20 bytes for P2PKH, P2SH, P2WPKH
    • 32 bytes for P2WSH, P2TR

Test Plan

  • Unit tests added to verify hashbyte buffer lengths for each address type (P2PKH, P2SH, P2WPKH, P2WSH, P2TR)

The withdraw builder was zero-padding all BTC address hash bytes to 32
bytes. P2PKH, P2SH, and P2WPKH addresses have 20-byte hashes and should
not be padded. Pass decoded hash bytes directly and add test assertions
to verify correct buffer lengths per address type.

Ticket: CSHLD-886
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 22, 2026

CSHLD-886

@abhi-bitgo abhi-bitgo marked this pull request as ready for review May 22, 2026 04:57
@abhi-bitgo abhi-bitgo requested a review from a team as a code owner May 22, 2026 04:57
@abhi-bitgo abhi-bitgo merged commit d22b297 into master May 22, 2026
22 checks passed
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