How do Bitcoin transactions actually work? Unconfirmed transaction on the blockchain: what to do? Blockchain info unconfirmed transactions

Whether you want to become a blockchain application developer or just wondering what happens when you send bitcoin to a friend, you need to understand the process of creating and executing transactions. Why?

Because transfers are the main operation, which is the pinnacle of the foundation on which the blockchain is built. Transactions combine the technologies of cryptography, data structures and scripts. These components are simple enough not to overload the transaction process, but they are flexible and allow programmers to customize the system for themselves. Today we will talk about these mechanisms in more detail.

Developers will learn how their Bitcoin client makes transactions on the network (and what happens when they are received).

Ordinary users will find the answer to the question: “What processes are launched when you send bitcoins to a friend?”.

This article assumes the reader has basic knowledge of asymmetric cryptography, hashing, and P2P networks. It would also be nice to know what blockchain mechanisms are, even if you are not familiar with the intricacies of how they work.

Bitcoin transactions and their role in the big picture

Bitcoin consists of two main parts: nodes and blockchain. The task of a typical node is to maintain the installed version of the blockchain and keep it up to date. The blockchain is made up of blocks that include transactions.

This simple but accurate description can be confusing: so what exactly is a transaction?

⦁ How can understanding the translation process help you become a good blockchain developer?

⦁ How do transactions allow you to transfer bitcoins to another person?

The answers to these questions vary depending on the type of transaction. Even working only with bitcoin, we can use several transfer systems.

But let's start with the basics and deal with the main type of transaction called pay-to-PK-hash. Now this type of transfer is used by 99% of bitcoin owners.

To begin with, let's simulate the operation of a cryptosystem. Many imagine it as a familiar environment for everyone. accounts. You send bitcoins to someone, the other person receives them, and your balance decreases.

In fact, everything is not so simple. All your money at the time of transfer leaves the balance (minus transaction fees). Some bitcoins are returned back to the account - this is how the balance is formed.

Each Bitcoin transaction consists of “inputs” (inputs) and “outputs” (outputs). We displayed its structure on the image:

The first time it is quite difficult to understand, so let's talk about the scheme in more detail.

When you send money to a friend, her “exit” is used as the address. And your "inputs" will be proof that the sender has enough money to complete the operation. You can have several "inputs", the sum of which is the account balance. In this simple case, there is only one input and one output involved in the transaction.

More about bitcoin transactions

Let's understand the mechanism of a real Bitcoin transaction. For clarity, take another look at the image.

If we study a typical transaction in a “section”, we will see that it consists of 3 large parts: header, input(s) and output(s). Let's take a quick look at the components that make up these sections, as they will be important to understanding the process. Note that all these fields are inherent in the so-called row-transactions. They are carried out between peers when a translation is created.

header

hash (hash): Applies to all transactions. Bitcoin uses it as a pointer, and the hash is also needed to check the integrity of the data. We will look at it in more detail in the next chapter.

ver: version number that is used to verify the block.

vin_sz: number of transaction inputs. Vout_sz displays the number of outputs.

lock_time: defines the earliest time a block can be added to the chain. This is either the block height or the unix timestamp.

Entrance

hash Previous Exit: Indicates the transaction's previous uncompleted exit (UTXO). Basically, it is your money that you are going to spend on this transaction.

n: index in the list of outputs of the previous transaction. Shows the actual number of the current output.

scriptSig: send script that confirms that the creator of the transaction has the rights to send money.

Exit

value: number of satoshi spent (1 BTC = 100,000,000 Satoshi).

scriptPubKey: The second of two scripts that execute the transaction. Needed to determine the hash of the recipient's public key.

Transaction Verification

One of the tasks of a bitcoin node is to verify the correctness of incoming transactions (the data should not be changed, only the intended recipients can use the funds, etc.). A more exhaustive list can be found on the Internet, here we will indicate the most important rules.

⦁ All outputs confirmed by the inputs of this transaction are in the UTXO pool. Unsent outputs can only be acknowledged once.

⦁ Signatures on each input are valid. This is determined by the execution of a sequence of scripts. You will find details in the next chapter.

⦁ No UTXO sent more than once per transaction. Pay attention to the differences with the first paragraph.

⦁ All transaction output values ​​are non-negative.

