Closed Sudz24 closed 2 years ago
The full taproot functionality still under review (not merged yet). You can find it in this PR: https://github.com/bitcoinjs/bitcoinjs-lib/pull/1742
@motorina0 Thanks for the PR link, been going through the additions.
For the example here - https://gist.github.com/motorina0/e6bb1b32b3d5d2fc80e1bd63d5efea4f, I am not able to find the buildTapscriptFinalizer
you imported.
You have said - "for the script-path
spend a custom finalizer (FinalScriptsFunc
) is required when a Taproot input is finalized. See test/psbt.utils.ts
for such an example."
But I can't find this file. Can you please point me towards the example.
Try looking at the PR branch:
https://github.com/bitcoincoretech/bitcoinjs-lib/blob/p2tr-v1/test/integration/taproot.spec.ts
Thank you @junderw
However, I am facing the following error while trying to create a P2TR Address :
Error: OP_1 5b6aed341b3959beb61e47738cc2e7e1ed721589ef38c2b657aafcf2a611b070 has no matching Address
Here is the snippet I tried: `
const seed1 = await bip39.mnemonicToSeed(seedPhrase1);
const BTC_TESTNET = bitcoin.networks.testnet;
const root1 = bip32.fromSeed(seed1, BTC_TESTNET)
const output = createKeySpendOutput(root1.publicKey);
const address = bitcoin.address.fromOutputScript(output, BTC_TESTNET);
console.log(address)`
Can you pls guide me on what's going wrong here?
The PR is still WIP, this might not be the final version:
bitcoin.initEccLib(ecc);
is called beforehand taproot.spec.ts
Ahh yess! Now it works.
Thanks for your time.
@motorina0 From the code examples, I observe that we require the scriptTree structure and the leafSript (for redeem) to be able to spend the balance. So does it mean I have to store the scriptTree somewhere to be able to use it later while spending?
And also, if you could take a scriptTree from the sample code and explain the way its structured, it would be of great help! The ASMs you have included other than the leafScript - '
does it mean I have to store the scriptTree somewhere to be able to use it later while spending?
leafSript
has to be stored since it is part of the witness
stack (penultimate item)scriptTree
you have two options
scriptTree
controlBlock
which contains the path in the tree for the leaf
controlBlock
is the last element in the witness
stack. You can obtain it using the p2tr
logic.And also, if you could take a scriptTree from the sample code and explain the way its structured
The details about how the scriptTree
is built can be found here:
Hi @motorina0 I noticed that P2TR Script Spend using OP_SEQUENCEVERIFY works without a problem. but using OP_CHECKLOCKTIMEVERIFY, the hex broadcast to spend the locked funds sometimes throw the error 'Non-Final' on mempool.space . Have you come across this before, could you help me understand this error?
Error 'Non-Final' means that you are not beyond the locktime.
If nLockTime says "Next tuesday" and you try to broadcast it. It will not propagate.
Hii,
The current samples under Taproot shows how to create and use a Key Spend Tx. Can you provide some example that works with Script Spend Tx as well? Thanks a lot.