<p>It depends for what purpose.</p>
<h3>When do segwit validation rules apply?</h3>
<p>P2WPKH/P2WSH script validity rules apply on a per-input basis.</p>
<p>Only inputs that spend a segwit output can have a non-empty witness.</p>
<h3>When is extended serialization used?</h3>
<p>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).</p>
<h3>When do the malleability protections afforded by segwit apply?</h3>
<p>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.</p>

CC BY-SA 4.0
2020-09-03T02:37:06.500Z
@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.
Pieter Wuille
CC BY-SA 4.0
2020-09-04T19:07:57.303Z
@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
CC BY-SA 4.0
2020-09-04T19:18:19.150Z
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.
Pieter Wuille
CC BY-SA 4.0
2020-09-04T21:25:44.283Z
I don't have anything particular in mind, I just wanted to know the difference because many articles/resources mention a segwit transaction or a non-segwit transaction, but I guess there is no clear answer to that. Thank you
yahiheb
CC BY-SA 4.0
2020-09-03T01:44:05.637Z
2020-09-03T01:44:05.637Z
Pieter Wuille
<p>Can we say that if there is at least 1 input with a legacy script then the tx is a non-segwit transaction?</p>

<segregated-witness>
What makes a transaction a SegWit transaction or a non-SegWit transaction?
yahiheb
# What makes a transaction a SegWit transaction or a non-SegWit transaction?

(Asked by: username_0 on 2020-09-03)

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

**Tags:** segregated-witness


---

## 1 answers

### Answer by username_1 on 2020-09-03. Score: 3 | Accepted answer

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.

> **Comments:**
> **username_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.  
> **username_0**: @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.  
> **username_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.  
> **username_0**: I don't have anything particular in mind, I just wanted to know the difference because many articles/resources mention a segwit transaction or a non-segwit transaction, but I guess there is no clear answer to that. Thank you  

---

