> For the complete documentation index, see [llms.txt](https://bitcoin-dev-project.gitbook.io/rust-for-bitcoiners/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bitcoin-dev-project.gitbook.io/rust-for-bitcoiners/bitcoin_in_rust/ch2/segwit.md).

# segwit

Transaction: txid -> hash(List\[TxIn] || List\[TxOut]) List\[TxIn] List\[TxOut]

TxIn: OutputPoint: Previous txid out\_index (Signature, Script)

TxOut: Satoshis public address

Segwit Transaction: txid -> hash(List\[TxIn] || List\[TxOut]) List\[SegTxIn] List\[TxOut] Witness data (List\[(Signature, Script)])

SegTxIn: OutputPoint: Previous txid out\_index NULL

Why Segwit was introduced?

* Scalability
* Transaction malleability

Digital signature is handled by ECDSA secp256k1 because the equations looks like y^2 = x^3 + 7.

new nodes will caluclate weight of a transaction like this

```
3 * (txsize - witeness data size) + 1 * txsize
```

p2pk p2pkh p2sh is used to employ segwit initially and it is called native segwit
