Skip to content

refactor(bitcoin_client_js): migrate descriptors to v3 and upgrade bitcoinjs-lib to v7#430

Open
landabaso wants to merge 3 commits intoLedgerHQ:developfrom
bitcoinerlab:issue-428-bitcoinjs-v7
Open

refactor(bitcoin_client_js): migrate descriptors to v3 and upgrade bitcoinjs-lib to v7#430
landabaso wants to merge 3 commits intoLedgerHQ:developfrom
bitcoinerlab:issue-428-bitcoinjs-v7

Conversation

@landabaso
Copy link
Contributor

This PR is a follow up to #428. It enables descriptors v3 support and aligns dependencies with the current bitcoinjs-lib major.

  • Migrate third-party address validation to @bitcoinerlab/descriptors v3 (DescriptorsFactory + Output), enabling tapscript address validation.
  • Extend appClient wallet-address integration vectors with additional testnet descriptor/address cases from Python coverage.
  • Upgrade bitcoinjs-lib from 6.x to 7.x
  • Upgrade the TS/JS toolchain to current versions (TypeScript 5.9, Jest 30, ts-jest, babel-jest, typedoc 0.28) and set node >= 18.14 (required by bitcoinjs-lib / @bitcoinerlab/descriptors).
  • Keep the library API non-breaking by converting v7 Uint8Array/bigint values internally to existing Buffer/number interfaces.
  • A future major release can switch public return types to Uint8Array/bigint if desired.

@landabaso
Copy link
Contributor Author

landabaso commented Feb 25, 2026

BTW, I added a console.warn when descriptor parsing fails. The musig key expression is currently unsupported in @bitcoinerlab/descriptors, so those cases warn. I can remove the warning if you prefer.

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.81%. Comparing base (96b0077) to head (64ff291).
⚠️ Report is 14 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #430      +/-   ##
===========================================
- Coverage    85.96%   85.81%   -0.16%     
===========================================
  Files           30       18      -12     
  Lines         3476     2812     -664     
  Branches       520      425      -95     
===========================================
- Hits          2988     2413     -575     
+ Misses         477      388      -89     
  Partials        11       11              
Flag Coverage Δ
unittests 85.81% <ø> (-0.16%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the bitcoin_client_js library from bitcoinjs-lib v6 to v7 and @bitcoinerlab/descriptors v1 to v3, enabling tapscript address validation while maintaining API backward compatibility through internal type conversions.

Changes:

  • Upgraded bitcoinjs-lib from 6.x to 7.x and @bitcoinerlab/descriptors from 1.x to 3.x, with TypeScript/Jest toolchain updates
  • Added type conversion helpers (asBuffer, asSatoshiNumber) to convert bitcoinjs-lib v7's Uint8Array/bigint to Buffer/number throughout psbtv2.ts
  • Migrated address validation from Descriptor to Output API, enabling tapscript support and extending test coverage with taproot descriptor cases

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
bitcoin_client_js/package.json Updated dependencies: bitcoinjs-lib ^7.0.1, @bitcoinerlab/descriptors ^3.0.6, Jest/TypeScript toolchain upgrades, node >=18.14 requirement
bitcoin_client_js/src/lib/psbtv2.ts Added asBuffer/asSatoshiNumber conversion helpers; wrapped all bitcoinjs-lib v7 Uint8Array/bigint values in Transaction and Psbt operations
bitcoin_client_js/src/lib/policy.ts Wrapped crypto.sha256 return values with Buffer.from to handle Uint8Array
bitcoin_client_js/src/lib/merkle.ts Added sha256AsBuffer helper function to convert crypto.sha256 Uint8Array output to Buffer
bitcoin_client_js/src/lib/clientCommands.ts Wrapped crypto.sha256 return value with Buffer.from for preimage handling
bitcoin_client_js/src/lib/appClient.ts Migrated from Descriptor({expression, network}) to Output({descriptor, network}) API; updated error handling comments for v3 tapscript support
bitcoin_client_js/src/tests/appClient.test.ts Added 6 new test cases covering sh(sortedmulti), sh(wsh(sortedmulti)), tr() taproot descriptors, and musig policies from Python test suite
bitcoin_client_js/jest.config.js Added testPathIgnorePatterns to exclude build directory from test runs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

3 participants