1

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?

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 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.

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.