Skip to content

feat: add taproot support for HD signing methods (signInputHD, signAllInputsHD)#2329

Draft
bittoby wants to merge 3 commits intobitcoinjs:masterfrom
bittoby:feat/taproot-hd-signing
Draft

feat: add taproot support for HD signing methods (signInputHD, signAllInputsHD)#2329
bittoby wants to merge 3 commits intobitcoinjs:masterfrom
bittoby:feat/taproot-hd-signing

Conversation

@bittoby
Copy link
Copy Markdown

@bittoby bittoby commented Mar 26, 2026

Summary

Taproot inputs with tapBip32Derivation now work with signInputHD, signInputHDAsync, signAllInputsHD, and signAllInputsHDAsync. Previously these methods only handled legacy/segwit via bip32Derivation and would fail on taproot inputs.

  • getSignersFromHD detects taproot inputs and delegates to a new getTaprootSignersFromHD function
  • Key-path spend (empty leafHashes): derives child key, tweaks it using tapMerkleRoot from the PSBT input
  • Script-path spend (non-empty leafHashes): derives child key untweaked, existing _signTaprootInput handles the rest
  • HDSigner / HDSignerAsync get optional signSchnorr? and tweak? - existing code unaffected
  • sighashTypes on HD methods changed from = [SIGHASH_ALL] to optional, matching signAllInputs - lets inner methods pick the right default per input type

Closes #2132

@bittoby bittoby force-pushed the feat/taproot-hd-signing branch from 7f07c2d to fc73b06 Compare March 26, 2026 23:46
@bittoby
Copy link
Copy Markdown
Author

bittoby commented Mar 31, 2026

@jasonandjay would you please review this pr? I'd appreciate any feedback.

@bittoby
Copy link
Copy Markdown
Author

bittoby commented Apr 2, 2026

@junderw could you please review this PR? welcome to any feedbacks.

… paths

Restore PSBT and tests to match master. Keep a short note in getSignersFromHD
that taproot inputs encode key origin in tapBip32Derivation (BIP 371), not bip32Derivation.

Made-with: Cursor
@bittoby bittoby marked this pull request as draft April 9, 2026 11:32
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.

Feature Request: Taproot support for signAllInputsHD

1 participant