⦁ The sum of the values ​​of the inputs of this transaction is greater than the sum of the values ​​of the outputs. Note! If the numbers differ from each other, the difference counts as a fee that the miner can charge.

Basic pay-to-PK-hash transaction

Bitcoin has its own scripting language. It is powerful enough to allow developers to create complex and custom transaction types. There are about five standard types of transfers that are supported by classic bitcoin clients. But there are other clients who work with other types of transactions for a fee. Here we will just look at the pay-to-PK-hash mechanism.

For any transaction to be considered valid, the scriptSig/scriptPubKey script pair must show the value "true". When a transaction is sent, a scriptSig is included. It collects information from the scriptPubKey and, when executed, confirms the exit of the transaction. Both scripts are in the same cell.

Since bitcoin addresses are actually hashes, the sender will not be able to know which key is being checked: public or private. So the recipient specifies both keys, and scriptPubKey will duplicate and hash the public key. This process allows the script to verify that the key belongs to the intended recipient.

During the execution of the operation, you will see that the constants are pushed onto the stack when they are encountered. The system adds or removes items from the stack as they are processed. For example, OP_HASH160 will take the top element from the stack and do it twice, first with SHA-256 and then with RIPEMD-160. When all the elements in our script have been evaluated, it will return true on success, or false on errors.

In general, pay-to-PK-hash is a fairly simple type of transaction. It ensures that only a user with a matching public/private key pair can receive and spend bitcoins. When all the criteria from the previous paragraph are met, the transaction is considered successful and placed in a block.

In the following articles, we will look at more complex types of transactions. You will learn how 3 or more people can participate in transfers and how long-term types of transactions can be implemented.

With the recent increase in the volume of cryptocurrency transfers, some users have a question about what to do if there is an unconfirmed transaction on the network.

The article will look at how the transfer of funds through the bitcoin network goes, why it can be delayed and what measures can be taken to speed up the process.

There are special sites that monitor system load and offer optimal size commission, which will allow you to complete the transaction faster.

Also, such services offer to evaluate the speed of the transaction with various payments for adding to the block.

The user can adjust the speed of transactions by offering a higher or average pay over the network.

Another important point– checking the possibilities of wallets. Most software products today support the ability to change commission charges. Some applications provide the ability to assess the workload of the blockchain system and automatically decide on the commission.

If the wallet does not support the ability to change the fee or automatically change it, it is recommended to switch to another software.

In this case, funds from the old wallet must be transferred to a new one.

Some programs provide the ability to export and import keys without .

How to speed up a transaction after it has been sent to the blockchain

If the transaction has already been sent to the system, but due to the low commission it is not being processed, there are several options to solve this problem.

First of all, you can use the Opt-In Replace-by-Fee option.

This option allows the user to send the crypto transaction again, but only with higher crypto costs.

If a bitcoin owner tries to do all this without the appropriate option, the network will perceive it as an attempt to double spend. Accordingly, such a crypto transaction will not be processed.

Using Opt-In Replace-by-Fee solves this problem, as the network will see that the user is sending the same transaction, but only with a higher fee.

The only problem that the network client may face in this case is that not all miners support this feature. That is, it is necessary to wait until the miner who works with Opt-In Replace-by-Fee pays attention to the operation. What else can be done with unconfirmed?

The second option is Child Pays for Parent. With this approach, the miner can choose not the transaction that offers a higher payment, but a series of transfers, the total commission of which will be higher. Unfortunately, the function is not yet supported by all miners.

Finally, you can use transfer accelerators like ViaBTC.

This service allows you to quickly confirm those transactions that are still not confirmed by the network.

Despite the fact that such an accelerator is currently processing several transactions per hour, ViaBTC is already in high demand.

All you need to do is enter the transaction identification number and captcha. The transaction will be automatically added to the queue.

The essence of acceleration lies in the fact that ViaBTC is a pool of miners. Accordingly, if the transfer is in such an accelerator, the miners process it in the first place.

How to minimize the risks of transaction "hanging"

In order to reduce the likelihood of such situations, it is necessary to understand how the network works and what factors affect the speed of translation.

One of the reasons for the "freezing" of transactions has already been considered above - a low commission.

But there is another important point - the path of sent bitcoins.

If a user receives 5 bitcoins from 5 different addresses, then this will be much larger in size than if he received even 10 bitcoins, but from one address.

