<p>You can import a descriptor composed of the <code>xpriv(s)</code> (or <code>xpub(s)</code> if you just want to watch the coins) to the <code>bitcoind</code> wallet, and then rescan the block chain for transactions involving derived key up to a configured gap limit.</p>
<p>For importing the descriptor, use the <code>importmulti</code> RPC call in versions &lt;0.21 and the <code>importdescriptors</code> RPC as of 0.21 (upcoming).</p>
<p>Both calls allow you to pass a creation timestamp in order to rescan the block chain from this point. You can otherwise manually call <code>rescanblockchain</code>.<br />
Note that, depending on the number of blocks you are scanning, it will take some time. You can monitor the progress in your <code>debug.log</code>.</p>

CC BY-SA 4.0
2021-01-12T21:18:05.277Z
Thanks, I will look into that. Initially, I wanted to avoid using bitcoind wallet and was looking for a lightweight solution which would construct a set of HD wallet PKHs and scan the full UTXO database for matches (even though that's not part of bitcoin core api, it can be done locally)
DeLorean88
CC BY-SA 4.0
2021-01-12T21:01:06.743Z
2021-01-12T21:01:06.743Z
Antoine Poinsot
<p>You can avoid risking exposing your private keys and just check the addresses with <code>scanutxooutset</code> in the console or via JSON-RPC. Although it takes a few minutes, you don't have to wait for a full rescan and it's easy to get all UTXOs for any address or even xpub and it doesn't have to already be in your wallet like when importing keys.</p>
<p>Example in the console:</p>
<pre><code>scantxoutset start '[{&quot;desc&quot;:&quot;addr(1SomeAddress)&quot;},{&quot;desc&quot;:&quot;addr(1AnotherAddressToCheck)&quot;}]'
</code></pre>
<p>or checking xpubs would look something like this:</p>
<pre><code>scantxoutset start '[{&quot;desc&quot;:&quot;pkh(xpubMyXpubToCheck)&quot;}]'
</code></pre>

CC BY-SA 4.0
2021-01-13T04:37:12.897Z
2021-01-13T04:37:12.897Z
m1xolyd1an
<p><a href="https://github.com/mcdallas/cryptotools" rel="nofollow noreferrer">This</a> python library comes close (disclaimer: I wrote it). It supports HD wallets via mnemonic or xprv and you can query outputs of addresses however it queries a block explorer for the outputs instead of bitcoind (you can probably tweak the code to replace the API call with an rpc call)</p>

CC BY-SA 4.0
2021-01-13T04:19:00.537Z
Looks interesting, but I didn't see the described functionality in the examples. I also specifically wanted to do everything locally and avoid queries to a 3rd party
DeLorean88
CC BY-SA 4.0
2021-01-13T02:36:01.990Z
2021-01-13T02:36:01.990Z
Mike D
<p>I am looking for an open source script or application which would take a private wallet key from the user (from terminal input or file, as mnemonic or xpriv string) and then connect to a bitcoind and output all UTXOs which are owned (spendable) by that key. Does something like that exist?</p>

<bitcoin-core><bitcoind><wallet><bip32-hd-wallets>
Is there a script for bitcoin core which prints all spendable UTXOs given a private seed?
DeLorean88
# Is there a script for bitcoin core which prints all spendable UTXOs given a private seed?

(Asked by: username_0 on 2021-01-12)

I am looking for an open source script or application which would take a private wallet key from the user (from terminal input or file, as mnemonic or xpriv string) and then connect to a bitcoind and output all UTXOs which are owned (spendable) by that key. Does something like that exist?

**Tags:** bitcoin-core, bitcoind, wallet, bip32-hd-wallets


---

## 3 answers

### Answer by username_1 on 2021-01-12. Score: 3

You can import a descriptor composed of the `xpriv(s)` (or `xpub(s)` if you just want to watch the coins) to the `bitcoind` wallet, and then rescan the block chain for transactions involving derived key up to a configured gap limit.

For importing the descriptor, use the `importmulti` RPC call in versions <0.21 and the `importdescriptors` RPC as of 0.21 (upcoming).

Both calls allow you to pass a creation timestamp in order to rescan the block chain from this point. You can otherwise manually call `rescanblockchain`.  
Note that, depending on the number of blocks you are scanning, it will take some time. You can monitor the progress in your `debug.log`.

> **Comments:**
> **username_0**: Thanks, I will look into that. Initially, I wanted to avoid using bitcoind wallet and was looking for a lightweight solution which would construct a set of HD wallet PKHs and scan the full UTXO database for matches (even though that's not part of bitcoin core api, it can be done locally)  

---

### Answer by username_2 on 2021-01-13. Score: 2

You can avoid risking exposing your private keys and just check the addresses with `scanutxooutset` in the console or via JSON-RPC. Although it takes a few minutes, you don't have to wait for a full rescan and it's easy to get all UTXOs for any address or even xpub and it doesn't have to already be in your wallet like when importing keys.

Example in the console:

```
scantxoutset start '[{"desc":"addr(1SomeAddress)"},{"desc":"addr(1AnotherAddressToCheck)"}]'

```

or checking xpubs would look something like this:

```
scantxoutset start '[{"desc":"pkh(xpubMyXpubToCheck)"}]'

```


---

### Answer by username_3 on 2021-01-13. Score: 2

[This](https://github.com/mcdallas/cryptotools) python library comes close (disclaimer: I wrote it). It supports HD wallets via mnemonic or xprv and you can query outputs of addresses however it queries a block explorer for the outputs instead of bitcoind (you can probably tweak the code to replace the API call with an rpc call)

> **Comments:**
> **username_0**: Looks interesting, but I didn't see the described functionality in the examples. I also specifically wanted to do everything locally and avoid queries to a 3rd party  

---

