<p>Not all unspent outputs need signature scripts. Of course, this doesn't have many uses (but puzzles. for example, proof of SHA256 collision to redeem funds) but such a thing exists. UTXO that don't need a ScriptSig are called an AnyoneCanSpend outputs. Such transactions are considered <a href="https://bitcoin.stackexchange.com/a/52529/38618">nonstandard</a> and are not relayed in the network. However, if a miner includes a nonstandard transaction in their block, their block will be valid and the transaction will be relayed.</p>

<p>A SegWit-P2WSH output looks like this:</p>

<pre><code>00148ca0e5d2474900bf82376926da8c5f4464bd7bd3
</code></pre>

<p>Does it start with a version byte? ✓
<br>Does it have a 20-byte Witness Program*? ✓
<br>Is the ScriptSig empty*? ✓</p>

<p>*Doesn't have to be. Details: <a href="https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki" rel="nofollow noreferrer">https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki</a></p>

<p>Congrats, that's a SegWit output! Legacy nodes see it as a nonstandard transaction, and don't relay it. The SegWit nodes check the output for the conditions above, understand that it's a SegWit output. Next, they check the transaction for a valid "witness". It's not a nonstandard transaction for them, and they relay it to the other SegWit nodes. After a miner puts it in their block, legacy nodes will understand that it's a nonstandard/AnyoneCanSpend script, and will honor it.</p>

CC BY-SA 4.0
2018-05-26T19:02:04.020Z
Makes sense, but where does the witness end up in this situation? And where does the segwit address come into play?
arshbot
CC BY-SA 4.0
2018-05-27T10:43:39.053Z
@arshbot Transactions have a witness part (https://bitcoincore.org/en/segwit_wallet_dev/#transaction-serialization example (enable advanced info): https://blockchain.info/tx/c586389e5e4b3acb9d6c8be1c19ae8ab2795397633176f5a6442a261bbdefc3a) The scriptSig carries the version + witness program, which is not the witness itself, but the hash of the pubkey in the witness part: https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#p2wpkh-nested-in-bip16-p2sh
MCCCS
CC BY-SA 4.0
2018-09-10T16:23:34.627Z
I stumbled over the "not a nonstandard" phrasing. You could just say it's a standard transaction for segwit-enabled nodes. ;)
Murch
CC BY-SA 4.0
2018-05-26T05:39:07.657Z
2018-05-26T05:39:07.657Z
MCCCS
<p>Can someone ELI5 Segregated Witness (AKA BIP 141)? I've been doing research and understand that there are segwit addresses, there are segwit transactions, and there are segwit nodes. </p>

<p>I understand that segwit basically works by removing the witness from the scriptSig and somehow it's weighed 1 weight point while other bytes are weighed at 4 weight points, but how? </p>

<p>How do older bitcoin nodes handle the segregated witness? Do they just not receive that data? I know that older nodes will treat those addresses as spendable by anyone since no witness is present or needed. This makes me believe the witness isn't in the transaction at all. But how? Where is the witness actually stored? </p>

<p>Where do segwit addresses come into all of this? </p>

<segregated-witness>
ELI5: How does Segregated Witness (segwit) work?
arshbot
# ELI5: How does Segregated Witness (segwit) work?

(Asked by: username_0 on 2018-05-26)

Can someone ELI5 Segregated Witness (AKA BIP 141)? I've been doing research and understand that there are segwit addresses, there are segwit transactions, and there are segwit nodes.

I understand that segwit basically works by removing the witness from the scriptSig and somehow it's weighed 1 weight point while other bytes are weighed at 4 weight points, but how?

How do older bitcoin nodes handle the segregated witness? Do they just not receive that data? I know that older nodes will treat those addresses as spendable by anyone since no witness is present or needed. This makes me believe the witness isn't in the transaction at all. But how? Where is the witness actually stored?

Where do segwit addresses come into all of this?

**Tags:** segregated-witness


---

## 1 answers

### Answer by username_1 on 2018-05-26. Score: 1

Not all unspent outputs need signature scripts. Of course, this doesn't have many uses (but puzzles. for example, proof of SHA256 collision to redeem funds) but such a thing exists. UTXO that don't need a ScriptSig are called an AnyoneCanSpend outputs. Such transactions are considered [nonstandard](https://bitcoin.stackexchange.com/a/52529/38618) and are not relayed in the network. However, if a miner includes a nonstandard transaction in their block, their block will be valid and the transaction will be relayed.

A SegWit-P2WSH output looks like this:

```
00148ca0e5d2474900bf82376926da8c5f4464bd7bd3

```

Does it start with a version byte? ✓
  
Does it have a 20-byte Witness Program\*? ✓
  
Is the ScriptSig empty\*? ✓

\*Doesn't have to be. Details: <https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki>

Congrats, that's a SegWit output! Legacy nodes see it as a nonstandard transaction, and don't relay it. The SegWit nodes check the output for the conditions above, understand that it's a SegWit output. Next, they check the transaction for a valid "witness". It's not a nonstandard transaction for them, and they relay it to the other SegWit nodes. After a miner puts it in their block, legacy nodes will understand that it's a nonstandard/AnyoneCanSpend script, and will honor it.

> **Comments:**
> **username_0**: Makes sense, but where does the witness end up in this situation? And where does the segwit address come into play?  
> **username_1**: @username_0 Transactions have a witness part (https://bitcoincore.org/en/segwit_wallet_dev/#transaction-serialization example (enable advanced info): https://blockchain.info/tx/c586389e5e4b3acb9d6c8be1c19ae8ab2795397633176f5a6442a261bbdefc3a) The scriptSig carries the version + witness program, which is not the witness itself, but the hash of the pubkey in the witness part: https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#p2wpkh-nested-in-bip16-p2sh  
> **username_2**: I stumbled over the "not a nonstandard" phrasing. You could just say it's a standard transaction for segwit-enabled nodes. ;)  

---

