Bitcoin Forum

Other => Beginners & Help => Topic started by: monerama on July 24, 2019, 01:30:07 PM



Title: Relationship between utxo and tx fee
Post by: monerama on July 24, 2019, 01:30:07 PM
Hi, I would like to ask:

Variant 1: I have one address with two utxo.

Variant 2: I have two addresses, each one with one utxo.

I want to spend these two utxos to one final address. Which transaction (1 or 2) will have lower tx fee?


Title: Re: Relationship between utxo and tx fee
Post by: Little Mouse on July 24, 2019, 01:53:39 PM
Both are same because your input will be the same here. In both case, input is 2, So, fee will not have any affect. I might be wrong, let's see an answer from SR member.


Title: Re: Relationship between utxo and tx fee
Post by: bitmover on July 24, 2019, 05:10:31 PM
Both are same because your input will be the same here. In both case, input is 2, So, fee will not have any affect. I might be wrong, let's see an answer from SR member.

You are right.

You can estimate your fees here (https://www.buybitcoinworldwide.com/fee-calculator/), according to how many inputs and outputs you have in a transaction.

Number of addresses doesn't matter, as long as they are in the same wallet (i.e. both private keys in the same wallet). If they are on different wallets you need to make 2 transactions., which will be more expensive.


Title: Re: Relationship between utxo and tx fee
Post by: BitMaxz on July 24, 2019, 05:18:46 PM
UTXO means "Unspent Transaction Output"  these are outputs that you can able to spend.

The variant 2 will count as two UTXO so they are both the same. The transaction fee will depend on your transaction size and the fee you set.

If you have a higher amount of UTXO(Higher Transaction size) in the transaction even if they are on different address the calculation of the fees will depend on the fee you set and the transaction size.

Sample you have 5 UTXO in one address/2 UTXO and 3 UTXO in your two addresses it will count as one if you spend them(Both will have the same size).
Sample Transaction size is 500bytes and the fee you set is 20sat/byte. (500x20=10,000) so your fee will be 10k sat.

We can set the fee to lower like 1sat/byte but the problem with lower fees it will take time to be process before it confirms.

Edit:
I forgot to mention that if you use segwit address it will decrease your transaction size and fee. So I suggest you use segwit address instead if you care about the fee.


Title: Re: Relationship between utxo and tx fee
Post by: odolvlobo on July 25, 2019, 12:05:07 AM
When you spend bitcoins, the transaction references only their UTXOs. Their addresses are not included in the transaction.


Title: Re: Relationship between utxo and tx fee
Post by: pooya87 on July 25, 2019, 04:12:19 AM
I forgot to mention that if you use segwit address it will decrease your transaction size and fee. So I suggest you use segwit address instead if you care about the fee.

your transaction "size" in bytes is actually bigger when you use SegWit, it is extra big if you use nested SegWit (SegWit addresses that start with 3) because SegWit transactions have overhead. the reason why you pay lesser fees compared to legacy transactions is the way transaction size or rather weight/virtual size is used for fee payment instead.


Title: Re: Relationship between utxo and tx fee
Post by: monerama on July 25, 2019, 07:52:36 AM
Thanks for responses. So there is no point of reusing addresses. I always thought that one "donation" address can somehow consolidate multiple utxo with lower fee. I was wrong. This also mean that dust utxo are hardly spendable. Tx fee of such transaction from many dust utxo will be higher than combined dust utxo value.


Title: Re: Relationship between utxo and tx fee
Post by: Pffrt on July 25, 2019, 08:03:04 AM
Thanks for responses. So there is no point of reusing addresses. I always thought that one "donation" address can somehow consolidate multiple utxo with lower fee. I was wrong. This also mean that dust utxo are hardly spendable. Tx fee of such transaction from many dust utxo will be higher than combined dust utxo value.
Any amount of fewer than 300 satoshis (probably) will be a loss to have transacted. However, you can consolidate transaction with 1 satoshi per byte which will not be much costly, assuming that donation is not less than 500 satoshi (which barely can be true.)


Title: Re: Relationship between utxo and tx fee
Post by: o_e_l_e_o on July 25, 2019, 08:50:49 AM
So there is no point of reusing addresses.
Correct. Address reuse is also generally discouraged as it reduces your privacy, by allowing someone to link you to many separate transactions.

This also mean that dust utxo are hardly spendable. Tx fee of such transaction from many dust utxo will be higher than combined dust utxo value.
Also correct. The default dustrelayfee is 3 satoshi/byte. With a typical non-segwit 148 byte input and 34 bytes output, this means the minimum spend is ((148+34)*3) = 546 satoshi. If you find yourself with many small UTXOs, then the best option is to consolidate them all together in to one UTXO with the lowest possible fee of 1 sat/byte. Loyce has a thread explaining this here: https://bitcointalk.org/index.php?topic=2848987.0

Dust is explained within the bitcoin code here: https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp (lines 16 - 29).


Title: Re: Relationship between utxo and tx fee
Post by: pooya87 on July 26, 2019, 05:24:39 AM
a typical non-segwit 148 byte input and 34 bytes output,
these numbers seem a bit weird since you are also including the "transaction" fields such as version (4 bytes), txincout (1 byte), txoutcount (1 byte), locktime (4bytes) as the input/output sizes. the input/output size itself is smaller.

Quote
https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.cpp (lines 16 - 29).
you can always click on the line numbers, hold shift click on second number to get the link. also add commit to it.
https://github.com/bitcoin/bitcoin/blob/a54a12046e98c57512715041d30ecf2f0ab8f6dd/src/policy/policy.cpp#L16-L29