bitcoinjs-lib icon indicating copy to clipboard operation
bitcoinjs-lib copied to clipboard

feat: support taproot for signAllInputsHD

Open jasonandjay opened this issue 1 year ago • 4 comments
trafficstars

  • 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.

jasonandjay avatar Jul 24 '24 08:07 jasonandjay

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

jasonandjay avatar Jul 26 '24 11:07 jasonandjay

How about code review progress?

jasonandjay avatar Aug 05 '24 13:08 jasonandjay

@junderw Could you check this PR?

cpuchainorg avatar Jan 31 '25 03:01 cpuchainorg

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.

landabaso avatar Mar 11 '25 09:03 landabaso