Convert ts-sdk to pnpm monorepo with boltz-swap#427
Draft
pietro909 wants to merge 442 commits into
Draft
Conversation
The Actions type in swap-manager now includes "signServerClaim" but the service worker message handler and runtime had hardcoded action union types that didn't include it, causing DTS build failure.
…untime The onActionExecuted listener callback type at line 330 also had the hardcoded action union without signServerClaim.
* fix: make signServerClaim error handling non-fatal Cooperative server claim signing is a courtesy action — if it fails, the server can still claim unilaterally. Previously, a failure in executeSignServerClaimAction would bubble to the outer try/catch in executeAutonomousAction, triggering swapFailedListeners and making consumers think the swap failed. Additionally, if no callback was set, actionExecutedListeners would fire despite nothing actually happening. Changes: - executeSignServerClaimAction now returns boolean (true on success) - Wrap invocation in local try/catch so failures are logged but don't propagate to the outer handler or emit swapFailed - Only emit actionExecutedListeners when the action actually succeeded * Update src/swap-manager.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Andrew Camilleri <[email protected]> --------- Signed-off-by: Andrew Camilleri <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
# Conflicts: # src/swap-manager.ts
Replace the heavy boltz-core (AGPL-3.0, ~2.7MB with transitive deps) with two lightweight local utilities built on @scure/btc-signer and @noble/curves — the same libraries boltz-core itself wraps. New files: - src/utils/musig.ts: MuSig2 signing wrapper over @scure/btc-signer/musig2.js - src/utils/boltz-swap-tx.ts: swap tree, taproot utils, claim tx, fee targeting All 8 boltz-core imports in arkade-chainswap.ts replaced with local equivalents.
Resolve conflicts: - arkade-chainswap.ts: deleted in refactor (merged into arkade-swaps.ts), applied boltz-core removal to arkade-swaps.ts instead - pnpm-lock.yaml: regenerated without boltz-core
Unify ArkadeLightning + ArkadeChainSwap into ArkadeSwaps
Implement repository versioning
Use 0.4.0-next-0 ts-sdk
Upgrade ts-sdk 0.4.21
Upgrade ts-sdk 0.4.22
Mirrors #446: flows that surrender control to remote peers (Boltz, Ark server, batch participants) can sit idle longer than the bus deadline. Both page and worker now skip the timeout for them; worker liveness stays covered by the existing PING / MESSAGE_BUS_NOT_INITIALIZED path on concurrent short requests.
fix(serviceWorker): exempt long-running messages from timeouts
Lets a user inspect and refund funds stranded at submarine swap lockup addresses — both successful swaps with extra deposits and failed swaps that never got refunded. Recovery is explicit; nothing scans on startup or in the background. Inspection is Boltz-amnesia-tolerant: it queries only the local repo and the Ark indexer. Post-CLTV recovery uses the unilateral refundWithoutReceiver path, so funds remain reachable even if Boltz purges the swap from its DB. - inspectSubmarineRecovery / scanRecoverableSubmarineSwaps return a structured SubmarineRecoveryInfo (recoverable / pre_cltv / none / already_spent / invalid_swap) with no side effects. - recoverSubmarineFunds wraps refundVHTLC; recoverAllSubmarineFunds runs sequentially with per-swap SubmarineRecoveryResult so a single failure never aborts the batch. - refundVHTLC skips the refundable/refunded flag write on transaction.claimed swaps to avoid muddling history when sweeping stranded extras. - Wired through IArkadeSwaps, ExpoArkadeSwaps, ServiceWorker message handler + runtime; new types exported from src/index.ts.
Boltz Ark VHTLCs encode `refund` as an absolute Unix timestamp (CLTV timestamp semantics, BIP65 ≥ 500_000_000) and the unilateral fields as BIP68 relative delays (seconds when ≥ 512). The block-height locktime branch was dead in practice, and the getChainHeight() round trip was unnecessary noise.
…os-manual Add user-initiated submarine VHTLC recovery APIs
Upgrade ts-sdk 0.4.23
Prod endpoint + polling logic
Resolved conflicts: keep monorepo root package.json and README; take arkd v0.9.4 image bump from master in .env.regtest; merge .gitignore additions from both sides. Applied master packages/ts-sdk/package.json (v0.4.23) and README directly — rename detection missed those. Added better-sqlite3 to root onlyBuiltDependencies for new SQLite migration tests introduced in master.
Subtree pull of 48 upstream boltz-swap commits. Resolved conflicts: - package.json: keep workspace:* for @arkade-os/sdk (monorepo dep) - regtest submodule: keep deleted (hoisted to monorepo root)
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
Converts this repository into a pnpm workspace monorepo that hosts both
@arkade-os/sdk(unchanged in behavior) and@arkade-os/boltz-swapas sibling packages, with shared regtest/CI/release tooling at the root.All ts-sdk sources now live at
packages/ts-sdk/; boltz-swap joins atpackages/boltz-swap/via a subtree merge so its full commit history is preserved and reachable through the merge's second parent.Structure (4 first-parent commits on top of
master)git log --followandgit blamecontinue to work.pnpm-workspace.yaml, rootpackage.jsonwith workspace scripts, sharedconfig/(tsconfig/vitest/eslint bases), monorepo CI workflows, rootscripts/release.shorchestrator, root README / AGENTS / CLAUDE.arkade-os/boltz-swap@d30cfbde(v0.3.16 tip at time of PR). Full boltz-swap history available atpackages/boltz-swap/with rename detection..env.regtest,.github/,.gitmodules,regtestsubmodule) and switches@arkade-os/sdkdep toworkspace:*.How to review
The Commits tab shows ~1100 commits because the boltz-swap subtree merge brings its full history into this PR. That's intentional and desirable for preserving history — but it means the commit tab is not the right place to review the monorepo conversion.
master, or locally:git log --first-parent master..monorepo-pr— the 4 conversion commitsgit diff master..monorepo-pr— total tree diffMerge strategy
Use Create a merge commit — do NOT squash or rebase. Squashing flattens the subtree merge and loses the boltz-swap history we worked to preserve.
Test plan
pnpm install(root, workspace mode)pnpm run build(ts-sdk + boltz-swap, ts-sdk builds first)pnpm run lintpnpm run test:unit(ts-sdk: 47 files / 790 passing; boltz-swap: 10 files / 255 passing)pnpm run regtest:up && pnpm run regtest:setup && pnpm run test:integration— needs Docker; not run locally by meFollow-ups (not in this PR)
pnpm.*overrides to the root (pnpm currently warns aboutpnpm.onlyBuiltDependenciesin package-level package.json).prettierrc/.husky/.gitignorenow that root versions existpnpm-lock.yamlfiles once workspace install is the source of truth