Skip to content

docs: Bitcoin library research & testnet setup guide (Phase 0)#598

Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1777412536-bitcoin-library-research
Open

docs: Bitcoin library research & testnet setup guide (Phase 0)#598
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1777412536-bitcoin-library-research

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented Apr 28, 2026

Summary

Phase 0 — Team B (Research) deliverable for Bitcoin native support in MetaMask Mobile. This PR adds a comprehensive research document evaluating Bitcoin libraries for React Native compatibility, documenting testnet/signet setup procedures, and providing UTXO management recommendations.

Key Findings

  • Recommended library stack: @scure/btc-signer + @noble/curves + @noble/hashes + @scure/bip32 + @scure/bip39

    • All audited by Cure53 / Kudelski / Trail of Bits
    • Pure JavaScript (no WASM/native modules) — fully React Native compatible
    • @noble/hashes and @metamask/scure-bip39 already in MM dependency tree
    • 39KB gzipped total for @scure/btc-signer (vs ~80-120KB for bitcoinjs-lib)
    • Built-in UTXO selection with multiple coin selection algorithms
  • Testnet recommendation: Signet (primary) + Testnet4 (secondary)

    • All Mempool.space and Blockstream API endpoints verified live
    • Faucet URLs documented
  • UTXO management: exactBiggest/accumSmallest strategy recommended; RBF enabled by default; BIP84 (P2WPKH) as default address type

Document Contents

  1. Library comparison matrix (9 libraries evaluated)
  2. Detailed evaluations with RN compatibility, bundle size, audit status, feature coverage
  3. Recommended stack with justification and bitcoinjs-lib comparison
  4. Testnet/signet connection guide with verified endpoints
  5. UTXO management (coin selection, fee estimation, RBF, gap limit)
  6. PoC code snippets (address generation, tx building, UTXO selection, API client, address discovery)
  7. Known risks and limitations
  8. API endpoint reference

Review & Testing Checklist for Human

  • Verify the library recommendations align with the MetaMask extension team's Bitcoin approach (check if extension uses bitcoinjs-lib or @scure/btc-signer)
  • Confirm Signet faucet URLs are accessible and dispensing test BTC
  • Review PoC code snippets for correctness — especially the selectUTXO usage and derivation paths
  • Validate that the recommended derivation path (m/84'/0'/0') matches the existing BtcAccountType.P2wpkh implementation in the Snap

Notes

  • The existing @metamask/bitcoin-wallet-snap uses a Snap-based architecture. The research document flags the "Snap vs native" architecture decision as a key risk to resolve early.
  • mempool.js on npm is an unrelated memory pooling library — document recommends direct REST API usage with fetch.
  • All API endpoints in the document were verified live at the time of writing.

Link to Devin session: https://app.devin.ai/sessions/4381153a30024e619faa91702c128aab
Requested by: @dr-phil


Open in Devin Review

Phase 0 Team B research deliverable for Bitcoin native support:
- Library comparison matrix (bitcoinjs-lib vs @scure/btc-signer vs @noble/*)
- Recommended library stack with justification
- Testnet/signet connection guide with verified API endpoints
- UTXO management recommendations (coin selection, fee estimation, RBF)
- PoC code snippets for key operations
- Known risks and limitations analysis

Co-Authored-By: Phil Bedford <phil.bedford@cognition.ai>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@staging-devin-ai-integration
Copy link
Copy Markdown

Devin Review

Status Commit
⚪ Not started

Open in Devin Review (Staging)

💡 Connect your GitHub account to enable automatic code reviews.

Copy link
Copy Markdown
Author

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant