Author

Topic: TXs that include unnecessary UTXOs (Read 244 times)

staff
Activity: 3458
Merit: 6793
Just writing some code
October 31, 2019, 04:56:40 PM
#7
As mentioned, it all comes down to the coin selection algorithm. There are many different coin selection algorithms in use by a number of different wallets which optimize for different parameters. In general, coin selection is a hard problem to solve well.

In coin selection, there are a number of things that need to be considered. First and foremost, the amount being selected. Then it also needs to consider the fee and whether to optimize for a lower transaction. While it may seem obvious that you should optimize for a lower transaction fee, the behavior of the coin selection algorithm now effects how it performs in the future. It could work "well" in the short term be not in the long term. The algorithm also has to consider how large the change output will be, if it's too small, it may be unspendable in the future (it could be considered dust).

So for your specific question, it all really depends on the coin selection algorithm in use and what it is optimizing for. And some algorithms are implemented not because they are good, but because they are easy.

For example, your wallet could be using a first in, first out strategy (FIFO). This means the oldest coins are chosen first. So what could have happened is that 0.2 was first, and that's not enough for 0.6. Then it chooses the next oldest coin, which would be 0.8. It's now over the target value, and so 0.2 and 0.8 are the coins selected. A couple of wallets do actually use this naive strategy, and that could be why you see this behavior.

If you want to read an actual scientific analysis of coin selection strategies and how they perform, I would suggest that you read Mark Erhardt's master's thesis on this subject: http://murch.one/wp-content/uploads/2016/11/erhardt2016coinselection.pdf
HCP
legendary
Activity: 2086
Merit: 4361
October 31, 2019, 12:55:11 PM
#6
It really comes down to a wallets "UTXO picker algorithm" and/or if the user is implementing manual coin-control.

Some wallets just use "oldest UTXO(s) first"... some use "least number of UTXO(s) required)" to keep transaction size to a minimum... some do all sorts of weird things in the name of "privacy"... some just include ALL UTXOs in a wallet in every transaction.

Then you have wallets like Bitcoin Core and Electrum that provide "coin-control" features that enable the user to pick and choose which UTXOs they want to include.

As ETFBitcoin stated above, without knowing the specific wallet you experienced this with, it is difficult to state with any confidence the reason why you witnessed this behaviour.
legendary
Activity: 2534
Merit: 6080
Self-proclaimed Genius
October 19, 2019, 08:27:07 PM
#5
Was your example based from your experience?
Because usually, that only happens when the remaining amount from one input isn't enough for the fee.
But the example wont fall to that category, for a 0.08 UTXO & 0.06 to send, the change is quite too high for the tx fee.

If it's something like 0.005 UTXO and 0.00495 to send, the wallet might include one more input to the transaction.
legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
October 19, 2019, 02:09:39 PM
#4
Without knowing the wallet which used to create the transaction, we only can make educated guess.

IMO it's not privacy feature because :
1. If the output have "neat" number (such as 0.01BTC), while the change have "random" number (such as 0.039653241BTC), then it's easy to guess to guess which one is output and which one is change.
2. Few wallet applies multiple change address as method to improve user's privacy
legendary
Activity: 2702
Merit: 3045
Top Crypto Casino
October 19, 2019, 11:21:38 AM
#3
You should use a wallet that have coin control feature.
Some wallets, by default, will use the oldest UTXOs. If the oldest is smaller than the amount you want to spend then it will add the next one and so on.
Other wallets will pick UTXOs randomly for more privacy.
copper member
Activity: 2856
Merit: 3071
https://bit.ly/387FXHi lightning theory
October 19, 2019, 10:49:53 AM
#2
It's to save money on fees. Most wallets have an option somewhere that let's you decide whether to favour lower fees or privacy.

It always a good idea to consolidate all of your nonprivate inputs while you're not in a rush too... At the same time, most wallets let you decide which inputs you want to spend so you could spend just the 0.08 and all the other utxos will remain the same.

I think this also goes to reducing the size of the chain state for full nodes too as there's less data to hold if you have 2 utxos from 2-5+
newbie
Activity: 1
Merit: 2
October 19, 2019, 10:40:29 AM
#1
I'm hoping someone here can help explain why certain transactions seem to include unnecessary UTXO inputs. eg, if I have a UTXO of 0.08 BTC, and am making a purchase of 0.06 btc, I should not need any other inputs; it should be a single 0.08 BTC input with a 0.06 BTC output and 0.02 BTC change.  However, I will frequently see another input added, such that the amount of change frequently ends up larger than the size of the purchase.  Is there a reason this would happen?  All I can imagine is that it is done as some kind of camouflage (the change ends up being the larger amount, and so someone looking at it might not realize it is actually the change), or as a defense against dust/creating change addresses with dust in them.  Can anyone confirm, or provide a better explanation?  Thanks!
Jump to: