Pay-to-Witness-Public-Key-Hash, or P2WPKH, is a transaction type used by cryptocurrencies like Bitcoin. It is thought to be the most contemporary, effective, and secure variant of the traditional P2PKH (Pay-to-Public-Key-Hash) transaction type.

Purpose and Origin
- With the release of the Segregated Witness (SegWit) soft fork in August 2017, Pay-to-Witness-Public-Key-Hash became one of two address formats. “The Blocksize War” by Jonathan Bier details the history of this soft fork.
- A new technique for keeping signatures, referred to as “witness data,” outside of the primary transaction structure was made possible by SegWit. The term “Segregated Witness” refers to the transition of the evidence of ownership, which consists of the public key and signature, from the scriptSig portion of the transaction to a separate section known as the “witness” of the input.
In addition to addressing transaction malleability, it was implemented to increase network scalability and block space efficiency.
How P2WPKH Works

Locking Funds (ScriptPubKey): Sending bitcoin to a Pay-to-Witness-Public-Key-Hash address locks the money to a public key hash. For P2WPKH, the locking script (also called scriptPubKey) is noticeably less complicated than for P2PKH. The recipient’s public key is hashed with 20 bytes after an OP_0, which serves as a version byte for SegWit v0. By applying the SHA-256 and RIPEMD 160 hash algorithms to the public key, a 20-byte hash is produced.
Unlocking Funds (Witness Field): A legitimate signature made with the matching private key and the recipient’s public key are required in order to spend money received through Pay-to-Witness-Public-Key-Hash. Importantly, these are in the transaction’s independent witness field for P2WPKH, as opposed to the scriptSig for P2PKH. A P2WPKH transaction usually has an empty scriptSig.
Public Key Requirement: In P2WPKH, only compressed public keys are accepted. Even though an uncompressed public key’s hash is theoretically acceptable, it will be regarded as non-standard and might not be relayed by nodes if it is included in the scriptPubKey.
Address Format
BIP 173 specifies Bech32 encoding for Pay-to-Witness-Public-Key-Hash addresses, which differs significantly from previous address types in appearance.
- They are easily recognised by their distinctive bc1q prefix.
- The character length of a Pay-to-Witness-Public-Key-Hash address is precisely 42.
- P2PKH addresses, on the other hand, are encoded in Base58 format and usually start with 1.
Key Benefits of P2WPKH
Lower Transaction Fees: It “discounts” the witness data when determining the transaction size for fee reasons when it is moved to a different section of the transaction. Accordingly, Pay-to-Witness-Public-Key-Hash transactions are typically less expensive to send than historical P2PKH transactions and take up less “block weight.”
Fixes Transaction Malleability: In contrast to earlier transaction types, a sort of transaction malleability is prevented by separating the witness data (signatures) from the transaction ID (TxID). Protocols such as the Lightning Network had issues since the signature, which is not a part of the data hashed to form the TxID, cannot be altered by a third party after broadcast.
Improved Scalability and Capacity Increase: The Bitcoin network’s total transaction throughput is increased by SegWit (including P2WPKH), which lowers the effective size of transactions so that more transactions may fit into a single block.
Simpler and Shorter Locking Script: P2WPKH’s scriptPubKey is significantly shorter than P2PKH’s.
Disadvantages
Compatibility: Very old wallets and services may not support Pay-to-Witness-Public-Key-Hash, even if the majority of contemporary Bitcoin tools and services do.
Developer Complexity: For developers, Pay-to-Witness-Public-Key-Hash may be a little trickier than traditional formats.
The primary distinction between P2WPKH and P2PKH is where the signature is located; otherwise, the semantics are identical. When a Bitcoin application comes across a scriptPubKey that has the Pay-to-Witness-Public-Key-Hash structure, it employs unique witness validation logic. This involves taking the public key and signature out of the witness field and verifying that it is a normal P2PKH script.
Summary Table
Feature | P2WPKH |
---|---|
Meaning | Pay-to-Witness-Public-Key-Hash |
Purpose | Lock funds to the hash of a public key using SegWit |
Output script | 0 <20-byte pubkey hash> |
Unlocking data (witness) | <signature> <public key> |
Address format | bc1 (bech32) |
Benefits | Lower fees, more efficient, SegWit features |
Use case | Default for many modern Bitcoin wallets |
P2WPKH Address
Pay-to-Witness-Public-Key-Hash, or P2WPKH, is a kind of Bitcoin address that makes use of Segregated Witness (SegWit).
SegWit Integration: As the “native SegWit” address format, Pay-to-Witness-Public-Key-Hash makes full use of the advantages of the SegWit upgrade to Bitcoin.
Address Format: These are called Bech32 addresses, and they usually begin with bc1q. Because they are all lowercase, they are less likely than previous address formats to contain transcription errors.
Key Benefit: Lower Fees: The main benefit of Pay-to-Witness-Public-Key-Hash addresses is that, in contrast to P2SH (which begins with 3) or P2PKH (which begins with 1) addresses, transactions made from them are subject to reduced transaction costs. The effective cost is decreased because the “witness” data which comprises the public key and digital signature is “segregated” and kept in a different section of the transaction that is given a lower weight when determining transaction size.
How it Works (Simplified): As with P2PKH, money are tied to a public key hash. The transaction data is more efficient when these funds are spent since the signature and public key information are entered in the “witness” field of the transaction instead of the scriptSig field.
Efficiency and Scalability: By lowering transaction sizes and promoting more effective block usage, P2WPKH helps the Bitcoin network become more scalable overall.
Because of their better error checking and reduced fees, Pay-to-Witness-Public-Key-Hash addresses are essentially the most effective and advised address type for standard Bitcoin transactions.
P2WPKH Wallet
What is a P2WPKH Wallet?
Wallet Capability: It is a feature or method of functioning within a Bitcoin wallet that is either hardware or software, not a distinct kind of physical wallet. A wallet that has adopted the Segregated Witness (SegWit) standard (BIP141 and BIP173) is known as a Pay-to-Witness-Public-Key-Hash wallet.
Address Generation: The ability of a P2WPKH wallet to generate Bitcoin addresses in the bc1q format is its primary feature. Such a wallet usually offers or defaults to a bc1q address when you create a new receiving address.
Transaction Construction: When you use a P2WPKH wallet to transmit Bitcoin from a Pay-to-Witness-Public-Key-Hash address, the wallet separates the “witness” data (such as the public key and digital signature) when creating the transaction. This makes it possible for the transaction to benefit from SegWit’s fee reductions.
How it Works (in the context of a wallet)
Address Derivation: Your master seed, also known as your private keys, is used by the wallet to generate new BC1Q addresses.
Receiving Funds: The money is recorded on the blockchain as outputs tied to your Pay-to-Witness-Public-Key-Hash script whenever someone sends Bitcoin to a bc1q address created by your P2WPKH wallet.
Spending Funds: Your P2WPKH wallet automatically prepares transactions to adhere to SegWit regulations when you start a transaction to spend these money. It inserts the public key and signature from the unlocking script into the “witness” portion of the transaction, which the network handles more effectively.
Key Benefits of Using a P2WPKH Wallet
Lower Transaction Fees: This is by far the biggest benefit. Because the “witness” data is given less weight in the calculation of the total transaction size, transactions spending from Pay-to-Witness-Public-Key-Hash addresses usually have lower fees than transactions from older address types (1 or 3 addresses).
Improved Scalability: P2WPKH wallets help the Bitcoin network scale by lowering the effective size of transactions, which enables more transactions to fit into each block.
Enhanced Error Detection: Due to their stronger error-correcting code, Bech32 addresses (such a s bc1q) are less likely to contain mistakes and the possible loss of cash in the event that an address is inadvertently typed incorrectly.
Future Compatibility: By aligning your transactions with the most recent Bitcoin protocol updates, P2WPKH addresses improve compatibility with upcoming network advancements.
P2WPKH addresses are supported by the majority of contemporary and trustworthy Bitcoin wallets (hardware and software), and they are frequently generated by default for new users.