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

new Output with descriptor: addr(TAPROOT) #35

Open
DmytroShalaiev opened this issue Dec 18, 2023 · 6 comments
Open

new Output with descriptor: addr(TAPROOT) #35

DmytroShalaiev opened this issue Dec 18, 2023 · 6 comments

Comments

@DmytroShalaiev
Copy link

new Output({ descriptor: 'addr(tb1prnwvuc8tc6t7lqn2x7eul6f8n9qmpaam8p64wanqnegnglp68dhsxnzalc)', networks.testnet }),

For now not working due to error 'No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance'
Снимок экрана 2023-12-18 в 13 57 44

Seems what address.toOutputScript for Taproot keys requiring initing EccLib in bitcoinjs as in tests https://github.com/bitcoinjs/bitcoinjs-lib/blob/1f92ada3fda587c1c0a6aa93649afa04e8382b93/test/address.spec.ts#L71

I understand that for addr() desc for now only https://github.com/bitcoinerlab/descriptors/blob/0511e6486efb7f3a6b8a81535835c2788ee5c238/src/descriptors.ts#L1027C68-L1027C68.
Just interesting do you plan to add taproot address?

@DmytroShalaiev
Copy link
Author

Right now, I am working with https://github.com/bitcoinerlab/coinselect

My main goal is processing 'coinslection' from P2WPKH utxo's to P2TP outputs. and seems that initing EccLib for bitcoin-js is the only thing missing to achieve the goal.

@landabaso
Copy link
Member

Hi @DmytroShalaiev,

This library doesn’t currently support Tapscript, and I won’t be able to add this feature until the beginning of next year. I'm currently quite busy on a related project involving BitcoinerLab, but please be assured that adding Tapscript support to the library is one of my top priorities.

That said, bitcoinjs-lib requires you to initialize the initEccLib for Taproot. This process will eventually be automated, but for now, you can do it manually. Please try calling initEccLib and tell me where this leads you. Depending on your situation, I might be able to propose a temporary solution for your specific needs.

Also, I'm curious to know if having p2tp outputs is an absolute necessity for you at this moment or can wait a bit.

@DmytroShalaiev
Copy link
Author

DmytroShalaiev commented Dec 18, 2023

Thank you so much for your time and your best

Tapscript support to the library is one of my top priorities.

It will be cool!

Depending on your situation, I might be able to propose a temporary solution for your specific needs.

Right now trying to do it, thanks.

Also, I'm curious to know if having p2tp outputs is an absolute necessity for you at this moment or can wait a bit.

I think can wait, but I will try to initEccLib.

@DmytroShalaiev
Copy link
Author

So such a trick works :) and Output object with TP address created. Next step extending functions inputWeight & outputWeight for working with TP 'sizes' (https://bitcoinops.org/en/tools/calc-size/), seems it's all that needed in CoinSelection usage

Снимок экрана 2023-12-18 в 16 04 49

@landabaso
Copy link
Member

Good to hear!

By the way, you don’t need both tiny-secp256k1 and @bitcoinerlab/secp256k1. Just choosing one should suffice.

Have you forked the project? It looks like you're on the right track. I believe your next step is to adapt the guessOutput() function for Taproot (tr) and then accurately determine the correct input and output sizes. Keep me updated on your progress. Once you've made headway, we can collaborate on crafting a new version.

One important aspect to consider is that releasing a new version would ideally require new test vectors. This is crucial for ensuring the reliability and robustness of the updates.

@DmytroShalaiev
Copy link
Author

@landabaso I added the implementation for (P2TR keypath input) and attached a draft PR #36
when you have time please take a look; it will be nice to hear your feedback.

The tests are not done yet, but I think I can add them after discussion.

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