Where are UTXOs stored?

"Where are UTXOs stored?" What are UTXOs? They are unspent transaction outputs. They are in the blockchain. Every transaction has outputs. If you have a copy of the blockchain, the transaction outputs are in that database. They are not in an easy-to-find index. They are just in the transactions. If you know the transaction ID, you can look up a transaction and find the outputs. Those outputs are in the blockchain, but not a neatly defined way. If you create a transaction index and add a watch address, your Bitcoin Core node software... create an index for all of the UTXO by script, corresponding to addresses you are watching. At any moment in time, you can look up by address, and find, specific UTXOs. In that case, you have the same database, but it is indexed as UTXOs by script pub key. You will be able to quickly look up all UTXO belonging to a specific address. Bitcoin Core only does that for specific addresses that you tell it to watch. It does not build that index for everything. UTXOs are stored in the blockchain, without being fully indexed. They are only indexed when you tell the Bitcoin Core [node software] to watch specific addresses. If you are building a block explorer, such as the infrastructure for Blockchain.info, Blockstream.info, or BlockCypher.com, one of these block explorer websites that allow you to search... for the balances of addresses, they are building a fully indexed database of all UTXOs and addresses. They will keep it updated all the time, which [requires] a very [large] amount of disk space to store. That is a much more complex database. They do not that because the need information. It can be [found] by re-scanning that database. They will store a fully indexed UTXO set, by a number of different indices so they can look up [data points] very quickly, and present them on your screen. That is custom software which they built to do this. Your wallet doesn't do this. The UTXO is stored when it is needed, for the purposes that it is needed.

Could you explain what bitcoin dust is, why it is bad, and how it can be avoided? In the long run, in the extreme scenarios, could it damage bitcoin owners or the network itself?

"Could you explain what bitcoin dust is, why it is bad, and how it can be avoided?" "In the long run, in the extreme scenarios, could it damage bitcoin owners or the network itself?" Dust is amounts of bitcoin that have become part of the UTXO set, but are no longer [economically feasible] to spend, because the cost in transaction fees exceeds the value of the bitcoin itself. For example, if I create a transaction and the change [payment] is a couple thousand satoshis, the cost to spend that chunk of bitcoin may be more than that in fees. Or I will end up paying a significant percentage in fees. Therefore, in practice, it is unspendable. Here is the key point: "in practice, unspendable" [may only apply to] bitcoin at the current price, and the fee [pressure] today. That doesn't mean it will be unspendable forever. It may become spendable in the future as the price of bitcoin goes up... and the relative percentage of fees goes down. Again, [the dust UTXO] will become valuable enough to spend at a lower fee. So the definition of bitcoin dust itself changes. There is a specific definition [in Bitcoin Core], which I believe is anything under 546 satoshis. There is a minimum amount below which you can't create transactions, UTXOs. That is to prevent the creation of ridiculously [small] amounts of dust in the beginning of Bitcoin's [history]. [At one time], you could create a one-satoshi output. Effectively, at any price of bitcoin or any fee level, that is dust and you can't do anything with that. It will just sit there, unspendable, and take up memory... and disk space on the Bitcoin blockchain, in order to keep track of an amount that can't be spent. It is like the loose change you find in your couch. If you were to carry that around in your pocket, it will just make a hole and ruin your pants. You won't be able to buy anything with it because it is such a tiny amount. Does it damage Bitcoin? Not really, it just sits around doing nothing. Depending on the level of dust, if it is true dust, amounts so tiny that you can't spend them... on the Bitcoin network today or ever, then it will just sit around forever. However, if it is just marginally dust at the current fee level and bitcoin price, it may be spendable in the future. Then it is pretty harmless. This is about how is your wallet is configured to handle these amounts. Preferably, your wallet will be intelligent enough to avoid creating amounts that are too small to spend. It [should] certainly avoid the absolute dust limit in the protocol, [and] avoid creating any UTXO that isn't useful. This is about [using] a wallet with good coin [and fee] management. It is harmless, but it can be a nuisance.

Will the crypto dust in the mempool ever need to be cleaned up, due to high RAM requirements for nodes, as time goes on and more transactions create dust?

