Skip to content

Feature: ln address for buyers invoice - Step 1#59

Merged
arkanoider merged 3 commits into
mainfrom
feat/ln-address
May 4, 2026
Merged

Feature: ln address for buyers invoice - Step 1#59
arkanoider merged 3 commits into
mainfrom
feat/ln-address

Conversation

@arkanoider

@arkanoider arkanoider commented May 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds persisted ln_address for buyers (Lightning address / user@domain.com), keeps backward compatibility for configs that omit the field, and exposes User-mode-only Settings flows to set or clear it.

Changes

Schema & template (PR1)

  • Settings.ln_address: String with #[serde(default)] — missing key in settings.toml deserializes to "".
  • Repo settings.toml: includes ln_address = "" so new installs always have the key.
  • Tests: legacy_settings_without_ln_address_deserializes_to_empty_string checks both toml::from_str and the same config::Configtry_deserialize path used at runtime.

Settings UI (PR2, User mode only)

  • New Settings rows (after “Add Nostr Relay”):
    • Set Lightning Address (buyer) — input → confirm → save trimmed value to disk.
    • Clear Lightning Address — confirm → clear ln_address on disk.
  • Admin Settings menu unchanged (same option count as before).
  • Format validation only on save path: LightningAddress::from_str (user@domain.com). No LNURL reachability check yet (planned follow-up).

Paste / UX

  • Bracketed paste and right-click paste supported on the Lightning address input (same pattern as other key-input modals).

Docs / help

  • Shift+H Settings (User) entries updated for the new options.

Backward compatibility

Existing settings.toml without ln_address still loads; treat “unset” as settings.ln_address.trim().is_empty().

Out of scope / follow-ups

  • LNURL-pay endpoint reachability before save (ln_exists-style).
  • Take-order / AddInvoice automation using saved address.

Summary by CodeRabbit

Release Notes

  • New Features
    • Added Lightning address configuration support for LNURL-pay payments
    • New user settings options: "Set Lightning Address (buyer)" and "Clear Lightning Address"
    • Lightning address changes persist to your settings file with confirmation prompts
    • Address format validation ensures correctness

arkanoider and others added 2 commits May 4, 2026 17:10
- Add Settings.ln_address (Option<String>, serde default) for backward-compatible loads
- Document example in repository settings.toml template

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2d6694e3-b254-4e75-b7bc-2243f771a70c

📥 Commits

Reviewing files that changed from the base of the PR and between 6898509 and 99ad88e.

📒 Files selected for processing (13)
  • settings.toml
  • src/main.rs
  • src/settings.rs
  • src/ui/app_state.rs
  • src/ui/draw.rs
  • src/ui/help_popup.rs
  • src/ui/key_handler/confirmation.rs
  • src/ui/key_handler/enter_handlers.rs
  • src/ui/key_handler/esc_handlers.rs
  • src/ui/key_handler/mod.rs
  • src/ui/key_handler/navigation.rs
  • src/ui/key_handler/settings.rs
  • src/ui/tabs/settings_tab.rs

Walkthrough

This PR adds user-facing Lightning address (LNURL-pay buyer address) management to the application. New configuration, state, validation, and UI handlers enable users to input, confirm, and persist a buyer Lightning address through dedicated settings menu options.

Changes

Lightning Address User Settings

Layer / File(s) Summary
Data Shape & Configuration
settings.toml, src/settings.rs
New ln_address: String field added to Settings with #[serde(default)] for backward compatibility. Legacy configs without ln_address deserialize to empty string. Test verifies deserialization via both direct TOML and config crate paths.
UI State Model
src/ui/app_state.rs
Three new UiMode variants: AddLnAddress(KeyInputState) for input, ConfirmLnAddress(String, bool) for confirmation with button state, and ConfirmClearLnAddress(bool) for clearing confirmation. Clone impl updated for new variants.
Validation & Persistence
src/ui/key_handler/settings.rs
Three new functions: validate_ln_address_format (validates user@domain.com shape via LightningAddress::from_str), save_ln_address_to_settings (persists trimmed address), and clear_ln_address_from_settings (clears stored address).
Input Handling
src/main.rs, src/ui/key_handler/mod.rs
Paste handler updated to accept bracketed/right-click paste into AddLnAddress input. Key event dispatcher treats AddLnAddress as a shared settings input popup with key state extraction.
Confirmation & Cancellation
src/ui/key_handler/confirmation.rs, src/ui/key_handler/esc_handlers.rs
handle_confirm_key validates input and persists address or clears on YES/NO; handle_cancel_key returns to prior mode or default_mode. ESC handling dismisses input and returns to appropriate fallback state.
Navigation & Selection
src/ui/key_handler/enter_handlers.rs, src/ui/key_handler/navigation.rs
Settings tab option refactored to route user role into nested match arms, adding LN address entry/clear options at indices 3 and 4. Left/Right keys toggle YES/NO selection in confirmation dialogs. Up/Down keys do nothing in LN address modes.
UI Rendering & Display
src/ui/draw.rs, src/ui/tabs/settings_tab.rs, src/ui/help_popup.rs
Draw handlers render input prompt and confirmation dialogs with Lightning-specific titles/messages. Settings tab constant USER_SETTINGS_OPTIONS_COUNT incremented from 7 to 9 and options list extended with "Set Lightning Address (buyer)" and "Clear Lightning Address" entries. Help popup adds two new user settings instruction rows for LN address.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

Suggested reviewers

  • mostronatorcoder

Poem

🐰 A hop, a skip, through settings we go,
Lightning addresses now steal the show,
With validation and saves, the user can configure,
LNURL-pay buyers will smile at this feature!
thump thump

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Feature: ln address for buyers invoice - Step 1' directly reflects the main change: adding Lightning address support for buyers as the first step of a multi-part feature.
Docstring Coverage ✅ Passed Docstring coverage is 80.77% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/ln-address

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@arkanoider

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@mostronatorcoder mostronatorcoder Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I reviewed this PR carefully and I do not see a blocker here.

What I checked:

  • backward-compatible settings deserialization when ln_address is missing
  • the User-mode-only Settings flow for set / confirm / clear
  • validation behavior for user@domain.com format
  • paste handling for the new input popup
  • Settings menu indexing so the new rows do not shift Admin-mode actions by mistake
  • the current AddInvoice path, to make sure this persisted field fits the direction of the buyer invoice / LN address flow

The implementation looks coherent to me:

  • ln_address defaults to "", so legacy configs still load
  • the new rows are correctly user-only and admin option ordering stays intact
  • save clears/trim logic is sensible for a first step
  • no reachability check is added yet, which matches the PR scope

Checks are green too, so this looks good from my side. Nice incremental step toward buyer LN address support.

@arkanoider arkanoider merged commit 6482f6c into main May 4, 2026
11 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.

1 participant