Whenever someone sends an amount of bitcoin, one or more locked unspent transaction outputs (UTXOs) are unlocked and used as the inputs for the bitcoin transaction. The output(s) of the bitcoin transaction are newly created locked UTXOs, which in turn can be used as future transaction inputs by the new owner (i.e. the person holding the private key associated with the bitcoin address which received the bitcoins).
A commonly asked question in this regard is “Where are unspent transaction outputs (UTXOs) stored?” Unspent transaction outputs are stored in the bitcoin blockchain. They are not stored in a defined database, but are scattered throughout all bitcoin transactions that have been recorded on the bitcoin blockchain. UTXOs are tracked by every full-node bitcoin client as a data set called the UTXO set.
Below I will explore this answer in more detail and answer some related questions, such as, “What is the structure of a bitcoin transaction?”, “What is the UTXO set?”, “Is it bad to keep all your UTXOs in a single bitcoin address?” and “What is bitcoin dust?”.
UTXOs constitute the inputs for a bitcoin transaction
Whenever a bitcoin transaction takes place, UTXOs are consumed as inputs for that bitcoin transaction. These UTXOs are unlocked using the private key associated with the bitcoin address to which the locked UTXOs are registered. Once unlocked, the UTXOs can be spent.
The output of the bitcoin transaction, are newly created locked UTXOs registered to the receiving bitcoin address. These newly created UTXOs are locked by an “encumbrance”, i.e. a locking script that locks the amount of bitcoin to a specific bitcoin address, by specifying the conditions that must be met to be able to spend the newly created locked UTXOs (such as the signature by the correct private key).
UTXOs are scattered throughout the bitcoin blockchain
Contrary to what you might think, the UTXOs that serve as the inputs for a bitcoin transaction are not stored in a separate database by the bitcoin protocol. The UTXOs are simply recorded in the various transactions stored within the bitcoin blockchain. Therefore, a person’s bitcoin balance is in essence the aggregate UTXOs that are scattered throughout numerous transactions recorded on the bitcoin blockchain which are locked to that person’s bitcoin address. In other words, someone’s bitcoin balance is merely a construct created by a bitcoin wallet application, which aggregates all the UTXOs registered to that person’s bitcoin address, by scanning the entire bitcoin blockchain for relevant UTXOs.
What is the structure of a bitcoin transaction?
It follows from the above that bitcoin transactions do not refer to an account or someone’s identity. Rather, a bitcoin transaction must be viewed as the unlocking of amounts of bitcoin (i.e. one or more UTXOs) that are subsequently locked with an “encumbrance”, which can only be unlocked by the new owner (i.e. the person that knows the correct private key). Hence, sending an amount of bitcoin means unlocking and subsequently encumbering UTXOs, which are always the result (i.e. outputs) of previous transactions, resulting in a continuous chain of ownership from one bitcoin address to another bitcoin address.
Therefore, a bitcoin transaction always consists of one or more “inputs” (i.e. one or more unlocked UTXOs and unlocking scripts) and one or more “outputs” (i.e. one or more newly locked UTXOs and locking scripts).
Transaction inputs
A transaction ‘input‘ consists of:
(1) the transaction ID: a reference to the 32-byte double SHA-256 of the bitcoin transaction where the relevant UTXO is recorded on the bitcoin blockchain;
(2) the vout index: a 4-byte unsigned integer, indicating the position of the relevant UTXO in the transaction where that UTXO is recorded on the bitcoin blockchain; and
(3) the unlocking script: a script that solves the spending conditions of the UTXO that is used as an input for the bitcoin transaction.
Transaction outputs
A transaction “output” in essence consists of (1) an amount of bitcoin (denominated in satoshis) and (2) a locking script (i.e. scriptPubKey), otherwise known as “encumbrance”, locking the amount of bitcoin by specifying the conditions that must be met in order to be able to spend the newly locked amount of bitcoin.
A bitcoin transaction will in most cases have at least 2 transaction outputs, even if you send bitcoin to a single destination address. This is because, unless the amount of bitcoin you want to send matches exactly the amount of a single existing input (i.e. a UTXO), multiple UTXOs, exceeding in aggregate the amount of bitcoin to be sent, will be selected as inputs for the transaction. Part of the aggregate amount of inputs in excess of the amount of bitcoin sent, will then be returned to the originating bitcoin address as change.
What is the UTXO set?
As already set forth above, the UTXOs that serve as the inputs for a bitcoin transaction are only stored in the bitcoin blockchain, without being fully indexed in a separate database. However, many applications and service providers in the bitcoin space track and index UTXO data, in order to be able to use this data efficiently.
In this regard, the bitcoin core client tracks and fully indexes UTXOs for those specific bitcoin addresses you tell the bitcoin client to track (e.g. your own bitcoin addresses). The indexed database of UTXOs is what is referred to as the “UTXO set”. The same goes for most bitcoin wallet applications. This allows the user to easily keep track of and spend his/her bitcoin balance at any time.
On the other hand, Block explorers (such as the Blockchain Explorer or the Blockstream Explorer), which allow any user to look up the balance of any bitcoin address, continuously keep track and fully index all UTXOs and all bitcoin addresses on the entire bitcoin blockchain.
Other related questions
Is it bad to keep all your UTXOs in a single bitcoin address?
Security perspective
As it stands today, the fact to keep all your UTXOs in a single bitcoin address does not heighten security risks.
Whenever you spend your bitcoins, the public key behind the bitcoin address from which the bitcoins are sent is revealed. Fortunately, for all practical purposes it is currently not possible for anyone to calculate a private key from a public key. The reason being that a public key is calculated from the private key using elliptic curve multiplication, which is a mathematical formula that can only be calculated in one direction. Therefore, the fact that your public key is exposed during a bitcoin transaction, does not heighten the risk of your private key being discovered in the future. It follows that the remaining UTXOs in that same bitcoin address remain as secure as before the public key was exposed.
Privacy perspective
From a privacy perspective, keeping all your UTXOs in a single bitcoin address may not be recommended, if you desire to keep the amount of your bitcoin holdings private.
The bitcoin address from which the bitcoins are sent and its UTXOs are publicly available, through the use of a block explorer (such as the Blockchain Explorer or the Blockstream Explorer). Therefore, if you keep all your UTXOs in a single bitcoin address, anyone who knows you are the owner of that bitcoin address will also know the amount of your entire bitcoin holdings. Hence, from a privacy perspective it may be recommended to spread your UTXOs over multiple bitcoin addresses.
What is bitcoin dust?
“Bitcoin dust” is a term that is used to refer to amounts of bitcoin that are part of the UTXO set that are so small that, from an economic point of view, they are no longer spendable, because the cost of spending these amounts, in terms of transaction fees, would exceed their value.
Hence, what is to be considered “bitcoin dust” is for the most part dependent on (1) the bitcoin price and (2) the transaction capacity of the bitcoin network (which determines transaction fees), both of which fluctuate over time. In the event the bitcoin price would go up substantially and/or the transaction capacity of the bitcoin network would drastically improve (thereby lowering transaction fees), it may at some point become cost effective to spend an amount of bitcoin that is considered to be “bitcoin dust” at present times.
From a practical point of view, it is recommended for a user to use a wallet application which does not allow the creation of bitcoin dust which he/she will for certain not be able to spend in the future regardless of the potential bitcoin price and network capacity.
Notwithstanding the foregoing, the bitcoin protocol does apply a default set minimum amount of bitcoin that can be created in a UTXO. This default absolute minimum amount is currently set at 546 satoshis. This minimum amount prevents the creation of bitcoin dust which will never be able to be spend in a cost effective way, no matter what.
Is bitcoin dust a problem?
At the present, bitcoin dust is not considered to be a problem for the bitcoin network.
However, the more bitcoin dust is created over time, the larger the UTXO set becomes. This may make it increasingly difficult for bitcoin nodes to fully index the UTXO set as time goes by. The larger the UTXO set becomes, the more resource intensive it will become for bitcoin nodes to keep track of the full UTXO set. If the UTXO set is kept in memory, this will in essence be a strain on a bitcoin node’s RAM.
Do we need to remove bitcoin dust?
It is currently not necessary to remove bitcoin dust, as the current amount of bitcoin dust does not seem to cause problems for bitcoin nodes in assembling full UTXO sets.
In addition, at this point in time we don’t know what (1) the value of bitcoin and (2) the capacity of the bitcoin network will look like in the future. Hence, what is to be considered bitcoin dust today, may become cost effective to spend in the future. It is therefore not possible, nor desirable to determine what amounts of bitcoin dust would need to be removed at this stage.
Attention! Do you store your cryptocurrencies on an online platform? Please note, in that case you are not the actual owner of your cryptocurrencies!
In particular, you run the risk of losing all your cryptocurrencies, without any recourse, in the event that the online platform or your personal account falls victim to hacking or in the event of an unexpected closure (e.g. insolvency) of the online platform.
Protect yourself against hacking and take real ownership of your cryptocurrencies by storing your cryptocurrencies offline on your very own Trezor hardware wallet. Don’t wait before it’s too late and take immediate action now!
Click on the ‘Buy Now’ button below to buy a Trezor wallet from the official Trezor website.