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.
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.
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.
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.
1. P2PKH (Pay-to-Public-Key-Hash) UTXO
2. P2SH (Pay-to-Script-Hash) UTXO
3. P2WPKH (Pay-to-Witness-Public-Key-Hash) UTXO
4. P2WSH (Pay-to-Witness-Script-Hash) UTXO
Transaction Size Comparison Table
Explanation: