Skip to content

feat: add LDK debug action to export pathfinding scores#915

Draft
ovitrif wants to merge 1 commit intomasterfrom
feat/ldk-debug-export-scorer
Draft

feat: add LDK debug action to export pathfinding scores#915
ovitrif wants to merge 1 commit intomasterfrom
feat/ldk-debug-export-scorer

Conversation

@ovitrif
Copy link
Copy Markdown
Collaborator

@ovitrif ovitrif commented Apr 28, 2026

This PR adds an "Export Scorer" action to the LDK Debug screen that dumps the running node's merged pathfinding scorer to a file and triggers an Android share sheet, so it can be moved off-device for inspection. It also nulls the regtest scorer URL since the staging endpoint serves a 5-byte minimal payload.

Depends on:

Description

Mirrors the existing exportNetworkGraph flow exactly:

  • New "Export Scorer" button under a PATHFINDING SCORER section in LdkDebugScreen.
  • LdkDebugViewModel.exportScorer() writes to <context.cacheDir>/exports/pathfinding_scores.bin and surfaces the file via FileProvider so a share sheet pops up — same UX as Export Network Graph.
  • LightningService.exportPathfindingScoresToFile() is a thin wrapper around node.exportPathfindingScores() (existing UDL binding).
  • LoggerLdk.exportPathfindingScoresToFile() writes the raw bytes; logs the byte count.
  • Env.ldkScorerUrl for Network.REGTEST is set to null. The staging endpoint (https://api.stag0.blocktank.to/scorer) serves 5 bytes — minimal/empty data — so wiring it through accomplishes nothing. Making this explicit matches "we don't use the scorer on regtest".

Dev-only screen — no localized strings (per CLAUDE.md "NEVER add string resources for strings used only in dev settings screens").

Preview

QA Notes

  • Build & install: ./gradlew installDevDebug (or installTnetDebug / installMainnet per network).
  • Open Settings → Dev → LDK Debug → tap "Export Scorer". A toast should show the byte count, then the system share sheet opens.
  • Save the .bin somewhere off-device.
  • (Optional) Pull via adb: adb shell "run-as to.bitkit.dev cat files/cache/exports/pathfinding_scores.bin" > /tmp/scorer_local.bin (adjust app id per flavor).
  • The exported bytes are ChannelLiquidities-encoded — same wire format as the served scorer at https://api.blocktank.to/scorer-prod. They can be inspected with the scorer-inspect CLI from feat(tools): add scorer-inspect CLI with text/csv/json output ldk-node#79 once that lands.
  • Regression-check: the existing "Export Network Graph" button still works.
  • Verified: ./gradlew compileDevDebugKotlin testDevDebugUnitTest detekt — all pass; only pre-existing detekt warnings (none introduced by this change).

🤖 Generated with Claude Code

Mirrors the existing network-graph export pattern: a new "Export Scorer"
button under a PATHFINDING SCORER section in LDK Debug calls
node.exportPathfindingScores(), writes the bytes to cacheDir/exports,
and triggers the Android share sheet via FileProvider so the file can
be moved off-device for inspection (e.g. with the scorer-inspect CLI
in synonymdev/ldk-node).

Also nulls the regtest ldkScorerUrl. The regtest endpoint serves a
5-byte minimal payload, so the only effect of pointing the node at it
is a no-op merge; setting it to null makes "we don't use the scorer on
regtest" explicit.
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.

1 participant