Bitcoin Forum
May 07, 2024, 02:32:28 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Electrum default coin selection  (Read 208 times)
hosseinimr93 (OP)
Legendary
*
Online Online

Activity: 2394
Merit: 5235



View Profile
May 28, 2021, 04:39:51 PM
Last edit: May 28, 2021, 05:00:31 PM by hosseinimr93
Merited by o_e_l_e_o (2), Pmalek (1)
 #1

Newbies usually don't have any information about coin control and how extra inputs can make them waste money on transactions fee. If the coins aren't selected by the user manually, they will be selected by electrum automatically.

The problem is that electrum selects the UTXOs based on balance of addresses, not UTXOs amounts.

Let's say I have 1.5  BTC in my wallet. UTXO A is in address A and is worth 1 BTC. UTXO B is in address B and is worth 0.5 BTC. If I want to spend 0.75 BTC, electrum selects the UTXO A and doesn't touch UTXO B. Everything is fine here.

I imported two random addresses into a watch-only wallet.
bc1qnntxhtfa7446euhyx9yxygwjql84rrpsk52c9y and 1KVkFrQyx1C8gxCz461o9ChZjEEDDAbLxB have received 0.515 BTC and 0.043 BTC in single transactions consecutively.
The image below has been taken from "Coins" tab.



Now, I am spending 0.5 BTC. As you see in the image below, electrum is only using bc1qnntxhtfa7446euhyx9yxygwjql84rrpsk52c9y and doesn't use 1KVkFrQyx1C8gxCz461o9ChZjEEDDAbLxB. It's 100% OK.




The problem is when the user has received multiple UTXOs in a single address.
I imported 1ChancecoinXXXXXXXXXXXXXXXXXZELUFD into a watch-only wallet.
The address has received 480 BTC in 267 transactions.
The image below has been taken from "Coins" tab.



Now, I am spending 0.1 BTC.
As displayed in the image below, electrum is using all the 267 UTXOs and makes the user waste a big money on transaction fee.
This transaction could be made with only 1 input.




Have developers designed the default coin selection in this way for a reason? Or you think they should change it in the next updates?

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
1715049148
Hero Member
*
Offline Offline

Posts: 1715049148

View Profile Personal Message (Offline)

Ignore
1715049148
Reply with quote  #2

1715049148
Report to moderator
Remember that Bitcoin is still beta software. Don't put all of your money into BTC!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715049148
Hero Member
*
Offline Offline

Posts: 1715049148

View Profile Personal Message (Offline)

Ignore
1715049148
Reply with quote  #2

1715049148
Report to moderator
1715049148
Hero Member
*
Offline Offline

Posts: 1715049148

View Profile Personal Message (Offline)

Ignore
1715049148
Reply with quote  #2

1715049148
Report to moderator
ranochigo
Legendary
*
Offline Offline

Activity: 2954
Merit: 4166


View Profile
May 28, 2021, 04:54:06 PM
Merited by nc50lc (1), hosseinimr93 (1)
 #2

The way Electrum functions is that it primarily tries to group the UTXOs into "buckets" with each bucket containing UTXOs associated with the same address. If any coins is being spent from a specific bucket (or address) in this case, then Electrum attempts to spend all of the UTXOs that are grouped into the same bucket as a way of consolidating and avoiding privacy leakage. A second bucket or more buckets would be selected if and only if a single bucket cannot fulfill your requirement. You have to manually select the inputs to spend via coin chooser if you want to spend specific inputs or avoid spending all of them.

With your example, all of the inputs are grouped into the same bucket as they are all associated with the same address and also all confirmed. Electrum thus selects to spend that bucket and it has to spend all of the UTXOs.

Electrum tries to maximize the user's privacy in this case. There isn't anyway to disable this kind of coin selection AFAIK. Interesting to note that other than this, Electrum also tries to only spend coins from the same bucket or select buckets which would produce the change that has the closest value to the recipient amount.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
BitMaxz
Legendary
*
Offline Offline

