<blockquote>
<p><strong>Is there a way to get <em>sender's public key</em> based <em>only</em> on the raw transaction data no matter the P2... type</strong></p>
</blockquote>
<p>Probably, if you exclude all current transaction types whose most popular names don't begin with the words &quot;pay to ...&quot;:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Script type</th>
<th>Public Key in locking script</th>
<th>Public Key in unlocking script</th>
</tr>
</thead>
<tbody>
<tr>
<td>Pay-to-Public-Key-Hash (P2PKH)</td>
<td>No</td>
<td>Yes</td>
</tr>
<tr>
<td>Pay-to-Public-Key</td>
<td>Yes</td>
<td>Yes</td>
</tr>
<tr>
<td>Multi-Signature</td>
<td>Yes</td>
<td>Yes</td>
</tr>
<tr>
<td>OP_RETURN</td>
<td>No</td>
<td>N/A</td>
</tr>
<tr>
<td>Pay-to-Script-Hash (P2SH)</td>
<td>No</td>
<td>Yes (in redeem script)</td>
</tr>
<tr>
<td><a href="https://en.bitcoin.it/wiki/Script#Transaction_puzzle" rel="nofollow noreferrer">Transaction Puzzle</a></td>
<td>N/A</td>
<td>N/A</td>
</tr>
<tr>
<td>...</td>
<td>?</td>
<td>?</td>
</tr>
</tbody>
</table>
</div>
<p>References:</p>
<ul>
<li><a href="https://www.oreilly.com/library/view/mastering-bitcoin/9781491902639/ch05.html" rel="nofollow noreferrer">https://www.oreilly.com/library/view/mastering-bitcoin/9781491902639/ch05.html</a></li>
<li><a href="https://en.bitcoin.it/wiki/Script" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Script</a></li>
<li><a href="https://www.quantabytes.com/articles/a-survey-of-bitcoin-transaction-types" rel="nofollow noreferrer">https://www.quantabytes.com/articles/a-survey-of-bitcoin-transaction-types</a></li>
</ul>
<p>The last of these is the most comprehensive of those listed, however it lacks full details.</p>
<hr />
<p>The method that can be used to retrieve the public keys in each case (i.e. answer to How?) can be found by inspecting the detailed descriptions in the linked references above. Exact details depend on available tools and skillsets.</p>

CC BY-SA 4.0
2021-02-25T15:42:25.320Z
@Prayank: Good point, I'll update the answer
RedGrittyBrick
CC BY-SA 4.0
2021-02-25T15:22:09.193Z
2021-02-25T16:33:44.363Z
2021-02-25T16:33:44.363Z
RedGrittyBrick
<p>Is there a way to get sender's public key based only on the raw transaction data no matter the P2... type?</p>

<transactions><public-key>
How to retrieve a public key from all types of transaction?
Curiousus
# How to retrieve a public key from all types of transaction?

(Asked by: username_0 on 2021-02-25)

Is there a way to get sender's public key based only on the raw transaction data no matter the P2... type?

**Tags:** transactions, public-key


---

## 1 answers

### Answer by username_1 on 2021-02-25. Score: 0 | Accepted answer

> **Is there a way to get *sender's public key* based *only* on the raw transaction data no matter the P2... type**

Probably, if you exclude all current transaction types whose most popular names don't begin with the words "pay to ...":

| Script type | Public Key in locking script | Public Key in unlocking script |
| --- | --- | --- |
| Pay-to-Public-Key-Hash (P2PKH) | No | Yes |
| Pay-to-Public-Key | Yes | Yes |
| Multi-Signature | Yes | Yes |
| OP\_RETURN | No | N/A |
| Pay-to-Script-Hash (P2SH) | No | Yes (in redeem script) |
| [Transaction Puzzle](https://en.bitcoin.it/wiki/Script#Transaction_puzzle) | N/A | N/A |
| ... | ? | ? |

References:

* <https://www.oreilly.com/library/view/mastering-bitcoin/9781491902639/ch05.html>
* <https://en.bitcoin.it/wiki/Script>
* <https://www.quantabytes.com/articles/a-survey-of-bitcoin-transaction-types>

The last of these is the most comprehensive of those listed, however it lacks full details.

---

The method that can be used to retrieve the public keys in each case (i.e. answer to How?) can be found by inspecting the detailed descriptions in the linked references above. Exact details depend on available tools and skillsets.

> **Comments:**
> **username_1**: @Prayank: Good point, I'll update the answer  

---

