user69016: 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?

user26873: 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)"}]'


user76567: This 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)

user101498: 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.

69016: <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>
 26873: <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>
 76567: <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>
 101498: <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>
