<p>6 types of Bitcoin addresses (in parentheses are the data they keep):</p>
<h2>Legacy</h2>
<ul>
<li>P2PKH 1... (a public key's hash)</li>
<li>P2SH  3... (a script's hash) (defined in BIP16)</li>
</ul>
<h2>SegWit (P2WPKH/P2WSH) nested in P2SH (defined in BIP141)</h2>
<ul>
<li>P2SH-P2WPKH 3... (a public key's hash)</li>
<li>P2SH-P2WSH 3... (a script's hash)</li>
</ul>
<p>(these start with three because these addresses are meant to be compatible with existing wallets, who would see those addresses as P2SH wallets)</p>
<h2>Native SegWit (P2WPKH/P2WSH) (defined in BIP141 + BIP173)</h2>
<ul>
<li>P2WPKH bc1... (a public key's hash)</li>
<li>P2WSH bc1... (a script's hash) (but longer than P2WPKH)</li>
</ul>
<blockquote>
<p>which kind of script I have? P2PK?</p>
</blockquote>
<p><code>getnewaddress</code> can't return P2PK because you can either pay directly to a script (which can be P2PK) or a script enclosed in P2SH (or its derivatives P2SH-P2WSH and P2WSH). But that's not very useful.</p>
<p>The documentation says:</p>
<blockquote>
<p>Arguments:</p>
<ol>
<li><p>&quot;label&quot;          (string, optional) The label name for the address to be linked to. If not provided, the default label &quot;&quot; is used. It can also be set to the empty string &quot;&quot; to represent the default label. The label does not need to exist, it will be created if there is no label by the given name.</p>
</li>
<li><p>&quot;address_type&quot;   (string, optional) The address type to use. Options are &quot;legacy&quot;, &quot;p2sh-segwit&quot;, and &quot;bech32&quot;. Default is set by -addresstype.</p>
</li>
</ol>
</blockquote>
<p>The <em>legacy</em> type means P2PKH, <em>p2sh-segwit</em> means P2SH-P2WPKH and <em>bech32</em> means P2WPKH.</p>

CC BY-SA 4.0
2020-03-29T14:47:16.523Z
In P2SH-P2WPKH that I can get with `getnewaddress` P2WPKH has the bech32 logic inside (https://en.bitcoin.it/wiki/BIP_0173)? is it native bech32 but wrapped into P2SH?
monkeyUser
CC BY-SA 4.0
2020-03-29T14:54:16.307Z
The goal of SegWit addresses is to move signatures to a register named "witness". Because both P2WPKH and P2SH-P2WPKH do that, both are SegWit addresses. But a native SegWit address is more space efficient than a P2SH-nested address; it saves about twenty bytes ([examples](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#examples)). And Bech32 is the serialization method to represent native SegWit addresses. So both are SegWit addresses but Bech32 is *more SegWit* as it doesn't aim to be backwards-compatible (so old wallets can't send to it but it can send anywhere)
MCCCS
CC BY-SA 4.0
2020-03-29T14:56:23.720Z
So slightly different mechanics.
MCCCS
CC BY-SA 4.0
2020-03-29T15:01:05.763Z
thanks again, here https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#examples I can See P2WPKH not inside P2SH. In that case what kind of address I have? With 1 ?
monkeyUser
CC BY-SA 4.0
2020-03-29T15:18:48.593Z
If it doesn't mention P2SH and it's SegWit then it's a native address, represented by Bech32. In mainnet all Bech32 addresses start with `bc1` (unless they change it in the future).
MCCCS
CC BY-SA 4.0
2020-03-29T15:20:49.587Z
Then P2SH-P2WPKH, P2SH wrap a native P2WPKH, right? thanks again for your time man
monkeyUser
CC BY-SA 4.0
2020-03-29T15:40:06.480Z
No they have different spending ways (different scriptSig and scriptPubKey). Another way to think of it as is that a P2WPKH is not a script (there is no CHECKSIG, etc opcodes recorded in the blockchain) therefore it can't be nested in P2SH therefore P2SH-P2WPKH is a completely different format. You're welcome, feel free to ask if you have more questions.
MCCCS
CC BY-SA 4.0
2020-03-29T19:21:59.003Z
how can I create P2WPKH not native?
monkeyUser
CC BY-SA 4.0
2020-03-29T20:36:55.693Z
The command you wrote in the question does that
MCCCS
CC BY-SA 4.0
2020-03-29T21:32:58.400Z
Than I don't understand the different between P2WPKH and P2WPKH nested in BIP16 P2SH and How create these addresses. If with this command `bitcoin-cli getnewaddress "segwit" "p2sh-segwit" ` I create `P2WPKH` How can I create `P2WPKH nested in BIP16 P2SH`? both address are inside P2SH, then both are nested
monkeyUser
CC BY-SA 4.0
2020-03-30T08:07:27.170Z
`bitcoin-cli getnewaddress "segwit" "p2sh-segwit"` is P2SH-P2WPKH. `bitcoin-cli getnewaddress "segwit" "bech32"` is native P2WPKH.
MCCCS
CC BY-SA 4.0
2020-03-29T14:33:27.210Z
2020-03-29T14:33:27.210Z
2020-06-16T11:10:03.350Z
MCCCS
<p>I have a little bit confusion about addresses segwit and not segwit.</p>

<p>I can see <strong>P2WPKH</strong> and <strong>P2WSH</strong> from this link <a href="https://en.bitcoin.it/wiki/BIP_0173" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/BIP_0173</a>, and they are segwit and start with <strong>bc</strong> (mainnet) or <strong>tb</strong> (testnet).</p>

<p>But I can see even P2SH, start with 3 nested P2WPKH or P2WSH, and that address start with 3.</p>

<p>Then When we speak about <strong>P2WPKH</strong> and <strong>P2WSH</strong> we mean Native and start with <strong>bc</strong>, or We can have even P2WPKH start with 1 and P2WSH start with 3?</p>

<p>when I create</p>

<pre><code>bitcoin-cli getnewaddress "segwit" "p2sh-segwit" 
</code></pre>

<p>which kind of script I have? P2PK?</p>

CC BY-SA 4.0
2020-03-29T21:19:49.873Z
For more information about address types, see [my github writeup](https://github.com/EAWF/Bitcoin-Merchants-Toolbox/blob/master/Address-Derivation.md) on address derivation.
Septem151
<address><segregated-witness><witness-data>
Confusion about Addresses
monkeyUser
# Confusion about Addresses

(Asked by: username_0 on 2020-03-29)

I have a little bit confusion about addresses segwit and not segwit.

I can see **P2WPKH** and **P2WSH** from this link <https://en.bitcoin.it/wiki/BIP_0173>, and they are segwit and start with **bc** (mainnet) or **tb** (testnet).

But I can see even P2SH, start with 3 nested P2WPKH or P2WSH, and that address start with 3.

Then When we speak about **P2WPKH** and **P2WSH** we mean Native and start with **bc**, or We can have even P2WPKH start with 1 and P2WSH start with 3?

when I create

```
bitcoin-cli getnewaddress "segwit" "p2sh-segwit" 

```

which kind of script I have? P2PK?

**Tags:** address, segregated-witness, witness-data

> **Comments:**
> **username_1**: For more information about address types, see [my github writeup](https://github.com/EAWF/Bitcoin-Merchants-Toolbox/blob/master/Address-Derivation.md) on address derivation.  

---

## 1 answers

### Answer by username_2 on 2020-03-29. Score: 4 | Accepted answer

6 types of Bitcoin addresses (in parentheses are the data they keep):

## Legacy

* P2PKH 1... (a public key's hash)
* P2SH 3... (a script's hash) (defined in BIP16)

## SegWit (P2WPKH/P2WSH) nested in P2SH (defined in BIP141)

* P2SH-P2WPKH 3... (a public key's hash)
* P2SH-P2WSH 3... (a script's hash)

(these start with three because these addresses are meant to be compatible with existing wallets, who would see those addresses as P2SH wallets)

## Native SegWit (P2WPKH/P2WSH) (defined in BIP141 + BIP173)

* P2WPKH bc1... (a public key's hash)
* P2WSH bc1... (a script's hash) (but longer than P2WPKH)

> which kind of script I have? P2PK?

`getnewaddress` can't return P2PK because you can either pay directly to a script (which can be P2PK) or a script enclosed in P2SH (or its derivatives P2SH-P2WSH and P2WSH). But that's not very useful.

The documentation says:

> Arguments:
>
> 1. "label" (string, optional) The label name for the address to be linked to. If not provided, the default label "" is used. It can also be set to the empty string "" to represent the default label. The label does not need to exist, it will be created if there is no label by the given name.
> 2. "address\_type" (string, optional) The address type to use. Options are "legacy", "p2sh-segwit", and "bech32". Default is set by -addresstype.

The *legacy* type means P2PKH, *p2sh-segwit* means P2SH-P2WPKH and *bech32* means P2WPKH.

> **Comments:**
> **username_0**: In P2SH-P2WPKH that I can get with `getnewaddress` P2WPKH has the bech32 logic inside (https://en.bitcoin.it/wiki/BIP_0173)? is it native bech32 but wrapped into P2SH?  
> **username_2**: The goal of SegWit addresses is to move signatures to a register named "witness". Because both P2WPKH and P2SH-P2WPKH do that, both are SegWit addresses. But a native SegWit address is more space efficient than a P2SH-nested address; it saves about twenty bytes ([examples](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#examples)). And Bech32 is the serialization method to represent native SegWit addresses. So both are SegWit addresses but Bech32 is *more SegWit* as it doesn't aim to be backwards-compatible (so old wallets can't send to it but it can send anywhere)  
> **username_2**: So slightly different mechanics.  
> **username_0**: thanks again, here https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#examples I can See P2WPKH not inside P2SH. In that case what kind of address I have? With 1 ?  
> **username_2**: If it doesn't mention P2SH and it's SegWit then it's a native address, represented by Bech32. In mainnet all Bech32 addresses start with `bc1` (unless they change it in the future).  
> **username_0**: Then P2SH-P2WPKH, P2SH wrap a native P2WPKH, right? thanks again for your time man  
> **username_2**: No they have different spending ways (different scriptSig and scriptPubKey). Another way to think of it as is that a P2WPKH is not a script (there is no CHECKSIG, etc opcodes recorded in the blockchain) therefore it can't be nested in P2SH therefore P2SH-P2WPKH is a completely different format. You're welcome, feel free to ask if you have more questions.  
> **username_0**: how can I create P2WPKH not native?  
> **username_2**: The command you wrote in the question does that  
> **username_0**: Than I don't understand the different between P2WPKH and P2WPKH nested in BIP16 P2SH and How create these addresses. If with this command `bitcoin-cli getnewaddress "segwit" "p2sh-segwit" ` I create `P2WPKH` How can I create `P2WPKH nested in BIP16 P2SH`? both address are inside P2SH, then both are nested  
> **username_2**: `bitcoin-cli getnewaddress "segwit" "p2sh-segwit"` is P2SH-P2WPKH. `bitcoin-cli getnewaddress "segwit" "bech32"` is native P2WPKH.  

---

