<p>Yes, the scriptCode would be that multisig script.</p>

CC BY-SA 4.0
2019-11-22T01:42:15.997Z
Thanks.

Now that I just found out, I wanted to add that in the bip143 transaction digest, the scriptCode needs to be preceded by a byte indicating the length of the scriptCode.
Darius
CC BY-SA 4.0
2019-11-21T00:19:30.173Z
2019-11-21T00:19:30.173Z
Ava Chow
<p>Let's say I am spending from a 2-of-2 multisig with this script:</p>

<pre><code>522103c2f21de0f430251d8e3987fbe89ff51f3d6f3a48b234b84b60ddb9f24d587cf52103e0948a03f50377290847d27c93d383b8ab7e2d0bc065e96e0e1136b315388b5452ae

OP_2 &lt;len(pubkey1)&gt; &lt;pubkey1&gt; &lt;len(pubkey2)&gt; &lt;pubkey2&gt; OP_2 OP_CHECKMULTISIG
</code></pre>

<p>What would go in the scriptCode according to BIP143? Is it just the script listed above? Here is the relevant part from <a href="https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki" rel="nofollow noreferrer">BIP143</a>.</p>

<blockquote>
  <p>For P2WSH witness program,<br>
  - if the witnessScript does not contain any OP_CODESEPARATOR, the scriptCode is the witnessScript serialized as scripts inside CTxOut.<br>
  - if the witnessScript contains any OP_CODESEPARATOR, the scriptCode is the witnessScript but removing everything up to and including the last executed OP_CODESEPARATOR before the signature checking opcode being executed, serialized as scripts inside CTxOut. (The exact semantics is demonstrated in the examples below)</p>
</blockquote>

<script><segregated-witness><p2wsh>
What is the scriptCode in a P2WSH transaction?
Darius
# What is the scriptCode in a P2WSH transaction?

(Asked by: username_0 on 2019-11-20)

Let's say I am spending from a 2-of-2 multisig with this script:

```
522103c2f21de0f430251d8e3987fbe89ff51f3d6f3a48b234b84b60ddb9f24d587cf52103e0948a03f50377290847d27c93d383b8ab7e2d0bc065e96e0e1136b315388b5452ae

OP_2 <len(pubkey1)> <pubkey1> <len(pubkey2)> <pubkey2> OP_2 OP_CHECKMULTISIG

```

What would go in the scriptCode according to BIP143? Is it just the script listed above? Here is the relevant part from [BIP143](https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki).

> For P2WSH witness program,  
> - if the witnessScript does not contain any OP\_CODESEPARATOR, the scriptCode is the witnessScript serialized as scripts inside CTxOut.  
> - if the witnessScript contains any OP\_CODESEPARATOR, the scriptCode is the witnessScript but removing everything up to and including the last executed OP\_CODESEPARATOR before the signature checking opcode being executed, serialized as scripts inside CTxOut. (The exact semantics is demonstrated in the examples below)

**Tags:** script, segregated-witness, p2wsh


---

## 1 answers

### Answer by username_1 on 2019-11-21. Score: 1 | Accepted answer

Yes, the scriptCode would be that multisig script.

> **Comments:**
> **username_0**: Thanks.  Now that I just found out, I wanted to add that in the bip143 transaction digest, the scriptCode needs to be preceded by a byte indicating the length of the scriptCode.  

---