Activity: 3248
Merit: 2965


Block halving is coming.


View Profile WWW
May 28, 2021, 05:08:41 PM
 #3

You can manually choose what you want to spend on the coins tab if you want to reduce the fee but how about if you are going to spend them all in the future?

You still have many outputs so you will still pay a huge fee in the future if you are going to spend them all in one transaction.

They set Electrum to merge all UTXO by default and sent it to address destination and change address but if you don't want to pay a large fee always make a transaction when the network is not congested.

And I think they shouldn't need to change it in the future it depends on users if how they want to make a transaction on Electrum they can enable the coins tab and spend what coins they want to spend.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
hugeblack
Legendary
*
Offline Offline

Activity: 2506
Merit: 3647


Buy/Sell crypto at BestChange


View Profile WWW
May 28, 2021, 08:56:33 PM
 #4

The main advantage of Coin Control is not saving money by suggesting fewer inputs but rather increasing privacy.
Sometimes you get a small sums (dust transaction) which with abuse may cause all addresses associated with your account to be disclosed.
If you do not know how to control your currencies, you may end up revealing all the addresses that the wallet initiates.

.BEST..CHANGE.███████████████
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
███████████████
..BUY/ SELL CRYPTO..
ranochigo
Legendary
*
Offline Offline

Activity: 2954
Merit: 4166


View Profile
May 29, 2021, 04:20:51 AM
 #5

You can manually choose what you want to spend on the coins tab if you want to reduce the fee but how about if you are going to spend them all in the future?

You still have many outputs so you will still pay a huge fee in the future if you are going to spend them all in one transaction.

They set Electrum to merge all UTXO by default and sent it to address destination and change address but if you don't want to pay a large fee always make a transaction when the network is not congested.
It isn't always an option for users to only use Electrum when the network is not congested. Users have to actively use coin control to change their outputs. Consolidation transactions should only be done when it is not congested but normal transactions should not be treated as consolidation transactions. It is unnecessary and incurs too much fees.

In normal usage as intended, the user won't run into such issues. Electrum tries to get their users to use different addresses from each transactions. This makes it such that each bucket only has 1 UTXO as the address is only used once. Hence, the transaction would end up being the most efficient. If the user reuses their addresses, this won't hold true and the user has to adjust it manually.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
o_e_l_e_o
In memoriam
Legendary
*
Offline Offline

Activity: 2268
Merit: 18510


View Profile
May 29, 2021, 08:17:16 AM
Merited by hosseinimr93 (1), DireWolfM14 (1)
 #6

You need to consider the alternative.

If someone isn't going to use coin control, then the two options are for Electrum either to use all the inputs on a given address to fund a transaction (as it does currently), or to use the bare minimum number of inputs to fund a transaction. If it only uses the minimum number of inputs and no more, then pretty much every transaction the user makes will create another change output, often for a small amount. Over time, they will end up with even more inputs that need spent, even more being paid in fees, and linking multiple transactions together because of multiple small change outputs that need consolidated, thereby decreasing their privacy.

The best option is obviously to use coin control and consolidate when fees are low, but in the absence of that, then Electrum's current behavior is the better of the remaining options.
khaled0111
Legendary
*
Offline Offline

Activity: 2520
Merit: 2853


Top Crypto Casino


View Profile WWW
May 30, 2021, 06:57:02 PM
Merited by hosseinimr93 (1)
 #7

Electrum old versions used to let the user choose between priority and privacy coin selection. When you select priority, Electrum will use the oldest utxos as inputs. Not sure why this feature was removed!
Although the current algorithm might be good for users privacy as it ensures an address can't be reused, it surely will make them lose a lot of money on fees.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
hosseinimr93 (OP)
Legendary
*
Online Online

Activity: 2394
Merit: 5235



View Profile
May 30, 2021, 07:25:49 PM
Last edit: May 31, 2021, 05:39:53 AM by hosseinimr93
 #8

