bitcoinjs-lib
bitcoinjs-lib copied to clipboard
feat: support taproot for signAllInputsHD
- issue discussion: https://github.com/bitcoinjs/bitcoinjs-lib/issues/2132
- feat
- affected Signature Methods
- signAllInputsHD
- signAllInputsAsyncHD
- signInputHD
- signInputAsyncHD
- remove conflict default sighashTypes of signInputHD
- Transaction.SIGHASH_DEFAULT for _signTaprootInput
- Transaction.SIGHASH_ALL for _signInput
- so we should remove the outermost default signType
- add integration test for HDWallet with tapBip32Derivation
- we will need more integration tests later.
- affected Signature Methods
When we use key-path to unlock UTXO, we don't need leafHashes, so I submitted another MR to solve this problem https://github.com/bitcoinjs/bip174/pull/38
How about code review progress?
@junderw Could you check this PR?
I have an observation regarding the asymmetry in signInput when using ecpair.
I'm not saying this is incorrect, but this PR allows psbt.signInputHD(index, node), which detects if the input is a Taproot input and internally tweaks the signer (getTweakSignersFromHD).
On the other hand, in psbt.signInput(index, ecpair), the user must pre-tweak the signer manually.
As a result, it's not possible to use signAllInputs with a common ecpair for both Taproot and non-Taproot inputs, whereas signAllInputsHD allows using a common node for both.
Again, I'm not saying this is necessarily wrong. Perhaps this is the only viable approach, but I wanted to highlight this to see if there’s anything further we can do, or at least reflect this behavior more clearly in the comments at the top of psbt.ts.