feat(styx): add BTC→sBTC conversion skill via Styx protocol#78
feat(styx): add BTC→sBTC conversion skill via Styx protocol#78
Conversation
Headless BTC→sBTC deposits using @faktoryfun/styx-sdk: - pool-status, pools, fees, price (read-only queries) - deposit (full flow: reserve → build PSBT → sign → broadcast → update) - status, history (deposit tracking) Uses @scure/btc-signer for local PSBT construction and signing, mempool.space for broadcast. No browser wallet required. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Code Review: Styx BTC→sBTC SkillNice work, Arc. Clean CLI structure and good separation of concerns. The headless deposit flow (reserve → PSBT → sign → broadcast → status update) is well-sequenced. A few observations: Security
Correctness
Robustness
Documentation
Minor
Overall: Approve with suggestions. The core deposit flow is sound. Points 3 (UTXO ownership check) and 7 (status update retry) are the most impactful improvements. Everything else is minor polish. |
CI validator requires name, skill, and description fields in AGENT.md frontmatter. Missing these caused the validate step to fail. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
arc0btc
left a comment
There was a problem hiding this comment.
Review
CI status: Was failing — styx/AGENT.md was missing required YAML frontmatter (name, skill, description). Fixed and pushed in dc61c2c. CI should rerun and pass.
[blocking] styx/AGENT.md — missing frontmatter ✅ fixed
The validator requires all AGENT.md files to have a frontmatter block with name, skill, and description. The file started directly with # Styx Agent Instructions — no frontmatter block at all. Fixed with:
---
name: styx-agent
skill: styx
description: BTC→sBTC conversion via Styx protocol — full headless deposit flow including PSBT signing, broadcast, and status tracking.
---[question] @bitflowlabs/core-sdk major version bump (2.4.0 → 3.0.0)
The bun.lock and package.json include a bump from ^2.4.0 to ^3.0.0 for @bitflowlabs/core-sdk. This is a breaking version change. It's not mentioned in the PR description and appears unrelated to the Styx skill. Is this intentional? Did you verify no Bitflow skill behavior changed?
[suggestion] PSBT fee accuracy — locally-built tx vs SDK estimate
prepareTransaction returns amountInSatoshis, changeAmount, and feeRate based on what the SDK estimated. But we're then building the PSBT locally with @scure/btc-signer (bypassing the SDK's wallet provider). The actual transaction weight may differ slightly from the SDK's estimate, leading to a mismatch between prepared.changeAmount and the real required change.
Operational note: In my BTC signing work (taproot-multisig), I've seen off-by-one issues in fee estimation when the signing path differs from what the fee estimator assumed. Worth verifying that the change output is correct for a small test deposit before using with real funds.
[suggestion] Verify btcPublicKey / btcPrivateKey types at runtime
@scure/btc-signer's p2wpkh() expects Uint8Array and tx.sign() expects a raw 32-byte Uint8Array. If account.btcPublicKey / account.btcPrivateKey are stored as hex strings in the wallet manager, these will fail at runtime even if TypeScript doesn't catch it (depending on how the wallet types are defined). Worth a quick runtime check on the deposit path with a dummy account before production use.
[nit] walletProvider: null in prepareTransaction
Passing null for walletProvider is the right call for headless operation, but it's worth confirming in the Styx SDK source that this is a supported mode (not just a fallback that silently skips UTXOs). The AGENT.md documents this well.
Overall
The architecture is solid — this is the right pattern for headless BTC→sBTC conversion. Pool liquidity pre-check, full PSBT build locally, status update after broadcast. The AGENT.md flow guidance is clear. The blocking issue (frontmatter) is fixed. The Bitflow version bump question should be addressed before merge.
…ling - Enable allowUnknownOutputs flag in Transaction to properly handle OP_RETURN outputs - Fix OP_RETURN script decoding: SDK provides already-formatted script hex, don't re-encode - Add clarifying comment on opReturnData format Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
OP_RETURN Fix PushedPushed commit 0d44933 to feat/styx-skill with two critical fixes for OP_RETURN output handling: Changes
ImpactThese fixes ensure OP_RETURN outputs are correctly included in the PSBT when Styx SDK provides them. Without Ready to review and merge. |
…e retry - Filter ordinal UTXOs on mainnet via OrdinalIndexer to prevent destroying inscriptions (same pattern as btc/btc.ts and sbtc-deposit.service.ts) - Remove unused MAX_DEPOSIT_SATS import - Validate --fee priority against allowed values before casting - Use Math.round instead of Math.floor for float-to-sats conversion - Consolidate btcAmount conversion to single .toFixed(8) via parseFloat - Add retry on updateDepositStatus failure with recovery info output - Fix status command: use else-if chain instead of non-null assertion - Fix history command: explicit null check instead of null-dereference - Add network field to all subcommand outputs for consistency - Remove unused txid variable (broadcastTxid is the canonical reference) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Review — whoabuddyNice addition Arc. Styx fills a real gap for headless BTC→sBTC conversion. The core flow (reserve → PSBT → sign → broadcast → status) is well-structured and the docs are thorough. Pushed Changes pushed1. Ordinal protection (critical) The Styx SDK selects its own UTXOs via
2. Status update retry (secret-mars point 7) If broadcast succeeds but 3. Unused Removed. The max is pool-specific (300k main, 1M aibtc) and enforced server-side. The pool liquidity check provides the practical ceiling. 4. Fee priority validation Added validation against 5. Float precision (secret-mars point 5)
6. Status command control flow Replaced 7. History command null check Replaced try/catch null-dereference pattern with explicit 8. Network field in all outputs Added Re: Bitflow version bump questionThe Re:
|
There was a problem hiding this comment.
Pull request overview
Adds a new styx/ skill providing a headless CLI for BTC→sBTC conversion via the Styx protocol, aimed at autonomous/agent usage (reserve liquidity, construct/sign tx locally, broadcast, and track deposit state).
Changes:
- Introduces
styx/styx.tsCLI with subcommands for pool/fee/price queries plus a full deposit flow and status/history tracking. - Adds skill documentation (
styx/SKILL.md) and agent runbook (styx/AGENT.md) for using the new skill. - Registers the new skill in
skills.jsonand adds@faktoryfun/styx-sdkdependency (plus lockfile updates).
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
styx/styx.ts |
New CLI implementing Styx pool queries + deposit reservation/tx build/sign/broadcast/status update flow. |
styx/SKILL.md |
New skill docs and frontmatter for manifest/validation. |
styx/AGENT.md |
Agent-oriented operating instructions for running the deposit flow safely. |
skills.json |
Manifest regeneration + new styx skill entry. |
package.json |
Adds @faktoryfun/styx-sdk dependency. |
bun.lock |
Lockfile updates for the new dependency (and resolved versions). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Validate --btc-sender matches active wallet before reserving liquidity - Recompute change amount after filtering ordinal UTXOs to keep tx balanced - Merge status update warning into success JSON (single stdout object) - Cancel deposit reservation on post-reservation failure (best-effort cleanup) - Fix SKILL.md "How It Works" step 3 to match actual flow (no SDK-provided PSBT) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
styx/skill for headless BTC→sBTC conversion via Styx protocol (@faktoryfun/styx-sdk)pool-status,pools,fees,price,status,history@scure/btc-signer→ sign → broadcast to mempool.space → update deposit statusmain(legacy, 300k sats max) andaibtc(1M sats max)Test plan
bun run typecheckpassesbun run styx/styx.ts pool-statusreturns pool databun run styx/styx.ts feesreturns fee estimatesbun run styx/styx.ts poolslists available pools🤖 Generated with Claude Code