<p>Because the address you are using is a P2SH-P2WPKH address as you mention (<code>sh (wpkh ())</code>), you get the output</p>
<blockquote>
<p>&quot;isscript&quot;: true,</p>
<p>&quot;iswitness&quot;: false</p>
</blockquote>
<p>It is talking only about the top level (P2SH), because it is a P2SH address, regardless of what the script &quot;inside&quot; it encodes. It doesn't &quot;see&quot; the underlying P2WPKH when you call <code>validateaddress</code>. The only time <code>isscript</code> and <code>iswitness</code> are both true, is for P2WSH addresses. You can view the code which creates this RPC <code>isscript</code>/<code>iswitness</code> output <a href="https://github.com/bitcoin/bitcoin/blob/244daa482151b5b9a8a145df0541880c8bdc03fc/src/rpc/util.cpp#L194" rel="nofollow noreferrer">here</a>.</p>
<p>When you spend it, you reveal the script inside the P2SH. Because it is a P2WPKH script, which is <code>OP_0 &lt;keyhash&gt;</code>, that script is then evaluated as such (using the key/signature data in the witness).</p>

CC BY-SA 4.0
2020-05-01T10:34:11.157Z
Is the wallet that decides which type of address to use? the incoming transactions to the addresses that I will generate will always be P2SH?
MaXbeMan
CC BY-SA 4.0
2020-05-01T11:56:02.613Z
You can choose which address type your wallet will generate. If you generate P2SH-P2WPKH addresses (as you have), then incoming transactions should follow the correct format yes. Technically though, if someone knows the key itself, they can also make transactions to the P2PKH and Bech32 forms of that key as well, and the wallet will currently accept them.
meshcollider
CC BY-SA 4.0
2020-05-01T13:24:10.157Z
for my wallet I generated 3 addresses with the getnewaddress command. All received utxo are in the same format. P2SH-P2WPKH is the standard format for  getnewaddress?
MaXbeMan
CC BY-SA 4.0
2020-05-05T04:21:27.133Z
It is the default for your version of bitcoin core, but you can change it
meshcollider
CC BY-SA 4.0
2020-05-01T09:36:42.667Z
2020-05-01T09:36:42.667Z
2020-06-16T11:10:03.350Z
meshcollider
<p>I state that I'm still a beginner. I need some clarification. I am using the Testnet. This is the information regarding the address I used to receive funds from a Faucet</p>

<pre><code> bitcoin-cli validateaddress 2N7MaihNErbNH8XTkuZWtJYPzMQAWMPVKHd
{
  "isvalid": true,
  "address": "2N7MaihNErbNH8XTkuZWtJYPzMQAWMPVKHd",
  "scriptPubKey": "a9149ac58ff47e27214b158b38da04bc8cbf72def14387",
  "isscript": true,
  "iswitness": false
}
bitcoin-cli decodescript a9149ac58ff47e27214b158b38da04bc8cbf72def14387
{
  "asm": "OP_HASH160 9ac58ff47e27214b158b38da04bc8cbf72def143 OP_EQUAL",
  "reqSigs": 1,
  "type": "scripthash",
  "addresses": [
    "2N7MaihNErbNH8XTkuZWtJYPzMQAWMPVKHd"
  ]
}
</code></pre>

<blockquote>
  <p>What do data mean? I interpret that my address will receive UTXO
  blocked by P2SH type scripts, correct? "iswitness": false means that
  this address cannot use UTXO segWit?</p>
</blockquote>

<p>On this address I received the following output as input:</p>

