2

Can we say that if there is at least 1 input with a legacy script then the tx is a non-segwit transaction?

3

It depends for what purpose.

When do segwit validation rules apply?

P2WPKH/P2WSH script validity rules apply on a per-input basis.

Only inputs that spend a segwit output can have a non-empty witness.

When is extended serialization used?

BIP144 defines a new way for serializing transactions. It is used whenever at least one input has a non-empty witness. It cannot be used when all witnesses are empty (as is the case for legacy spends).

When do the malleability protections afforded by segwit apply?

Only when all (relevant) inputs are segwit inputs do these protections work. However, say a transaction has a multisig segwit input and a legacy single-sig input from yourself, you may be fine, as the single-sig input may be considered non-malleable.

6
  • I didn't understand this part: "Only inputs that spend a segwit output can have a non-empty witness". Does that mean Tx: 96bae089a98234fe4bec93dcd92bfb24acdba84563cffd70d8cba1adf276567b would have no witness if the input was spending a segwit output?
    – Prayank
    Sep 3 '20 at 2:01
  • 1
    @Prayank I'm confused by your question. There is a rule that only segwit inputs can have (segregated) witnesses, that's all I'm saying. Sep 3 '20 at 2:37
  • Sorry I read your answer and my question again. My question doesn't make sense. Maybe I need to sleep for a while.
    – Prayank
    Sep 3 '20 at 3:04
  • @PieterWuille Thanks for the answer. Is it correct to say that a segwit transaction is a transaction that spends at least one input with a non-empty witness? It would be nice if you can explain this in layman's terms.
    – yahiheb
    Sep 4 '20 at 19:07
  • 1
    Well what do you care about when you say "segwit transaction"? You must have a particular definition of that term in mind. I would indeed say that a transaction with at least one segwit input is a segwit transaction, but that's a rather arbitrary convention. If for example by "segwit transaction" you mean "a transaction that is protected from malleability through segwit", then the answer may differ. Sep 4 '20 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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