Post
Topic
Board Beginners & Help
Merits 2 from 2 users
Re: How do we calculate the correct transaction fee to send?
by
o_e_l_e_o
on 17/01/2020, 09:38:20 UTC
⭐ Merited by AdolfinWolf (1) ,hosseinimr93 (1)
By the way, could you help me with the conversion of fees from satoshi/ byte to satoshi / vbyte, please.
The difference between: https://coinb.in/#fees and https://btc.com/stats/unconfirmed-tx, then how to make conversion?
So, the simple answer here is that coinb.in/#fees is stating the fee in sats/vbyte, although they call it sats/byte. We can tell this because the transaction sizes they show are different for legacy and SegWit transactions.

The longer answer is more complicated, and there is no straightforward way to "convert" between the two, since it depends entirely on the particular transaction you are looking at.

Plain bytes are not used to measure the size of transactions anymore, since the SegWit soft fork. Instead we use weight units. You can read more about these here: https://en.bitcoin.it/wiki/Weight_units. Essentially, insteading of blocks being able to hold 1 million bytes, they now hold 4 million weight units. For legacy transactions, each byte takes up 4 weight units, so the effective size of these transactions doesn't change. For SegWit transactions, however, the witness data only takes up 1 weight unit per byte, so the effective size is smaller. To prevent having to multiply and divide by 4 all the time, lots of people instead use virtual bytes or vbytes, which again, are equal to 4 weight units. So a block can contain 1 million vbytes.

This means that for legacy transactions, 1 byte of transaction data takes up 1 vbyte on the block, but for SegWit transactions, 1 byte of witness data will only take up 0.25 vbytes of block space (the non witness data is unchanged, and still takes up 1 vbyte per byte). This makes SegWit transactions take up less block space, and therefore, cost less in fees.

Now for some examples. Take a look at this legacy transaction: https://blockchair.com/bitcoin/transaction/b74c4d36e9835923556b34f53fead7c9d51c03435e80805a2c8b904852a8a35f

You can see its size is 224, and its weight is 896, which is exactly 4 times its size. This is because it is a legacy transaction. Its fee per vbyte and fee per byte are the same.

Now look at this SegWit transaction: https://blockchair.com/bitcoin/transaction/dcddd311deb7c4a4a2b63b10bc762badc7a0fcefd7afc336838cc2f57e326360

It has a size of 374, but its weight is only 1,169, which is about 3.1 times its size. Its fee per vbyte is higher than its fee per byte, because some of the bytes (the witness data) are "discounted" as explained above.