<p>Regularly you'd use <code>walletcreatefundedpsbt</code> and then <code>walletprocesspsbt</code>. But since you've only got two coins in your wallet that you want to sweep you can simply use <code>sendall</code>.</p>
<p>Let's walk through a reproduction of your scenario. I've created two regtest-WIF-encoded private keys:</p>
<ul>
<li><code>cRZ9wuYhwKYm82rXfSk9hhc9beJy6p7rV4y3aoAdzqFD6YAUVQcJ</code> (corresponding to <code>029d759b09cec94b6f2bd322cedd5d136e7f24a4936998fe24da09827d8a12e9dd</code>)</li>
<li><code>cVFkDn9fS1rwU1SR7geC3rgoGNXLpZXsnrCq2gutYVsGA2FoLpCD</code> (corresponding to <code>03bd0d0b820dae844107803c9323fe73e81b9adf8abe329930ae9311dab6c3573e</code>)</li>
</ul>
<p>I'm creating a new wallet and importing a <code>tr()</code> and <code>wpkh()</code> descriptor.</p>
<pre><code>$ bitcoin-cli -regtest createwallet repro_stackexchange
{
  &quot;name&quot;: &quot;repro_stackexchange&quot;,
  &quot;warning&quot;: &quot;&quot;
}
$ bitcoin-cli -regtest -rpcwallet=repro_stackexchange importdescriptors '[{&quot;desc&quot;:&quot;tr(cRZ9wuYhwKYm82rXfSk9hhc9beJy6p7rV4y3aoAdzqFD6YAUVQcJ)#uj39yr2v&quot;,&quot;timestamp&quot;:&quot;now&quot;},{&quot;desc&quot;:&quot;wpkh(cVFkDn9fS1rwU1SR7geC3rgoGNXLpZXsnrCq2gutYVsGA2FoLpCD)#nayxphlw&quot;,&quot;timestamp&quot;:&quot;now&quot;}]'
[
  {
    &quot;success&quot;: true
  },
  {
    &quot;success&quot;: true
  }
]
</code></pre>
<p>Now i'm sending a coin to each descriptor:</p>
<pre><code>$ bitcoin-cli -named -regtest -rpcwallet=main sendtoaddress address=bcrt1ps66a3wss3l0ay0agnkd57cfu6qrw26z632e0kez0ppjzkyaq0vhskxlrvs amount=0.00042 fee_rate=1
b2e975dee4ab0c68748e85fc847d7ef3fef44f53ee95e4765b1cc2b2c33939d2
$ bitcoin-cli -named -regtest -rpcwallet=main sendtoaddress address=bcrt1q9vsfxgf4t3wmtj9429g539txyv4p2qnuak03sv amount=0.00043 fee_rate=1
e34a3b8116f328d2b1529134dfcc795fbe27eae3991eeb017bc582879cb73b81
</code></pre>
<p>We can see that the reproduction wallet got the two coins:</p>
<pre><code>$ bitcoin-cli -regtest -rpcwallet=repro_stackexchange listunspent 0
[
  {
    &quot;txid&quot;: &quot;e34a3b8116f328d2b1529134dfcc795fbe27eae3991eeb017bc582879cb73b81&quot;,
    &quot;vout&quot;: 0,
    &quot;address&quot;: &quot;bcrt1q9vsfxgf4t3wmtj9429g539txyv4p2qnuak03sv&quot;,
    &quot;label&quot;: &quot;&quot;,
    &quot;scriptPubKey&quot;: &quot;00142b209321355c5db5c8b55151489566232a15027c&quot;,
    &quot;amount&quot;: 0.00043000,
    &quot;confirmations&quot;: 0,
    &quot;ancestorcount&quot;: 1,
    &quot;ancestorsize&quot;: 130,
    &quot;ancestorfees&quot;: 130,
    &quot;spendable&quot;: true,
    &quot;solvable&quot;: true,
    &quot;desc&quot;: &quot;wpkh([2b209321]03bd0d0b820dae844107803c9323fe73e81b9adf8abe329930ae9311dab6c3573e)#k6qfdnw5&quot;,
    &quot;parent_descs&quot;: [
      &quot;wpkh(03bd0d0b820dae844107803c9323fe73e81b9adf8abe329930ae9311dab6c3573e)#45n94hja&quot;
    ],
    &quot;safe&quot;: false
  },
  {
    &quot;txid&quot;: &quot;b2e975dee4ab0c68748e85fc847d7ef3fef44f53ee95e4765b1cc2b2c33939d2&quot;,
    &quot;vout&quot;: 1,
    &quot;address&quot;: &quot;bcrt1ps66a3wss3l0ay0agnkd57cfu6qrw26z632e0kez0ppjzkyaq0vhskxlrvs&quot;,
    &quot;label&quot;: &quot;&quot;,
    &quot;scriptPubKey&quot;: &quot;512086b5d8ba108fdfd23fa89d9b4f613cd006e5685a8ab2fb644f08642b13a07b2f&quot;,
    &quot;amount&quot;: 0.00042000,
    &quot;confirmations&quot;: 0,
    &quot;ancestorcount&quot;: 1,
    &quot;ancestorsize&quot;: 154,
    &quot;ancestorfees&quot;: 154,
    &quot;spendable&quot;: true,
    &quot;solvable&quot;: true,
    &quot;desc&quot;: &quot;tr([caa3ae90]9d759b09cec94b6f2bd322cedd5d136e7f24a4936998fe24da09827d8a12e9dd)#e2lr407t&quot;,
    &quot;parent_descs&quot;: [
      &quot;tr(9d759b09cec94b6f2bd322cedd5d136e7f24a4936998fe24da09827d8a12e9dd)#u9ras3xm&quot;
    ],
    &quot;safe&quot;: false
  }
]
</code></pre>
<p>Now i'll get the transactions confirmed and sweep the coins using <code>sendall</code>:</p>
<pre><code>$ bitcoin-cli -regtest -rpcwallet=main generatetoaddress 1 $(bitcoin-cli -regtest -rpcwallet=main getnewaddress)
$ bitcoin-cli -named -regtest -rpcwallet=repro_stackexchange sendall recipients='[&quot;bcrt1qre2fezscuke8qaj9ham2klddj2rt7m4s78tvqq&quot;]' fee_rate=1
{
  &quot;txid&quot;: &quot;a39b70bf4636bb78053d10a3bc03eb6866e6777e84aeb274bb4002a543b7bb99&quot;,
  &quot;complete&quot;: true
}
</code></pre>
<p>Let's inspect the transaction. It does indeed spend the two coins from the wallet (one Taproot and one native segwit v0 as you can see from the witness):</p>
<pre><code>$ bitcoin-cli -regtest getrawtransaction a39b70bf4636bb78053d10a3bc03eb6866e6777e84aeb274bb4002a543b7bb99 1
{
  &quot;txid&quot;: &quot;a39b70bf4636bb78053d10a3bc03eb6866e6777e84aeb274bb4002a543b7bb99&quot;,
  &quot;hash&quot;: &quot;be1fcf89ec92649ee0780a8ea86ade1512a7fff6cfc8f75430b1115f1321b8f1&quot;,
  &quot;version&quot;: 2,
  &quot;size&quot;: 298,
  &quot;vsize&quot;: 167,
  &quot;weight&quot;: 667,
  &quot;locktime&quot;: 0,
  &quot;vin&quot;: [
    {
      &quot;txid&quot;: &quot;e34a3b8116f328d2b1529134dfcc795fbe27eae3991eeb017bc582879cb73b81&quot;,
      &quot;vout&quot;: 0,
      &quot;scriptSig&quot;: {
        &quot;asm&quot;: &quot;&quot;,
        &quot;hex&quot;: &quot;&quot;
      },
      &quot;txinwitness&quot;: [
        &quot;304402201e3ba83ca58a357e72d9df4d555f11a747e128ab2131868cb5620afc9b383d540220011c6fe77e37ed8ca83d50870fc5cc3995ecbd1cbd6305ede59bd4fd8aa05c2901&quot;,
        &quot;03bd0d0b820dae844107803c9323fe73e81b9adf8abe329930ae9311dab6c3573e&quot;
      ],
      &quot;sequence&quot;: 4294967293
    },
    {
      &quot;txid&quot;: &quot;b2e975dee4ab0c68748e85fc847d7ef3fef44f53ee95e4765b1cc2b2c33939d2&quot;,
      &quot;vout&quot;: 1,
      &quot;scriptSig&quot;: {
        &quot;asm&quot;: &quot;&quot;,
        &quot;hex&quot;: &quot;&quot;
      },
      &quot;txinwitness&quot;: [
        &quot;6cd85a806478d00f062e0bd7a43f46d7be082e4287819fcf07d3dda1d6a613a11e1197d15021f87aad16a697e326181d82156ff957fcb6593f5d030f33516471&quot;
      ],
      &quot;sequence&quot;: 4294967293
    }
  ],
  &quot;vout&quot;: [
    {
      &quot;value&quot;: 0.00084833,
      &quot;n&quot;: 0,
      &quot;scriptPubKey&quot;: {
        &quot;asm&quot;: &quot;0 1e549c8a18e5b2707645bf76ab7dad9286bf6eb0&quot;,
        &quot;desc&quot;: &quot;addr(bcrt1qre2fezscuke8qaj9ham2klddj2rt7m4s78tvqq)#5gumgp89&quot;,
        &quot;hex&quot;: &quot;00141e549c8a18e5b2707645bf76ab7dad9286bf6eb0&quot;,
        &quot;address&quot;: &quot;bcrt1qre2fezscuke8qaj9ham2klddj2rt7m4s78tvqq&quot;,
        &quot;type&quot;: &quot;witness_v0_keyhash&quot;
      }
    }
  ],
  &quot;hex&quot;: &quot;02000000000102813bb79c8782c57b01eb1e99e3ea27be5f79ccdf349152b1d228f316813b4ae30000000000fdffffffd23939c3b2c21c5b76e495ee534ff4fef37e7d84fc858e74680cabe4de75e9b20100000000fdffffff01614b0100000000001600141e549c8a18e5b2707645bf76ab7dad9286bf6eb00247304402201e3ba83ca58a357e72d9df4d555f11a747e128ab2131868cb5620afc9b383d540220011c6fe77e37ed8ca83d50870fc5cc3995ecbd1cbd6305ede59bd4fd8aa05c29012103bd0d0b820dae844107803c9323fe73e81b9adf8abe329930ae9311dab6c3573e01406cd85a806478d00f062e0bd7a43f46d7be082e4287819fcf07d3dda1d6a613a11e1197d15021f87aad16a697e326181d82156ff957fcb6593f5d030f3351647100000000&quot;
}
</code></pre>

