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

How to Sign an Unsigned Base64 PSBT (Taproot Wallet)? #165

Open
ZhiYuan1688 opened this issue Dec 20, 2024 · 2 comments
Open

How to Sign an Unsigned Base64 PSBT (Taproot Wallet)? #165

ZhiYuan1688 opened this issue Dec 20, 2024 · 2 comments

Comments

@ZhiYuan1688
Copy link

I am encountering an issue while attempting to purchase an Ordinal NFT on Magic Eden using a Taproot wallet. Their API provides an unsignedBuyingPSBTBase64 string, representing a Partially Signed Bitcoin Transaction (PSBT) encoded in Base64. An example of this string is: cHNidP8BAPw…….AAAAAAAAAAAAAA=.

As it stands, this PSBT requires the necessary signatures from my Taproot wallet to become a fully valid transaction. My understanding is that I need to:

  1. Decode the Base64 string into a usable PSBT format.
  2. Use the private key from my Taproot wallet to sign the relevant inputs of the PSBT.
  3. Extract the final, signed transaction (raw transaction or tx) from the signed PSBT.
  4. Broadcast this raw transaction to the Bitcoin network to finalize the purchase.

My goal is to automate this process via scripting. I am seeking guidance on how to perform these steps using either nodejs or Python. Specifically, I would be interested in:

  • Recommended libraries or packages for handling PSBTs in my chosen language.
  • The correct methodology for signing the PSBT inputs using private keys derived from a Taproot wallet.
  • Any caveats or common pitfalls to avoid when working with PSBTs, especially related to taproot transactions.

I would greatly appreciate any insights, code examples, or references that could help me successfully complete this transaction.

@chadchapnick
Copy link
Contributor

chadchapnick commented Dec 20, 2024

Are you using a hardware wallet to provide the signature, or a hot wallet? For the latter this could be accomplished with the RPC commands walletprocesspsbt , finalizepsbt and sendrawtransaction.

It will be best to avoid using a hot wallet—and if you'd like the didactic experience of implementing this process you could consider HWI and bdk-ffi or buidl-python if using Python. Caravan-wallets will also serve effectively as a HWI for javascript. If urgent, you may even consider exploring open source wallet coordinators that support Taproot today. Caravan-psbt also provides a very nice API for interacting with PSBT V2 and supports V0 as well.

Caravan coordinator itself has the capacity to do all of this, though not with Taproot just yet—but it may not take much to make it so. It's certainly possible to load a 1-of-1 quorum with the right wallet configuration file, upload a PSBT, sign, and broadcast.

A ColdCard alone could get you very far in this process as well, it appears their new Edge Version 6.3.4X/QX supports Taproot signing.

@ZhiYuan1688
Copy link
Author

Are you using a hardware wallet to provide the signature, or a hot wallet? For the latter this could be accomplished with the RPC commands walletprocesspsbt , finalizepsbt and sendrawtransaction.

It will be best to avoid using a hot wallet—and if you'd like the didactic experience of implementing this process you could consider HWI and bdk-ffi or buidl-python if using Python. Caravan-wallets will also serve effectively as a HWI for javascript. If urgent, you may even consider exploring open source wallet coordinators that support Taproot today. Caravan-psbt also provides a very nice API for interacting with PSBT V2 and supports V0 as well.

Caravan coordinator itself has the capacity to do all of this, though not with Taproot just yet—but it may not take much to make it so. It's certainly possible to load a 1-of-1 quorum with the right wallet configuration file, upload a PSBT, sign, and broadcast.

A ColdCard alone could get you very far in this process as well, it appears their new Edge Version 6.3.4X/QX supports Taproot signing.

Hi, I really appreciate you taking the time to provide such a detailed response. As someone with limited experience in the Bitcoin space, I must confess that I'm still finding it a little challenging to fully grasp everything you've explained. I've experimented with some of the more common libraries, like bitcoinlib and bitcoinlib-js, but unfortunately, I haven't yet been able to successfully navigate the signing process.

I'm currently working on developing an automated trading bot for Magic Eden Ordinals, and given my current understanding, it seems I might need to directly embed my private key or mnemonic seed within my Node.js or Python code, rather than utilizing a hot or cold wallet.

Thank you again for your insightful reply. I was hoping you might be willing to share some practical code examples that could help point me in the right direction? Also, would you be open to the possibility of communicating via Discord or Telegram? Should you be able to assist me in overcoming these obstacles, I would be more than happy to compensate you for your time and guidance.

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