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


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.

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)

1 Answer 1


Yes, the scriptCode would be that multisig script.

  • 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
    Commented Nov 22, 2019 at 1:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.