1

I'm wondering what the workflow is for building tapscripts. I can generate a new address, but how do I tweak it with the tap script?

I've done the bitcoin taproot workshop a couple times now and starting to get a grip of what is going on, but I can't find where I can do the same things in the workshop's provided python libraries with bitcoin core, I'm also wary of generating my own keys, as the workshop says specifically not to do that. "Bad randomness and no side channel protection." to loosely quote.

Could bitcoin core benefit from this added functionality? Command's like tweak add, Tapleaf construction of csa, hashlock, csa hashlock delay and proper Tapscript construction?

Right now it seems like I would have to implement these features in a separate python library, maybe by calling bindings to secp256k1 lib for safe randomness?

Thanks Andrew

2
  • Are you seeking to do this with real money? I'd recommend not to and do this with signet or testnet coins if it is just for educational purposes. Then you don't need to worry about bad randomness, side channel protection. In the functional tests of Bitcoin Core there is some Taproot functionality in Python. github.com/bitcoin/bitcoin/blob/master/test/functional/… Nov 9, 2022 at 16:43
  • Yea I would be only doing this on signet. Thanks
    – Kaizen
    Nov 9, 2022 at 22:34

1 Answer 1

0

I've done the bitcoin taproot workshop a couple times now and starting to get a grip of what is going on, but I can't find where I can do the same things in the workshop's provided python libraries with bitcoin core

I think you need to be clearer on exactly what you want to achieve. There is Taproot code in Python in the Bitcoin Core functional tests if you want to dig a bit deeper for educational purposes in Python. But that isn't set up to be a standalone library to interact with. A Python library that does have Taproot support (and MuSig2 support) is buidl-python. Other Python libraries like python-bitcoinlib, ofek's bit and darosior's python-bip380 don't support Taproot at the time of writing (May 2023) unfortunately.

Could bitcoin core benefit from this added functionality? Command's like tweak add, Tapleaf construction of csa, hashlock, csa hashlock delay and proper Tapscript construction?

Bitcoin Core as a full node implementation already supports verifying any Taproot spend in C++. The Bitcoin Core wallet supports Taproot via the tr() descriptor again written in C++. OP_CHECKSIGADD (CSA) is supported via the multi_a and sortedmulti_a descriptors within the tr() descriptor. Hashlocks isn't at the time of writing (May 2023) supported within the tr() descriptor but there is a PR open (PR 27255) to add Taproot'd Miniscript to the Bitcoin Core wallet which would enable it.

I can generate a new address, but how do I tweak it with the tap script?

A note on the terminology. You tweak the internal public key, you don't tweak the address. How you tweak the internal public key is explained in the Bitcoin Optech Taproot workshop here.

I'm also wary of generating my own keys, as the workshop says specifically not to do that. "Bad randomness and no side channel protection." to loosely quote.

Right now it seems like I would have to implement these features in a separate python library, maybe by calling bindings to secp256k1 lib for safe randomness?

If you are using signet or testnet coins you don't need to worry about bad randomness and potentially losing your coins. But note the randomness for seeds, private keys isn't generated in secp256k1, it is generated in the main Core repo (random.cpp).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.