WitnessScript vs. Script Witness In BIP 174/PSBT, there is a PSBT Input key-value pair called &quot;PSBT_IN_WITNESS_SCRIPT&quot; (0x05) and another called &quot;PSBT_IN_FINAL_SCRIPTWITNESS&quot; (0x08). What is the difference between a WitnessScript and a scriptWitness?
From what I understood, a witness script is the witness data for a single input (the signatures and scripts that unlock it). Is the scriptWitness something different?
PSBT_IN_WITNESS_SCRIPT is specifically the actually executed script for a P2WSH or P2SH-P2WSH scriptPubKey being spent. It is added by an Updater who knows it.
PSBT_IN_FINAL_SCRIPTWITNESS is the witness stack needed to spend an output, including scripts, signatures, public keys, ... whatever is needed. It is created by a Finalizer, using other fields necessary (including PSBT_IN_WITNESS_SCRIPT) to produce it.