bitcoin-segwit
Segregated Witness: BIP141 (consensus), BIP143 (sighash), BIP144 (P2P serialization), BIP173 (Bech32 address). Witness segregation, weight units, txid vs wtxid, witness commitment. USE WHEN: working with native segwit (P2WPKH/P2WSH), embedded segwit (P2SH-P2WPKH/P2SH-P2WSH), or understanding the witness discount.
What this skill does
# SegWit (BIP141 family) Activated August 2017. Moved signatures and other auxiliary data into a new **witness** section that is **not** included in `txid` hashing. ## Goals achieved 1. **Fixed transaction malleability** for SegWit-only inputs. 2. **Weight discount** — witness bytes count 1 WU (vs 4 WU for base). Effective block size cap rose from 1 MB to ~4 MWU. 3. **Linear sighash** (BIP143) — O(n) signing instead of O(n²) for multi-input txs. 4. **Soft-fork upgrade path** — version field on witness program enables future versions (1 = Taproot). ## Witness program structure `scriptPubKey` for SegWit outputs: ``` <version_byte> <data_push> ``` Version byte = `OP_0` (v0), `OP_1` (v1 = Taproot, BIP341). Future versions reserved. Length of data push determines type: - v0, 20 bytes: P2WPKH - v0, 32 bytes: P2WSH - v1, 32 bytes: P2TR - Other v0 lengths: invalid (consensus failure post-activation). - v2..v16 with **any** length: forward-compat (anyone-can-spend until future soft fork). ## Address encoding (BIP173 / BIP350) - Bech32 (BIP173) for v0 → `bc1q...` (mainnet), `tb1q...` (testnet). - **Bech32m** (BIP350) for v1+ → `bc1p...`. Different checksum constant to fix BIP173 length-extension bug. Encoding helpers usually check the witness version byte and auto-select Bech32 vs Bech32m. ## Embedded SegWit (legacy compat) For wallets that can only produce P2SH addresses: - **P2SH-P2WPKH**: - `scriptPubKey = OP_HASH160 <H160(redeemScript)> OP_EQUAL` - `redeemScript = OP_0 <H160(pk)>` - `scriptSig = OP_PUSH(redeemScript)` - `witness = [<sig>, <pk>]` - **P2SH-P2WSH**: similar with 32-byte witness program. ## Sighash (BIP143) For SegWit v0 inputs, sighash is computed over a precomputed digest: `hashPrevouts || hashSequence || outpoint || scriptCode || amount || nSequence || hashOutputs || nLockTime || nHashType`. Two key facts: 1. The **input amount** is committed → fee-bumping attack with old signatures is detected (each input value is signed). 2. `hashPrevouts`, `hashSequence`, `hashOutputs` are reused across all inputs → O(n) total cost. Taproot (BIP341) supersedes this with an even cleaner digest. ## P2P relay (BIP144) - Old nodes see SegWit transactions as anyone-can-spend (witness stripped). - New nodes use service flag `NODE_WITNESS` (1 << 3) to advertise witness support. - Block download: `getdata` with type `MSG_WITNESS_BLOCK` for full witness data. ## Common gotchas - Forgetting `marker/flag` (0x00, 0x01) bytes when serializing for network → wire-format invalid. - Computing `txid` over the segwit serialization (with witness) → wrong, must strip witness for txid. - Using P2SH-P2WPKH addresses (`3...`) when wallet supports native P2WPKH (`bc1q...`) → wastes ~10 vB per input. - Mixing v1 (Taproot) outputs and assuming Bech32 addresses → must use Bech32m, otherwise checksum is rejected by spec-compliant wallets. ## See also - [transactions/SKILL.md](../transactions/SKILL.md) - [taproot/SKILL.md](../taproot/SKILL.md) - [scripts/SKILL.md](../scripts/SKILL.md)
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.