CC BY-SA 4.0
2023-06-07T03:06:18.033Z
Antoine, great thorough answer. I do have a concept question follow up. Can you take any WIF and import it as any descriptor type? For instance if you previously had a taproot utxo/descriptor would you need to make sure that was imported as a tr()? or could you import also as wpkh()?
Michael Tidwell
CC BY-SA 4.0
2023-06-07T03:43:23.647Z
Antoine, another followup question. 
When i run something like `bitcoin-cli -rpcwallet=wallet_x2 getnewaddress "label" "bech32m"` How do I know it's using the imported tr() descriptor? and not the wallet's generic tr ranged descriptor?
Michael Tidwell
CC BY-SA 4.0
2023-06-07T07:54:26.310Z
You can use a WIF encoded private key everywhere a key expression is expected.
Antoine Poinsot
CC BY-SA 4.0
2023-06-07T07:56:14.227Z
You can set a descriptor as active when importing it to use it to generate receive addresses (but it needs to be ranged if i'm remembering correctly). Otherwise just use `deriveaddresses`.
Antoine Poinsot
CC BY-SA 4.0
2023-06-06T10:31:33.287Z
2023-06-06T10:31:33.287Z
Antoine Poinsot
<h1>My goal</h1>
<p>Learn how to send an imported tr(wif) and wpkh() utxo in the same transaction.</p>
<h1>What I've tried</h1>
<p>I imported a WIF utxo containing a v1 segwit utxo.</p>
<p><code>bitcoin-cli importdescriptors '[{&quot;desc&quot;:&quot;tr(wifkey)#checksum&quot;, &quot;timestamp&quot;:unixts}]'</code></p>
<p>I didn't know the checksum, but when importing I got an error that told me what the checksum should be, so I used that.</p>
<p>The balance showed up after import, I assume it was imported correctly.</p>
<p>Learned <code>createrawtransaction</code>, <code>fundrawtransaction</code>, <code>signrawtransactionwithwallet</code> are not acceptable for taproot. This was resulting in &quot;Witness program was passed an empty witness&quot;.</p>
<p>It seems psbt commands are more appropriate. However, I couldn't figure out how to successfully sign with cli. I kept getting <code>&quot;complete&quot;: false</code> returned.</p>
<p>I then tried bitcoin-qt and attempted to sweep funds to an address as a test.
I received this: <a href="https://i.sstatic.net/PZ7pq.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/PZ7pq.png" alt="fail signing" /></a></p>
<p>While using bitcoin-cli and running <code>bitcoin-cli listunspent</code> I see:</p>
<pre><code>[
  {
    &quot;txid&quot;: &quot;TX_1&quot;,
    &quot;vout&quot;: x,
    &quot;address&quot;: &quot;ADDR_1&quot;,
    &quot;label&quot;: &quot;xxx1&quot;,
    &quot;scriptPubKey&quot;: &quot;44_LEGNTH_HEX_STRING&quot;,
    &quot;amount&quot;: xxxxxx.xxxxxx,
    &quot;confirmations&quot;: xxx,
    &quot;spendable&quot;: true,
    &quot;solvable&quot;: true,
    &quot;desc&quot;: &quot;wpkh([FINGERPRINT/84'/0'/0'/0/0]KEY)#CHECKSUM1&quot;,
    &quot;parent_descs&quot;: [
      &quot;wpkh(xpub_key/84'/0'/0'/0/*)#CHECKSUM-parent&quot;
    ],
    &quot;safe&quot;: true
  },
  {
    &quot;txid&quot;: &quot;TX_2&quot;,
    &quot;vout&quot;: xx,
    &quot;address&quot;: &quot;ADDR_2&quot;,
    &quot;label&quot;: &quot;xxx2&quot;,
    &quot;scriptPubKey&quot;: &quot;68_LENGTH_HEX_STRING&quot;,
    &quot;amount&quot;: xxxxxx.xxxxxx,
    &quot;confirmations&quot;: xxxx,
    &quot;spendable&quot;: true,
    &quot;solvable&quot;: true,
    &quot;desc&quot;: &quot;tr([FINGERPRINT2]KEY2)#CHECKSUM2&quot;,
    &quot;parent_descs&quot;: [
      &quot;tr(KEY2)#CHECKSUM2&quot;
    ],
    &quot;safe&quot;: true
  }
]
</code></pre>
<p>Output sanitized</p>
<h1>Question</h1>
<ul>
<li>What are the methodical steps starting with an imported WIF/taproot utxo + wpkh utxo and creating a signed tx to send funds?</li>
</ul>

CC BY-SA 4.0
2023-06-04T11:32:56.110Z
You need to use a descriptor wallet, and import the key as a taproot descriptor (if it's just a key path key, it would be `tr(WIF)`, but scripts can also be included there). Further, you need to use PSBT RPCs; the old raw transacrion RPCs in general do not support taproot.
Pieter Wuille
CC BY-SA 4.0
2023-06-04T21:51:40.663Z
I'm currently doing `createpsbt` then `walletcreatefundedpsbt` but not sure where to go from here. I've tried both `walletprocesspsbt` and `finalizepsbt` but they return the base64 encoding and `"complete": false`. 
I've tried `utxoupdatepsbt` but unsure what I would need to do since I've already successfully imported this into my wallet.

What steps am I missing?
Michael Tidwell
CC BY-SA 4.0
2023-06-04T21:58:36.817Z
It would be useful if you'd include the exact commands and output you're seeing in your question. If need be, you can try to recreate on regtest / signet / testnet.
Pieter Wuille
CC BY-SA 4.0
2023-06-04T23:36:37.923Z
I tried to reproduce everything on regtest, but I keep getting `"complete": true` and no issues like what I'm seeing on mainnet. 

The main difference I see is when I do `getaddressinfo` on regtest it shows I'm using an hd key I believe via: 

```"desc": "tr([e4b96d59/86'/1'/0'/0/0]d5de651411b49df50bc37a17620755ec019866332794cc3e73a6effbb766aa1c)#kh27dth2",```



on mainnet when I run `getaddressinfo` I see something similar minus the `/86'/1'/0'/0/0`.
Michael Tidwell
CC BY-SA 4.0
2023-06-04T23:55:30.303Z
It would seem that the way you import things on mainnet and on regtest differs then.
Pieter Wuille
CC BY-SA 4.0
2023-06-05T00:12:53.847Z
Yeah, I'm trying to reproduce, I did find another discrepancy though, `"isrange": false,` on mainnet but true on regtest. What does this mean? I get this after running the `getdescriptorinfo` command
Michael Tidwell
CC BY-SA 4.0
2023-06-05T00:18:52.223Z
A `tr(WIF)` descriptor is not ranged, so that's clearly not what you're doing on regtest
Pieter Wuille
CC BY-SA 4.0
2023-06-05T00:40:01.927Z
Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/146473/discussion-between-michael-tidwell-and-pieter-wuille).
Michael Tidwell
CC BY-SA 4.0
2023-06-05T02:56:14.593Z
When looking at the output of `getdescriptorinfo` why would 
`solvable` be `true` but `hasprivatekeys` be `false`.

After doing a non ranged tr(wif) import?
Shouldn't they both be `true`?
Michael Tidwell
CC BY-SA 4.0
2023-06-05T03:11:41.330Z
This is all impossible to say without knowing what your actual commands are.
Pieter Wuille
CC BY-SA 4.0
2023-06-05T03:22:32.487Z
1. `bitcoin-cli importdescriptors '[{"desc":"tr(WIF)", "timestamp":UNIXTIME}]'`
2. `bitcoin-cli listdescriptors`
> (grab the `desc` for the imported wif = "tr(hex)#CHECKSUM")
3. `bitcoin-cli getdescriptorinfo "DESC"`
Michael Tidwell
CC BY-SA 4.0
2023-06-05T03:27:59.790Z
`listdescriptors` will give descriptors without private key material (the "hex" you state is the public key); that's why it says hasprivatekeys false. But please update your question to reflect all information, with the commands you did, and the responses you get. It's very hard to discuss this via comments.
Pieter Wuille
CC BY-SA 4.0
2023-06-05T03:37:55.463Z
so.. just working through this 
1. `bitcoin-cli createpsbt '[{"txid":"TX_ASSOCIATED_WITH_WIF","vout":INDEX}]' '[{"BTC_ADDRESS":AMOUNT},{ "data": "WHAT_IS_SUPPOSED_TO_GO_HERE?"}]'`
I've been putting `00` for data maybe that is incorrect?
Michael Tidwell
CC BY-SA 4.0
2023-06-05T03:45:58.840Z
Similarly for `walletcreatefundedpsbt` with the same json parameter. Not sure if `00` is ok. Or how to find out what to put for this.
Michael Tidwell
CC BY-SA 4.0
2023-06-05T11:30:21.487Z
Whatever you want to go in an OP_RETURN goes there. But again, please update your question with whatever your question has now evolved to be
Pieter Wuille
CC BY-SA 4.0
2023-06-06T02:38:42.613Z
In the future, especially if you don’t have answers yet, please edit instead of opening a new question.
Murch
CC BY-SA 4.0
2023-06-06T03:11:45.857Z
@Murch thanks for the tip. I edited the original post with most up to date info.
Michael Tidwell
CC BY-SA 4.0
2023-06-07T12:35:34.593Z
Wrong:  _"Further, you need to use PSBT RPCs; the old raw transacrion RPCs in general do not support taproot. – Pieter Wuille Jun 4 at 11:32"_ . As a matter of fact, Bitcoin Core v. 24 RPC commands like `createrawtransaction` and `signrawtransactionwithwallet` support Taproot (P2TR). Also, the goal could be acheived without using any PSBT-related RPC.
Greg Tonoski
CC BY-SA 4.0
2023-06-07T12:42:29.190Z
There is the example of using the raw transaction RPC commands: [https://bitcoin.stackexchange.com/a/117013/135945](https://bitcoin.stackexchange.com/a/117013/135945).
Greg Tonoski
<bitcoin-core><wallet><bitcoin-cli><taproot>
Sweep Taproot and native Segwit v0 coins in a single transaction using Bitcoin Core wallet
Michael Tidwell
# Sweep Taproot and native Segwit v0 coins in a single transaction using Bitcoin Core wallet

(Asked by: username_0 on 2023-06-04)

# My goal

Learn how to send an imported tr(wif) and wpkh() utxo in the same transaction.

# What I've tried

I imported a WIF utxo containing a v1 segwit utxo.

`bitcoin-cli importdescriptors '[{"desc":"tr(wifkey)#checksum", "timestamp":unixts}]'`

I didn't know the checksum, but when importing I got an error that told me what the checksum should be, so I used that.

The balance showed up after import, I assume it was imported correctly.

Learned `createrawtransaction`, `fundrawtransaction`, `signrawtransactionwithwallet` are not acceptable for taproot. This was resulting in "Witness program was passed an empty witness".

It seems psbt commands are more appropriate. However, I couldn't figure out how to successfully sign with cli. I kept getting `"complete": false` returned.

I then tried bitcoin-qt and attempted to sweep funds to an address as a test.
I received this: [![fail signing](https://i.sstatic.net/PZ7pq.png)](https://i.sstatic.net/PZ7pq.png)

While using bitcoin-cli and running `bitcoin-cli listunspent` I see:

```
[
  {
    "txid": "TX_1",
    "vout": x,
    "address": "ADDR_1",
    "label": "xxx1",
    "scriptPubKey": "44_LEGNTH_HEX_STRING",
    "amount": xxxxxx.xxxxxx,
    "confirmations": xxx,
    "spendable": true,
    "solvable": true,
    "desc": "wpkh([FINGERPRINT/84'/0'/0'/0/0]KEY)#CHECKSUM1",
    "parent_descs": [
      "wpkh(xpub_key/84'/0'/0'/0/*)#CHECKSUM-parent"
    ],
    "safe": true
  },
  {
    "txid": "TX_2",
    "vout": xx,
    "address": "ADDR_2",
    "label": "xxx2",
    "scriptPubKey": "68_LENGTH_HEX_STRING",
    "amount": xxxxxx.xxxxxx,
    "confirmations": xxxx,
    "spendable": true,
    "solvable": true,
    "desc": "tr([FINGERPRINT2]KEY2)#CHECKSUM2",
    "parent_descs": [
      "tr(KEY2)#CHECKSUM2"
    ],
    "safe": true
  }
]

```

Output sanitized

# Question

* What are the methodical steps starting with an imported WIF/taproot utxo + wpkh utxo and creating a signed tx to send funds?

**Tags:** bitcoin-core, wallet, bitcoin-cli, taproot

> **Comments:**
> **username_1**: You need to use a descriptor wallet, and import the key as a taproot descriptor (if it's just a key path key, it would be `tr(WIF)`, but scripts can also be included there). Further, you need to use PSBT RPCs; the old raw transacrion RPCs in general do not support taproot.  
> **username_0**: I'm currently doing `createpsbt` then `walletcreatefundedpsbt` but not sure where to go from here. I've tried both `walletprocesspsbt` and `finalizepsbt` but they return the base64 encoding and `"complete": false`.  I've tried `utxoupdatepsbt` but unsure what I would need to do since I've already successfully imported this into my wallet.  What steps am I missing?  
> **username_1**: It would be useful if you'd include the exact commands and output you're seeing in your question. If need be, you can try to recreate on regtest / signet / testnet.  
> **username_0**: I tried to reproduce everything on regtest, but I keep getting `"complete": true` and no issues like what I'm seeing on mainnet.   The main difference I see is when I do `getaddressinfo` on regtest it shows I'm using an hd key I believe via:   ```"desc": "tr([e4b96d59/86'/1'/0'/0/0]d5de651411b49df50bc37a17620755ec019866332794cc3e73a6effbb766aa1c)#kh27dth2",```    on mainnet when I run `getaddressinfo` I see something similar minus the `/86'/1'/0'/0/0`.  
> **username_1**: It would seem that the way you import things on mainnet and on regtest differs then.  
> **username_0**: Yeah, I'm trying to reproduce, I did find another discrepancy though, `"isrange": false,` on mainnet but true on regtest. What does this mean? I get this after running the `getdescriptorinfo` command  
> **username_1**: A `tr(WIF)` descriptor is not ranged, so that's clearly not what you're doing on regtest  
> **username_0**: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/146473/discussion-between-username_0-and-username_1-username_1).  
> **username_0**: When looking at the output of `getdescriptorinfo` why would  `solvable` be `true` but `hasprivatekeys` be `false`.  After doing a non ranged tr(wif) import? Shouldn't they both be `true`?  
> **username_1**: This is all impossible to say without knowing what your actual commands are.  
> **username_0**: 1. `bitcoin-cli importdescriptors '[{"desc":"tr(WIF)", "timestamp":UNIXTIME}]'` 2. `bitcoin-cli listdescriptors` > (grab the `desc` for the imported wif = "tr(hex)#CHECKSUM") 3. `bitcoin-cli getdescriptorinfo "DESC"`  
> **username_1**: `listdescriptors` will give descriptors without private key material (the "hex" you state is the public key); that's why it says hasprivatekeys false. But please update your question to reflect all information, with the commands you did, and the responses you get. It's very hard to discuss this via comments.  
> **username_0**: so.. just working through this  1. `bitcoin-cli createpsbt '[{"txid":"TX_ASSOCIATED_WITH_WIF","vout":INDEX}]' '[{"BTC_ADDRESS":AMOUNT},{ "data": "WHAT_IS_SUPPOSED_TO_GO_HERE?"}]'` I've been putting `00` for data maybe that is incorrect?  
> **username_0**: Similarly for `walletcreatefundedpsbt` with the same json parameter. Not sure if `00` is ok. Or how to find out what to put for this.  
> **username_1**: Whatever you want to go in an OP_RETURN goes there. But again, please update your question with whatever your question has now evolved to be  
> **username_2**: In the future, especially if you don’t have answers yet, please edit instead of opening a new question.  
> **username_0**: @username_2 thanks for the tip. I edited the original post with most up to date info.  
> **username_3**: Wrong:  _"Further, you need to use PSBT RPCs; the old raw transacrion RPCs in general do not support taproot. – username_1 username_1 Jun 4 at 11:32"_ . As a matter of fact, Bitcoin Core v. 24 RPC commands like `createrawtransaction` and `signrawtransactionwithwallet` support Taproot (P2TR). Also, the goal could be acheived without using any PSBT-related RPC.  
> **username_3**: There is the example of using the raw transaction RPC commands: [https://bitcoin.stackexchange.com/a/117013/135945](https://bitcoin.stackexchange.com/a/117013/135945).  

---

## 1 answers

### Answer by username_4 on 2023-06-06. Score: 2

Regularly you'd use `walletcreatefundedpsbt` and then `walletprocesspsbt`. But since you've only got two coins in your wallet that you want to sweep you can simply use `sendall`.

Let's walk through a reproduction of your scenario. I've created two regtest-WIF-encoded private keys:

* `cRZ9wuYhwKYm82rXfSk9hhc9beJy6p7rV4y3aoAdzqFD6YAUVQcJ` (corresponding to `029d759b09cec94b6f2bd322cedd5d136e7f24a4936998fe24da09827d8a12e9dd`)
* `cVFkDn9fS1rwU1SR7geC3rgoGNXLpZXsnrCq2gutYVsGA2FoLpCD` (corresponding to `03bd0d0b820dae844107803c9323fe73e81b9adf8abe329930ae9311dab6c3573e`)

I'm creating a new wallet and importing a `tr()` and `wpkh()` descriptor.

```
$ bitcoin-cli -regtest createwallet repro_stackexchange
{
  "name": "repro_stackexchange",
  "warning": ""
}
$ bitcoin-cli -regtest -rpcwallet=repro_stackexchange importdescriptors '[{"desc":"tr(cRZ9wuYhwKYm82rXfSk9hhc9beJy6p7rV4y3aoAdzqFD6YAUVQcJ)#uj39yr2v","timestamp":"now"},{"desc":"wpkh(cVFkDn9fS1rwU1SR7geC3rgoGNXLpZXsnrCq2gutYVsGA2FoLpCD)#nayxphlw","timestamp":"now"}]'
[
  {
    "success": true
  },
  {
    "success": true
  }
]

```

Now i'm sending a coin to each descriptor:

```
$ bitcoin-cli -named -regtest -rpcwallet=main sendtoaddress address=bcrt1ps66a3wss3l0ay0agnkd57cfu6qrw26z632e0kez0ppjzkyaq0vhskxlrvs amount=0.00042 fee_rate=1
b2e975dee4ab0c68748e85fc847d7ef3fef44f53ee95e4765b1cc2b2c33939d2
$ bitcoin-cli -named -regtest -rpcwallet=main sendtoaddress address=bcrt1q9vsfxgf4t3wmtj9429g539txyv4p2qnuak03sv amount=0.00043 fee_rate=1
e34a3b8116f328d2b1529134dfcc795fbe27eae3991eeb017bc582879cb73b81

```

We can see that the reproduction wallet got the two coins:

```
$ bitcoin-cli -regtest -rpcwallet=repro_stackexchange listunspent 0
[
  {
    "txid": "e34a3b8116f328d2b1529134dfcc795fbe27eae3991eeb017bc582879cb73b81",
    "vout": 0,
    "address": "bcrt1q9vsfxgf4t3wmtj9429g539txyv4p2qnuak03sv",
    "label": "",
    "scriptPubKey": "00142b209321355c5db5c8b55151489566232a15027c",
    "amount": 0.00043000,
    "confirmations": 0,
    "ancestorcount": 1,
    "ancestorsize": 130,
    "ancestorfees": 130,
    "spendable": true,
    "solvable": true,
    "desc": "wpkh([2b209321]03bd0d0b820dae844107803c9323fe73e81b9adf8abe329930ae9311dab6c3573e)#k6qfdnw5",
    "parent_descs": [
      "wpkh(03bd0d0b820dae844107803c9323fe73e81b9adf8abe329930ae9311dab6c3573e)#45n94hja"
    ],
    "safe": false
  },
  {
    "txid": "b2e975dee4ab0c68748e85fc847d7ef3fef44f53ee95e4765b1cc2b2c33939d2",
    "vout": 1,
    "address": "bcrt1ps66a3wss3l0ay0agnkd57cfu6qrw26z632e0kez0ppjzkyaq0vhskxlrvs",
    "label": "",
    "scriptPubKey": "512086b5d8ba108fdfd23fa89d9b4f613cd006e5685a8ab2fb644f08642b13a07b2f",
    "amount": 0.00042000,
    "confirmations": 0,
    "ancestorcount": 1,
    "ancestorsize": 154,
    "ancestorfees": 154,
    "spendable": true,
    "solvable": true,
    "desc": "tr([caa3ae90]9d759b09cec94b6f2bd322cedd5d136e7f24a4936998fe24da09827d8a12e9dd)#e2lr407t",
    "parent_descs": [
      "tr(9d759b09cec94b6f2bd322cedd5d136e7f24a4936998fe24da09827d8a12e9dd)#u9ras3xm"
    ],
    "safe": false
  }
]

```

Now i'll get the transactions confirmed and sweep the coins using `sendall`:

```
$ bitcoin-cli -regtest -rpcwallet=main generatetoaddress 1 $(bitcoin-cli -regtest -rpcwallet=main getnewaddress)
$ bitcoin-cli -named -regtest -rpcwallet=repro_stackexchange sendall recipients='["bcrt1qre2fezscuke8qaj9ham2klddj2rt7m4s78tvqq"]' fee_rate=1
{
  "txid": "a39b70bf4636bb78053d10a3bc03eb6866e6777e84aeb274bb4002a543b7bb99",
  "complete": true
}

```

Let's inspect the transaction. It does indeed spend the two coins from the wallet (one Taproot and one native segwit v0 as you can see from the witness):

```
$ bitcoin-cli -regtest getrawtransaction a39b70bf4636bb78053d10a3bc03eb6866e6777e84aeb274bb4002a543b7bb99 1
{
  "txid": "a39b70bf4636bb78053d10a3bc03eb6866e6777e84aeb274bb4002a543b7bb99",
  "hash": "be1fcf89ec92649ee0780a8ea86ade1512a7fff6cfc8f75430b1115f1321b8f1",
  "version": 2,
  "size": 298,
  "vsize": 167,
  "weight": 667,
  "locktime": 0,
  "vin": [
    {
      "txid": "e34a3b8116f328d2b1529134dfcc795fbe27eae3991eeb017bc582879cb73b81",
      "vout": 0,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "txinwitness": [
        "304402201e3ba83ca58a357e72d9df4d555f11a747e128ab2131868cb5620afc9b383d540220011c6fe77e37ed8ca83d50870fc5cc3995ecbd1cbd6305ede59bd4fd8aa05c2901",
        "03bd0d0b820dae844107803c9323fe73e81b9adf8abe329930ae9311dab6c3573e"
      ],
      "sequence": 4294967293
    },
    {
      "txid": "b2e975dee4ab0c68748e85fc847d7ef3fef44f53ee95e4765b1cc2b2c33939d2",
      "vout": 1,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "txinwitness": [
        "6cd85a806478d00f062e0bd7a43f46d7be082e4287819fcf07d3dda1d6a613a11e1197d15021f87aad16a697e326181d82156ff957fcb6593f5d030f33516471"
      ],
      "sequence": 4294967293
    }
  ],
  "vout": [
    {
      "value": 0.00084833,
      "n": 0,
      "scriptPubKey": {
        "asm": "0 1e549c8a18e5b2707645bf76ab7dad9286bf6eb0",
        "desc": "addr(bcrt1qre2fezscuke8qaj9ham2klddj2rt7m4s78tvqq)#5gumgp89",
        "hex": "00141e549c8a18e5b2707645bf76ab7dad9286bf6eb0",
        "address": "bcrt1qre2fezscuke8qaj9ham2klddj2rt7m4s78tvqq",
        "type": "witness_v0_keyhash"
      }
    }
  ],
  "hex": "02000000000102813bb79c8782c57b01eb1e99e3ea27be5f79ccdf349152b1d228f316813b4ae30000000000fdffffffd23939c3b2c21c5b76e495ee534ff4fef37e7d84fc858e74680cabe4de75e9b20100000000fdffffff01614b0100000000001600141e549c8a18e5b2707645bf76ab7dad9286bf6eb00247304402201e3ba83ca58a357e72d9df4d555f11a747e128ab2131868cb5620afc9b383d540220011c6fe77e37ed8ca83d50870fc5cc3995ecbd1cbd6305ede59bd4fd8aa05c29012103bd0d0b820dae844107803c9323fe73e81b9adf8abe329930ae9311dab6c3573e01406cd85a806478d00f062e0bd7a43f46d7be082e4287819fcf07d3dda1d6a613a11e1197d15021f87aad16a697e326181d82156ff957fcb6593f5d030f3351647100000000"
}

```

> **Comments:**
> **username_0**: username_4, great thorough answer. I do have a concept question follow up. Can you take any WIF and import it as any descriptor type? For instance if you previously had a taproot utxo/descriptor would you need to make sure that was imported as a tr()? or could you import also as wpkh()?  
> **username_0**: username_4, another followup question.  When i run something like `bitcoin-cli -rpcwallet=wallet_x2 getnewaddress "label" "bech32m"` How do I know it's using the imported tr() descriptor? and not the wallet's generic tr ranged descriptor?  
> **username_4**: You can use a WIF encoded private key everywhere a key expression is expected.  
> **username_4**: You can set a descriptor as active when importing it to use it to generate receive addresses (but it needs to be ranged if i'm remembering correctly). Otherwise just use `deriveaddresses`.  

---

