Skip to content

validate pool authority pubkey to prevent broken TOML#117

Merged
pavlenex merged 2 commits intostratum-mining:mainfrom
rx18-eng:fix/113-validate-pool-pubkey
Apr 23, 2026
Merged

validate pool authority pubkey to prevent broken TOML#117
pavlenex merged 2 commits intostratum-mining:mainfrom
rx18-eng:fix/113-validate-pool-pubkey

Conversation

@rx18-eng
Copy link
Copy Markdown
Contributor

@rx18-eng rx18-eng commented Apr 20, 2026

Body

Closes #113.

Pool authority pubkeys in the SRI docs and Discord channels are almost always shown wrapped in quotes, and users copy them with the quotes. The wizard dropped that value verbatim into a TOML basic string, producing invalid TOML and a silent container crash loop.

Fix is input-time validation mirroring how Bitcoin addresses are already validated (per @GitGab19 and @lucasbalieiro's note that this field is base58check). bs58check.decodeUnsafe catches both charset errors and checksum failures, which is what copy-paste corruption looks like. Wrapping quotes get stripped on every update so the dominant paste case becomes a zero-click fix; the validator itself stays strict and rejects anything still quoted or whitespace-padded. Same treatment for user_identity - rejects ", \, and control characters that would break TOML.

Bootstraps vitest for src/ and covers the validators with 40 unit tests: every preset pubkey, wrapping-quote paste, tampered checksum, and each individual TOML-unsafe character. Verified manually: pasted quoted Braiins key, quotes stripped on entry, made it through to the review page cleanly.

@rx18-eng
Copy link
Copy Markdown
Contributor Author

@lucasbalieiro please give this a look !

Comment thread src/lib/utils.test.ts Outdated
Comment thread src/lib/utils.test.ts Outdated
@rx18-eng rx18-eng force-pushed the fix/113-validate-pool-pubkey branch 2 times, most recently from 1ee8c95 to eec80b9 Compare April 21, 2026 06:40
@rx18-eng rx18-eng requested a review from lucasbalieiro April 21, 2026 06:40
Comment thread src/components/setup/steps/PoolConfigStep.tsx
Comment thread package.json Outdated
Comment thread package.json
Comment thread src/lib/utils.ts Outdated
@rx18-eng rx18-eng force-pushed the fix/113-validate-pool-pubkey branch from eec80b9 to 2357b4b Compare April 21, 2026 17:04
@rx18-eng rx18-eng requested a review from lucasbalieiro April 21, 2026 17:46
@lucasbalieiro
Copy link
Copy Markdown
Collaborator

image MIssing validation on the Settings page

@rx18-eng
Copy link
Copy Markdown
Contributor Author

rx18-eng commented Apr 21, 2026

Yeah I had already noticed that locally and am working on it will push it soon !

@rx18-eng rx18-eng force-pushed the fix/113-validate-pool-pubkey branch from 2357b4b to 5ef654d Compare April 21, 2026 21:45
@rx18-eng
Copy link
Copy Markdown
Contributor Author

@lucasbalieiro please give it a look at this !

Copy link
Copy Markdown
Collaborator

@lucasbalieiro lucasbalieiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK 5ef654d

@rx18-eng
Copy link
Copy Markdown
Contributor Author

@lucasbalieiro Thanks for your review let me know if any other changes are needed before merging this :)

Signed-off-by: rx18-eng <remopanda78@gmail.com>
Signed-off-by: rx18-eng <remopanda78@gmail.com>
@pavlenex pavlenex force-pushed the fix/113-validate-pool-pubkey branch from 5ef654d to 4587711 Compare April 23, 2026 06:37
@pavlenex pavlenex merged commit 79eaabb into stratum-mining:main Apr 23, 2026
5 checks passed
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.

Wizard writes broken TOML if user input has " in it, containers crash silently

3 participants