spesmilo / electrum

Electrum Bitcoin Wallet
https://electrum.org
MIT License
7.38k stars 3.07k forks source link

Cannot estimate fees without recipient address #8965

Open gasull opened 6 months ago

gasull commented 6 months ago

Electrum doesn't allow fee estimation without having a recipient address.

At the same time, exchanges like https://Trocador.app and https://StealthiEX.io don't give you the recipient address until you input the exact amount you're sending.

But if I want to empty a UTXO, I don't know the exact amount until I have the fee estimation.

This is a chicken and egg problem.

This makes very difficult to empty UTXOs, leaving a lot of dust behind.

The solution is just to allow fee estimation without the address, assuming there is only one recipient address.

SomberNight commented 6 months ago

Different type of recipient addresses map to different types of output scripts, which go into the transaction and have different byte sizes.

Something along these lines (haven't double-checked exact values):

In old versions of Electrum, years ago, we used to use a dummy "1" address in your use case (e.g. when clicking "Max"), however that is no longer practical. As you can see, without knowing the type of the output, exact amounts are not known ahead of time.

gasull commented 6 months ago

Electrum could use a sensible default. E.g. what's the most common type of address nowadays? Taproot?

Then the estimation fee could say in a tooltip "assuming p2tr type of address".

This is a UX issue, and if this cannot be solved for all users, it should be solved at least for most users.

SomberNight commented 6 months ago

I highly doubt it is taproot. Are the exchanges you mentioned using such addresses?

What happens in your example if we guess wrong and the amount will be a few hundred sats off?

gasull commented 6 months ago

If after entering the recipient address the fee is changed, there should be a warning, specially if this changes the amount sent after subtracting the fee.

And the new fee estimation can be left there even if the recipient address is removed (because the user is trying to get the new recipient address given by the exchange)

What doesn't make sense is having to fidget on both Electrum and the exchange, trying to send everything without leaving dust behind, trying back and forth several times.

nostitos commented 6 months ago

it should be solved at least for most users

I think it's a weird exchange's problem. Just use a similar address type and the difference in fees will be microscopic.