If you need to send bitcoins to several recipients, it is recommended to carry out everything in one payment, setting the desired addresses through Input.

Results

Unconfirmed transactions are the result of congestion in the bitcoin network.

Accordingly, to solve this problem, the user can either optimize the sending of cryptocurrency to several addresses by combining it into one transaction, or offer a higher payout to miners for including the hash in the next block.

Data stored using blockchain technology is a continuous chain of blocks, each of which contains information. This chain is updated and supplemented over time. To confirm the truth of the recorded blocks, the hashing function is used in the blockchain.

Blockchain is a revolutionary technology for storing and processing data, which has several properties at the same time:

  • distribution, i.e. information is stored on all computers working with the blockchain;
  • unnecessary double entries: the accounting system operates in such a way that when a transaction is created to transfer a certain number of coins, another transaction is automatically formed with the number of coins that the sender formally sends to himself, and the sum of these transactional operations is equal to the initial number of coins;
  • resistance to substitution, blocks are simultaneously copied as many times as there are users participating in the blockchain, so an attacker's attempt to replace one block is doomed to failure.

To hash the data obtained in the process of generating bitcoins (bitcoin), they use the SHA-256 encryption algorithm, which is also used in cryptography. It consists in the fact that information of any size and type is encoded in a 256-bit key, consisting of numbers and letters of the Latin alphabet.

The hash function is unique in that it encodes both a multi-volume book and a single word, and the size of the resulting key will be the same. If you try to make changes to at least 1 character of the source block, the resulting hash key will be radically different. This situation is called the "avalanche effect" and serves to protect against change. Also, the SHA-256 algorithm guarantees protection against collisions, i.e., the probability of generating matching hashes with unequal initial data tends to zero.

Hashing in mining


The computational process of generating data in the blockchain is called mining. Hashing is an integral part of it. Each new block carries the following information: the hash of the previous and the hash of the current blocks, the list of transactions and other system values. The technology understands, based on the decryption of the hash, which block is old and which is new, and accordingly writes them to the list of transactions.

During mining, users create new containers with information, but only those that meet the specified blockchain conditions receive confirmation. The hash of a user-generated block must be less than the maximum possible minus a variable referred to as "complexity". Depending on the speed of the previous blocks, the difficulty of the task increases or decreases so that the speed of mining in the future remains at a relatively constant level. If more than one block that satisfies the specified condition is tracked at the same time, then it will be checked and only the one whose chain is longer will be added to the list of transactions.


IMPORTANT! To find out the hash of a particular transaction, you need to use special software tools or websites. For example, if you enter information about a bitcoin transaction on the website www.blockchain.info, then the screen will display all the information about it, including the desired hash. Transactions are managed in personal account, they also track the senders and recipients of bitcoins, start a bitcoin wallet, and exchange cryptocurrency.

The use of hashing in the field of blockchain and when creating bitcoins helps to verify the truth and immutability of the received blocks, protects them from outside interference. In addition to SHA-256 encryption, other good cryptographic methods are used in the blockchain: X11, DaggerHashimoto, Scrypt.

Video: Cryptographic Hash Functions

Video: what is called hashing?

Since the beginning of last week, the Bitcoin network has seen a decrease in the queue of unconfirmed transactions, and the amount of commission fees has been significantly reduced. Community members say that they are now able to send transactions for a lower fee, but some of them have also encountered difficulties - some wallets keep the reward amount well above the required minimum.

Network congestion has subsided

The number of unconfirmed transactions has become significantly less than at the peak at the end of May - mempool (pool of unconfirmed transactions) averages from 7,000 to 15,000 transactions per day. This is a stark contrast to the recent situation where the queue reached 200,000 transactions just a few weeks ago. The number of unconfirmed transactions began to decrease in the first week of June and the positive trend has continued until today.

As the number of unconfirmed transactions declined, creating a fertile ground for bitcoin transactions, fees also declined. Less than two years ago, anyone could send bitcoin for a fee that was then roughly $0.02 in BTC. However, in May of this year, fees reached an average of $5 per transaction. However, now the fees have begun to decrease again and have become less than a dollar, and according to the reports of some bitcoin supporters, fees that are sufficient for a quick confirmation are about $0.25.

Difficulties in testing theories

