electrum icon indicating copy to clipboard operation
electrum copied to clipboard

Cannot estimate fees without recipient address

Open gasull opened this issue 4 months ago • 5 comments

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.

gasull avatar Mar 20 '24 04:03 gasull

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):

  • p2pkh ("1" address) is 25 bytes,
  • p2sh ("3" address) is 23 bytes,
  • p2wpkh is 22 bytes,
  • p2wsh is 35 bytes,
  • p2tr is 35 bytes

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.

SomberNight avatar Mar 20 '24 06:03 SomberNight

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.

gasull avatar Mar 20 '24 07:03 gasull

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?

SomberNight avatar Mar 20 '24 07:03 SomberNight

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.

gasull avatar Mar 20 '24 10:03 gasull

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.

nostitos avatar Mar 21 '24 18:03 nostitos