The algorithm is “selection of coins” of the blockchain of Bitcoin will soon receive an important update. Code, deciding which data to participate in the formation transactions will be optimized to reduce fees for remittances.
The term “selection of coins” refers to the algorithm that decides which bits of data will combine to create the end-user transaction. In fact, the selection code of the coin replicates the process of providing, say, 10 dollars to the cashier for the goods, the cost of 7 dollars, and the consumer receives $ 3 back.
If it does not seem complicated, remember that Bitcoin is experimental software, and that its function is not completely optimized. What’s worse, this feature directly affects the cost of the user.
“The selection algorithm of coins in Bitcoin Core, in fact, you need to seriously refined, especially in relation to transactional commissions. It is inefficient and to calculate the required number of charges it creates a weird cycle,” said one of the developers of Bitcoin Core Andrew Chow
Mark Erhardt, an engineer of the client for the cryptocurrency wallet BitGo, agrees that the algorithm is “confused.”
As explained Erhardt, the current algorithm is almost always automatically creates “outputs for delivery” in which there is no need and it takes up the space of blocks. For example, to transmit the same 0.2 BTC, you could use two segments of data, each of which holds for 0.1 BTC.
“Nobody wants the transaction was milled to dust,” says Erhardt, meaning by “dust” the parts of Bitcoin that are just impractical to spend because the transaction fee exceeds their cost.
Thus, the developers are working on a new algorithm called “branch and bound” or “BnB”, which more efficiently combines data that leads to a small scale and lower transaction fees.
Erhardt suggested several optimizations almost two years ago, while Chow became the first developer who wrote this code change.
The last change was ready to integrate the most popular software implementation of Bitcoin, Bitcoin Core, and therefore it was included in the codebase. Good news for users, the feature should be available for widespread use with the release of the 17th version of the software next year.
On the way back, as mentioned above, every Bitcoin transaction that sends the user consists of separate smaller parts of coins.
Let’s say you have one Bitcoin in your wallet. This Bitcoin is not a single piece of data. It often consists of several segments assembled together. You can have one, two or transactional dozens of small fragments, each of which is called “unspent transaction outputs” (UTXO).
For example, tied to your address bitcoin wallet can store one piece of data worth of 0.1 BTC, the other is 0.3 BTC, the other is 0.1 BTC and the last price of 0.5 BTC, that is a Bitcoin.
So, when sending 0.2 BTC program can decide to take part of the data constituting 0.3 BTC and send them to two choices: the amount and the recipient’s balance for the sender. The algorithm can also create a few “spare” outputs (UTXO) for the section of the transaction between them, while using them only partially.
According to the developers, this algorithm is not so good at selection the method of selection of coins for transactions.
Erhardt explained that the algorithm almost always automatically creates “outputs”, which often is not necessary. In the above example, the algorithm can avoid this by choosing two pieces of data at 0.1 BTC, and do not send “change” back.
New BnB algorithm tries to eliminate as many options with which you want to send the change.
“It helps to reduce the number of UTXO,” said Chow. “In addition, the transaction with an exact match coin base and the desired amount will be less than those that involve change. This will allow the user to save on transaction fees and to free up a few bytes of space in the blockchain “
Already there is evidence that the new algorithm works as promised. The simulation Erhardt found that he was able to get rid of unnecessary data, approximately 40 percent of transactions. In addition to all the benefits, change the code also helps developers because new algorithm is much easier to understand from a technical point of view.
However, Chou and the other developers plan to use the algorithm by adding the so-called “simple random selection”.
When the BnB algorithm, after analyzing all the UTXO user simply can not avoid the issue of delivery, he returns to the original process of selection of coins. But simple random selection algorithm will use a random unspent outputs random method, until you reach the required amount of money.
Interestingly, the developers find a random selection of coins a better option than polling algorithm Bitcoin Core used today.
It is the culmination of years of work, but, according to Erhardt, the process couldn’t be faster. Selection of coins – “sensitive part” of the code and its changes will have “global consequences”
To date, we have laid a solid Foundation for further changes,” said Erhardt.