Skip to content

fix: update address validation logic in SendCubit and SendScreen#2125

Open
phalmeidal wants to merge 1 commit into
SatoshiPortal:developfrom
phalmeidal:fix/2076-lightning-address-validation
Open

fix: update address validation logic in SendCubit and SendScreen#2125
phalmeidal wants to merge 1 commit into
SatoshiPortal:developfrom
phalmeidal:fix/2076-lightning-address-validation

Conversation

@phalmeidal
Copy link
Copy Markdown

Summary

Fixes #2076

Small fix to avoid showing the "Invalid address" error while the user is typing a Lightning Address.

Validation now runs when the user clicks Continue/Send, instead of while the input is still being edited.

Files changed

  • send_cubit.dart
  • send_screen.dart

Changes

  • Removed immediate error emission from SendCubit.onChangedText, so typing a partial Lightning Address no longer sets invalidBitcoinStringException
  • Enabled the Continue button when the recipient input is non-empty via copiedRawPaymentRequest.trim().isNotEmpty
  • Added final validation at the start of SendCubit.continueOnAddressConfirmed
  • Kept invalidBitcoinStringException for cases where the address is invalid after the user clicks Continue

Manual testing

  1. Open the app and go to the Send screen (SendAddressScreen)
  2. Type a Lightning Address character by character, for example name@example.com
    • Expected: no "Invalid address" error appears while typing
  3. Click Continue with an invalid address
    • Expected: the "Invalid address" error appears
  4. Click Continue with a valid Lightning Address
    • Expected: the flow proceeds to the amount step

@i5hi
Copy link
Copy Markdown
Collaborator

i5hi commented May 16, 2026

Hey @phalmeidal !

Thanks for the contribution.

@BullishNode
Copy link
Copy Markdown
Contributor

BullishNode commented May 24, 2026

Requesting one change before merge:

onChangedText() still parses every edit via _detectBitcoinStringUsecase.execute(...), and Lightning Address parsing can perform async LNURL validation. continueOnAddressConfirmed() only checks cached state.paymentRequest, so validation has not really moved to Continue.

Impact: a valid Lightning Address can still depend on typing-time async validation. The user can type/paste an address, tap Continue before parsing finishes, and get "Invalid address" even though the input is valid. The Continue button can also remain disabled until onChangedText() finishes because copiedRawPaymentRequest is emitted only after parsing returns or throws.

Please make onChangedText() only store sanitized input and clear stale errors/request state. Then parse state.copiedRawPaymentRequest at the start of continueOnAddressConfirmed(), emit invalidBitcoinStringException only if that submit-time parse fails, and proceed with the parsed request on success.

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.

Relax address validation during send

3 participants