Of course, there are several theories that explain the decrease in the number of unconfirmed transactions and the size of commission fees. Some believe that the high fee situation is the result of a "spam attack" whereby one person or group sent a large number of low fee transactions. However, most community members consider this theory untenable - it would take too many funds to support such an attack.

Another explanation is that the decrease in the number of transactions and the reduction in fees is due to a decrease in network activity. For example, the price of bitcoin fell several times after reaching an all-time high, which led to a decrease in the number of transactions. Along with this, trading volume has dropped to 1 billion, compared to $2 billion in BTC per day. Another theory is that companies such as Genesis mining and other large enterprises are doing more off-chain transactions. Most of these theories are difficult to test and so far remain only conjectures of community members.

Wallets adapt to the situation

Since the market for fees, as well as the number of unconfirmed transactions, began to decline significantly, many users have problems with wallets that do not allow changing the size of fees. Some wallets offer three different levels fees so that senders can prioritize transactions, while others allow you to set the fee yourself.

For example, Breadwallet yesterday recommended a fee of $1.76 for a typical transaction of 226 bytes. If you go to the fee converter page on the 21 Inc website, you can see that “the most optimal transaction fee is currently 300 satoshi/byte” for a 226-byte transaction, which was $1.73 yesterday. Many wallets are now asking for higher fees than necessary.

There are other wallets that allow you to change the size of the commissions - users can set the commissions themselves to much less than 300 satoshi / byte. Such transactions are likely to be confirmed as quickly as those with higher recommended fees. Most wallets use dynamic fee settings which offer only three fee options based on the same instruments as 21 Inc. charts. However, there are several wallets that allow you to set the fee yourself - Bitcoin Core, Electrum, Blockchain.info, Trezor, Armory, Green Address, Airbitz and others.

As long as the network load is low, users can check the mempool to see if there is a minimum number of unconfirmed transactions and reduce the fee for their transaction if possible. Bitcoin users can choose the most profitable fee within their wallets or switch to another wallet that allows you to set your own fees.

One of the features of the Bitcoin protocol is limited throughput. Due to the increase in the number of transactions, the system is getting worse at sending them, and users often face the problem of unconfirmed transfers. In this article, we will talk in detail about what to do if a transaction in the blockchain is stuck and how to protect yourself from such situations.

Why the transaction is not confirmed

Every transfer in the Bitcoin network is verified by miners. If the transaction is legitimate, it is included in a new block: in this case, the transaction is said to have been confirmed. Inclusion in each subsequent block increases the number of confirmations, which increases the trust in the transaction among all network participants.

Ideally, every bitcoin transaction should receive at least 6 confirmations, although fewer are often used in practice. However, no service will accept an unconfirmed transaction, that is, one that is not included in any new block. It is in such cases that it is customary to say that the transfer is stuck in the blockchain.

The problem of stuck transactions arises for one reason: the insufficient amount of the commission. The fact is that miners check transactions on a competitive basis: the higher the commission, the greater the likelihood of a transfer getting into the next block. If the fee is too low, miners may ignore the transfer for a long time, preferring high-fee transactions.

Modern wallets like Bitcoin Core or blockchain.info automatically offer the optimal fee. The problem is that the calculation algorithm is not perfect, and may not take into account powerful bursts of activity on the network. Even if the user has specified a recommended fee for their transaction, there is a risk of it getting stuck in the blockchain.

Blockchain transaction stuck: what to do

First, don't panic: a transaction cannot disappear on the blockchain forever. Depending on the network load, three scenarios are possible:

  • the transaction will enter a new block (get confirmation) within a few minutes or hours;
  • the confirmation process can be accelerated by one of the available methods;
  • if the network is highly congested and there is no way to speed up the transaction, the transfer will simply return to the sender's account within a few days.

The first thing to do is get information about the status of the transaction. To do this, go to the blockchain.info website and enter the transaction id (usually denoted as tx or txid) in the text field located in the upper right corner. The request is made by pressing the key on the keyboard (no need to press a button!).

Check the number of confirmations. The screenshot shows the case when the transaction hangs in the list of unconfirmed. If there is a specific number in place of the red field, there is nothing to worry about: the transfer is already included in the chain, and it is enough just to wait a few more tens of minutes.

In the column "Pay per byte" the size of the commission is indicated. This number will be useful for further assessment of the situation.

