Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative effective value UTXOs. Should CoinChooser include them? Should "send max" include them? #5433

Open
SomberNight opened this issue Jun 17, 2019 · 3 comments
Labels
enhancement ✨ topic-wallet 👛 related to wallet.py, or maybe address_synchronizer.py/coinchooser.py

Comments

@SomberNight
Copy link
Member

SomberNight commented Jun 17, 2019

Let's define a UTXO as having "negative effective value" if it costs more to include in a transaction than its value at the requested feerate. A related concept is dust; which I think is a strict subset where the requested feerate is the min relayfee.
How hard should the wallet logic try not to spend these?


Problem 1.
User is constructing a new transaction and clicks "Max" (as value to send). Should the negative effective value UTXOs be included? Several points to consider.

  1. Micro-economically for the user it makes more sense to exclude the small UTXOs as then a larger value output can be created. Is "Max" supposed to maximise the output value?
  2. When the user clicks "Max" they might be abandoning that wallet forever, so the leftover UTXOs might remain in full nodes' UTXO set forever.
  3. If these UTXOs are left behind that probably increases the number of support requests :P Note that after sending "Max" in this case, the user would still be shown a positive balance for the wallet...
  4. If "Max" tries to include all UTXOs, then it might not be possible to create a transaction at all at a given high feerate, potentially confusing the user. (consider wallet with many small value UTXOs but also some larger ones)

Problem 2.
The CoinChooser atm has a policy to spend all UTXOs associated with an address if it spends any. What if negative and positive effective value UTXOs are both associated with an address?

First, if any coin is spent from a user address, all coins are.
Compared to spending from other addresses to make up an amount, this reduces
information leakage about sender holdings. It also helps to
reduce blockchain UTXO bloat, and reduce future privacy loss that
would come from reusing that address' remaining UTXOs.


At the moment, the codebase ignores this issue.
"Send max" selects all UTXOs as inputs.
Also, the CoinChooser in some cases assumes that negative effective value UTXOs don't exists. If you specify a high feerate (say 5000+ sat/byte), it will often bail out and incorrectly tell the user they have insufficient funds to create a transaction.

@SomberNight SomberNight added enhancement ✨ topic-wallet 👛 related to wallet.py, or maybe address_synchronizer.py/coinchooser.py labels Jun 17, 2019
@ziggamon
Copy link

I think privacy should be the main principle here.

I think if it's associated with an address that has more utxos it should be included as to not risk dust for future analysis. In that case the privacy win is worth a slight cost.

If it's just a small utxo not associated with anything then the wallet can leave it IMO. There may be a time when it becomes economical to spend the output.
It may also be useful to suggest the user to use a lower fee to be able to spend that coin. It might be that they aren't in a hurry.

I would also add that ideally the wallet should try hard to prevent such utxos from forming in the first place. That's probably a separate ticket, but there are ways of offering customers to round up fees or receiving amounts to avoid small change being left. Samourai does some stuff in that regard.

@jlopp
Copy link

jlopp commented Jun 19, 2019

In my opinion "send max" is a "wallet sweep" operation which is a special case for wallets. I think the conservative assumption that developers should make is that the wallet may very well be abandoned after this transaction. As such, I'd hope that we'd be good stewards of the UTXO set and not leave any outputs behind.

During normal operation (not sweeping the wallet) the coin selector should avoid spending uneconomic UTXOs; the user can always consolidate them later.

SomberNight added a commit that referenced this issue Jun 20, 2019
Calculate the effective value of buckets, and filter <0 out.
Note that the filtering is done on the buckets, not per-coin.
This should better preserve the user's privacy in certain cases.

When the user "sends Max", as before, all UTXOs are selected,
even if they are not economical to spend.

see #5433
@ecdsa
Copy link
Member

ecdsa commented Jun 26, 2019

I agree with @jlopp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ topic-wallet 👛 related to wallet.py, or maybe address_synchronizer.py/coinchooser.py
Projects
None yet
Development

No branches or pull requests

4 participants