Skip to main content
43 votes

What is P2PK, P2PKH, P2SH, P2WPKH - ELI5

P2PKH: "Pay To Public Key Hash" This is how transactions are made. You are requiring the sender to supply a valid signature (from the private key) and public key. The transaction output script will ...
Monstrum's user avatar
  • 1,334
11 votes
Accepted

Can I mix P2PKH and P2WPKH inputs in the same transaction?

Is it acceptable to mix P2PKH and P2WPKH inputs in the same transaction as described above? Yes, absolutely. In the same way that you can mix multisig and P2SH and P2PK inputs in the same transaction....
Pieter Wuille's user avatar
11 votes
Accepted

Is there an economic incentive to switch from P2WPKH to P2TR?

Facts A P2WPKH input weighs 68 vB (assuming the worst-case with a high-r signature, -0.25 vB with a low-r signature) and a P2WPKH output weighs 31 vB for a total of 99 vB. A P2TR input weighs 57.5 vB ...
Murch's user avatar
  • 76k
10 votes

What is the largest multisig quorum currently possible?

The rules governing this depend on the type of script used and whether that script is in the output script, in a P2SH, in a P2WSH, or in P2TR. Additionally, the rules are more restrictive for ...
Ava Chow's user avatar
  • 71k
8 votes
Accepted

In simple terms, what are the major differences between P2WPKH and P2WSH bech32 addresses?

P2WPKH - This stands for "Pay To Witness Public Key Hash" and the scriptPubkey is OP_0 0x14 {20-byte-hash}, where OP_0 is the version, byte 0x14 is the size of the data, and the {20-byte-hash} is a ...
kawthuldrok's user avatar
8 votes
Accepted

How do the fees for taproot transactions compare to P2WPKH?

Taproot inputs are smaller but outputs are larger. Specifically, P2WPKH (Native SegWit) inputs and outputs take 68 and 31 vbytes in a transaction, respectively, while P2TR (Taproot) inputs and outputs ...
Vojtěch Strnad's user avatar
8 votes
Accepted

What are the scriptPubKey, scriptSig, redeem script and witness for the various output types?

This was answered during the Bitcoin Core PR review club on July 7th 2021 hosted by Gloria Zhao (who also provided this table). The <public key> in the P2TR (key path) and P2TR (script path) ...
Michael Folkson's user avatar
7 votes
Accepted

How do I Derive Bech32 Address from P2WPKH Output Script?

Okay so I think I've figured it out for anyone else wondering what exactly you have to do to derive an address from this type. In the case of the already mentioned transaction, (coinbase of block ...
Mason Ticehurst's user avatar
6 votes
Accepted

Can a coinbase transaction have a segwit output?

Other than the total value needing to be correct (no more than the block reward plus fees), the outputs of a coinbase transaction are completely unrestricted and act the same as any other transaction.
Claris's user avatar
  • 15.4k
6 votes
Accepted

Is a P2WPKH address synonymous with a Bech32 address?

are P2WPKH and Bech32 synonyms now? No. Bech32 is also used for P2WSH addresses. Native segwit and Bech32 are synonyms. Is there such a thing as Base58 P2WPKH address? No.
Ava Chow's user avatar
  • 71k
6 votes
Accepted

What is the size and weight of a P2WPKH input?

TL;DR: A P2WPKH input should be conservatively estimated with 68.0 vbytes. Standard P2WPKH inputs generally weigh 67.75 or 68.0 vbytes, depending on whether the r-value in the signature is low or high....
Murch's user avatar
  • 76k
5 votes
Accepted

How hard is it for an exchange to adopt native segwit? Is it not as simple as updating the address regex checker on the front-end?

Adopting any deposit change at all is not as simple as "just change regex". There are a few considerations: Addresses must be generated, and generated properly. All generated addresses that ...
instagibbs's user avatar
4 votes

tracking invoice address type migration

You can find the first on https://txstats.com/dashboard/db/utxo-set-repartition-by-output-type?orgId=1. For a version weighed by value you can look at the graphs of the individual output types on the ...
Pieter Wuille's user avatar
4 votes
Accepted

Compute checksum for Bech32 address

You may want to look at the reference implementation section: https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#reference-implementations It lists implementations for various languages, ...
Pieter Wuille's user avatar
4 votes

Bech32 encoded address to scriptPubKey

So is it correct that I can not transform a bech32 encoded address to a scriptPubKey? That is incorrect. Addresses are by definition instructions for wallet on how to create transaction outputs. ...
Pieter Wuille's user avatar
3 votes
Accepted

