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
21 votes
Accepted

Why is P2PKH used instead of the simpler P2PK?

The original reason why addresses were a public key hashes is something you'll need to ask Satoshi. My guess however is that it was just shorter and more convenient (note that compressed public keys ...
Pieter Wuille's user avatar
20 votes

Why do you use Bitcoin addresses instead of public keys?

Yes, you could send bitcoins directly to the public key: in fact, both Pay-to-PubKey (P2PK) and Pay-to-PubKey-Hash (P2PKH) were introduced in the first Bitcoin release. IIRC, P2PK is still used for ...
Murch's user avatar
  • 76k
15 votes

Why do you use Bitcoin addresses instead of public keys?

As @Murch correctly pointed out it is indeed possible to send bitcoin to either a public key or to the hash of a public key. The original motivation for using hashes of public keys was to shorten the ...
Benedikt Bünz's user avatar
10 votes
Accepted

How did pay-to-pubkey hash come about? What is its history?

Pay to Public Key Hash has existed for the entirety of Bitcoin's life. P2PKH addresses have existed since the earliest release of Bitcoin. Creating P2PKH addresses and sending to P2PKH addresses was ...
Ava Chow's user avatar
  • 70.9k
10 votes
Accepted

Why does vout sometimes not have address?

An address is a convenience feature designed to make human usage of Bitcoin easier - the Bitcoin protocol itself does not know anything about addresses. All outputs are actually sent to programs ...
Raghav Sood's user avatar
  • 17.1k
7 votes
Accepted

How were P2PK transactions made?

I know of only two ways that P2PK output were commonly constructed: Bitcoin's original codebase would use P2PK in mined coinbase outputs. This practice disappeared as the coinbase constructed ...
Pieter Wuille's user avatar
6 votes

Why is P2PKH used instead of the simpler P2PK?

The public key is first SHA256 hashed and then RipeMD160 hashed. A Bitcoin address is actually an encoded hash of the public key. A public key is 65 bytes long (0x04 + 64 bytes public key) or 33 ...
MCCCS's user avatar
  • 10.2k
5 votes
Accepted

Why don't P2PK scripts have their own address?

One of the issues with encoding P2PK outputs as an address is that they can be very long. P2PK can have both compressed and uncompressed keys. Uncompressed keys are 65 bytes, which means that the ...
Ava Chow's user avatar
  • 70.9k
5 votes
Accepted

How to extract all the bitcoin addresses with bitcoin-cli?

Answering this question requires first defining what an address means. Historically (before BIP16 activated in 2012) an address was a synonym with a "public key identifier", as there were ...
Pieter Wuille's user avatar
5 votes
Accepted

A question about the role of OP_DUP in the P2PK(H) transaction specification, and possibility of slightly smaller single address transactions

Re-reading your question, I realize my other answer may be besides the point. It is certainly possible that the scripting language's semantics would recognize this scenario and cause failure if ...
Pieter Wuille's user avatar
5 votes

Different balances between fullnode and bitcoin explorer

You appear to have searched for a Pay to Public Key Hash (P2PKH) address, but the output on the coinbase transaction of block 200 is a Pay to Public Key (p2pk) output. There is no address standard for ...
Murch's user avatar
  • 76k
4 votes

How did pay-to-pubkey hash come about? What is its history?

The earliest client by satoshi had both. P2PK was default for mining and payments received using the interactive IP-to-IP payment protocol; P2PKH was intended for use in non-interactive payments. ...
skang404's user avatar
  • 616
4 votes

A question about the role of OP_DUP in the P2PK(H) transaction specification, and possibility of slightly smaller single address transactions

The first thing to remember here is that the entire script that is executed comes in two parts. The first part comes in the output that is being spent. This script fragment is incomplete - if you run ...
Ava Chow's user avatar
  • 70.9k
4 votes

How to recover and sweep P2PK coins

You can achieve this without any script, simply using the Bitcoin Core wallet. For each public key you received funds on you can import a pk() descriptor containing the corresponding private key, WIF-...
Antoine Poinsot's user avatar
4 votes

How to figure out the output address when there is no "address" key in vout["scriptPubKey"]

