Pages:
Author

Topic: Bitcoin Taproot transaction STEP BY STEP on bitcoin-cli... (Read 514 times)

legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
--snip--

Is this AI generated text? While it sounds convincing, it has several wrong details such as this one,

#### 2. Create a New Receiving Address:
Generate a new Taproot receiving address using the `getnewaddress` command:
```bash
bitcoin-cli getnewaddress "" "taproot"
```
Note the generated Taproot address; this will be your receiving address.

"taproot" isn't valid value for second parameter. It should be "bech32m".

Quote from: help getnewaddress
2. address_type    (string, optional, default=set by -addresstype) The address type to use. Options are "legacy", "p2sh-segwit", "bech32", and "bech32m".
member
Activity: 143
Merit: 82
About signrawtransactionwithkey maybe it works, I heard many times we couldn't do taproot transactions without PSBT's, etc and I did it, so, maybe everything have solution and the problem is just doing the configuration of the command with all variables.

If someone have success please report it.
Contrary to the name signrawtransactionwithkey, the command doesn't sign a transaction unless it isn't of the TapRoot-type, I'm afraid. I have verified it. There isn't any tool to do it.

Seems to be fixed in Bitcoin Core 26.0 and it is possible sign TapRoot-type transaction using signrawtransactionwithkey.
member
Activity: 264
Merit: 16
I still believe it is possible.

This post:

https://bitcointalksearch.org/topic/m.62647223

Says we could only use PSBT's what is not true, signrawtransactionwithwallet works well.

I believe we can't use signrawtransactionwithkey to sign complex taproot script as the post says, but signing with privatekey path is not complex taproot script, so, maybe it is possible if we create the full command with the respective witness value.
member
Activity: 143
Merit: 82
About signrawtransactionwithkey maybe it works, I heard many times we couldn't do taproot transactions without PSBT's, etc and I did it, so, maybe everything have solution and the problem is just doing the configuration of the command with all variables.

If someone have success please report it.
Contrary to the name signrawtransactionwithkey, the command doesn't sign a transaction unless it isn't of the TapRoot-type, I'm afraid. I have verified it. There isn't any tool to do it.
member
Activity: 264
Merit: 16
In my case, the trick is importing the address with "timestamp"= date of the block of the first UTXO and let it do it until the end, after that, when I want to move, just repeat the command with "now" and it works perfectly.

About signrawtransactionwithkey maybe it works, I heard many times we couldn't do taproot transactions without PSBT's, etc and I did it, so, maybe everything have solution and the problem is just doing the configuration of the command with all variables.

If someone have success please report it.
member
Activity: 143
Merit: 82
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 search 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 if rescanning hasn't completed (after user started it manually). The error message is shown 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 (cache) data relevant for keys it stores. Without the data signing can't succeed and the error message is shown.
legendary
Activity: 2618
Merit: 6452
Self-proclaimed Genius
That's it.

But now... Here we go again, infatuation !

If we want to use signrawtransactionwithkey and we are using the simplest syntax:
So the issue is specific to signrawtransactionwithkey with TapRoot and not just the goal of signing a transaction?
In that case, although it has the same error, it's not related to your previous issue with signrawtransactionwithwallet.
Bitcoin Core simply doesn't currently support signing TapRoot inputs with signrawtransactionwithkey.

Refer to this post: https://bitcointalksearch.org/topic/m.62647223
And issue: https://github.com/bitcoin/bitcoin/issues/27017
member
Activity: 264
Merit: 16
Here goes the answers for many posts you made.

Before I was using version 23, but I managed to upgrade to 25, problem was that I was running a service in this website:

https://console.shuken.io/account/

And they were running only version 23.

They said they would upgrade just next month, so 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.

But now... Here we go again, infatuation !

If we want to use signrawtransactionwithkey and we are using the simplest syntax:

bitcoin-cli signrawtransactionwithkey 0200000001... '["your_private_key"]'

I got the same old f* error:

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

Now we can't use the bitcoin-cli importdescriptors trick with "timestamp": "now", so, what is the solution?

Try it yourself please and give here feedback about if you have the same results or not.
member
Activity: 143
Merit: 82

This command:

