<p>SegWit introduced a compatibility mode usually called <em>wrapped SegWit</em> or <em>nested SegWit</em>. It allows you to create a P2SH output spendable using SegWit rules, which include the witness discount and malleability fix. It's slightly more expensive than <em>native SegWit</em> (which uses a new output type whose addresses start with bc1) because of the extra data included in the scriptSig, but it has the advantage of being supported in older software (which was especially useful after SegWit activation as some exchanges and wallets took years to implement sending to native SegWit).</p>

CC BY-SA 4.0
2024-02-26T15:10:03.333Z
2024-02-26T15:16:50.950Z
2024-02-26T15:16:50.950Z
Vojtěch Strnad
<p>You are looking at a transaction that spends <em>wrapped-segwit</em> (2-of-3 P2SH-P2WSH) inputs. Wrapped segwit was introduced as a bridging technology with segwit, because other than native segwit addresses, any sender that could already send to P2SH addresses was able to pay to them without an update and it allowed the receiver to immediately benefit from segwit improvements such as a reduced blockspace weight and the transaction malleability fix. In wrapped segwit inputs, the redeem script just checks the pre-image of the P2SH hash in the output, and then forwards to the witness stack for further validation.</p>

CC BY-SA 4.0
2024-02-26T15:08:49.983Z
2024-03-02T14:03:14.197Z
2024-03-02T14:03:14.197Z
Murch
<p><em>I wonder if the wallet screwed up or if I am missing something in my bitcoin understanding.</em></p>
<p><strong>Here is the tx output being spent:</strong></p>
<pre class="lang-json prettyprint-override"><code>    &quot;value&quot;: 0.00180675,
                &quot;n&quot;: 154,
                &quot;scriptPubKey&quot;: {
                    &quot;asm&quot;: &quot;OP_HASH160 771962306e72e479245d48e879dd2a1862225b4c OP_EQUAL&quot;,
                    &quot;hex&quot;: &quot;a914771962306e72e479245d48e879dd2a1862225b4c87&quot;,
                    &quot;address&quot;: &quot;3CYkk3x1XUvdXCdHtRFdjMjp17PuJ8eR8z&quot;,
                    &quot;type&quot;: &quot;scripthash&quot;
</code></pre>
<p><strong>Here is the spending Input:</strong></p>
<pre class="lang-json prettyprint-override"><code>    &quot;txid&quot;: &quot;d80ff02d0d9eb2da8c8a1c47ab099901f447dd197e34220ea13eca72d7d6d21d&quot;,
                    &quot;vout&quot;: 154,
                    &quot;scriptSig&quot;: {
                        &quot;asm&quot;: &quot;002044c55c1da36a576217259c3bc21b0c3943f7eb3ff4e3c381d9fd3502434b9e87&quot;,
                        &quot;hex&quot;: &quot;22002044c55c1da36a576217259c3bc21b0c3943f7eb3ff4e3c381d9fd3502434b9e87&quot;
                    },
                    &quot;txinwitness&quot;: [
                        &quot;&quot;,
                        &quot;304402202c3f94e5daf4057377d9f16d45b57e962de42fb42cb7e95a0382b7c66624980a02204098f6acd43b0391ea1b4a8102797e78895848fb7e883f98d207d14d45945a6901&quot;,
                        &quot;30440220448460edd5291a548c571ccf3a72caf47b02364035dc84f420d311e3a0c5494802205bb1cc89f20dc1e2c1f6eadb74898f8eecc46fbf488b676636b45fafaeb96e0f01&quot;,
                        &quot;5221021e6617e06bb90f621c3800e8c37ab081a445ae5527f6c5f68a022e7133f9b5fe2103bea1a8ce6369435bb74ff1584a136a7efeebfe4bc320b4d59113c92acd869f38210280631b27700baf7d472483fadfe1c4a7340a458f28bf6bae5d3234312d684c6553ae&quot;
                    ],
                    &quot;sequence&quot;: 4294967295
</code></pre>

<p2sh><input-script><spending><witness-data>
Why do some P2SH spending transactions have data both in the ScriptSig and Witness field?
J S
# Why do some P2SH spending transactions have data both in the ScriptSig and Witness field?

(Asked by: username_0 on 2024-02-26)

*I wonder if the wallet screwed up or if I am missing something in my bitcoin understanding.*

**Here is the tx output being spent:**

```json
    "value": 0.00180675,
                "n": 154,
                "scriptPubKey": {
                    "asm": "OP_HASH160 771962306e72e479245d48e879dd2a1862225b4c OP_EQUAL",
                    "hex": "a914771962306e72e479245d48e879dd2a1862225b4c87",
                    "address": "3CYkk3x1XUvdXCdHtRFdjMjp17PuJ8eR8z",
                    "type": "scripthash"

```

**Here is the spending Input:**

```json
    "txid": "d80ff02d0d9eb2da8c8a1c47ab099901f447dd197e34220ea13eca72d7d6d21d",
                    "vout": 154,
                    "scriptSig": {
                        "asm": "002044c55c1da36a576217259c3bc21b0c3943f7eb3ff4e3c381d9fd3502434b9e87",
                        "hex": "22002044c55c1da36a576217259c3bc21b0c3943f7eb3ff4e3c381d9fd3502434b9e87"
                    },
                    "txinwitness": [
                        "",
                        "304402202c3f94e5daf4057377d9f16d45b57e962de42fb42cb7e95a0382b7c66624980a02204098f6acd43b0391ea1b4a8102797e78895848fb7e883f98d207d14d45945a6901",
                        "30440220448460edd5291a548c571ccf3a72caf47b02364035dc84f420d311e3a0c5494802205bb1cc89f20dc1e2c1f6eadb74898f8eecc46fbf488b676636b45fafaeb96e0f01",
                        "5221021e6617e06bb90f621c3800e8c37ab081a445ae5527f6c5f68a022e7133f9b5fe2103bea1a8ce6369435bb74ff1584a136a7efeebfe4bc320b4d59113c92acd869f38210280631b27700baf7d472483fadfe1c4a7340a458f28bf6bae5d3234312d684c6553ae"
                    ],
                    "sequence": 4294967295

```

**Tags:** p2sh, input-script, spending, witness-data


---

## 2 answers

### Answer by username_1 on 2024-02-26. Score: 3 | Accepted answer

SegWit introduced a compatibility mode usually called *wrapped SegWit* or *nested SegWit*. It allows you to create a P2SH output spendable using SegWit rules, which include the witness discount and malleability fix. It's slightly more expensive than *native SegWit* (which uses a new output type whose addresses start with bc1) because of the extra data included in the scriptSig, but it has the advantage of being supported in older software (which was especially useful after SegWit activation as some exchanges and wallets took years to implement sending to native SegWit).


---

### Answer by username_2 on 2024-02-26. Score: 2

You are looking at a transaction that spends *wrapped-segwit* (2-of-3 P2SH-P2WSH) inputs. Wrapped segwit was introduced as a bridging technology with segwit, because other than native segwit addresses, any sender that could already send to P2SH addresses was able to pay to them without an update and it allowed the receiver to immediately benefit from segwit improvements such as a reduced blockspace weight and the transaction malleability fix. In wrapped segwit inputs, the redeem script just checks the pre-image of the P2SH hash in the output, and then forwards to the witness stack for further validation.


---

