Post
Topic
Board Development & Technical Discussion
Re: Bitcoin Taproot transaction STEP BY STEP on bitcoin-cli...
by
Greg Tonoski
on 20/10/2023, 11:49:22 UTC
I moved on to a VPS and I installed a pruned node.

Now with my own version 25, I got solution for the problem:

"error": "Witness program was passed an empty witness"

What is the problem?
If we add some address to our wallet and we use the option to rescan the wallet since some "timestamp" value it will never work, we will see always that error.

So, if you use a "timestamp" to rescan wallet, at the end you need to always run this command:

bitcoin-cli importdescriptors '[{"desc": "tr(your_private_key)#your-checksum", "timestamp": "now", "internal": false, "label": "your_label"}]'

Sometimes even if you stop the core and restart again you need to do it again what is a pain in the ass.

After that you just create the raw normally with this command:

bitcoin-cli createrawtransaction '[{"txid":"your_txid","vout":your_vout}]' '[{"your_destination_address":your_amount}]'

That will give some output like this:
0200000001...

Then we sign that output RAW with this command:

bitcoin-cli signrawtransactionwithwallet 0200000001...

That will give us some output like this:
020000000001...

And we use it to broadcast it with:

bitcoin-cli sendrawtransaction 020000000001...

That's it.

Thank you for feedback. Indeed, there is the serious issue that many seem to encounter trying to use Bitcoin Core.

The message
Code:
"error": "Witness program was passed an empty witness"
is not meaningful to a user. It leaves them with no clue what to do next and if anything is possible. There is what happened most probably:
1) A key was imported to a wallet.
2) Wallet searched for UTXO and other Bitcoin blockchain data relevant to the key and found none.
3) User ran signrawtransactionwithwallet RPC command.
4) Wallet didn't perform signing and send the confusing message instead.

Why?
Wallet didn't searched for UTXO and other Bitcoin blockchain data in the complete dataset. As a matter of fact, only a small percentage of the dataset was scanned - typically spanning a few hours from the moment of import - as indicated by the "now" timestamp option in the importdescriptor RPC command. The UTXO had been created (transaction took place) earlier. In order to be aware of the UTXO, Bitcoin Core wallet needs (re-)scanning earlier data. There are additional two catches: wallet doesn't search other data automatically (so-called rescan) and shows the same error even rescanning hasn't completed (after user started it manually). The error shows for the next few days or more until rescan is completed (Initial Blockchain Download-long in most cases, especially so-called "prune nodes" with default settings). During rescan Bitcoin Core wallet searches for and records data relevant for keys it stores them in order to use them for signing later.