Closes#59 (BRIEF decision 4). Client-only: no changes to protocol, consensus or server/.
What
scripts/build-randomx-android.sh: an NDK (r29) cross-build of the pinned native/ RandomX v1.2.1 engine for arm64-v8a and x86_64, output to android/app/src/main/jniLibs/<abi>/libwikideck_randomx.so (an executable named like a lib; useLegacyPackaging true, so Android extracts it to nativeLibraryDir where exec is allowed). The binaries are gitignored, and android/build-debug.sh builds them when they're missing.
MinerPlugin.java (Capacitor WikiDeckMiner, registered in MainActivity):
spawns 1–4 light-mode engine processes and speaks the line protocol
selfTest() runs upstream's known vector on the device
halts engines on handleOnPause (background), battery saver, thermal status ≥ MODERATE, battery ≥ 40 °C, and < 20 % while unplugged, and reports each halt with a halted event
receives only public work, never keys
src/mobile-miner.ts: the same template → mine → sign → submit loop as server/testnet/miner.ts, in the WebView with Web Crypto. Signing uses the existing web wallet (sign).
src/MobileMiningPanel.tsx: shown only in the native app, and disabled on mainnet builds.
explicit consent checkbox
intensity: Low, Normal (1 thread, the default), High (2), and Max (4, only while charging)
live H/s, hashes, height, accepted blocks, battery % and °C, and the self-test result
docs/night2/MOBILE_MINING.md: how it works, the safeguards, measured hashrate, the Google Play / App Store ban on on-device mining → sideload APK only, and options for Eric.
Verified
npm test passes 248/248 on Node 24 (node:24-alpine). npm run build passes (tsc + vite), including with the testnet VITE env.
tests/mobile-mining-miner.test.ts (6 tests, zero network): the browser miningBlob and mintId are byte-identical to consensus; validateBlock accepts the assembled block; the loop mines, signs and submits; a tripped safeguard prevents the engine from starting; stop() halts a search.
Emulator (Android 15 x86_64):
the known vector passes for x86_64, and for arm64 through ARM translation
~37 H/s per light thread, ~125 H/s at Max
thermal, battery saver, low battery and background each halt the engines (the process count drops to 0, and the reason is shown)
The debug APK is at ~/worker/jobs/night/mobile-mining/apk/wikideck-mining-testnet-debug.apk on inspiron.
Review notes
Wallet idle lock: while mining is active (foreground, consented), each status update calls touchWallet(), so a found block can still be signed after 5 idle minutes. The 4 h absolute limit and lock-on-hide still apply. Please check that this trade-off is acceptable.
Accepted block: the emulator has been mining on :3101 since ~22:40. At ~452 K expected hashes per block, that's about 1 h on average. I'll report the result on #59.
Closes #59 (BRIEF decision 4). Client-only: **no changes to protocol, consensus or `server/`.**
## What
- **`scripts/build-randomx-android.sh`**: an NDK (r29) cross-build of the pinned `native/` RandomX v1.2.1 engine for `arm64-v8a` and `x86_64`, output to `android/app/src/main/jniLibs/<abi>/libwikideck_randomx.so` (an executable named like a lib; `useLegacyPackaging true`, so Android extracts it to `nativeLibraryDir` where exec is allowed). The binaries are gitignored, and `android/build-debug.sh` builds them when they're missing.
- **`MinerPlugin.java`** (Capacitor `WikiDeckMiner`, registered in `MainActivity`):
- spawns 1–4 **light-mode** engine processes and speaks the line protocol
- `selfTest()` runs upstream's known vector on the device
- halts engines on `handleOnPause` (background), battery saver, thermal status ≥ MODERATE, battery ≥ 40 °C, and < 20 % while unplugged, and reports each halt with a `halted` event
- receives only public work, never keys
- **`src/mobile-miner.ts`**: the same template → mine → sign → submit loop as `server/testnet/miner.ts`, in the WebView with Web Crypto. Signing uses the existing web wallet (`sign`).
- **`src/MobileMiningPanel.tsx`**: shown only in the native app, and disabled on mainnet builds.
- explicit consent checkbox
- intensity: Low, **Normal (1 thread, the default)**, High (2), and Max (4, only while charging)
- live H/s, hashes, height, accepted blocks, battery % and °C, and the self-test result
- **`docs/night2/MOBILE_MINING.md`**: how it works, the safeguards, measured hashrate, the **Google Play / App Store ban on on-device mining → sideload APK only**, and options for Eric.
## Verified
- `npm test` passes **248/248** on Node 24 (`node:24-alpine`). `npm run build` passes (tsc + vite), including with the testnet VITE env.
- `tests/mobile-mining-miner.test.ts` (6 tests, zero network): the browser `miningBlob` and `mintId` are byte-identical to consensus; `validateBlock` accepts the assembled block; the loop mines, signs and submits; a tripped safeguard prevents the engine from starting; `stop()` halts a search.
- **Emulator** (Android 15 x86_64):
- the known vector passes for x86_64, and for arm64 through ARM translation
- ~37 H/s per light thread, ~125 H/s at Max
- thermal, battery saver, low battery and background each halt the engines (the process count drops to 0, and the reason is shown)
- The debug APK is at `~/worker/jobs/night/mobile-mining/apk/wikideck-mining-testnet-debug.apk` on inspiron.
## Review notes
- **Wallet idle lock:** while mining is active (foreground, consented), each status update calls `touchWallet()`, so a found block can still be signed after 5 idle minutes. The 4 h absolute limit and lock-on-hide still apply. Please check that this trade-off is acceptable.
- **Accepted block:** the emulator has been mining on :3101 since ~22:40. At ~452 K expected hashes per block, that's about 1 h on average. I'll report the result on #59.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
claude
added this to the Night 2: Magic-style duel, PvP, polite Wikimedia milestone 2026-11-18 03:33:18 +00:00
- scripts/build-randomx-android.sh: NDK cross-build of the pinned native/ engine
(light mode) for arm64-v8a and x86_64, packaged as jniLibs/<abi>/libwikideck_randomx.so
- MinerPlugin.java (Capacitor "WikiDeckMiner"): runs engine processes over the
line protocol, on-device self-test, and halts on background, battery saver,
thermal, hot or low battery. Never receives wallet keys.
- src/mobile-miner.ts: template -> mine -> sign -> submit loop in the WebView,
byte-identical to consensus miningBlob/mintId (tests/mobile-mining-miner.test.ts)
- src/MobileMiningPanel.tsx: consent, intensity (1 thread default; Max = 4 only
while charging), live hashrate/status; testnet-only (disabled on mainnet builds)
- docs/night2/MOBILE_MINING.md: how it works, safeguards, measured hashrate,
store policies (sideload APK only), options for Eric
No protocol, consensus or server changes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[night-review] Reviewed at 8694239: MinerPlugin.java, MainActivity, mobile-miner.ts, MobileMiningPanel.tsx, the App.tsx change, the build scripts, MOBILE_MINING.md and the tests.
No deps, and nothing in server/, shared/protocol.ts or consensus.
The .so binaries are gitignored and built by script. Only the small screenshot jpg is committed, which is fine.
BRIEF decision 4:
The panel now shows in the native app (isNativeApp() no longer hides mining).
MOBILE_MINING.md states the Google Play / App Store ban and that the build is sideload-only, with the policy quote.
The panel is disabled on mainnet builds (IS_MAINNET).
Explicit consent is required, the default is 1 light thread, and Max (4) is only allowed while charging.
Mining halts on background, battery saver, thermal, heat and low battery, and never auto-restarts.
The engine receives only public work, and signing stays in the WebView wallet.
The mining loop uses the same /api/mining/template and /api/blocks as the desktop miner, and the test checks byte-identical miningBlob/mintId against consensus.
Your wallet idle-lock question:touchWallet() on each status update while consented foreground mining runs is acceptable to me. The absolute 4 h limit and lock-on-hide still apply, and handleOnPause halts mining, so the session can't stay unlocked in the background. Please add one sentence to MOBILE_MINING.md saying so, so the trade-off is on record for Eric.
Note:ref={isNativeApp() ? undefined : minerPanel} on the old section, plus ref={minerPanel} on the new panel, means any "scroll to miner" call lands on the right element in both builds. Fine as written.
VERDICT: APPROVED
[night-review] Reviewed at 8694239: `MinerPlugin.java`, `MainActivity`, `mobile-miner.ts`, `MobileMiningPanel.tsx`, the `App.tsx` change, the build scripts, MOBILE_MINING.md and the tests.
**Checks** (merge preview onto 2af2e7f, `node:24-alpine`, `--network none`):
- `tsc --noEmit`: clean
- `tests/mobile-mining-miner.test.ts`: 6/6 pass
- No deps, and nothing in `server/`, `shared/protocol.ts` or consensus.
- The `.so` binaries are gitignored and built by script. Only the small screenshot jpg is committed, which is fine.
**BRIEF decision 4:**
- The panel now shows in the native app (`isNativeApp()` no longer hides mining).
- MOBILE_MINING.md states the Google Play / App Store ban and that the build is sideload-only, with the policy quote.
- The panel is disabled on mainnet builds (`IS_MAINNET`).
- Explicit consent is required, the default is 1 light thread, and Max (4) is only allowed while charging.
- Mining halts on background, battery saver, thermal, heat and low battery, and never auto-restarts.
- The engine receives only public work, and signing stays in the WebView wallet.
- The mining loop uses the same `/api/mining/template` and `/api/blocks` as the desktop miner, and the test checks byte-identical `miningBlob`/`mintId` against consensus.
**Your wallet idle-lock question:** `touchWallet()` on each status update while consented foreground mining runs is acceptable to me. The absolute 4 h limit and lock-on-hide still apply, and `handleOnPause` halts mining, so the session can't stay unlocked in the background. Please add one sentence to MOBILE_MINING.md saying so, so the trade-off is on record for Eric.
**Note:** `ref={isNativeApp() ? undefined : minerPanel}` on the old section, plus `ref={minerPanel}` on the new panel, means any "scroll to miner" call lands on the right element in both builds. Fine as written.
VERDICT: APPROVED
[mobile-mining] Thanks. I've added the wallet keep-alive trade-off sentence to MOBILE_MINING.md (15470d5, docs-only). It's ready for night-lead to squash-merge.
[mobile-mining] Thanks. I've added the wallet keep-alive trade-off sentence to MOBILE_MINING.md (15470d5, docs-only). It's ready for night-lead to squash-merge.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Closes #59 (BRIEF decision 4). Client-only: no changes to protocol, consensus or
server/.What
scripts/build-randomx-android.sh: an NDK (r29) cross-build of the pinnednative/RandomX v1.2.1 engine forarm64-v8aandx86_64, output toandroid/app/src/main/jniLibs/<abi>/libwikideck_randomx.so(an executable named like a lib;useLegacyPackaging true, so Android extracts it tonativeLibraryDirwhere exec is allowed). The binaries are gitignored, andandroid/build-debug.shbuilds them when they're missing.MinerPlugin.java(CapacitorWikiDeckMiner, registered inMainActivity):selfTest()runs upstream's known vector on the devicehandleOnPause(background), battery saver, thermal status ≥ MODERATE, battery ≥ 40 °C, and < 20 % while unplugged, and reports each halt with ahaltedeventsrc/mobile-miner.ts: the same template → mine → sign → submit loop asserver/testnet/miner.ts, in the WebView with Web Crypto. Signing uses the existing web wallet (sign).src/MobileMiningPanel.tsx: shown only in the native app, and disabled on mainnet builds.docs/night2/MOBILE_MINING.md: how it works, the safeguards, measured hashrate, the Google Play / App Store ban on on-device mining → sideload APK only, and options for Eric.Verified
npm testpasses 248/248 on Node 24 (node:24-alpine).npm run buildpasses (tsc + vite), including with the testnet VITE env.tests/mobile-mining-miner.test.ts(6 tests, zero network): the browserminingBlobandmintIdare byte-identical to consensus;validateBlockaccepts the assembled block; the loop mines, signs and submits; a tripped safeguard prevents the engine from starting;stop()halts a search.~/worker/jobs/night/mobile-mining/apk/wikideck-mining-testnet-debug.apkon inspiron.Review notes
touchWallet(), so a found block can still be signed after 5 idle minutes. The 4 h absolute limit and lock-on-hide still apply. Please check that this trade-off is acceptable.🤖 Generated with Claude Code
[night-review] Reviewed at
8694239:MinerPlugin.java,MainActivity,mobile-miner.ts,MobileMiningPanel.tsx, theApp.tsxchange, the build scripts, MOBILE_MINING.md and the tests.Checks (merge preview onto
2af2e7f,node:24-alpine,--network none):tsc --noEmit: cleantests/mobile-mining-miner.test.ts: 6/6 passserver/,shared/protocol.tsor consensus..sobinaries are gitignored and built by script. Only the small screenshot jpg is committed, which is fine.BRIEF decision 4:
isNativeApp()no longer hides mining).IS_MAINNET)./api/mining/templateand/api/blocksas the desktop miner, and the test checks byte-identicalminingBlob/mintIdagainst consensus.Your wallet idle-lock question:
touchWallet()on each status update while consented foreground mining runs is acceptable to me. The absolute 4 h limit and lock-on-hide still apply, andhandleOnPausehalts mining, so the session can't stay unlocked in the background. Please add one sentence to MOBILE_MINING.md saying so, so the trade-off is on record for Eric.Note:
ref={isNativeApp() ? undefined : minerPanel}on the old section, plusref={minerPanel}on the new panel, means any "scroll to miner" call lands on the right element in both builds. Fine as written.VERDICT: APPROVED
[mobile-mining] Thanks. I've added the wallet keep-alive trade-off sentence to MOBILE_MINING.md (
15470d5, docs-only). It's ready for night-lead to squash-merge.