./bitcoin-cli.exe -testnet signrawtransactionwithwallet "02000000012164dff98653ce57c1a35c581caa993f526a118bf54e3138f04ade3aed19df8c00000 00000fdffffff01e8030000000000002251202befa14431d4cb71889ea1df7a7eaa2f1d8b9107e6 0b01564e15dabe5c0dfd3200000000" '[{"txid": "8cdf19ed3ade4af038314ef58b116a523f99aa1c585ca3c157ce5386f9df6421", "vout": 0, "scriptPubKey": "5120c38859777bc9c3294d3587035fc3823a146dabaab1fa250bc04e92f16887a065", "amount": 0.00000000}]' "DEFAULT"

At least in mainnet will output something like this:

"complete": false,
       "error": "Witness program was passed an empty witness"

Can you test it on mainnet and see?

Even the syntax of the command is not well done, the last parameter "DEFAULT" don't exist, here is the right syntax of it:

Argument #3 - sighashtype
Type: string, optional, default=ALL

The signature hash type. Must be one of
“ALL” “NONE” “SINGLE” “ALL|ANYONECANPAY” “NONE|ANYONECANPAY” “SINGLE|ANYONECANPAY”


If you want to use the default value you need to put ALL and not DEFAULT, some beginner made that.

I suggest checking that the command is executed with the correct wallet loaded (the one where descriptor had been imported). It may be easier to do it within Bitcoin Core GUI console.

I verified all in Bitcoin Core versions 24 and 25 where the "DEFAULT" argument is accepted.

What is the result of your attempts, cfbtcman?
hero member
Activity: 1274
Merit: 681
I rather die on my feet than to live on my knees
But you are saying you got that error also with createrawtransaction command? I can try to repeat the commands for you if you want (or if it is still doable)...
It was with signrawtransactionwithwallet command that I tried to reproduce based from OP's reply.
But refer to my reply just above yours for the update. (latest test worked)

It may not be a coincidence that I got the same result the first time but the command worked after a while.
So it's either his node is lacking the necessary UTXO, using the incorrect wallet or missing the needed descriptor.

Yeah, probably a sync'ing problem. Somehow, when me and the OP tried the procedure in my node, I didn't even have to do any sync for the wallet. He had sent some sats to that address recently, so, everything was kind of recent. Maybe because of that we didn't have any issues!
legendary
Activity: 2618
Merit: 6452
Self-proclaimed Genius
But you are saying you got that error also with createrawtransaction command? I can try to repeat the commands for you if you want (or if it is still doable)...
It was with signrawtransactionwithwallet command that I tried to reproduce based from OP's reply.
But refer to my reply just above yours for the update. (latest test worked)

It may not be a coincidence that I got the same result the first time but the command worked after a while.
So it's either his node is lacking the necessary UTXO, using the incorrect wallet or missing the needed descriptor.
hero member
Activity: 1274
Merit: 681
I rather die on my feet than to live on my knees
We have tried the simple approach of createrawtransaction, signrawtransactionwithwallet and sendrawtransaction with my node and all commands worked flawlessly. Something he was doing wrong because I didn't face any of his problems!
Did you added anything in signrawtransactionwithwallet or just the raw transaction?

Because I tried to spend a TapRoot input and I got the same "Witness program was passed an empty witness" error as OP with
signrawtransactionwithwallet command whether "witnessScript" was included under "prevtxs" or not. (prob. didn't helped bec. it's for P2WSH or P2SH-P2WSH)

No, just the output of the createrawtransaction. The only thing I added to all commands was the -rpcwallet=Wallet-name but this has no influence in the command other than to specify the wallet in question!

But you are saying you got that error also with createrawtransaction command? I can try to repeat the commands for you if you want (or if it is still doable)...
legendary
Activity: 2618
Merit: 6452
Self-proclaimed Genius
-snip-
Data in your wallet need refreshing (rescan blockchain), most likely. Alternatively, you could pass the data ("prevtxs") manually in the signrawtransactionwithkey RPC.
I did another quick test with non-PSBT workflow and it worked this time, without even including "prevtxs" during signrawtransactionwithwallet RPC.
Probably previous sync issue or something.

Anyways, AFAIK signrawtransactionwithkey wont work with TapRoot at the moment.
member
Activity: 143
Merit: 82
We have tried the simple approach of createrawtransaction, signrawtransactionwithwallet and sendrawtransaction with my node and all commands worked flawlessly. Something he was doing wrong because I didn't face any of his problems!
Did you added anything in signrawtransactionwithwallet or just the raw transaction?

