<p>In most cases, if you really want to use a P2PK transaction, you would have to ask the receiver to tell you their public key.</p>

<p>You can't determine the public key from the address alone.   The address is a hash of the public key, and hash functions are one-way.  So if all you have is an address, you can't use a P2PK transaction.  </p>

<p>If the receiver has previously had other transactions sent to the desired address, and has spent at least one of those transactions, then the public key was included as part of the spending transaction's signature.  So in that case, the public key is in the blockchain, and you could use it to make a P2PK transaction.  </p>

<p>I'm not sure why you would bother, though.  P2PK transactions are pretty much obsolete, and P2PKH should be used for all normal purposes.</p>

CC BY-SA 3.0
2016-10-06T16:51:14.813Z
So at the beginning of Bitcoin, everybody needed to get public key from receivers? I heard that P2PK is still used in coinbase transactions. If so, miners are set a public key in coinbase?
Satoshi Nakanishi
CC BY-SA 3.0
2016-10-06T16:54:46.697Z
@SatoshiNakanishi: That's true, Bitcoin Core uses P2PK when it produces coinbase transactions.  In that case it is using the miner's own key, generated by Bitcoin Core itself, so of course it knows the public key.  But this is mostly a holdover from old code.  It's legal to use P2PKH in a coinbase transaction, and other mining software can do so; it just happens that Bitcoin Core uses P2PK.
Nate Eldredge
CC BY-SA 3.0
2016-10-11T03:47:13.813Z
At the beginning of Bitcoin history, everybody needed to get public key from receivers?
Satoshi Nakanishi
CC BY-SA 3.0
2016-10-11T03:57:04.767Z
@SatoshiNakanishi: They didn't *need* to; as far as I know P2PKH was legal from the outset.  But some people apparently used P2PK for regular transactions also (e.g. the first non-coinbase transaction in block 170).  In that case, yes, you would have to get the public key from the intended recipient.  But that's not really any harder than getting an address, which you also have to get from the intended recipient.
Nate Eldredge
CC BY-SA 3.0
2016-10-06T14:02:50.433Z
2016-10-06T14:15:47.777Z
2016-10-06T14:15:47.777Z
Nate Eldredge
<p>When you create a "Pay To Public Key" transaction, you need to know the receiver's public key. How can we know receiver's public key?</p>

<p>You can get public key hash from address like <a href="https://bitcoin.stackexchange.com/">this</a>, but I'm not sure how to get public key.</p>

<p>FYI: scriptPubkey in P2PK
scriptPubKey:  OP_CHECKSIG</p>

<public-key>
How can a sender know receiver's public key when creating "Pay To Public Key" tx?
Satoshi Nakanishi
# How can a sender know receiver's public key when creating "Pay To Public Key" tx?

(Asked by: username_0 on 2016-10-06)

When you create a "Pay To Public Key" transaction, you need to know the receiver's public key. How can we know receiver's public key?

You can get public key hash from address like [this](https://bitcoin.stackexchange.com/), but I'm not sure how to get public key.

FYI: scriptPubkey in P2PK
scriptPubKey: OP\_CHECKSIG

**Tags:** public-key


---

## 1 answers

### Answer by username_1 on 2016-10-06. Score: 2 | Accepted answer

In most cases, if you really want to use a P2PK transaction, you would have to ask the receiver to tell you their public key.

You can't determine the public key from the address alone. The address is a hash of the public key, and hash functions are one-way. So if all you have is an address, you can't use a P2PK transaction.

If the receiver has previously had other transactions sent to the desired address, and has spent at least one of those transactions, then the public key was included as part of the spending transaction's signature. So in that case, the public key is in the blockchain, and you could use it to make a P2PK transaction.

I'm not sure why you would bother, though. P2PK transactions are pretty much obsolete, and P2PKH should be used for all normal purposes.

> **Comments:**
> **username_0**: So at the beginning of Bitcoin, everybody needed to get public key from receivers? I heard that P2PK is still used in coinbase transactions. If so, miners are set a public key in coinbase?  
> **username_1**: @username_0: That's true, Bitcoin Core uses P2PK when it produces coinbase transactions.  In that case it is using the miner's own key, generated by Bitcoin Core itself, so of course it knows the public key.  But this is mostly a holdover from old code.  It's legal to use P2PKH in a coinbase transaction, and other mining software can do so; it just happens that Bitcoin Core uses P2PK.  
> **username_0**: At the beginning of Bitcoin history, everybody needed to get public key from receivers?  
> **username_1**: @username_0: They didn't *need* to; as far as I know P2PKH was legal from the outset.  But some people apparently used P2PK for regular transactions also (e.g. the first non-coinbase transaction in block 170).  In that case, yes, you would have to get the public key from the intended recipient.  But that's not really any harder than getting an address, which you also have to get from the intended recipient.  

---

