feat(bitcoin): add headless + browser wallet SDK#8
Open
jinglescode wants to merge 2 commits into
Open
Conversation
Implement IBitcoinWallet across two surfaces: - BitcoinHeadlessWallet: in-process signer (BIP-39 → BIP-32 → BIP-84/86). - getNetwork, getAddresses, getAccounts, getBalance - signMessage (ECDSA with magic-prefix + 65-byte recoverable sig) - signTransfer (RBF opt-in, dust-aware change, P2WPKH vbyte estimates) - signPsbt (P2WPKH ECDSA + P2TR BIP-86 key-path Schnorr w/ tweaked key) - BitcoinBrowserWallet: registry + Xverse adapter speaking Sats Connect with dual-envelope support (sats-connect-core normalised + raw JSON-RPC 2.0). Test coverage: 93 bitcoin tests across 5 suites — BIP-84/86 vectors, recoverable-sig verification, dust-handling, Taproot tweaked-key signing, Xverse wire-format compatibility, and address-type validation. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Mirrors existing signMessage (BIP-137, 65-byte compact recoverable ECDSA, base64). Cross-type acceptance: recovered pubkey matched against P2PKH / P2SH-P2WPKH / P2WPKH / P2TR (BIP-86). Adds IBitcoinWallet.verifyMessage, instance methods on Headless + Browser wallets, and local trustless verify in the Xverse adapter (throws clear "not yet supported" for non-65-byte BIP-322 sigs). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
IBitcoinWalletmethods (getNetwork,getAddresses,getAccounts,getBalance,signMessage,signTransfer,signPsbt).provider.request(method, params). Handles both the sats-connect-core-normalised{status, result}envelope and the raw JSON-RPC 2.0{jsonrpc, result}envelope so it works against any Xverse build.Crypto correctness
signMessageproduces a 65-byte ECDSA recoverable signature with the"Bitcoin Signed Message:\n"magic prefix and computed recovery id — verifiable by Electrum / Sparrow /bitcoinjs-message.signTransferopts into BIP-125 RBF (sequence0xfffffffd), uses realistic P2WPKH vbyte math (overhead 11, input 68, output 31), and absorbs sub-dust change (< 546 sats) into the miner fee instead of producing a non-standard output.signPsbtfor Taproot uses BIP-86 single-key spend with the tweaked private key; signer'spublicKeyexposes the tweaked output key (matching bitcoinjs-lib'sgetTaprootHashesForSigcheck) andtapInternalKeyis set on the PSBT input so finalisers can round-trip.Dependencies (3 added)
bitcoinjs-lib ^6.1.7bip39 ^3.1.0ecpair ^2.1.0(reuses existing
bip32 ^5.0.0+tiny-secp256k1 ^2.2.4)Test plan
npx tsc --noEmit— no errors insrc/ortest/npx jest test/bitcoin/— 5 suites, 93 tests passnpx jest(full repo) — 16 suites, 171 tests passnpx tsup— ESM 187 KB + CJS 173 KB + dts 39 KB builds clean🤖 Generated with Claude Code