What will it mean if the tranasaction input contains both signature script and witness, in case of scriptpubkey_type of p2sh or p2pkh, will it be invalid or valid ? As we use witness for SegWit Transactions.

1 Answer 1


Any input spending a non-segwit script type must not have a witness. If it does, the transaction is invalid.

P2SH-P2WSH and P2SH-P2WPKH are the exceptions: if the script type is P2SH and the redeemScript is P2WSH or P2WPKH, then a witness is allowed, and is verified according to the P2WSH and P2WPKH verification rules.

  • how is it determined when p2wsh is nested with p2sh or p2wpkh is nested with p2sh?
    – lladane
    Commented Mar 21 at 18:49
  • It is determined during script evaluation. When a P2SH is evaluated and the redeemScript pulled out as part of that, the redeemScript is inspected to see if it is P2WPKH or P2WSH.
    – Ava Chow
    Commented Mar 22 at 16:27

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.