How does Bitcoin work?

Today, only the laziest probably hasn’t heard of Bitcoin. We’ve heard about  it, but not many people have wondered how it “works” from the inside. A lot of people are satisfied with the knowledge, that is enough to start a wallet, receiving or trading cryptocurrency. It’s good if it works, but how it works is not really important. Nevertheless, it is necessary to know, because this information can remove a lot of questions and avoid problems with the use.

Once we have already considered what Bitcoin is, but we did not go into details. In this article, we will try to give an accessible and detailed description. So, how does bitcoin work?

How does Bitcoin work?

The Network

As many sources tell us, Bitcoin is a peer-to-peer payment system (network) where the unit of account is the cryptocurrency of the same name.

A peer-to-peer network is a computer network with the principle that all participants are equal. Each peer or node as they are called, functions as both a client and a server. This structure allows you to keep the network working with any number and any combination of available nodes (six of one, half a dozen of the other). All peers are participants in the network, so the main feature of the system is complete decentralization: there is no central administrator or server. Instead of the term “peer-to-peer” you can use definitions such as: decentralized, peer-to-peer or p2p (peer-to-peer) network.

Blockchain

The basis of Bitcoin, and incidentally the transactions “record book”  is a queue sequence (chain) of data sets (blocks), simply a blockchain. Each block of the Bitcoin network holds up to 1 MB of data, takes an average of 10 minutes to form, contains information about all the transactions placed in it and the information that links it to the previous block.

Each block in the blockchain is cryptographically interconnected with the previous and subsequent blocks. This interconnectivity protects the network from replacing or modifying existing blocks in the future, making the blockchain immutable and transactions irreversible.

How does bitcoin function?

To better understand the basics of the Bitcoin network, let’s introduce a hypothetical crypto-enthusiast Tony, who has a Bitcoin wallet with 2 BTC in the balance.  

Our Tony wishes to present 1 BTC to his friend Cindy. He needs her unique Bitcoin wallet address (the equivalent of a traditional bank account number) to do this. Tony enters this address into the appropriate field of his wallet, and in the other field he specifies the amount of the transfer – 1 BTC. Then Tony moves on to setting the amount of fee for the transaction, here we will stop in a little more detail.

Transactions and network load

As with any other payment system, Bitcoin has transactions that mean moving assets from one customer to another. Bitcoin transactions are subject to a fee, which is awarded to the miners who confirm those transactions. The higher the fee and the lower the network load, the faster the transactions are confirmed.

The network load is understood as the generalized number of participants sending their translations at the same moment.

In essence, the transaction is a set of information that indicates to network participants by which value decreased the balance of the sender, and by which value increased the balance of the recipient.

The Miners

For a transaction to be successful, it must be confirmed (validated) by the miner.

Now, the miners are specialized organizations that use powerful computing equipment (ASIC-farms) to check the transactions for “correctness”, collect these transactions into blocks, and the blocks are sequentially attached to each other. It takes an average of 10 minutes for the formation of 1 block by the network algorithm, during which the miners perform the same type of computational work every second in search of one single correct solution. It is not difficult, it is not a mathematical problem, but it is a very huge amount of work, which is hard to do with small computing power quickly and efficiently.

Miners get their BTC through mining. This reward consists of the fees that users paid for transactions and the brand new Bitcoins that the network itself generated when a new block was collected and validated from the transactions. New Bitcoins are a reward for miners for work done. Every 210,000 blocks there is a halving of the reward for miners for a block found.

Fees

Back to our crypto-enthusiast… When setting the transaction fee, Tony assumes that he has to pay a certain amount of satoshi – a fraction of a Bitcoin – for each byte of information. Since Tony does not know how much data his transaction will take, he decides to save money and set the price at 1 satoshi per byte.

For the readers, we will tell how the weight and value of Tony’s transaction will be formed. Those 2 BTC, which he has on the balance, appeared in the wallet for a reason. Tony earned it. 1 BTC was earned in 2017 and 1 BTC was obtained in 2018. Now he wants to send half to his girlfriend. His transaction, in addition to information about the number of coins, will include information about the addresses from which his coins came (called inputs), information about the addresses of recipients (called outputs), and information about his own address.

– Each input from which coins were received weighs ~148 bytes

– Each output to which the coins go is ~34 bytes

– The transaction itself weighs ~10 bytes, regardless of the number of addresses or transfer amount.

Let’s calculate: 148*2+34*2+10=374 bytes. Now we know that our “greedy” Tony will pay 374 satoshi for the transaction.

Surrender

You may ask, why do we multiply 34 (the weight of the recipient’s address) by 2 when there is only one recipient?

The matter is that when you send a part of your balance to someone, not a part but the whole amount goes from your balance, and after validation, i.e. including the transaction in the block, the balance (minus the network fee) comes back to your wallet. Therefore, in addition to the information about the recipient’s address, the transaction also includes information about the sender’s address, that is, your address. This return is called surrender. In browsers you can see this moment in the following form.

How does BTC work?

Mempool

After posting a paltry 374 satoshi fee, Tony confirms sending 1 BTC and waits for the miners to confirm the transaction. But miners are in no hurry to confirm it, the transaction ends up in the mempool – the book of the confirmation queue. Why? Because miners want to earn, not just exploit their equipment, because they only get 374 satoshi for confirming a Tony transaction. Especially for such very cheap transactions and there is a mempool with its sorting system.

First of all, miners “take” from the mempool lighter transactions with higher fees, because it is more profitable to confirm them and in the block they fit much more.