Those block explorers use an outdated notion of "address". This output simply has no address. The RPC output, as well as more modern block explorers such as https://mempool.space and https://...
Pieter Wuille's user avatar
3 votes

A question about the role of OP_DUP in the P2PK(H) transaction specification, and possibility of slightly smaller single address transactions

Let's work out the hypothetical scenario. Alice sends coins to Bob, and then to Carol, and the malicious miner Mallory tries to steal the last sent coins. The honest scenario is this: Bob generates a ...
Pieter Wuille's user avatar
3 votes

Why does vout sometimes not have address?

I don't really know why it doesn't include some addresses. Here's how to get both of the addresses for your second transaction example: For vout index 0, it says the type is a pubkeyhash. The hex ...
MrPuzzler's user avatar
  • 233
3 votes
Accepted

What is scriptpubkey for in the coinbase transaction ? (and more..)

The mined Bitcoin "goes" to the scriptPubKey(s) in the coinbase transaction. Bitcoin operates on spending transaction outputs. Submitting a block does not magically cause a transaction ...
Ava Chow's user avatar
  • 70.9k
3 votes
Accepted

p2pkh vs. p2pk keeping public key private

Bitcoin addresses, and the public key by extension, should ideally only ever be used once. So your time of exposure of the public key in P2PKH is the time between when the spend is made and when it ...
Claris's user avatar
  • 15.4k
3 votes

How bitcoin browsers check P2PK and P2SH balance?

Each output in Bitcoin transactions has a scriptPubKey restricting how the UTXO can later be spent. For P2PK the scriptPubKey consists of <pubkey> OP_CHECKSIG, the output type associated with ...
Murch's user avatar
  • 76k
3 votes

Why is P2PKH used instead of the simpler P2PK?

what's the reason for hashing our public key for use in P2PKH? There is no link to ECDSA, besides that a priv key generates a pub key. But in the transaction, you would see the signature and the ...
pebwindkraft's user avatar
  • 5,096
3 votes
Accepted

Why most of pubkeys in the first batch of blocks in blk00000.dat are different

The original Bitcoin software (and even the current Bitcoin Core) always used a new private key (and thus public key) for every transaction. Keys were never reused. Since the Coinbase transaction for ...
Ava Chow's user avatar
  • 70.9k
3 votes

P2PUBKEY in witness program (P2WPUBKEY)

If the concerns are related to performance, we can observe how the ethereum works and reaches about 1M tx per day (this is like 1M inputs per day in Bitcoin). Ethereum is really not a good comparison ...
Ava Chow's user avatar
  • 70.9k
3 votes

Retrieve address corresponding to pubkey using bitcoin-cli/RPC

The ScriptPubKey 2103f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1ac is a pay-to-public-key. There is no defined address for this output type. There is therefore no way to retrieve ...
Antoine Poinsot's user avatar
3 votes
Accepted

How to figure out the output address when there is no "address" key in vout["scriptPubKey"]

It is impossible to give the correct address for this output, because this output doesn’t follow one of the patterns that have an address standard. The correct way to refer to this output’s “...
Murch's user avatar
  • 76k
3 votes
Accepted

get source address of a transaction

Bitcoin itself does not know the concept of an address. The term address arose from the desire to bring end users working with bitcoin closer to the way they manage their bank account. This is ...
dassd's user avatar
  • 1,099
2 votes

How to extract all the bitcoin addresses with bitcoin-cli?

The second output you are showing is using the pay to pubkey output script. Pay to pubkey (P2PK) eponymously locks funds to a public key. The corresponding input script only needs to provide a ...
Murch's user avatar
  • 76k
2 votes
Accepted

bitcoinj java library not decoding input addresses for some transactions

When an input redeems a P2PKH output (pay to an address starting with a 1), the format of the input script (the scriptSig) is: [signature] [public key]. Because public keys are included in both ...
Vecna's user avatar
  • 324
2 votes
Accepted

What is type 'pubkey' in a scriptpubkey output from getrawtransaction?

The script for an output describes the condition that must be satisfied for the money to move. It means that the public key is contained in the scriptPubKey. Usually, the scriptPubKey only contains a ...
Nick ODell's user avatar
  • 29.4k

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