1

The term CTxOut is mentioned several times in BIP143 and BIP341. However, I can't understand what it actually represents? I assume it's just the transaction output, but I am not sure and the confusion comes from the following. BIP143 says:

  • For P2WSH witness program,
    • if the witnessScript does not contain any OP_CODESEPARATOR, the scriptCode is the > witnessScript serialized as scripts inside CTxOut.

I know that the witness script in P2WSH is the same as the redeem script in P2SH. While in P2SH the redeem script is the last push inside scriptSig, the witness script in P2WSH is the last item on the witness stack, that is the last item in witness data. However, in both cases, this (redeem/witness) script in the output is serialized in the form of its hash. Since I know that the scriptCode in P2WSH is the witness script (with its operators and data) and not its hash, CTxOut looks more like the witness data section of the transaction to me than the output of the transaction.

What is the CTxOut? Am I misinterpreting what is written in BIP143?

1 Answer 1

2

CTxOut is a class in Bitcoin Core which represents a transaction's output. It is the output amount and the output script. The sentence in question is specifically stating that the witnessScript should be serialized in the same way that output scripts in CTxOuts are serialized.

3
  • Looks like I misinterpreted it then. Thanks Andrew!
    – dassd
    Oct 24, 2023 at 0:37
  • Just one question, does output script inside CTxOut start with the length of the script or is it just a script?
    – dassd
    Oct 24, 2023 at 0:39
  • 1
    They are length prefixed.
    – Ava Chow
    Oct 24, 2023 at 0:41

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.