Skip to content

#108 Feature: Implement Lightning Address#113

Draft
andycreed0x wants to merge 6 commits into
developfrom
108-jan3-ln-address
Draft

#108 Feature: Implement Lightning Address#113
andycreed0x wants to merge 6 commits into
developfrom
108-jan3-ln-address

Conversation

@andycreed0x

Copy link
Copy Markdown
Collaborator

Purpose

Implements Lightning Address support for JAN3/AQUA accounts. Closes #108 Feature: Implement Lightning Address.

Each AQUA user has a Lightning Address (ln_username@<domain>) assigned by the backend. This PR exposes the full LN-address lifecycle as MCP tools and CLI commands: check username availability, purchase a username with an on-chain L-BTC payment, enable/disable delivery, and keep the unused Liquid address pool healthy so the backend can deliver inbound Lightning payments.

Description

The backend delivers inbound Lightning payments to a rotating batch of off-chain Liquid receive addresses registered by the client. Because these addresses are handed out before any on-chain activity, lwk's next-unused tip can't track them — WalletData now persists a monotonically-increasing next_address_index counter so two flows never share an address. The pool self-heals: jan3_user_info and jan3_enable_lightning_address both call ensure_ln_pool (best-effort, never failing the primary operation).

Main Changes

  • ✨ Added jan3_user_info — account profile + auto pool top-up when LN-address is active
  • ✨ Added jan3_enable_lightning_address — opt in/out; on enable immediately registers a Liquid address batch
  • ✨ Added jan3_ln_check_username — availability check before paying L-BTC
  • ✨ Added jan3_purchase_ln_username — on-chain L-BTC payment to buy/update the LN username; computes txid locally from the raw tx since the API omits it
  • ✨ Added register_ln_addresses / ensure_ln_pool / _auto_ensure_ln_pool internal manager methods (jan3_accounts.py) for pool lifecycle; not exposed as MCP tools
  • ✨ Added Jan3AccountsClient API methods: get_user, ln_address_toggle, ln_username_available, register_addresses, create_ln_username_payment_request, submit_raw_tx
  • 🏗️ Added WalletData.next_address_index (storage.py) with migration from legacy ln_addr_next_index key; advances via WalletManager.reserve_addresses
  • ✨ Added CLI commands: aqua jan3 user-info, enable-lightning-address, ln-check-username, purchase-ln-username (cli/jan3.py)
  • 🔧 Updated features.py CLI→MCP mappings for new commands
  • ✨ Added next_step hint to jan3_verify / jan3_login_complete results to cue agents to offer LN-address opt-in post-login
  • ✅ Added tests in test_jan3_accounts.py, test_storage.py, test_tools.py, test_wallet.py (~600 lines)

Checklist

  • No hardcoded values (they should go in constants.py, .env, or our database)
  • Added/updated tests (if necessary)
  • Added/updated relevant documentation (if necessary)

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