Repository navigation
fix: allow transfers on local spark regtest - #2139
Conversation
A local Spark config made Env.sparkSharesNodeChain false even when the node and hardware wallets sync from the fixture's own Electrum, so Savings → Transfer To Spending opened Transfer Unavailable on the local stack. It now matches iOS: true when Spark reads the fixture's REST on the local host (or loopback over adb reverse) and the running node uses the fixture's Electrum. A restored or chosen Electrum server, an Esplora node source or an incomplete config keep it false. Verified: just compile, just test, just lint (the new SparkChainServiceTest case failed on the old rule)
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4044efb22e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
[Medium impact] The behavior is limited to local Spark regtest but reaches several Savings workflows. The PR appears safe to merge, with a non-blocking hardware-funding edge case during regtest server changes. Findings
SummaryEnables local Spark regtest transfers when Spark's REST URL and the running node's Electrum URL match the fixture.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Configure node source] --> B[Start node]
B --> C[Publish active Electrum URL]
C --> D[Check local fixture URLs]
D --> E[Update Funding options]
F[Stop node] --> G[Clear active Electrum URL]
G --> D
H[Saved Electrum setting] --> I[Hardware compose and broadcast]
Reviews (1) · Last reviewed commit: "fix: allow transfers on local spark regt..." · Reviewed by Greptile |
talosmachina
left a comment
There was a problem hiding this comment.
No findings. Lets a local Spark regtest build (fixture REST on :23090/api, node on the fixture's Electrum, no ESPLORA_URL) count as sharing the node's chain, so Transfer To Spending, Spark withdrawals to Savings and exit fees from Savings work on bitkit-docker's spark stack; the node's Electrum is published to Env.activeElectrumServerUrl on start and cleared on stop. Reviewed 4044efb, full tier, static: build skipped, the Bitkit track does not build bitkit-android branches on this reviewer's machine, so this is reasoned from the code and CI.
What I checked, and 5 candidates I ruled out
Read in full: Env.kt (sparkSharesNodeChain, ElectrumServers, LocalSparkSettings), LightningService.kt (buildNode, configureChainSource, start, stop), the restartWithElectrumServer / skipStartForRunningNode paths in LightningRepo.kt, HwWalletRepo.syncWatchers, the Funding route and the three sparkSharesNodeChain gates in ContentView.kt.
Call sites traced: every reader of Env.sparkSharesNodeChain (SparkExitRepo, SparkExitViewModel, TransferViewModel, ContentView); every writer of the node's Electrum URL (customServerUrl ?: settings.electrumServer).
CI: build-and-test, lint, compose-ui and build-local were still running when this was posted.
Ruled out
- Hardware wallet on a different Electrum than the node: the node uses
customServerUrlonly insiderestartWithElectrumServer, which persists the same URL to settings on success and rebuilds from settings on failure, and a failed start never publishes, so the published URL and the oneHwWalletRepowatchers read agree outside that window. - Stale URL after a failed start:
chainElectrumUrlkeeps the last build's value, but it is published only afternode.start()returns, and the next build overwrites it inconfigureChainSourceon both the Esplora and Electrum branches. - A running node not reported after a skipped start:
skipStartForRunningNoderefuses a custom server, and a plain skip leaves the value the earlier successful start published. - Funding screen showing a stale answer: it now collects
sparkSharesNodeChainFlow; the other gates read the flag when they act, and before the node starts they read false, which is the guarded case. - Default emulator setup missing the rule: the local backend's default Electrum is
ElectrumServers.REGTEST.LOCAL, the sametcp://<E2E_LOCAL_HOST>:60001the check compares against, and loopback Spark URLs underadb reverseare accepted.
Merge confidence: 4/5, no findings, but CI had not finished and the branch was not built here; SparkChainServiceTest and LightningServiceTest cover the new rule and the publish/clear.
Reviewer model: Claude Opus 5.5 (claude-opus-5-5)
Reasoning effort: Not exposed (the review session's runtime does not report an effort setting)
Regtest APKDownload bitkit-dev-debug universal APK (expires in 30 days). |
Verified: none (journey text only)
|
QA for 725d977: 🟢 J1: Savings → Transfer To Spending on the local stackJ1: Savings → Transfer To Spending on the local stack A fresh wallet connected Spark to the fixture's chain, the node synced from the fixture's Electrum (
🟢 Before: the same tap on masterBefore: the same tap on master The same setup on master c12ff7c opens the Transfer Unavailable sheet. Its recording stopped before the tap, so the screenshot is the evidence.
|
jvsena42
left a comment
There was a problem hiding this comment.
Code scan at 725d977: no HIGH/MEDIUM. One LOW (journey docs), inline.
Checked and clean:
- Release and default dev builds are unchanged. In
Env.kt:175-189, thenetwork != REGTESTandlocalSpark == nullbranches give the same result as the old rule and don't readnodeElectrumUrl. Only thelocalSpark != nullbranch changed.localSparkSettingsis non-null only for debug + local E2E backend + regtest withSPARK_LOCAL_*set, so mainnet, tnet, every release build and the hosted-Spark dev build never reach it. chainElectrumUrlis published only afternode.start()returns and cleared first instop(). Its only readers are the twosparkSharesNodeChain*members, which ignore it outside the local branch.lifecycleMutexkeeps a start from publishing after a concurrent stop's clear.- Fails safe: while the node is stopped or restarting on a local build, the transfer gates read false and show Transfer Unavailable,
TransferViewModelskips the Spark withdrawal, andSparkExitReporefuses. tcp://<E2E_LOCAL_HOST>:60001andhttp://<host>:23090/apiare one chain on bitkit-dockermain(spark-bitcoind -addnode=bitcoind), and "Reset To Default → Connect To Host" saves exactly that URL string.- The SKILL.md bullet matches
Env.ktand bitkit-docker'ssparkcommands and published ports.
perf: not relevant.
Device gate (partial): 725d977 — not run yet; J1 needs the local Spark stack. Result to follow.
Reviewer model: Opus 5.5 (claude-opus-5-5) coordinating and verifying; Fable 5.2 (claude-fable-5-2) primary review
Reasoning effort: Not exposed
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: full PR diff against its merge base, at 725d977.
No new actionable code findings.
No new actionable code findings. The new Env.sparkSharesNodeChain rule gives the same result as the old one for mainnet, hosted regtest and every build without localSparkSettings. Only the localSpark != null branch changed, and localSparkSettings is non-null only in a debug, local-E2E, regtest build. The node's Electrum URL is published to Env.activeElectrumServerUrl only after node.start() succeeds, and LightningService.stop() clears it first. lifecycleMutex in LightningRepo serializes start and stop, and stop() always nulls the node handle, so a stale non-null URL cannot outlive a stopped node. While the node is stopped or restarting on the local stack, every gate (Funding, the Savings, Spending and HW Transfer To Spending buttons, TransferViewModel, SparkExitRepo and SparkExitViewModel) reads false and fails safe. The click-time gates in ContentView read the current value when tapped, and Funding collects the new flow.
Existing review threads:
- jvsena42's LOW still applies at this head and its thread is open: the
journeys/README.mdCapabilities row for Spark still names only hosted regtest. The author has deferred it to a follow-up PR. - The Codex journey-precondition thread is resolved, and
spark-transfer-to-spending.xmlis updated at this head. - Greptile's hardware-wallet chain-split thread is resolved and withdrawn. I confirmed at this head that the split needs a failed settings write after
restartWithElectrumServerhas already started the node on the new server. In every other path the node and HW wallets both readsettingsStore.electrumServer.
Validation: CI run 45874331337 for 725d977 passed build-and-test (which includes the updated SparkChainServiceTest and LightningServiceTest), lint and compose-ui; the local e2e jobs also passed. I ran no tests myself.
iOS comparison (bitkit-ios d30d2d6, Env.sharesLocalSparkChain and SparkManager.readsSavingsChain): iOS requires the Spark URL on the fixture host and checks the hardware wallet's Electrum separately. Android also accepts 127.0.0.1, for adb reverse, and covers hardware wallets through the node's saved Electrum setting. The PR body states both differences, and I found no violated requirement.
Device testing: not performed in this review. The author's QA comment reports J1 on an Android 15 emulator at 725d977, reaching only the amount screen.
Suggested additional test cases
- Android, local
./sparkstack build as in the PR's QA setup, Savings funded: open Funding and verify "Transfer from Savings" and "Transfer from HW wallet" are enabled. Then use Settings › Advanced › Electrum Server to connect to a different Electrum server, return to Funding, and verify both options are disabled and Savings → Transfer To Spending opens Transfer Unavailable. Reset to default, connect, and verify they are enabled again. - Android, same setup: background the app until the node stops, return, and immediately tap Savings → Transfer To Spending. Expect Transfer Unavailable until the node is running, then the transfer intro, with no crash or stuck state.
- Android, same setup: start an emergency exit and choose to pay the exit fee from Savings. Verify the Savings option is offered and the payment completes on the local chain; on base it was never offered.
Reviewer model: claude-opus-5-5
Reasoning effort: high
|
Merged: approved by @piotr-iohk, checks green, and the device run on 725d977 is posted above. I resolved @jvsena42's README thread as deferred; the Capabilities row change follows in its own PR. |
|
Device gate (partial): 725d977 — run on the Android emulator against the local bitkit-docker Spark stack, unpatched PR build, node on the default local Electrum.
Still running: the driver's run of the runbook. |

Refs:
Description
SPARK_LOCAL_CONFIG_B64+SPARK_LOCAL_CHAIN_URLagainst bitkit-docker'ssparkprofile), becauseEnv.sparkSharesNodeChainreturned false for every local Spark config, although that stack's Spark and the node read the same chain.sparkSharesNodeChainnow follows iOS'sEnv.sharesLocalSparkChain. A local config shares the node's chain only when all of these hold::23090/api, onE2E_LOCAL_HOSTor on127.0.0.1(the emulator reaches the fixture overadb reverse);tcp://<E2E_LOCAL_HOST>:60001;ESPLORA_URLis set.LightningServicepublishes the node's Electrum server toEnv.activeElectrumServerUrloncenode.start()succeeds, and clears it onstop(). The Funding screen collects it, so its on-chain options follow the running node.spark-regtestskill note, which said the local stack always turns these off on Android.spark-transfer-to-spending.xmlprecondition so the journey runs on the local stack too.Before: Savings → Transfer To Spending opens Transfer Unavailable on the local stack.
After: it opens the transfer flow.
Out of Scope
ESPLORA_URL), and mainnet always shares the chain.SparkExitRepo,SparkExitViewModel,TransferViewModel: they read the flag when they act, so they need no change.journeys/README.md: listing the local./sparkstack in the Capabilities table goes in a follow-up PR after this merges, raised in fix: allow transfers on local spark regtest #2139 (comment).Design
N/A — no UI changes.
Preview
N/A
QA Notes
Setup
bitkit-docker's local Spark stack (
./spark up), and a dev debug build made as in.claude/plugins/spark-regtest/skills/spark-regtest/SKILL.md, "Local./sparkstack":Fund Savings with
./spark send <savings address> 100000, then./spark mine 1.Journeys
spark-transfer-to-spending.xml— on the local stack, Savings → Transfer To Spending opens the transfer flow instead of Transfer UnavailableManual Tests
N/A
Automated Checks
SparkChainServiceTest.kt— a local fixture shares the node's chain only when the node runs on the fixture's Electrum; another Electrum, an Esplora source, another Spark host or port, and an incomplete config stay falseLightningServiceTest.kt— the node's Electrum is published only after the node starts, and cleared on stopEvidence
SparkChainServiceTestcase failed on the old rule and passes with this change.just compile,just testandjust lintpassed.Gaps
Models used
Claude Opus 5.5(reasoning:medium)Claude Opus 5.5(reasoning:medium),Claude Sonnet 5.5(reasoning:high)