Skip to content

feat: taproot escrow backend - #2427

Draft
keshav0479 wants to merge 5 commits into
RoboSats:mainfrom
keshav0479:feat/taproot-escrow-backend
Draft

feat: taproot escrow backend#2427
keshav0479 wants to merge 5 commits into
RoboSats:mainfrom
keshav0479:feat/taproot-escrow-backend

Conversation

@keshav0479

Copy link
Copy Markdown
Contributor

What does this PR do?

Been porting the taptrade-core Rust implementation to the Python backend for a while now. This adds the backend pieces needed for non-custodial on-chain escrow using Taproot/MAST.

Refs #230

What's in this PR

  • api/taproot_escrow.py - core library: MuSig2 aggregation, 4-leaf MAST tree, PSBT builder, bond validation
  • api/models/taproot_payment.py - model for tracking escrow UTXO lifecycle
  • api/models/order.py - 10 TAP_* statuses, is_taproot flag, FK
  • api/logics.py - state machine methods for taproot flow
  • 40 unit tests, all passing

MAST tree

Internal key: MuSig2(maker, taker) - keypath (happy path)
Leaf A: maker + coordinator (dispute)
Leaf B: taker + coordinator (dispute)
Leaf C: maker + after(12228) (protection ~85 days)
Leaf D: maker + taker + after(2048) (rescue ~14 days)

Coordinator is an orchestrator, not a custodian - can't spend without a trader's co-signature.

Still TODO

  • API endpoints (views/serializers)
  • bitcoind RPC wiring for broadcast
  • Frontend (keypair gen, PSBT signing in browser)
  • Integration tests

Opening as draft to get early feedback on the approach. Happy to iterate on anything.

Checklist before merging

  • Install pre-commit and initialize it: pip install pre-commit, then pre-commit install. Pre-commit installs git hooks that automatically check the codebase. If pre-commit fails when you commit your changes, please fix the problems it points out.

@joelklabo

Copy link
Copy Markdown

Great work on this PR! The backend implementation looks solid. I'm available to help with the frontend integration (keypair generation, PSBT signing UI) if needed. This could help move the 600k sats bounty forward. Happy to discuss further.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants