1. P2PKH (Pay-to-Public-Key-Hash) UTXO

  • Size: ~148 vB
  • Structure:
    • A P2PKH transaction includes a scriptSig (signature script) in each input, which contains a cryptographic signature and the public key of the sender. This is the traditional way of making transactions in Bitcoin.
    • The scriptSig in P2PKH transactions is relatively large because it includes both the signature and the full public key.
  • Why the Size?
    • The scriptSig (around 107 bytes), combined with other input fields (like previous transaction reference and sequence), accounts for the larger size of P2PKH UTXOs.

2. P2SH (Pay-to-Script-Hash) UTXO

  • Size: Typically 91 vB to 102 vB
  • Structure:
    • P2SH transactions allow the sender to lock funds to a script hash instead of a public key hash. The actual spending conditions are revealed and verified only when the funds are spent.
    • This method is used for more complex transactions like multisig wallets, where multiple signatures are required to spend the funds.
  • Why the Size?
    • The scriptSig for P2SH is variable depending on the complexity of the script. For a simple multisig, it might be shorter than a P2PKH scriptSig, but for more complex scripts, it can be longer.

3. P2WPKH (Pay-to-Witness-Public-Key-Hash) UTXO

  • Size: Approximately 68 vB
  • Structure:
    • P2WPKH is part of the Segregated Witness (SegWit) update, which was designed to reduce the size of transactions and improve scalability.
    • The signature and public key information (the witness data) are separated from the main transaction structure.
  • Why the Size?
    • Since witness data is discounted in the calculation of virtual bytes, P2WPKH transactions are smaller in size. This makes them more efficient in terms of space usage on the blockchain.

4. P2WSH (Pay-to-Witness-Script-Hash) UTXO

  • Size: Varies based on script complexity
  • Structure:
    • Similar to P2WPKH, P2WSH is a SegWit version of P2SH. The script conditions for spending the UTXOs are stored outside of the main transaction structure.
  • Why the Size?
    • The size varies greatly depending on the complexity of the script. Since the witness data is segregated and discounted, P2WSH can accommodate more complex scripts without excessively increasing the transaction size.

Transaction Size Comparison Table

UTXO TypeNumber of InputsNumber of OutputsAverage Size per UTXO (vB)Total Transaction Size (vB)
P2PKH12148226
P2SH32100 (Approx.)378
P2WPKH2168180
P2WSH12120 (Approx.)198

Explanation:

  1. P2PKH Scenario:
    • Calculation: Transaction overhead (10 vB) + 1 input (148 vB) + 2 outputs (34 vB each) = 10 + 148 + 68 = 226 vB
  2. P2SH Scenario:
    • Calculation: Transaction overhead (10 vB) + 3 inputs (100 vB each, approx.) + 2 outputs (34 vB each) = 10 + 300 + 68 = 378 vB
  3. P2WPKH Scenario:
    • Calculation: Transaction overhead (10 vB) + 2 inputs (68 vB each) + 1 output (34 vB) = 10 + 136 + 34 = 180 vB
  4. P2WSH Scenario:
    • Calculation: Transaction overhead (10 vB) + 1 input (120 vB, approx.) + 2 outputs (34 vB each) = 10 + 120 + 68 = 198 vB