feat(settings): normalize hex keys to bech32 in admin key setup - #101
Conversation
|
Warning Review limit reached
Next review available in: 11 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
WalkthroughAdmin key setup now trims and normalizes hexadecimal or valid ChangesAdmin key normalization
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant handle_enter_admin_mode
participant normalize_to_nsec
participant handle_input_to_confirmation
handle_enter_admin_mode->>normalize_to_nsec: key input
normalize_to_nsec-->>handle_enter_admin_mode: normalized nsec or error
handle_enter_admin_mode->>handle_input_to_confirmation: normalized key
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
2165cca to
c800aa3
Compare
There was a problem hiding this comment.
Approved. I reviewed the full PR conversation and the exact current head c800aa3fc90dc2044823b839d56620694bc4c3ad.
The admin-key flow now converts valid hex secret keys before confirmation and persistence, while the existing Add Solver normalization and UX complete the linked issue scope. Local verification with Rust 1.90.0 passed:
cargo testcargo clippy --all-targets --all-features -- -D warningscargo fmt --all -- --check
Non-blocking follow-up: normalize_to_nsec returns valid bech32 input verbatim, so an uppercase NSEC1... remains uppercase despite the canonical lowercase nsec1... wording. Parsing and re-encoding valid bech32 input would make that guarantee exact.
|
LGTM! |
Summary
Closes #57
normalize_to_nsec()tovalidation.rs— validates and converts a raw 64-char hex private key tonsec1...bech32 format in a single pass, reusing the existinghex_seckey_to_nsechelpernormalize_to_nsecinto theSetupAdminKeyflow so both the confirmation popup andsettings.tomlalways receive canonicalnsec1...format regardless of whether the user typed hex or bech32What was already implemented
The validation functions (
validate_npub,validate_nsec), UI placeholders (nsec... / hex...), and wire-format normalization for Add Solver (normalize_solver_pubkey) were already in place. This PR completes the missing normalization step for the admin key input path.Test plan
nsec1...(not raw hex)~/.mostrix/settings.tomlsavesadmin_privkeyasnsec1...nsec1...key — verify it is accepted and saved unchangedcargo test normalize_to_nsec— all 4 tests passSummary by CodeRabbit
New Features
nsec1...format.Bug Fixes
nsec1...keys continue to work unchanged.Tests