<ul>
<li><strong>P2PKH</strong>: Starts with &quot;1&quot;. Commonly known as &quot;Legacy Address&quot;. They have a known vbyte size. Size to spend is predictable.</li>
<li><strong>P2SH</strong>: Starts with &quot;3&quot;. You would know if you made a P2SH address, since they're almost always involved with n-of-m multisig. Vary in size depending on how many parties are involved in the multisig. Size to spend is unknown unless the wallet you're spending from knows how to spend it or you created the transaction manually.</li>
<li><strong>P2WPKH in P2SH</strong>: Starts with &quot;3&quot;. Commonly known as &quot;Segwit Address&quot;. Quickly becoming, if not already, the most common address type. They have a known vbyte size. Size to spend is predictable.</li>
<li><strong>P2WSH in P2SH</strong>: Starts with &quot;3&quot;. Likewise with P2SH, you'd know if you made this type of address as it's involved in n-of-m multisig. Vary in size depending on how many parties are involved in the multisig. Size to spend is known unless the wallet you're spending from knows how to spend it or you created the transaction mnually.</li>
<li><strong>P2WPKH</strong>: Starts with &quot;bc1q&quot;. Commonly known as &quot;Native Segwit Address&quot;. They have a known vbyte size. Size to spend is predictable.</li>
<li><strong>P2WSH</strong>: Just like P2SH but starting with &quot;bc1q&quot; and much longer than a P2WPKH address.</li>
<li><strong>P2TR</strong>: No idea what this is unfortunately. Looks like it stands for &quot;Pay 2 Taproot&quot;. But I admit that I don't know much about Taproot, and I don't think this has been implemented on mainnet yet.</li>
</ul>
<blockquote>
<p>Please tell me how to get the address type by API for implementing this formula?</p>
</blockquote>
<p>I don't know what API you're referring to, but if you are running a Bitcoin Node you can run the command <code>bitcoin-cli getaddressinfo &quot;YOUR_ADDRESS_HERE&quot;</code> to get information about a particular address. Note that for addresses starting with &quot;3&quot;, you will not be able to determine if it is P2WPKH in P2SH vs. P2SH, as they are indistinguishable from each other until spent. They will both have <code>&quot;isscript&quot;: true</code>. For &quot;bc1q&quot; addresses, they will both have <code>&quot;iswitness&quot;: true</code> and P2WSH will also have <code>&quot;isscript&quot;: true</code>.</p>

CC BY-SA 4.0
2020-06-20T04:17:00.723Z
2020-06-20T04:17:00.723Z
Septem151
<p>Help me please. I need to calculate vsize and multiply it by the function result  <code>estimatesmartfee</code>.
To calculate vsize, I implement a formula like this <a href="https://jlopp.github.io/bitcoin-transaction-size-calculator/" rel="nofollow noreferrer">https://jlopp.github.io/bitcoin-transaction-size-calculator/</a>
byt i cannot getting address type from Bitcoin API.</p>
<p>Please tell me how to <strong>get the address type by API</strong> for implementing this formula?</p>

CC BY-SA 4.0
2020-06-18T13:25:25.997Z
Related: https://bitcoin.stackexchange.com/a/67896/26873
m1xolyd1an
CC BY-SA 4.0
2020-06-18T13:44:20.320Z
Perhaps this is somehow related to my question, but I did not understand how to determine which type the address from which I send funds and the address to which I send funds according to the following types, belong to?

`P2PKH`
`P2SH`
`P2WPKH in P2SH`
`P2WSH in P2SH`
`P2WPKH`
`P2WSH`
`P2TR`

If you can more details please
ArchiKu
<transaction-fees>
How to get address type(format). Need to calculate vsize and fee
ArchiKu
# How to get address type(format). Need to calculate vsize and fee

(Asked by: username_0 on 2020-06-18)

Help me please. I need to calculate vsize and multiply it by the function result `estimatesmartfee`.
To calculate vsize, I implement a formula like this <https://jlopp.github.io/bitcoin-transaction-size-calculator/>
byt i cannot getting address type from Bitcoin API.

Please tell me how to **get the address type by API** for implementing this formula?

**Tags:** transaction-fees

> **Comments:**
> **username_1**: Related: https://bitcoin.stackexchange.com/a/67896/26873  
> **username_0**: Perhaps this is somehow related to my question, but I did not understand how to determine which type the address from which I send funds and the address to which I send funds according to the following types, belong to?  `P2PKH` `P2SH` `P2WPKH in P2SH` `P2WSH in P2SH` `P2WPKH` `P2WSH` `P2TR`  If you can more details please  

---

## 1 answers

### Answer by username_2 on 2020-06-20. Score: 1 | Accepted answer

* **P2PKH**: Starts with "1". Commonly known as "Legacy Address". They have a known vbyte size. Size to spend is predictable.
* **P2SH**: Starts with "3". You would know if you made a P2SH address, since they're almost always involved with n-of-m multisig. Vary in size depending on how many parties are involved in the multisig. Size to spend is unknown unless the wallet you're spending from knows how to spend it or you created the transaction manually.
* **P2WPKH in P2SH**: Starts with "3". Commonly known as "Segwit Address". Quickly becoming, if not already, the most common address type. They have a known vbyte size. Size to spend is predictable.
* **P2WSH in P2SH**: Starts with "3". Likewise with P2SH, you'd know if you made this type of address as it's involved in n-of-m multisig. Vary in size depending on how many parties are involved in the multisig. Size to spend is known unless the wallet you're spending from knows how to spend it or you created the transaction mnually.
* **P2WPKH**: Starts with "bc1q". Commonly known as "Native Segwit Address". They have a known vbyte size. Size to spend is predictable.
* **P2WSH**: Just like P2SH but starting with "bc1q" and much longer than a P2WPKH address.
* **P2TR**: No idea what this is unfortunately. Looks like it stands for "Pay 2 Taproot". But I admit that I don't know much about Taproot, and I don't think this has been implemented on mainnet yet.

> Please tell me how to get the address type by API for implementing this formula?

I don't know what API you're referring to, but if you are running a Bitcoin Node you can run the command `bitcoin-cli getaddressinfo "YOUR_ADDRESS_HERE"` to get information about a particular address. Note that for addresses starting with "3", you will not be able to determine if it is P2WPKH in P2SH vs. P2SH, as they are indistinguishable from each other until spent. They will both have `"isscript": true`. For "bc1q" addresses, they will both have `"iswitness": true` and P2WSH will also have `"isscript": true`.


---