Because I tried to spend a TapRoot input and I got the same "Witness program was passed an empty witness" error as OP with
signrawtransactionwithwallet command whether "witnessScript" was included under "prevtxs" or not. (prob. didn't helped bec. it's for P2WSH or P2SH-P2WSH)
Data in your wallet need refreshing (rescan blockchain), most likely. Alternatively, you could pass the data ("prevtxs") manually in the signrawtransactionwithkey RPC.
legendary
Activity: 2618
Merit: 6452
Self-proclaimed Genius
We have tried the simple approach of createrawtransaction, signrawtransactionwithwallet and sendrawtransaction with my node and all commands worked flawlessly. Something he was doing wrong because I didn't face any of his problems!
Did you added anything in signrawtransactionwithwallet or just the raw transaction?

Because I tried to spend a TapRoot input and I got the same "Witness program was passed an empty witness" error as OP with
signrawtransactionwithwallet command whether "witnessScript" was included under "prevtxs" or not. (prob. didn't helped bec. it's for P2WSH or P2SH-P2WSH)
hero member
Activity: 1274
Merit: 681
I rather die on my feet than to live on my knees
We have tried the simple approach of createrawtransaction, signrawtransactionwithwallet and sendrawtransaction with my node and all commands worked flawlessly. Something he was doing wrong because I didn't face any of his problems!
legendary
Activity: 3500
Merit: 6320
Crypto Swap Exchange
....I read that is only supported in last core version 25 and for moments I can't try it because I only have 23 and is a testing node that I don't control.

Have you tested it with success on what core version?

Yes it works, I just did a quick(ish) test on a 25 node following what nc50lc posted.

This is going to be a bit more snarky then I want it to really come out as, but why are you testing / running on an older node that you don't control?
23 is at maintenance end and will be full EOL in 7 weeks: https://bitcoincore.org/en/lifecycle/

If you are going to be using this to provide a service you should be on a newer version of core.

As I said, it looks more snarky on a screen then I am trying to be, but something you should be thinking about.

-Dave
legendary
Activity: 2618
Merit: 6452
Self-proclaimed Genius
Have you tested it with success on what core version?
Version 25, but I tested it with a ranged descriptor that can derive the input's prvKey.

I read that is only supported in last core version 25 and for moments I can't try it because I only have 23 and is a testing node that I don't control.
Do you mean a node that doesn't contain the descriptor with private key?
Because walletprocesspsbt wont work in that case since it relies on the descriptor that can sign that particular PSBT.

Otherwise, I should've noted to use: utxoupdatepsbt after creating the PSBT.
Here's the command (use between the second and third steps):
Code:
utxoupdatepsbt ""
or
Code:
utxoupdatepsbt "" "[\"\"]"
member
Activity: 264
Merit: 16
Use PSBT instead of raw transaction:

Firstly, import the necessary descriptor to the wallet if it's not available (command already provided).

Secondly, create a partially signed Bitcoin transaction:
Code:
createpsbt "[{\"txid\":\"\",\"vout\":}]" "[{\"\":},{\"\":}]"
Thirdly, process the psbt (update, sign):
Code:
walletprocesspsbt ""
Fourthly, finalize it:
Code:
finalizepsbt ""
Lastly, send it to mempool:
Code:
sendrawtransaction ""

Hi, thanks for the answer, I have also tested without success, seems the wallet can't sign.

I read that is only supported in last core version 25 and for moments I can't try it because I only have 23 and is a testing node that I don't control.

Have you tested it with success on what core version?
legendary
Activity: 2618
Merit: 6452
Self-proclaimed Genius
Use PSBT instead of raw transaction:

Firstly, import the necessary descriptor to the wallet if it's not available (command already provided).

Secondly, create a partially signed Bitcoin transaction:
Code:
createpsbt "[{\"txid\":\"\",\"vout\":}]" "[{\"\":},{\"\":}]"
Thirdly, process the psbt (update, sign):
Code:
walletprocesspsbt ""
Fourthly, finalize it:
Code:
finalizepsbt ""
Lastly, send it to mempool:
Code:
sendrawtransaction ""
Pages:
Jump to: