14

Bech32 (starts with bc1) and P2SH (starts with 3) can both be used for segwit transactions. I know bech32 is supposed to create smaller transactions, but I'd like to know how much smaller (than P2SH). How do transactions coming from a normal single-key address compare?

1
10

bech32 produces smaller transactions than P2SH segwit transactions.

  • one extra byte per output to create P2SH outputs than to create bech32 utxos (P2SH uses OP_HASH160 and OP_EQUAL in addition to a 20 byte hash in its script, whereas bech32 just uses a fixed 00 byte in addition to a 20 byte hash), and
  • 23 extra bytes per input to spend from P2SH utxos than from bech32 utxos (P2SH has to produce the script that was hashed when spending in the sigscript, which takes 23 bytes to encode - bech32 has no non-witness sigscript at all).

Basically P2SH requires a script hash, native SegWit doesn't, and everything else is much the same. Native SegWit provides the script when the output is created, and P2SH provides it when the output is spent.


If you want to know how much you saved (or can save) in each transaction, Blockstream explorer provides nice feature, where you can see the savings. For example for this transaction, can save extra 16% on fees

3
0

They are both just an encoding. The resulting tx could be exactly identical. In real life however people use bech32 just fur native segwit transactions, while p2sh is used as a wrapper around segwit. the tx is actually a tiny bit smaller when using p2sh.

3
  • 2
    Oh really? P2SH is actually smaller? What's the advantage of bech32 then? I don't quite understand what "native" means in the context of "native segwit". By the way, do you have sources where we could read more about this / verify your answer? – B T Dec 26 '17 at 23:24
  • 1
    The best source is always the actual source. bech32 have been proposed in bip173 which you can find here: github.com/bitcoin/bips/blob/master/bip-0173.mediawiki It also has a section on how bech32 is better than different encodings. For the size there is no definite source without specifying what exactly you want to compare. bech32 is an encoding, p2sh is a type of transaction. For my comparison I assumed that bech32 is equivalent to native segwit. – blues Dec 31 '17 at 23:56
  • This answer is false in multiple ways: 1. It's not just a different encoding, wrapped segwit and native segwit outputs are different output types. When funds are sent to a wrapped segwit address, they can only be spent in a wrapped segwit input, and vice versa for native segwit. 2. Wrapped segwit and native segwit transactions cannot be identical, even though they can have equivalent effect (at different fee costs). 3. Wrapped segwit transactions use more blockspace, than native segwit transactions. – Murch Apr 10 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.