feat(bip322-multisig): new package for BIP-322 PSBTs from P2WSH descriptors#165
Merged
Conversation
6406164 to
97ea30e
Compare
…alidate pubkeys - parseDescriptor: strip whitespace/newlines (Sparrow exports often line-wrapped) - parseKey regex: accept both `h` and `'` as hardened markers (BIP-380), normalise to `h` - parseDescriptor: throw on inconsistent receive/change branches across cosigners - buildSortedMultisigScript: validate each pubkey is 33 bytes and starts with 0x02/0x03 - centralise bitcoin.initEccLib(ecc) in ecc-init.ts (was duplicated in psbt.ts and witness.ts) - add 5 tests covering apostrophe paths, whitespace, branch inconsistency, uncompressed and malformed pubkeys
…lize) CLI scripts moved into the package as thin TS wrappers that import from the package's own lib. Single source of truth for both the JS API (used by services frontend) and the CLI (npm install -g @dfx.swiss/bip322-multisig provides bip322-sign and bip322-finalize commands). - src/bin/sign.ts: fetch DFX challenge, build PSBT, write file - src/bin/finalize.ts: read signed PSBT, extract witness, POST to /v1/auth - package.json: add bin field + engines >=18 (uses native fetch) - tsconfig.build.json: emit CommonJS so CLI runs in Node without ESM resolver Replaces the standalone DFXswiss/bip322-multisig-cli repo (to be archived).
…mitives Split the package into two layers so btc-wallet (React Native) can import the pure BIP-322 math without triggering ecc side-effects: - core.ts: bip322MessageHash, buildToSpendTx, buildToSignPsbt, extractBip322Signature, buildSortedMultisigScript, p2wshScriptPubKey, p2wshAddress — no ecc-init import, no descriptor/bip32 dependency - psbt.ts: high-level buildBip322Psbt (descriptor-based, imports ecc) - descriptor.ts: imports helpers from core instead of duplicating - witness.ts: removed (absorbed into core.ts) - New core.test.ts with 10 tests for the low-level API
8 tasks
# Conflicts: # package-lock.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New monorepo package `@dfx.swiss/bip322-multisig` providing the deterministic core logic to:
The package is consumed by both the CLI tool (`DFXswiss/bip322-multisig-cli`) and the upcoming services frontend integration so they share one tested implementation.
Public API
```ts
import { parseDescriptor, deriveAddress, findAddress, buildBip322Psbt, extractBip322Signature } from '@dfx.swiss/bip322-multisig';
```
Test plan