By the way, if the sender uses SegWit technology, its outgoing transactions weigh less than usual, which also attracts miners.

But don’t think that once in the mempool, the transaction is assigned a number. No. This queue is dynamic, with many transactions with different fees and weights every second, so our Tony’s transaction can wait a long time for its confirmation. And, most importantly, while it’s in the mempool, Tony can’t dispose of the change.

In fact, in such a situation, the sender’s balances are sort of “frozen”. It is this mechanism that protects the network from spam transactions, that is, situations where a spammer creates a lot of cheap sends, thereby overloading the network.

As long as Tony’s transaction is in the mempool, it is not considered confirmed and is not considered pending. At the same time, it can stay in the waiting for quite a long time – until it is confirmed or it is removed by validating nodes from the mempool. According to statistics, the maximum waiting period of the queueis ~ 3 days, but in moments of high network activity, this period may stretch to a week or longer.

You have to agree that nowadays the speed of transfers is one of the priority characteristics in the use of payment systems, and such queues are not very pleasant, to put it mildly.

There are many ways to push a transaction through a mempool. All of them are quite complicated to understand and implement for the average user, and some of them border on such a fraudulent way as “double-spending”. Nevertheless, there is one great feature that anyone can use, so let’s talk about it. It’s called Replace-by-Fee (RBF).

Replace-by-fee (RBF)

At the moment, not every Bitcoin wallet, especially an app, has this kind of advanced functionality.

RBF is to edit an existing transaction that is in a mempool. Editing means that the new transaction will use the same inputs as the previous transaction, but the fee will be changed. Such an edited transaction will not be considered “double-spending” since using the Replace-by-Fee option will avoid this. The Bitcoin network nodes treat the edited transaction as an old transaction, and it is moved in the mempool queue to more attractive positions for miners.

Thus, if the fee is too low, it is normal practice to increase it if you need to speed up a transaction. Do not neglect the RBF feature and enable it before making transactions, it will allow you to hedge in case the transfer will be delayed in the queue.  

Confirmation

Tony realized in time that because of his greed Cindy might not get the gift at all, so he used the RBF feature in time and increased the fee. The transaction, as expected, became more attractive to the miners, and they included it in the next block – the transaction received 1 confirmation. With each subsequent block found, this transaction will receive 1 additional confirmation. When there are 6 or more such confirmations, the transaction is considered confirmed.

Transaction rate

Talking about the transfer rate, we should understand that there is no clear value. But let’s calculate it based on Tony’s transaction and the data we have.

Сondition:

  • the size of one block is ~1 MB (1’048’576 bytes);

each block filled with transactions is generated every ~10 minutes (600 seconds);

  • our Tony’s transaction has a weight of 374 bytes.

Solution:

1’048’576 bytes: 374 bytes = 2803.6 transactions in one ten-minute block.

2803.6 transactions: 600 seconds = 4.6 transactions per second

Answer: every second the miners confirm ~5 transactions like Tony’s.

Of course, these are all approximate values, as the processing rate changes every second and depends on many factors. The main thing is that your transaction should be taken from the mempool as soon as possible, and if this happens, your transfer will reach the recipient within 1-600 seconds.

In fact, once a transaction is included in a block, the recipient can not only see the funds on his balance, but also, under certain conditions, dispose of them. Fast, isn’t it?

That’s right, but what about the 6 confirmations rule? Six blocks, 10 minutes each and one hour in total…

Bitcoin clients

It’s all about the software that cryptocurrency holders use. Classic Bitcoin wallets will display a transaction as “unconfirmed” until it receives six confirmations (blocks).

Services that accept BTC as local payment can put their limits on the number of blocks needed for confirmation (7, 10, 45, 214 …).

BTC, which are generated by the network as a reward for finding a block, can only be used after 100 confirmations, but classic Bitcoin wallets will not display the coins received for finding a block until 120 confirmations have been obtained.

The number “6” was not chosen by chance. With each new block, the transaction becomes less and less vulnerable to spoofing or modification. To do something with an already confirmed transaction in a block, you would have to “rewrite” all subsequent blocks, and that requires very huge computing power and investing millions of dollars. And the more confirmations a transaction receives, the more secure it will be.

But in a blockchain as powerful and stable as Bitcoin, this is more a recipient requirement of the transaction than a protocol rule.

That’s why our Cindy and Tony use a very advanced and functional Bitcoin wallet, rather than the classic one. Because of the unconfirmed transactions feature activated in it, Tony’s outgoing transaction, once included in the block, will immediately show up in Cindy’s wallet. Tony will be able to dispose of the change immediately, and Cindy will be able to dispose of the gift she received.

Complex “SegWit + RBF + use of unconfirmed transactions” allows to get the maximum rate from the BTC blockchain, which is important for non-castodial services.

Anticipating your question about what Bitcoin wallet Tony and Cindy use, the answer is Trustee Wallet.

Conclusion

Bitcoin is very complex and very technological. In one article it is impossible to describe all the details and nuances of Bitcoin function, but we did tell you about its basics. Now you know what complex trips your coins make within just one single transaction between two wallets, and the rate of it. How and in which way the network protects itself from hacking, spam attacks, fraud, or rash actions by dummies.

The sustainability of Bitcoin depends equally on miners and ordinary users, and the more participants there are in the network, the more secure and decentralized it will become.

If you still have questions or have suggestions, we will be glad to see it in our Telegram chat!

Download Trustee - single multi-currency wallet for crypto
Share

Leave a Reply

Your email address will not be published. Required fields are marked *