Skip to content

Conversation

@ekzyis
Copy link
Member

@ekzyis ekzyis commented Nov 6, 2025

Description

This is a partial refactor of #2564.

Only partial, because the automatic switch to the lightning address if it has an initial value is still hard-coded in a useEffect:

// we switch to the LN_ADDR protocol form if it exists and there's an initial value
// else we just select the first protocol.
const lnAddrProto = protocols.find(p => p.name === 'LN_ADDR')
if (lnAddrForm?.initial.address && lnAddrProto) {
setProtocol(lnAddrProto)
} else {

Ideally, we would generally switch to the first protocol form that has an initial value.

Additional Context

#2575 will also use this code to set the identity public key from the mnemonic.

Checklist

Are your changes backward compatible? Please answer below:

yes

On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:

8. Tested by pasting a Coinos NWC string and seeing the initial lightning address value set to the lud16 parameter. Also tested skipping NWC and SSR.

For frontend changes: Tested on mobile, light and dark mode? Please answer below:

n/a

Did you introduce any new environment variables? If so, call them out explicitly here:

no

Did you use AI for this? If so, how much did it assist you?

no


Note

Adds a generic populate for protocol fields and moves Lightning Address initial value derivation from NWC into the LN_ADDR protocol, with domain handling done via schema transform.

  • Form logic:
    • Introduce field.populate support in useProtocolForm, using global form state to prefill values; remove NWC-specific parsing from hooks.js.
    • Normalize LUD-16 handling: strip domain from address in initial values and append via schema transform on submit.
  • Protocols:
    • Extend ProtocolField type with populate callback.
    • LN_ADDR: add populate that reads lud16 from NWC URL (when present and domain-compatible) to prefill address.
  • UI:
    • WalletProtocolFormField transforms now accept and ignore populate prop to avoid passing it to inputs.

Written by Cursor Bugbot for commit 02a900d. This will update automatically on new commits. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants