Add the BLAKE2b chains xbt and txbt4, signing with SIGHASH_UNIFIED - #48
Conversation
xbt (the BLAKE2b fork of Bitcoin) and txbt4 (the BLAKE2b fork of testnet4) join the chain table, with Kilombino and mempool.guide as explorers. Each chain now carries its bech32 prefix, so xbt gets bc1p addresses instead of falling through to tb. On both, marks are signed with SIGHASH_ALL|SIGHASH_UNIFIED: a 65-byte signature over the unified message, which SHA256d nodes reject, so a mark spending a pre-fork coin cannot be replayed onto the original chain. lib/unified-sighash.js is the implementation from bitcoin-blake/blaketest and passes Knots's 166 test vectors, now in test/unified_sighash.json. Closes #47
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The new chain registry entries, unified sighash implementation, and signing integration are covered by deterministic unit tests (including the full Knots vector set) and appear consistent with the stated replay-protection goals.
Review effort: Lite
Findings: None
What changed in this PR
This PR adds support for the BLAKE2b fork chains xbt and txbt4 to gitmark, including replay-protected Taproot signing using SIGHASH_UNIFIED to prevent pre-fork UTXO spends from being replayed onto the SHA256d Bitcoin chains.
Changes:
- Added
xbtandtxbt4to the chain registry, including per-chain Bech32m HRPs (bc/tb) and aunifiedflag to opt into unified sighash signing. - Implemented Unified opt-in sighash (and parsing utilities) in
lib/unified-sighash.js, and wiredbuildTransaction(..., { unified })to produce 65-byte signatures with hash type0x21when enabled. - Added documentation and test coverage: chain tables in docs plus full Knots unified sighash vector verification and signature behavior tests.
| File | Description |
|---|---|
| URI.md | Documents the new chain codes used in txo:<chain>:<txid>:<vout> URIs. |
| README.md | Adds a chains table and explains SIGHASH_UNIFIED replay protection for xbt/txbt4. |
| lib/unified-sighash.js | Adds Unified sighash implementation + transaction parser used for testing and signing. |
| bin/git-mark.js | Extends CHAINS with xbt/txbt4, adds per-chain HRP, and enables unified signing via buildTransaction({ unified }). |
| test/unified_sighash.json | Adds 166 Knots unified sighash test vectors. |
| test/git-mark.test.js | Adds tests for new chain registry entries, address HRPs, vector verification, and 64-byte vs 65-byte signature behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Tested end to end on
|
Closes #47.
What changes
CHAINS:xbt: the BLAKE2b fork of Bitcoin, from block 961,640, usinghttps://mempool.kilombino.com/api.txbt4: the BLAKE2b fork of testnet4, from block 150,308, usinghttps://mempool.guide/testnet4/api.hrp, replacingchain === 'btc' ? 'bc' : 'tb', soxbtgetsbc1p…addresses.buildTransactiontakes{ unified }. When set, it signs the unified message withSIGHASH_ALL|SIGHASH_UNIFIED(0x21), producing a 65-byte signature. SHA256d nodes reject it, so a mark that spends a pre-fork coin can't be replayed onto the original chain. The other four chains are unchanged and keep 64-byte BIP341 signatures.lib/unified-sighash.jsis the implementation from bitcoin-blake/blaketest. The spec is unified-sighash.md.URI.md.Testing
npm test: 49 pass, 0 fail. New tests:test/unified_sighash.json)xbtandtxbt4addresses matchbtcandtbtc40x21, which verifies against the unified message and not against a BIP341 onegit mark init --chain xbtand--chain txbt4run offline and printbc1p…andtb1p…addresses; an unknown chain is still refused./blocks/tip/height: xbt 973,814, txbt4 151,579).txbt4will be funded by a melchain peg-out, and I'll add the result here.