Electrum old versions used to let the user choose between priority and privacy coin selection. When you select priority, Electrum will use the oldest utxos as inputs. Not sure why this feature was removed!
I didn't know this. Thanks for the info.
I just made a search and found the following image from an old post made by TryNinja.



So, they removed the choosing UTXOs selection method option and electrum is now using the privacy method as the default coin selection method.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
ranochigo
Legendary
*
Offline Offline

Activity: 2954
Merit: 4166


View Profile
May 30, 2021, 11:20:51 PM
 #9

Electrum old versions used to let the user choose between priority and privacy coin selection. When you select priority, Electrum will use the oldest utxos as inputs. Not sure why this feature was removed!
It was there when Bitcoin Core still considered transaction priority in their relaying and miners still mined free transaction. It was removed once Bitcoin Core removed the logic as well. Don't see much point in keeping this as spending coins in chronological order is quite detrimental to the user's privacy as well.

Might seem paradoxical since the client leaks so much privacy but it's better than them not doing anything about it.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
Pmalek
Legendary
*
Offline Offline

Activity: 2758
Merit: 7135



View Profile
May 31, 2021, 12:41:25 PM
 #10

I had no idea that Electrum does what hosseinimr93 mentioned by default. ranochigo's explanation about the buckets system makes sense, but being overconcerned with privacy can certainly cause you to lose a lot of money. Although it's the user's job to learn how to properly send and receive bitcoin, I still think users should be informed that they are about to spend an unnecessary amount of UTXOs for a transaction that can be spent by using only one input that is big enough. Some sort of pop-up or system notification would be nice.  

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
o_e_l_e_o
In memoriam
Legendary
*
Offline Offline

Activity: 2268
Merit: 18510


View Profile
May 31, 2021, 12:52:12 PM
Last edit: May 31, 2021, 01:46:27 PM by o_e_l_e_o
Merited by ranochigo (1), hosseinimr93 (1)
 #11

ranochigo's explanation about the buckets system makes sense, but being overconcerned with privacy can certainly cause you to lose a lot of money.
But again, consider the alternative. Electrum has no way of knowing if the user is going to choose to pay 1 sat/vbyte or 100 sat/vbyte, or if their next transaction is going to pay 1 sat/vbyte or 100 sat/vbyte, or any subsequent transaction after that. It simply has to ignore the fees and consolidate whatever it can, whenever it can, without compromising privacy by linking different addresses together. Otherwise, a user is going to be left with dozens of small inputs across different addresses, plus dozens of small change outputs across different addresses, and end up paying more in fees in the long run, as well as compromising their privacy.

Some sort of pop-up or system notification would be nice.
I don't think it would solve the issue. A simple pop up saying "Do you want to save fees by using fewer inputs?" will result in everyone who doesn't understand coin control clicking on "Yes". No one is not going to want to save on fees. Which just leads us back down the route of loads of small inputs across multiple addresses.

If the user doesn't want to use coin control, then Electrum is going to have to consolidate all their inputs for them at some point. Better to do it on a per-transaction and per-address basis when privacy can be maintained, rather than in one big transaction using every address in their wallet.
ranochigo
Legendary
*
Offline Offline

Activity: 2954
Merit: 4166


View Profile
May 31, 2021, 12:54:17 PM
 #12

Although it's the user's job to learn how to properly send and receive bitcoin, I still think users should be informed that they are about to spend an unnecessary amount of UTXOs for a transaction that can be spent by using only one input that is big enough. Some sort of pop-up or system notification would be nice.  
Electrum does give a warning if the fees is outrageously large when compared to the amount that is supposed to be sent. That should be sufficient.

If the transaction size is too big, and the user ends up paying too much, then the user will notice and adjust either their fees or their inputs accordingly. If it doesn't trigger the warning, then the fees should be within an acceptable amount and since it is a consolidation transaction in a sense, it is still beneficial to the user as it can potentially save more on the fees in the long run. While there is nothing wrong with a dialog or a popup, users tend to be quite myopic and won't see the point behind specific client behavior such as this.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!