计划执行与检查节点
executing-plans
按既定实施计划完成工作,保持过程检查和反馈。
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.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Activated August 2017. Moved signatures and other auxiliary data into
a new witness section that is not included in txid hashing.
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:
bc1q... (mainnet), tb1q... (testnet).bc1p.... Different checksum constant
to fix BIP173 length-extension bug.Encoding helpers usually check the witness version byte and auto-select Bech32 vs Bech32m.
For wallets that can only produce P2SH addresses:
scriptPubKey = OP_HASH160 <H160(redeemScript)> OP_EQUALredeemScript = OP_0 <H160(pk)>scriptSig = OP_PUSH(redeemScript)witness = [<sig>, <pk>]For SegWit v0 inputs, sighash is computed over a precomputed digest:
hashPrevouts || hashSequence || outpoint || scriptCode || amount || nSequence || hashOutputs || nLockTime || nHashType.
Two key facts:
hashPrevouts, hashSequence, hashOutputs are reused across all
inputs → O(n) total cost.Taproot (BIP341) supersedes this with an even cleaner digest.
NODE_WITNESS (1 << 3) to advertise
witness support.getdata with type MSG_WITNESS_BLOCK for full
witness data.marker/flag (0x00, 0x01) bytes when serializing for
network → wire-format invalid.txid over the segwit serialization (with witness) →
wrong, must strip witness for txid.3...) when wallet supports native
P2WPKH (bc1q...) → wastes ~10 vB per input.