Hey #[0], I have a question that you might be able to help me with. When you send multiple inputs in a transaction, the size of the transaction increases and so does the miner fee. In my research on how the fee changes depending on the size and inputs of the tx, I found several calculators that calculate the size of a tx based on the number of inputs and outputs. For a hypothetical tx with three bech32 inputs and one bech32 output + fee, Sparrow Wallet told me that the tx size was about 150 vB. The calculators all came up with just under 280 vB. Why the discrepancy? Do the calculators include the witness data?

Reply to this note

Please Login to reply.

Discussion

Hey #[1]​! I’m certainly not an expert but I found these two good posts on how to calculate virtual size for a transaction and did it for the situation you mentioned.

https://bitcoin.stackexchange.com/questions/92689/how-is-the-size-of-a-bitcoin-transaction-calculated

https://bitcoin.stackexchange.com/questions/92587/calculate-transaction-fee-for-external-addresses-which-doesnt-belong-to-my-loca/92600#92600

All transactions will have at least 40 weight units

40 (weight unit of constant* fields in a transaction: version 16, num inputs 4, num outputs 4, locktime 16)

+

2 (this is a segwit tx so need to add marker and flag)

+

(3 * 272) (3 p2wpkh inputs)

+

(2 * 124) (1 p2wpkh output)

= 1106 WU (weight units)

1106 / 4 = 276.5

Need to round this up so it equals = 277vB

I made a slight mistake. I calculated for 2 outputs instead of one like you said

Don’t worry, still right! There are always two outputs: Your own and the one for the miner’s fee 😎

The miners fee actually gets included in the coinbase tx of each block! For a normal tx you can calculate the fee by subtracting the sum of the outputs from the sum of the inputs. It’s pretty cool that the fee is implicit rather than an explicit utxo. It saves a lot of space on the chain

You never stop learning… This means that you are absolutely right and Sparrow’s 150 vB is correct. 277 - 124 = 153 vB. Case closed. Thank you very much 💜