Transaction. 3. Transaction Inputs And Outputs And Their Interconnection
In the previous articles we have described main transaction components and discussed the problem of the network capacity. The transfer of the same amount of assets to a recipient’s account may be executed through different transactions. It looks similar to paying for goods with banknotes of different values. The different number of a records inside of a single transaction requires different spacing.
Bitcoin generation peculiarity
Before examining a single transaction structure and content in detail, we should make a reservation. Even though bitcoins are one of optional legal tenders, they are not generated on demand. In other words, their generation is not similar to the common currency emission. In case of common money, a special government print house emits a required amount of paper units that may wait for their time to be issued.
In contradiction, bitcoin has no single source, which gets along with the decentralization. All coins appear at the moment of a new block approval, and they come from different sources. It would be more correct to say that a new bitcoin sum starts being associated with one of full nodes wallet after successful mining. Thus, each bitcoin has both its own and general genesis sources simultaneously.
Any transaction consists of three different element sets. They are inputs, outputs and service data.
Transaction inputs define where assets came from. These assets are managed by the transaction’s author. Transaction’s output defines a recipient, the one the author gives the right to manage assets. According to the main transaction rule, the inputs assets sum must be more than the output assets sum or equal.
In accordance with the Bitcoin protocol rules, each transaction input is a reference to one output of the available transaction from a previously approved block. The transaction author selects a set of these references, unites them into a list and place into the transaction, making sure that all outputs have not been used before and are accessible. If the same reference is used several times, all transactions but the first by time are dropped by miners. All transaction outputs, in their turn, become new references of the same kind. After the transaction is placed in a block, and the block is placed in blockchain — they can be referred.
Assets inside of transactions are subjected to changes as well. First of all, the sum of the assets on all input addresses is calculated. This is a maximal value of funds a transaction author is able to manage. Later on, he or she chooses what parts are this sum will be divided into. Here, the rule is rather simple. Each recipient requires a single output. Each output has an available asset value. The sum of all outputs values must be less than the sum at all inputs or equal.
If there is a difference in the amounts, it is received by the miner who closes the block with this transaction inside. This difference becomes a part of the reward for closing the block and is called a transaction fee.
The difference in the sums brings some inconvenient consequences for inexperienced users.
Firstly, zero fee may cause troubles for those who select it. In this case, the sum of all outputs is equal to the sum of all inputs. Since miners are interested in profit maximisation, they will obviously prefer dealing with paid transactions. Taking into account blockchain network capacity problems, these transaction might never be placed into the block.
Secondly, users might decide that the change is calculated automatically, similar to the credit card payment. Unfortunately, the whole unaccounted difference will be directed to a miner’s account. If a sender wants to get the change back, this should be specified in the transaction output list.
Basically, the concept of transaction outputs and inputs is easy to understand. For a user, it is important to learn how to calculate fees and clearly set changes. Modern wallets in most cases do this automatically obviating the need to get deeper into details.