Skip to content

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

Merged
arkanoider merged 4 commits into
mainfrom
feat/accept-hex-keys
Apr 29, 2026
Merged

feat: accept hex pubkey/seckey in Add Solver and Setup Admin Key#56
arkanoider merged 4 commits into
mainfrom
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
@mostronatorcoder

Copy link
Copy Markdown
Contributor Author

I reviewed this one carefully. I do not see a blocker in the current diff.

What I checked:

  • hex and bech32 validation paths for solver pubkeys and admin secret keys
  • solver pubkey normalization before sending AdminAddSolver
  • runtime hydration after saving the admin key
  • the dispute-finalization refactor, to ensure Mostro still receives the order UUID while the UI keeps using the dispute UUID for local state
  • docs and UI placeholder updates

The behavior change looks correct to me:

  • operators can now paste either npub / nsec or 64-char hex keys
  • solver pubkeys are normalized to bech32 before sending to Mostro
  • the finalization helper flow is cleaner and less error-prone than the duplicated version it replaced

Checks are green too. Since this PR was opened by the bot account I am using, GitHub will not let me submit a formal approval on my own PR, but from a review standpoint this looks good to merge.

@arkanoider arkanoider merged commit 77246d0 into main Apr 29, 2026
10 checks passed
@arkanoider arkanoider deleted the feat/accept-hex-keys branch April 29, 2026 12:16
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.

2 participants