<p>There is no address format that can produce a P2PK script. You can produce a P2PKH address from a pubkey with the process that you describe, but that address will result in a P2PKH script. This is a different script from a P2PK script and cannot be used to make a P2PK script as there is a hash involved. Therefore it is misleading to return an address for a P2PK script as such an address does not exist, and any address that would be returned does not actually map to the P2PK script.</p>

CC BY-SA 4.0
2023-05-04T17:48:40.347Z
Yes you are right but if we want to know the wallet address of P2PK then we convert this P2PK into PKHash and get the address because this is the only way to find out the wallet address of person which can be already done by the functions ExtractDestination and EncodeDestination in L165 of core_write.cpp so why don't just remove that check  type != TxoutType::PUBKEY and let the bitcoin core return the address of person instead of instead of just ignoring the address field in PUBKEY case . ?
saffi Khan
CC BY-SA 4.0
2023-05-04T18:19:05.567Z
P2PK and P2PKH are two distinct output types. There is no address standard for P2PK outputs. Returning the P2PKH address produced from the same public key is misleading and not helpful.
Murch
CC BY-SA 4.0
2023-05-04T14:27:52.767Z
2023-05-04T14:27:52.767Z
Ava Chow
<p>a few days ago I created a PR <a href="https://github.com/bitcoin/bitcoin/pull/27546" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/pull/27546</a>
where I proposed ScriptToUniv can give us wallet address of public key But some guy commented
&quot;Concept NACK
Sorry, no. P2PK outputs do not have an address. It's an outdated and confusing practice to refer to them as their corresponding P2PKH address&quot;</p>
<p>as far as my understanding</p>
<p>see we have</p>
<p>private key --&gt; secp256k1 -- &gt; public key --&gt; sha256 --&gt; RIPEMD160 --&gt; Hashed Publickey --&gt; hashed Publickey + checksum = wallet address</p>
<p>and we have the flow of ExtractDestination</p>
<p>PUBKEY --&gt;passed to --&gt; EXTRACT DESTINATION --&gt;PKHash returned</p>
<p>PUBKEYHASH --&gt;passed to --&gt; EXTRACT DESTINATION --&gt; PKHash returned</p>
<p>we pass this PKHash to EncodeDestination which passes it to DestinationEncoder which returns us the wallet address</p>
<p><a href="https://github.com/bitcoin/bitcoin/blob/master/src/core_write.cpp#L165" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/blob/master/src/core_write.cpp#L165</a></p>
<p>can someone please guide me where I am getting it wrong ?</p>

CC BY-SA 4.0
2023-05-04T14:41:05.680Z
See also https://bitcoin.stackexchange.com/a/117426/208
Pieter Wuille
<bitcoin-core><address><public-key><validation><p2pkh>
In bitcoin core can ScriptToUniv give us wallet address of public key?
saffi Khan
# In bitcoin core can ScriptToUniv give us wallet address of public key?

(Asked by: username_0 on 2023-05-04)

a few days ago I created a PR <https://github.com/bitcoin/bitcoin/pull/27546>
where I proposed ScriptToUniv can give us wallet address of public key But some guy commented
"Concept NACK
Sorry, no. P2PK outputs do not have an address. It's an outdated and confusing practice to refer to them as their corresponding P2PKH address"

as far as my understanding

see we have

private key --> secp256k1 -- > public key --> sha256 --> RIPEMD160 --> Hashed Publickey --> hashed Publickey + checksum = wallet address

and we have the flow of ExtractDestination

PUBKEY -->passed to --> EXTRACT DESTINATION -->PKHash returned

PUBKEYHASH -->passed to --> EXTRACT DESTINATION --> PKHash returned

we pass this PKHash to EncodeDestination which passes it to DestinationEncoder which returns us the wallet address

<https://github.com/bitcoin/bitcoin/blob/master/src/core_write.cpp#L165>

can someone please guide me where I am getting it wrong ?

**Tags:** bitcoin-core, address, public-key, validation, p2pkh

> **Comments:**
> **username_1**: See also https://bitcoin.stackexchange.com/a/117426/208  

---

## 1 answers

### Answer by username_2 on 2023-05-04. Score: 2

There is no address format that can produce a P2PK script. You can produce a P2PKH address from a pubkey with the process that you describe, but that address will result in a P2PKH script. This is a different script from a P2PK script and cannot be used to make a P2PK script as there is a hash involved. Therefore it is misleading to return an address for a P2PK script as such an address does not exist, and any address that would be returned does not actually map to the P2PK script.

> **Comments:**
> **username_0**: Yes you are right but if we want to know the wallet address of P2PK then we convert this P2PK into PKHash and get the address because this is the only way to find out the wallet address of person which can be already done by the functions ExtractDestination and EncodeDestination in L165 of core_write.cpp so why don't just remove that check  type != TxoutType::PUBKEY and let the bitcoin core return the address of person instead of instead of just ignoring the address field in PUBKEY case . ?  
> **username_3**: P2PK and P2PKH are two distinct output types. There is no address standard for P2PK outputs. Returning the P2PKH address produced from the same public key is misleading and not helpful.  

---