"Will the crypto dust in the mempool ever need to be cleaned up, due to high RAM requirements for nodes, as time goes on and more transactions create dust?" Not necessarily. Dust is a problem, but it is not a problem for the mempool. Dust is a problem for the UTXO set. These are two different things. The mempool is the list of currently outstanding transactions waiting to be confirmed in a block. The UTXO set is a collection of all bitcoin that can be spent. All the little chunks [of different sizes] in the [circulating supply] of 17 million bitcoin mined so far. They are transaction outputs and have not been spent. That database accumulates dust. If [people] create lots of tiny fragments of bitcoin, then the database [will grow]. Imagine this: almost 17 million bitcoin have been mined so far. If [each] bitcoin was one UTXO chunk, then there would be 17 million chunks to keep track of. But they are not. [Many] are smaller amounts, smaller chunks. I believe that there are more than a hundred million unspent transaction outputs, the minimal units of Bitcoin. Among those are hundreds of thousands of dust [outputs], given the current fees and network capacity. They cannot be cost-effectively spent because the transaction fee would be more than the amount. Cleaning up that dust is not easy. You must consider that, in the future, the value of the dust might be higher. There may be circumstances where there is capacity to spend that dust, in a way that makes economic sense. We don't really need to clean up dust now. It might happen in the future. It is not a problem for the mempool, but it is a problem for indexing the full UTXO set. It does impose a resource burden on nodes keeping that UTXO set. If they keep it in memory, it is a RAM problem. If they keep it on disk, then it is a disk [space] problem.

What should you do when you have all of your UTXOs in a single address?

"What [should] you do when you have all of your UTXOs in a single address?" Basically, all your coins in a single address. "Over time, I have accumulated some bitcoin, but against all advice, my UTXO are in a single address." "I understand this is bad for privacy, but I also understand it will be less secure once I spend." "[Spending means] the public key behind the double hash of the address [will be] revealed." "The key pair [could be] more vulnerable to future attack possibilities." Tim is talking about... the rather remote possibility of a successful quantum computing attack in the future. Address reuse makes you more vulnerable [to that]. Not reusing addresses makes you more resilient. If your public key is revealed when you spend and you keep using the same address, if there is a quantum computing attack one day that is big enough [to crack ECDSA], it would be a problem. [For now], it is a remote possibility, for the foreseeable future. But the privacy implications [of address reuse] are worth considering in this situation. If you have all UTXO, your coins, in one address, that means every time you make a payment to someone, the person you just paid can look up where that payment came from and know how much [bitcoin] you have. It is all in that address. From a privacy perspective, that is terrible. What can you do to get out of the situation, be more private and secure? Well, one of the things you can do... Construct transactions that send payments to other address in your own wallet [or another wallet], amounts that are not obviously just transfers between wallets. Perhaps [you could] make them look like payments to merchants and things like that. If you spread the crypto you have in that address enough, across many different different addresses, managed by [software and] hardware wallets... Tim mentioned that he has a hardware wallet. You will also need to spread some of the change to different address. This will make it a bit more private for you. There are other techniques, which I can't [broadly] recommend. It depends on whether they are legal in your jurisdiction. But you can use various coin mixing tools like CoinJoin on Join Market in order to maintain better privacy. You will need to look up whether that is something you can do, in your jurisdiction.

I would be very interested to hear how to consolidate UTXOs while maintaining privacy

Follow-up question: "I would be very interested to hear how to consolidate UTXOs while maintaining privacy." The answer is, you can consolidate them into bigger UTXOs, bigger amounts, but spread across multiple addresses to still maintain some privacy. You don't want a lot of tiny UTXOs that are difficult or cost a lot [of fee] to spend. If network fees go up again, that UTXO becomes unspendable. So you should look for opportunities, when [average] transaction fees are very low, during times when the network is being under-utilized, to consolidate small-value UTXOs into larger UTXOs. You should not consolidate into one address. Consolidate into multiple addresses. Pay them out to different addresses, with different amounts, to break it up a bit. But it won't be perfect. If you want to do it properly, you will need to use some kind of CoinJoin tool.