1

AFIK, UTXO of an address cannot be retrieved using bitcoin-core, without importing the address in the wallet.

  1. How are application in production able to get UTXO ?
  2. Does all the application use Indexed database like Insight or Abe to get UTXO ?
  3. Is there any way to get UTXO from bitcoin core without importing the address into the wallet?

4 Answers 4

2

Most services run their own services which track the UTXOs that they need. They use Bitcoin Core as an edge node which forwards all of the valid blocks and transactions to their internal software that adds them all to a database. This could be a software based on insight or Abe or something homegrown. In this way, they don't need to implement consensus and validation logic, just deserialization and database storage.

Is there any way to get UTXO from bitcoin core without importing the address into the wallet?

Bitcoin Core has a scantxoutset command that you can use to get the UTXOs for a particular scriptPubKey (from an address, descriptor, raw script, etc.).

2

My major concern was having privatekey in the Bitcoin Core wallet, So I did generate the address outside the Bitcoin core from third party library or HSM and used importaddress RPC method to import the address as watch-only address and then Bitcoin core handled all UTXO monitoring, Then use listunspent to get the UTXO of the imported address. By this approach privatekey is cold from the core.

Thanks @yyforyongyu for suggesting this.

1
  • This is a valid approach for using Bitcoin Core as a cold wallet. In the future I suspect many Bitcoin will be lost as the result of inheritance where the priv-key must be passed from one generation to another, but usually, the priv-key will be in the offline wallet to sign transactions and only the password will be necessary. The transactions can be hand loaded into mempool of the online wallet to gossip.
    – Willtech
    Commented Dec 28, 2021 at 14:29
1

Most services operating large scale wallets only use Bitcoin Core for networking information, and maintain a separate utxo set for wallet purposes.

There are many existing options to build a full utxo set that can be queried for arbitrary addresses, such as the insight project.

Moreover, recent versions of Bitcoin Core come with the scantxoutset RPC call, which allows you to locate unspent outputs for a given address or locking script.

0

Speaking as a formal wallet engineer, what we did back then,

  1. Once in a while, we would batch generate lots of bitcoin addresses and import them into bitcoind.
  2. Can't speak for ALL applications, for us, we let bitcoind manage all its UTXO set.
  3. Depending on the situation,
    • if the address is newly generated by you, then no, you have to import it first because, well, it's new, you have to tell bitcoind to use it.
    • if it's a used address, I believe you can parse its UTXOs from all the block data, though we never did that.
4
  • Thanks, Does having address imported in the wallet suggested for production ?, What are the safety measure that has to be taken? Commented Nov 14, 2019 at 7:38
  • Yes. You probably need to periodically import a batch of addresses into the wallet, as a production site, however that's more of a topic of software engeering. As for safety measure, if you are generating those addresses, it's recommended to use HD wallet so your private keys won't get exposed. Commented Nov 14, 2019 at 9:31
  • 1
    Using an HD wallet does not prevent exposure of your private keys, especially if you are importing them into Bitcoin Core Commented Nov 14, 2019 at 9:33
  • 1) Import addresses as watch-only; 2) Use an HD wallet, and save the master private key offline; 3) Construct raw transaction online, send it to offline signing. How's my private key exposed? Commented Nov 14, 2019 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.