feat: POC — bark (Ark) as an alternative spending backend [DO NOT MERGE] - #1129
Draft
jvsena42 wants to merge 11 commits into
Draft
feat: POC — bark (Ark) as an alternative spending backend [DO NOT MERGE]#1129jvsena42 wants to merge 11 commits into
jvsena42 wants to merge 11 commits into
Conversation
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Warning
This is a proof of concept and must not be merged. It exists to evaluate Second's Bark (Ark) as a
replacement for the local ldk-node Lightning node. Ark funds created by this branch are not backed
up — the recovery phrase alone cannot restore them — and several flows are deliberately unfinished.
Use signet and trivial amounts only.
Description
Adds Bark (Second's Ark implementation) as an alternative spending backend, switchable at runtime from
Settings → Advanced. Savings is untouched: ldk-node keeps running and keeps owning the on-chain wallet, so
only the Lightning/spending half is swapped out.
Second publishes an official Kotlin/UniFFI binding, so this is an integration rather than a bindings project.
tech.second.bark:bark-android:0.12.2+bark-0.4.0from Second's public GitLabMaven, plus a new
signetflavor (the only test network with a Second-hosted Ark server). Signet reusesthe testnet
applicationIdso the checked-ingoogle-services.jsonresolves without a signet Firebaseclient; the trade-off is that signet and tnet cannot be installed side by side.
BarkService— thin wrapper overuniffi.bark.Wallet, shaped afterLightningService, with all rustcalls on a dedicated
ServiceQueue.ARKthread.BarkRepo—BarkStateStateFlow plus anexecuteWhenRunninggate mirroringLightningRepo.executeWhenNodeRunning.uniffi.barktypes are wrapped so they never reach UI state.DeriveBalanceStateUseCasebranches on the selected backend, so every existing balancesurface (home tiles, spending screen, send flows) works with no UI change.
Movements are mapped to bitkit-coreLightningActivityand inserted through theexisting path, so the activity list, detail screen, tags and contacts all work unchanged.
boards from its own on-chain wallet; a persisted state machine survives the app being killed between them.
WorkManagerworker plus a foreground pass runmaintenanceDelegated(), themobile refresh path. This is not optional: VTXOs expire (~28 days, ~3 days for Lightning receives) and the
server can sweep them.
is in flight and no Ark exit is in progress. When blocked on a balance it deep-links into the existing
Transfer → Savings flow.
Two findings worth calling out
CustomOnchainWalletCallbacks, which wouldhave given one-step boarding and a single UTXO set — but it needs
prepareTx→ PSBT andfinishPsbt, andldk-node's
OnchainPaymentInterface(verified against0.7.0-rc.62sources) has no PSBT API at all. barktherefore keeps a second on-chain wallet on the same seed. It is never presented as "Savings".
libbark_ffi_kotlin.sopackages cleanlywithout bark's README-mandated
useLegacyPackaging = true(which would have changed packaging forldk-node/bitkit-core/paykit/vss too), and the arm64 lib is 16 KB page-size compliant (
PT_LOADalign0x4000).Deliberately out of scope
the backend, and the Transfer screens still need bark-specific copy.
WakeNodeWorker(FCM push wake) is untouched — bark has no push, so waking on an LSP notification would bea no-op. Background liveness comes from
BarkMaintenanceWorkerinstead.Preview
QA Notes
Journeys live in
journeys/bark/and are written for theandroid-clijourney runner:bark-toggle-gate.xml— the switch is blocked with a spending balance and offers Transfer To Savingsbark-enable.xml— the no-backup warning shows, and Lightning-only rows disappear once enabledbark-receive-lightning.xml— BOLT11 receive over Ark lands in balance and activitybark-send-lightning.xml— BOLT11 send decreases balance and records a sent activitybark-board.xml— savings → spending shows as in-transfer until the board completesldk-regression.xml— run this on adevbuild; guards that the shipping ldk-node path is untouchedand that the Ark toggle is hidden on networks with no Ark server
Unit tests:
BarkMovementsTest.kt(movement → activity mapping),CanSwitchSpendingBackendUseCaseTest.kt(every allow/block branch, both directions),
BarkTransferRepoTest.kt(board state machine, includingresume-after-death and failure keeping the pending board), plus
ContentViewTest.ktfor the extractedtransferSavingsStartRoutehelper.Validation run:
just compile,just test,just lintall pass, andassembleSignetDebugproduces an APKwith
libbark_ffi_kotlin.sopresent.compileMainnetDebugKotlinneeds a localapp/src/mainnet/google-services.json, which is gitignored and not present in a fresh worktree.🤖 Generated with Claude Code