Bitcoin Forum

Bitcoin => Wallet software => Topic started by: Waldschrat2 on February 08, 2021, 04:29:32 AM



Title: Transaction Fees Native SegWit / Wrapped SegWit etc
Post by: Waldschrat2 on February 08, 2021, 04:29:32 AM
Hey,

Avid user of mempool.space (http://mempool.space) here which I think is a pretty awesome tool to improve transaction efficiency on the Bitcoin main chain.

I am currently looking to find information what the approximate difference in fees (%-wise) is when spending *to*

- Legacy Address
- Wrapped SegWit
- Native SegWit

I know that generally the major impact on the transaction fees come from which type of address you spend, but I know that there are also (more negligible) tx size/fee differences depending if one is sending to a Legacy/Wrapped SegWit or Native SegWit address.

If somebody has a link to some guidance / data table / Dataviz or whatever else might be useful in understanding the differences, would be highly appreciative.  :)

Thanks in advance!


Title: Re: Transaction Fees Native SegWit / Wrapped SegWit etc
Post by: pooya87 on February 08, 2021, 04:41:11 AM
There is https://coinb.in/#fees which lets you change the input type and count and lets you see the approximate transaction sizes. You can use that to measure legacy versus SegWit transactions but not nested/wrapped SegWit. However these wrapped ones have an additional 22 bytes in their signature script, add that to total size of a SegWit tx and to get their weight it has to be multiplied by 4 and added to the whole sum (4*22=88 extra weight).


Title: Re: Transaction Fees Native SegWit / Wrapped SegWit etc
Post by: Waldschrat2 on February 08, 2021, 04:49:52 AM
There is https://coinb.in/#fees which lets you change the input type and count and lets you see the approximate transaction sizes. You can use that to measure legacy versus SegWit transactions but not nested/wrapped SegWit. However these wrapped ones have an additional 22 bytes in their signature script, add that to total size of a SegWit tx and to get their weight it has to be multiplied by 4 and added to the whole sum (4*22=88 extra weight).

That's helpful already - thanks!

So basically if I pay e.g. 10 Sats/vByte the difference would be 880 Sats in Fees between Native & Wrapped SegWit in this example, correct?


Title: Re: Transaction Fees Native SegWit / Wrapped SegWit etc
Post by: pooya87 on February 08, 2021, 04:59:26 AM
So basically if I pay e.g. 10 Sats/vByte the difference would be 880 Sats in Fees between Native & Wrapped SegWit in this example, correct?
It's a bit more complicated than that.
Weight is 3*(size with witnesses stripped) + total size (the raw byte size of all parts including witness)
Virtual size is weight / 4

This means anything that goes into witness part will increase the virtual size by 1/4x of its size while anything added to legacy part adds 1x of its size.
So when we add the 22 bytes to signature script those bytes exist both in "size with witness stripped" and "raw byte size" and when calculating weight it will be 3*22 + 22 = 4*22 ergo the virtual size is 4*22/4 = 22.
=> For 10 sat/vbyte it adds 220 satoshi.


Title: Re: Transaction Fees Native SegWit / Wrapped SegWit etc
Post by: PrimeNumber7 on February 08, 2021, 05:02:56 AM
So basically if I pay e.g. 10 Sats/vByte the difference would be 880 Sats in Fees between Native & Wrapped SegWit in this example, correct?
It's a bit more complicated than that.
Weight is 3*(size with witnesses stripped) + total size (the raw byte size of all parts including witness)
Virtual size is weight / 4

This means anything that goes into witness part will increase the virtual size by 1/4x of its size while anything added to legacy part adds 1x of its size.
So when we add the 22 bytes to signature script those bytes exist both in "size with witness stripped" and "raw byte size" and when calculating weight it will be 3*22 + 22 = 4*22 ergo the virtual size is 4*22/4 = 22.
=> For 10 sat/vbyte it adds 220 satoshi.
You are referring to the cost of a transaction based on the type of address the transaction is sent from. The OP is asking about the cost of a transaction based on the type of address the transaction is sent to.


Title: Re: Transaction Fees Native SegWit / Wrapped SegWit etc
Post by: pooya87 on February 08, 2021, 05:23:22 AM
You are referring to the cost of a transaction based on the type of address the transaction is sent from. The OP is asking about the cost of a transaction based on the type of address the transaction is sent to.
I'm sorry I missed that :(
Here are the "output" or "txout" sizes of each type that includes the 8 byte amount + the pubkey script:
Legacy (P2PKH): 34
Legacy (P2SH): 32
Legacy (P2PK): 44/76 for comp/uncomp pubkey
SegWit (P2WPKH): 31
SegWit (P2WSH): 43
Wrapped SegWit (P2SH-P2WPKH): 32 (same as P2SH)
Wrapped SegWit (P2SH-P2WSH): 32 (same as P2SH)


Title: Re: Transaction Fees Native SegWit / Wrapped SegWit etc
Post by: NotATether on February 08, 2021, 05:30:35 AM
You are referring to the cost of a transaction based on the type of address the transaction is sent from. The OP is asking about the cost of a transaction based on the type of address the transaction is sent to.

Then you'd count the size of the locking script. We can get the script type and therefore it's bytes from the types of the receiving addresses but that's about it. But this is probably a moot point since in segwit their hashes are put in the transaction anyway, which are 32 bytes each along with a bunch of other fields in the txout (and txin) which have a fixed format and whose sizes can be predetermined.


Title: Re: Transaction Fees Native SegWit / Wrapped SegWit etc
Post by: dkbit98 on February 08, 2021, 10:09:15 AM
There are several Bitcoin transaction calculators and I collected them all in one topic Bitcoin Transaction Size Calculators (https://bitcointalk.org/index.php?topic=5315125).
Jameson Lopp website is probably most complete with all address formats and explanations.

If you like using mempool.space website you can check out and test our open source browser extension for monitoring Bitcoin mempool in your browser ticker HERE (https://bitcointalk.org/index.php?topic=5312406.05) and it works in both Firefox and Chrome browsers.
Feel free to write us a feedback and suggestions if you can.


Title: Re: Transaction Fees Native SegWit / Wrapped SegWit etc
Post by: Waldschrat2 on March 08, 2021, 05:12:21 PM
Thanks everybody for the answers - very enlightening and got pointed in a few good directions on the matter!

A lot of good resources I/we will certainly take a regular look on  :)

When it comes to these topics, the good ol' Bitcointalk still shining  :)

You are referring to the cost of a transaction based on the type of address the transaction is sent from. The OP is asking about the cost of a transaction based on the type of address the transaction is sent to.
I'm sorry I missed that :(
Here are the "output" or "txout" sizes of each type that includes the 8 byte amount + the pubkey script:
Legacy (P2PKH): 34
Legacy (P2SH): 32
Legacy (P2PK): 44/76 for comp/uncomp pubkey
SegWit (P2WPKH): 31
SegWit (P2WSH): 43
Wrapped SegWit (P2SH-P2WPKH): 32 (same as P2SH)
Wrapped SegWit (P2SH-P2WSH): 32 (same as P2SH)