Published nov 11, 2020
In today's article, we will consider concepts such as confirming a transaction, what determines the speed of confirmation, what can be done with a frozen transaction and what to do to avoid this in the future. We will also talk about the commission of the BTC network, why it is needed, who receives it and how to calculate it correctly.
First, let's define what a transaction is from the point of view of the network. In fact, this is a set of information about the coins and transactions in which these coins were received, as well as a set of information where these coins are sent. A transaction is considered valid if previously unspent coins (outputs) are spent and they are correctly signed with private keys. If the transaction is correct, the bitcoin node we are referring to for sending will include it in the mempool and send it to all other nodes known to it. Mempool is something like a queue of transactions to be included in the main blockchain (network transaction history).
The confirmation of a transaction is, in fact, its inclusion in the block (in the history of all transactions in the network). All confirmations received after the first one are just blocks mined by the network since the transaction was confirmed, this simply indicates how long ago the transaction was confirmed. From the point of view of the network, coins can be considered received after the first confirmation, however, some services and wallets set a larger number of required confirmations. Moreover, you can create and send to mempool a transaction that uses funds from unconfirmed transactions as inputs. This does not contradict the rules, because these coins have not yet been used up, but such a transaction can be included in the block only together with the confirmation of all the past ones associated with it.
Now let's talk about the factors that affect the speed of including a transaction in a block. As we have already figured out, confirmation is a record of a transaction in a network block. The average block size at the moment does not exceed 1 megabyte, that is, it can accommodate a certain number of transactions. What determines the priority of enabling transactions? It is believed that the more you pay for a transaction, the more likely it is to be included in a block. This statement is not entirely true, since there are many more factors involved in determining the priority.
To determine the priority of a transaction, there is a formula:
Priority = amount (sat.) * Coin age in blocks \ transaction size in bytes.
We said earlier that a transaction is a collection of information. Let's consider two options.
As we can see from the formula, the larger the amount and age of the transaction outputs and the smaller the transaction size (and hence the place it will take in the block), the higher the priority is.
In each block, a certain amount of data is allocated to enable transactions with high priority, regardless of the commission.
Miners fill the rest of the space in the block at their discretion, namely, based on considerations of benefits. That is, transactions are included in the block on a competitive basis. The more you pay for each piece of information in your transaction, the higher the chances of being included in the transaction in the next block.
In the next part of the article, we will look at specific examples, tell you what to do with a hung transaction, and also tell you what to do to avoid a hanging transaction!