Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example to show P2TR or Taproot address #114

Open
anoncodemonkey opened this issue Jan 29, 2024 · 2 comments
Open

Example to show P2TR or Taproot address #114

anoncodemonkey opened this issue Jan 29, 2024 · 2 comments

Comments

@anoncodemonkey
Copy link

It seems that this library can support taproot receiving address, can there be example on how to generate a P2TR receiving address using this library?

@tiero
Copy link
Member

tiero commented Jan 29, 2024

The time we added support for Taproot, BitcoinJS (which we fork from) didnt yet agreed on a payments.p2tr interface, so you have to generate it low-level so to speak.

This is an example of how to build a Taproot address with
https://github.com/vulpemventures/liquidjs-lib/blob/master/test/integration/taproot.spec.ts#L38-L73

The key-path spend is simply passing a public key as the first argument of bip341.taprootOutputScript and the taproot tree as second.

You can then get the taproot address from the script passing the network object

const unconfidentialAddress = address.fromOutputScript(
      output,
      networks.regtest,
    );
    const confidentialAddress = address.toConfidential(
      unconfidentialAddress,
      bob.publicKey,
    );

@tiero
Copy link
Member

tiero commented Jan 29, 2024

Let me know if it's enough, I keep it open in case, will close later

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

No branches or pull requests

2 participants