jhoenicke / mempool

Bitcoin Mempool Statistics
GNU Affero General Public License v3.0
334 stars 92 forks source link

Weight units becoming potentially useful #28

Closed weex closed 6 years ago

weex commented 6 years ago

As more and more transactions use segwit, the price per weight unit calculation becomes more important than sat/byte. So it would be interesting to be able to switch to sat/wu.

dooglus commented 6 years ago

I guess what is "useful" depends on what metric miners are using to rank transactions. To optimize revenue they should be using fee/WU, and so that's likely what we need to be seeing on the charts.

I recently made a segwit transaction using Bitcoin Core and asked for it to pay a fee of 100 sat/B. The transaction shows up on blockchain.info like this:

So it seems it didn't pay the 100 sat/B I asked for, but aimed for a sat/WU of 100/4 instead.

How would such a transaction show up in the jhoenicke/mempool charts? Would it count as 100 or 67 sat/B? ie. is the 'segwit discount' already being taken into account in the chart?

jhoenicke commented 6 years ago

I use the size the bitcoin node gives, lets call it "virtual bytes". It already includes the segwit discount when computing the size, so it is "real size - 75 % witness size". I had already extended the description to mention that. The size the block explorers show differ, e.g., blockchain.info shows real size in bytes including witness, and weight, which is 4 times virtual bytes. Insight shows what the bitcoin nodes computes, with the 75 % discount of witness bytes. blocktrail.com shows the size of the transactions without witness, i.e. with 100 % discount, probably because they use an outdated full node that doesn't see the witness.

Since the miners use the segwit discount when determining priority, it makes most sense to use that. Most wallets also use that when they are given a sat/B fee as dooglus' example shows. The unit sat/wu of blockchain.info is just sat/virtual bytes divided by 4 and I haven't seen it anywhere outside blockchain.info (except inside the bitcoin core source code, but it is not used in the RPC interface). My statistics would show the transaction as 100 sat/B.

So if you use segwit you should give your wallet the same sat/B level as you would give it for non-segwit The wallet should handle the discount when computing the "virtual size" of the transaction.

dooglus commented 6 years ago

That's the reply I was hoping to see. :)

I had already extended the description to mention that

I don't see it, either on the site or in the list of recent commits. I see "The transactions are colored by the amount of fee they pay per byte", but nothing about virtual size, witness discount, etc.