<pre><code>{
      "value": 0.01944571,
      "n": 1,
      "scriptPubKey": {
        "asm": "OP_HASH160 9ac58ff47e27214b158b38da04bc8cbf72def143 OP_EQUAL",
        "hex": "a9149ac58ff47e27214b158b38da04bc8cbf72def14387",
        "reqSigs": 1,
        "type": "scripthash",
        "addresses": [
          "2N7MaihNErbNH8XTkuZWtJYPzMQAWMPVKHd"
        ]
      }
</code></pre>

<p>The blocked UTXO is as follows:</p>

<pre><code>"txid": "a61389ff9af670770182198a984a4c1785625c60795bd57645ecc78765b23679",
    "vout": 1,
    "address": "2N7MaihNErbNH8XTkuZWtJYPzMQAWMPVKHd",
    "label": "",
    "redeemScript": "0014778daf651b21684b572644b47d551fce0ff71c74",
    "scriptPubKey": "a9149ac58ff47e27214b158b38da04bc8cbf72def14387",
    "amount": 0.01944571,
    "confirmations": 116,
    "spendable": true,
    "solvable": true,
    "desc": "sh(wpkh([7de694b7/0'/0'/7']032c27921f2d15e7eca768c0e8a8b1aeb863328c74d6c194d41dde2888d4b0e75b))#6z7uwusp",
</code></pre>

<p>"Sh (wpkh ())" describes a P2SH-P2WPKH output and the public key with which it is associated.</p>

<blockquote>
  <p>The descriptor is telling us that the hash (sh) script incorporates
  wpkh (Witness - Public - Key - Hash) output. In simple words the
  RedeemScript should match the HASH of this public key, correct?</p>
</blockquote>

<p>When I unlock and use this UTXO my input will generate a separate txinwitness field.</p>

<pre><code>"scriptSig": {
        "asm": "0014778daf651b21684b572644b47d551fce0ff71c74",
        "hex": "160014778daf651b21684b572644b47d551fce0ff71c74"
      },
      "txinwitness": [
        "3044022034a07f088dd88396cd378912a4ed6a156701b075f0facbbae810677048c390e602205df07e13bf4d56feece791a1b5e4d94bec9c93aae14bb87a1b4c6c54ae9bf2f701",
        "032c27921f2d15e7eca768c0e8a8b1aeb863328c74d6c194d41dde2888d4b0e75b"
      ],
      "sequence": 4294967295
</code></pre>

<p>I can't understand the link between my address information ("iswitness": false) and the ways in which I received / spent the UTXO.</p>

<address><segregated-witness><utxo><p2sh><output-script-descriptors>
What is the link between address and use of the UTXO?
MaXbeMan
# What is the link between address and use of the UTXO?

(Asked by: username_0 on 2020-05-01)

I state that I'm still a beginner. I need some clarification. I am using the Testnet. This is the information regarding the address I used to receive funds from a Faucet

```
 bitcoin-cli validateaddress 2N7MaihNErbNH8XTkuZWtJYPzMQAWMPVKHd
{
  "isvalid": true,
  "address": "2N7MaihNErbNH8XTkuZWtJYPzMQAWMPVKHd",
  "scriptPubKey": "a9149ac58ff47e27214b158b38da04bc8cbf72def14387",
  "isscript": true,
  "iswitness": false
}
bitcoin-cli decodescript a9149ac58ff47e27214b158b38da04bc8cbf72def14387
{
  "asm": "OP_HASH160 9ac58ff47e27214b158b38da04bc8cbf72def143 OP_EQUAL",
  "reqSigs": 1,
  "type": "scripthash",
  "addresses": [
    "2N7MaihNErbNH8XTkuZWtJYPzMQAWMPVKHd"
  ]
}

```

> What do data mean? I interpret that my address will receive UTXO
> blocked by P2SH type scripts, correct? "iswitness": false means that
> this address cannot use UTXO segWit?

On this address I received the following output as input:

```
{
      "value": 0.01944571,
      "n": 1,
      "scriptPubKey": {
        "asm": "OP_HASH160 9ac58ff47e27214b158b38da04bc8cbf72def143 OP_EQUAL",
        "hex": "a9149ac58ff47e27214b158b38da04bc8cbf72def14387",
        "reqSigs": 1,
        "type": "scripthash",
        "addresses": [
          "2N7MaihNErbNH8XTkuZWtJYPzMQAWMPVKHd"
        ]
      }

```

The blocked UTXO is as follows:

```
"txid": "a61389ff9af670770182198a984a4c1785625c60795bd57645ecc78765b23679",
    "vout": 1,
    "address": "2N7MaihNErbNH8XTkuZWtJYPzMQAWMPVKHd",
    "label": "",
    "redeemScript": "0014778daf651b21684b572644b47d551fce0ff71c74",
    "scriptPubKey": "a9149ac58ff47e27214b158b38da04bc8cbf72def14387",
    "amount": 0.01944571,
    "confirmations": 116,
    "spendable": true,
    "solvable": true,
    "desc": "sh(wpkh([7de694b7/0'/0'/7']032c27921f2d15e7eca768c0e8a8b1aeb863328c74d6c194d41dde2888d4b0e75b))#6z7uwusp",

```

"Sh (wpkh ())" describes a P2SH-P2WPKH output and the public key with which it is associated.

> The descriptor is telling us that the hash (sh) script incorporates
> wpkh (Witness - Public - Key - Hash) output. In simple words the
> RedeemScript should match the HASH of this public key, correct?

When I unlock and use this UTXO my input will generate a separate txinwitness field.

```
"scriptSig": {
        "asm": "0014778daf651b21684b572644b47d551fce0ff71c74",
        "hex": "160014778daf651b21684b572644b47d551fce0ff71c74"
      },
      "txinwitness": [
        "3044022034a07f088dd88396cd378912a4ed6a156701b075f0facbbae810677048c390e602205df07e13bf4d56feece791a1b5e4d94bec9c93aae14bb87a1b4c6c54ae9bf2f701",
        "032c27921f2d15e7eca768c0e8a8b1aeb863328c74d6c194d41dde2888d4b0e75b"
      ],
      "sequence": 4294967295

```

I can't understand the link between my address information ("iswitness": false) and the ways in which I received / spent the UTXO.

**Tags:** address, segregated-witness, utxo, p2sh, output-script-descriptors


---

## 1 answers

### Answer by username_1 on 2020-05-01. Score: 2 | Accepted answer

Because the address you are using is a P2SH-P2WPKH address as you mention (`sh (wpkh ())`), you get the output

> "isscript": true,
>
> "iswitness": false

It is talking only about the top level (P2SH), because it is a P2SH address, regardless of what the script "inside" it encodes. It doesn't "see" the underlying P2WPKH when you call `validateaddress`. The only time `isscript` and `iswitness` are both true, is for P2WSH addresses. You can view the code which creates this RPC `isscript`/`iswitness` output [here](https://github.com/bitcoin/bitcoin/blob/244daa482151b5b9a8a145df0541880c8bdc03fc/src/rpc/util.cpp#L194).

When you spend it, you reveal the script inside the P2SH. Because it is a P2WPKH script, which is `OP_0 <keyhash>`, that script is then evaluated as such (using the key/signature data in the witness).

> **Comments:**
> **username_0**: Is the wallet that decides which type of address to use? the incoming transactions to the addresses that I will generate will always be P2SH?  
> **username_1**: You can choose which address type your wallet will generate. If you generate P2SH-P2WPKH addresses (as you have), then incoming transactions should follow the correct format yes. Technically though, if someone knows the key itself, they can also make transactions to the P2PKH and Bech32 forms of that key as well, and the wallet will currently accept them.  
> **username_0**: for my wallet I generated 3 addresses with the getnewaddress command. All received utxo are in the same format. P2SH-P2WPKH is the standard format for  getnewaddress?  
> **username_1**: It is the default for your version of bitcoin core, but you can change it  

---

