If I understand addresses correctly, different types of addresses are used to map to a particular locking script (scriptPubKey).

So based on the leading character of an address, a wallet will decode the address, and then form the appropriate locking script around it.

For example:

P2PKH = 1address

OP_DUP OP_HASH160 1f1cafe31d63e061a3f74b541f4ce7a4515b4d0c OP_EQUALVERIFY OP_CHECKSIG

P2SH = 3address

OP_HASH160 dc37feb38b5a4ad4bf09bc61eea4831f85c58103 OP_EQUAL

P2PK = n/a

031b0e8c2567c12536aa13357b79a073dc4444acb83c4ec7a0e2f99dd7457516c5 OP_CHECKSIG

Why is it that P2PK scripts have never been given their own address?

Why not give the public key in a P2PK a checksum, then base58 encode it with it's own leading character so that we can have an address for it?


I think there is a mix of transaction type (p2pk, p2sh, p2pkh...) and pubkeys or addresses. The addresses are generated from the hex pubkey (a cool playground here: http://gobittest.appspot.com/Address). The pubkeys are hashed, a network Byte added, some check summing and base58check encoded. This gives me the bitcoin address of a public key.

In a transaction I can use different methods to transfer funds. I had replied to your other post as well. So when the spending condition only requires you to present your public key and signature, then it is a p2pk transaction. The public key would be recognized by your wallet (following the above mentioned coding scheme) as „type 1“ address.

If the spending condition is set to present a public key hash, then it is a p2pkh tx, and you have the std Op_Dup, Op_Hash160,... structure.

When having a look onto the stack, it becomes clear, what happens. The spending tx puts its sig and pubkey on stack. Then the pubkey script goes onto stack. First command is OP_Dup, so pubkey is duplicated. Then OP_Hash160 follows, hashing the pubkey. This hash is then compared with the hash of the pubkey script (in your example „1f1cafe31d63e061a3f74b541f4ce7a4515b4d0c“), and hopefully these two match (as per the following OP_Equal). This proves, that you are the rightful person to spend the funds, cause you could proof, that you can hash your pubkey to the referenced pubkey hash. And hashing is a one way function... no one else could do this. In the last step, the signature in the transaction is verified, and with your now provided pubkey the transaction would be checked for a valid signature (OP_Checksig).

Hope I could shed some light in the confusion on addresses and „pay to pubkey“ or „pay to pubkey hash“ transactions :-)

  • 2
    Downvoted. This is very confused and does not answer the question. P2PK outputs do not require presenting a public key and a signature; only a signature. P2PKH outputs do not require presenting a public key hash and a signature; they require a public key and a signature. – Pieter Wuille Jun 23 '19 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.