feat(bitcoin): Maestro data provider and first-class coin selection#10
Open
jinglescode wants to merge 6 commits into
Open
feat(bitcoin): Maestro data provider and first-class coin selection#10jinglescode wants to merge 6 commits into
jinglescode wants to merge 6 commits into
Conversation
Milestone: standard headless wallet on Bitcoin. - MaestroProvider implements IBitcoinProvider against Maestro's Esplora-compatible Bitcoin API using platform fetch (no new deps): address info/UTXOs/txs, per-tx unspent outputs via outspends, tx status, sat/vB fee estimates with closest-target selection, and raw-tx broadcast. - Extract largest-first coin selection from BitcoinHeadlessWallet into src/bitcoin/utils/coin-selection.ts and export it; behavior unchanged (BIP-141 vbyte model, 546-sat dust handling). - Unit tests for provider (mocked HTTP) and coin selection. - README Bitcoin section and bitcoin-milestone.md evidence doc. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Member
✅ Bitcoin Provider Integration DemoTested using the new > tsx bitcoin-run.ts
⚡ Bitcoin playground [testnet]
────────────────────────────────────────────────────────────
Payment address : tb1qj6jl9g9c0j4qcwcxz4nn27c6rerz5xv30yprvs
Public key (hex): 02b628626f6dd36dabdd973a4e5d150c0b8b203a6f838ee2accaf9abe187fbaa11
────────────────────────────────────────────────────────────
Fetching balance…
confirmed : 0 sats
unconfirmed: 5,000 sats
total : 5,000 sats
────────────────────────────────────────────────────────────
Fetching UTxOs…
[0] 0b08ac6d03d87445060aed42451cec736c75fd1775511762e143e97b4670070a:1 5,000 sats confirmed=false
────────────────────────────────────────────────────────────
Signing transfer (coin selection is automatic)…
recipient : tb1qj6jl9g9c0j4qcwcxz4nn27c6rerz5xv30yprvs
amount : 4,000 sats
✓ Transaction submitted!
txid: 007db8cdf25306f2d942c9367874a0e663f22a9b0ad80d8b62fed701df311ad4
────────────────────────────────────────────────────────────
Fetching tx history…
[0] 0b08ac6d03d87445060aed42451cec736c75fd1775511762e143e97b4670070a confirmed=false
[1] 007db8cdf25306f2d942c9367874a0e663f22a9b0ad80d8b62fed701df311ad4 confirmed=false
────────────────────────────────────────────────────────────
✓ Donehttps://mempool.space/testnet4/tx/007db8cdf25306f2d942c9367874a0e663f22a9b0ad80d8b62fed701df311ad4 Verified Functionality
This validates the end-to-end functionality of the new Bitcoin provider implementation, including read operations, transaction construction, signing, and broadcasting. |
…/MeshJS/wallet into feature/bitcoin-maestro-provider
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.
Milestone: standard headless wallet on Bitcoin
Closes the remaining gap for the Bitcoin headless wallet milestone: the wallet, coin selection, and
signTransferalready existed insrc/, but no concrete data provider did. This PR adds the Maestro provider and promotes coin selection to a first-class, tested module.A1 — UTXO querying via Maestro
MaestroProvider(src/bitcoin/providers/maestro.ts) implements the existingIBitcoinProviderinterface against Maestro's Esplora-compatible Bitcoin API: address info/UTXOs, per-tx unspent outputs (via/outspends), paginated tx history, tx status, sat/vB fee estimates (closest-target selection, testnet fallback), and raw-tx broadcast.fetch— zero new runtime dependencies. Shared plumbing insrc/bitcoin/providers/common.tswith a typedProviderHttpError.A2 — Coin selection on queried UTXOs
src/bitcoin/utils/coin-selection.tsand exported it (selectUtxosLargestFirst,DUST_THRESHOLD_P2WPKH). Behavior unchanged: BIP-141 vbyte fee model, 546-sat dust absorption.BitcoinHeadlessWallet.signTransfernow delegates to it.A3 — Send transfer
signTransferflow (query → select → PSBT → sign → broadcast) runs end-to-end on the Maestro provider; covered by the existing wallet regression tests.Tests & docs
bitcoin-milestone.mdmapping acceptance criteria to code.🤖 Generated with Claude Code