Blockchair / Blockchair.Support

Public repository for issues and feature requests. Submit your favorite bug!
432 stars 319 forks source link

Bitcoin-BTC transaction weight #170

Open lugaxker opened 5 years ago

lugaxker commented 5 years ago

Hello,

It do not know if I am right, but it looks like something is wrong with the computation of the transaction weight (in weight units).

For instance, your explorer says that the weight of transaction 9500c3da069d6462ac8b7021d04e04202cba79b55db73a79a66b801f4eb141d9 is 600 weight units: https://blockchair.com/bitcoin/transaction/9500c3da069d6462ac8b7021d04e04202cba79b55db73a79a66b801f4eb141d9 Whereas the blockchain.com explorer says 597 weight units: https://www.blockchain.com/btc/tx/9500c3da069d6462ac8b7021d04e04202cba79b55db73a79a66b801f4eb141d9

When I do the math, I find 597 WU because I include the marker and the flag of the transaction (1 byte each) into the witness. As they are witness data, their size is not multiplied by 4, hence the 3-WU difference.

I hope this will help, I do not know which explorer is wrong. SegWit is so complex!

Have a nice day, and thank you for all the great work you are doing at blockchair!

Har01d commented 5 years ago

Hey,

Thanks!

It seems like there’s indeed a bug, we calculate weight units as simply vsize * 4. Despite this formula is mentioned on many SegWit resources (like https://en.bitcoin.it/wiki/Weight_units, A unit of vsize is equal to four weight units), it seems to be wrong.

This particular transaction has the following properties:

"size":315,
"vsize":150,
"weight”:597

We’ll look into it.