Skip to content

feat: accept hex pubkey/seckey in Add Solver and Setup Admin Key#56

Open
mostronatorcoder[bot] wants to merge 1 commit intomainfrom
feat/accept-hex-keys
Open

feat: accept hex pubkey/seckey in Add Solver and Setup Admin Key#56
mostronatorcoder[bot] wants to merge 1 commit intomainfrom
feat/accept-hex-keys

Conversation

@mostronatorcoder
Copy link
Copy Markdown
Contributor

What

Accept hex-encoded keys in the Add Solver and Setup Admin Key input popups, in addition to the existing bech32 (npub/nsec) support.

Changes

Validation (src/ui/key_handler/validation.rs)

  • validate_npub(): try PublicKey::from_bech32() first, fall back to PublicKey::from_hex(). Accepts npub and 64-char hex.
  • validate_nsec(): try SecretKey::from_bech32() first, fall back to SecretKey::from_str(). Accepts nsec and 64-char hex.
  • Error messages updated to guide users: "expected npub1... (bech32) or 64-char hex string" / "expected nsec1... (bech32) or 64-char hex string"
  • Added hex_pubkey_to_npub() and hex_seckey_to_nsec() conversion helpers

Mostro wire format (src/util/order_utils/execute_admin_add_solver.rs)

  • normalize_solver_pubkey() converts hex input to npub before sending to Mostro, so the node always receives bech32 regardless of how the operator entered the key

UI placeholders (src/ui/draw.rs)

  • Add Solver: "npub... / hex..." (was "npub...")
  • Setup Admin Key: "nsec... / hex..." (was "nsec...")

Motivation

Currently the only way to add a solver or set the admin key is with bech32 keys. Operators who have hex-encoded keys (e.g. from rana, raw Nostr tooling, or Mostro config files) must manually convert before pasting. Accepting hex directly reduces friction.

Complements Mostro node's solver permission levels (PR #708).

- validation::validate_npub() now accepts both npub bech32 and hex (64-char)
  via PublicKey::from_bech32() + PublicKey::from_hex() fallback
- validation::validate_nsec() now accepts both nsec bech32 and hex (64-char)
  via SecretKey::from_bech32() + SecretKey::from_str() fallback
- Added hex_pubkey_to_npub() and hex_seckey_to_nsec() conversion helpers
- execute_admin_add_solver() normalizes hex input to npub before sending
  to Mostro so the node always receives bech32 format
- Updated UI placeholders in draw.rs:
  - Add Solver: 'npub... / hex...' instead of 'npub...'
  - Setup Admin Key: 'nsec... / hex...' instead of 'nsec...'
- Error messages updated to guide users toward the correct format
@mostronatorcoder mostronatorcoder Bot closed this Apr 22, 2026
@grunch grunch reopened this Apr 22, 2026
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