SHA256 vs RIPEMD160 in SegWit

The P2WPKH actually uses the HASH160 hashing algorithm, which is just RIPEMD160(SHA256(pubkey)). The reason for using SHA256 is mentioned in BIP141: The increased size improves security against ...
JBaczuk's user avatar
  • 7,418
3 votes

What are the scriptPubKey, scriptSig, redeem script and witness for the various output types?

I thought it would be useful to have a text version of the image of a table in Michael Folkson's answer. If only for accessibility reasons. (it initially proved rather too hard to edit into his answer ...
RedGrittyBrick's user avatar
3 votes
Accepted

What is the content of ScriptPubKey for P2WPKH?

This is just a matter of notation. <20-byte value> is a human-readable way of writing "the script that pushes said 20-byte value onto the stack". Practically that's encoded using 0x14 ...
Pieter Wuille's user avatar
2 votes
Accepted

Redeem script for segwit addresses

Feb2018: an older request, I just answer it so that future research might reveal useful data :-) To compose the redeem script for a P2WPKH, there is a fairly simple structure, I copied this mostly ...
pebwindkraft's user avatar
  • 5,096
2 votes
Accepted

Using segwit and creating Pay-To-Witness (P2WPKH) addresses

I might be understanding this incorrectly, but it sounds like the users and/or wallet custodian (coinbase, blockchain.info, etc) must create a P2SH-P2WPKH addresses in order for the witness data to be ...
Murch's user avatar
  • 76k
2 votes

How to quickly find the private key from Segwit P2SH address?

How to quickly find the private key from Segwit P2SH address? As per today, it is impossible to find the private key from any public key or address. Also from a SegWit P2SH address. There is always ...
pebwindkraft's user avatar
  • 5,096
2 votes

BIP 84, BIP 173 Implementation in BitcoinJ

i don't think bitcoinj support BIP-173 but you can read more from Bitcoinj repo For Segwit Bitconj 0.14 branch is ~2 years old and has got no support for segwit at all. For receiving on native ...
Zombie's user avatar
  • 548
2 votes
Accepted

scriptcode, scriptsig, pubkeyscript confusion

The execution order is: scriptSig/witness to construct the initial stack scriptPubKey (which may invoke redeemScript evaluation in case of P2SH, and witness script invocation in case of P2WSH) The ...
Pieter Wuille's user avatar
2 votes
Accepted

What is the signature digest for Segwit outputs

For signatures in P2WPKH and P2WSH spends, the sighash algorithm is described in BIP143. It is very different from the one used in legacy spends.
Pieter Wuille's user avatar
2 votes
Accepted

ScriptSig in P2SH-P2WPKH BIP16

For node > 0.13 is it a trigger the say to node, Hey, I'm a segwit transaction! check in Txinwitness! For node < 0.13 Push ScriptSig inside and that's it, the transaction is ANYONE_CAN_SPEND ...
Pieter Wuille's user avatar
2 votes

SHA256 vs RIPEMD160 in SegWit

As the protocol is upgraded with soft-forks changing script interpreter behaviour, the script-machine is extended with additional runs. Each new upgrade brings a new script run with new rules, whilst ...
James C.'s user avatar
  • 2,521
2 votes

Spending transaction output with only xpriv key

No, you need the private key that the address in question was derived from. There is no mechanism for the wider network to determine that an address was derived from a private key, that was derived ...
chytrik's user avatar
  • 18.3k
2 votes
Accepted

Convert Electrum p2pkh wallet to p2wpkh one?

You could theoretically export the wallet to a new type by seed (p2pkh to p2wpkh) but it would not recognize any utxo that came into it as the derivation for p2pkh and p2wpkh are different. It's not ...
Tony Sanak's user avatar
  • 1,699
2 votes

Generating P2WSH addresses | Is there a standard WitnessScript?

First of all, like pointed out in the first comment on your question, you're confusing the "witness program" and "witness script". The witness program for p2wpkh is OP_0 followed ...
Steven Roose's user avatar
  • 11.9k
2 votes

How hard is it for an exchange to adopt native segwit? Is it not as simple as updating the address regex checker on the front-end?

I assume that you're referring to withdrawals, and I think that you're probably right if the company's backend relies on bitcoind to fully process transactions. If the company's backend manually ...
Gabriel's user avatar
  • 121

Only top scored, non community-wiki answers of a minimum length are eligible