Next, you need to compare this commission with the current statistics of the Bitcoin network. You can do this by looking at the recommended fees on bitaps.com. If the fee per byte is approximately equal to or greater than the last number in the "Recommended fee" field, you can hope to confirm the transaction within 1 - 2 hours.

To confirm the information, you can use the Bitcoinfees service, which shows the number of unconfirmed transfers, dividing them by the size of the commission.

In the event that the transfer fee is significantly lower than the recommended one, it is advisable to use one of the methods to speed up transfers.

Ways to speed up transactions

If you have an unconfirmed transaction in the blockchain, what to do next and how to quickly “push” it? There are several ways to speed up transactions that can help in different situations. We list the main methods in order of increasing complexity.

Using mining pool accelerators

Mining pools that control a large share of the power in the Bitcoin system can help users speed up transactions. At the moment, the services of two large pools are of interest:

First of all, it is worth using the ViaBTC accelerator: it does not require registration, and all the user needs to do is enter the transaction id and captcha.

If after several attempts the transaction is still not confirmed, you should switch to using the Antpool accelerator. To register on the site, you need to specify your E-mail and password.

Bot accelerator in Telegram

Telegram bot @FastTXbot was created to automatically speed up transfers in the Bitcoin network. To use it, you must send the number of the hung transaction and wait for the result. In fact, the bot uses one of the previous methods - acceleration through Antpool. At the same time, the robot automatically does all the work for the user: just wait for the notification of the result of the procedure, which usually comes within 10 minutes.

This method does not always work for transfers that use a very low commission.

replace-by-fee

This feature allows you to create a copy of a stuck transaction with an increased commission. Today, replace-by-fee is supported by the popular Bitcoin Core and Electrum desktop wallets, as well as the GreenAddress online wallet. To use the function, you need to create a transfer containing exactly the same amount, while increasing the commission to an acceptable level. In addition, when sending a transaction, be sure to select the replace-by-fee option: otherwise, the funds will be sent twice. In Bitcoin Core, the required checkbox is hidden at the bottom of the send window.

CPFP (Child pays for parent)

This method is intended primarily for the recipient of a hung transaction, but in most cases it can also be used by the sender.

Without going into complex technical details, we can say that the method is based on the use of funds, the receipt of which has not yet been confirmed in the blockchain. Many mining pools are able to see the connection between an unconfirmed transfer and a new transaction that is linked to the previous address.

To use CPFP in Bitcoin Core, you need to go to the "Settings" - "Options" menu, select the "Wallet" tab and check the boxes, as shown in the screenshot.

After that, it remains to create a new transaction on the "Send" tab. By clicking on the "Inputs" button, you need to select the amount that was originally sent to the recipient's account. If the sender makes the acceleration, the “change” left after the transaction was sent should be chosen as the input. You can see the amount of change when viewing the transaction on the blockchain.info website.

When using CPFP, you should set a commission that is sufficient for two transactions at once. For example, with a recommended fee of 150 sat/B, a fee of 300 sat/B or higher should be set.

double spending

The most complex method available only to Bitcoin Core users. Recommended for advanced users as it requires command line skills and very careful handling of transaction inputs.

First you need to start the wallet from the command line with the -zapwallettxes parameter. In addition, modern versions of Bitcoin Core require the removal of the mempool.dat file from the program folder. After that, you can create a new transaction, which will exactly repeat the old one, except for the increased commission.

With double spending, an important nuance arises: at some point, the old transfer may also be confirmed, due to which the funds from the wallet will be debited twice. You can avoid this situation by specifying in the list of inputs for the new transaction at least one input that was used in the previous transaction.

Conclusion: How to Protect Against Unconfirmed Transactions

Practice shows that an unconfirmed transaction that has gone into the blockchain is not such a terrible phenomenon. In most cases, the situation can be corrected using one of the methods to speed up the check. However, if the speed and reliability of the transaction is critical, a high commission should be set. This is the only way to protect yourself from the risks associated with freezing translations.

  • News collections once a day to you by Email:
  • Collections of crypto news 1 time per day in Telegram: BitExpert
  • Insides, forecasts for discussing important topics in our Telegram chat: BitExpert Chat
  • The entire cryptocurrency news feed of the BitExpert magazine is in your Telegram: BitExpert LIVE

Found a mistake in the text? Select it and press CTRL+ENTER