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

How to make taproot P2TR multiSig wallet

Open whisdev opened this issue 1 year ago • 2 comments
trafficstars

Bitcoinjslib provides us how to make Segwit multisig wallet.

But in my project, I need to provide all of it.

Who can help me?

whisdev avatar Jun 14 '24 19:06 whisdev

In taproot there are two ways to make a multisig script. Since CHECKMULTISIG op code was removed for taproot.

  1. "Musig", a method in which you combine N keys into a single key for signing, is more difficult and error prone. We don't offer a simple API to perform that.
  2. Currently, the most secure way of doing multisig in taproot is using the CHECKSIG + CHECKSIGADD + NUMEQUAL method. See the example linked below for an example. If all you want is a single multisig, creating a scriptTree with only a single "leaf" (script) is fine. However, the multisig participants should verify that the key spend (internal pubkey) is unspendable.

https://github.com/bitcoinjs/bitcoinjs-lib/blob/8c88016d8f36e5268d6a3de3c5209e8dc29312e0/test/integration/taproot.spec.ts#L443-L529

I think I'll add a new example with just a simple multisig use case.

junderw avatar Jun 15 '24 01:06 junderw

I added an example for your use case.

Please ask any questions you might have.

https://github.com/bitcoinjs/bitcoinjs-lib/blob/8d9775c20da03ab40ccbb1971251e71d117bcd8b/test/integration/taproot.spec.ts#L531-L593

junderw avatar Jun 15 '24 02:06 junderw

Thx for ur kind advice

whisdev avatar Jul 16 '24 10:07 whisdev

I followed above examples After generate PSBT, I tried to sign PSBT use Unisat wallet but got below error "Can not sign for input #0 with the key 025321d780d099750e7fbcec128213184c9ae0a86241eeacc826c37bce7febc0b8" image

What kind of problem is this?

rustyneuron01 avatar Jul 30 '24 21:07 rustyneuron01