Skip to content

Conversation

@jvsena42
Copy link
Member

@jvsena42 jvsena42 commented Jan 19, 2026

This PR fixes unified invoice validation to accept Lightning payment when on-chain balance is zero.

Description

When typing or pasting a unified invoice (BIP21 with embedded Lightning), the validation incorrectly rejected it if on-chain balance was zero, even when the user had sufficient Lightning balance. The fix adds unified invoice detection to validateOnChainAddress(), mirroring the existing logic in onScanOnchain().

Changes:

  1. Extracts a reusable extractViableLightningInvoice() helper that checks if a BIP21 URI contains a valid, non-expired Lightning invoice with sufficient sending capacity
  2. Updates validateOnChainAddress() to check for Lightning payment viability before falling back to on-chain balance validation
  3. Refactors onScanOnchain() to use the same helper, eliminating code duplication
  4. Fixes on-chain balance checks to only trigger when payment method is on-chain

Preview

zero-amount-invoice.webm
with-amount.webm

QA Notes

1. Unified invoice with Lightning balance only

  1. Create wallet with 0 on-chain balance but funded Lightning channel
  2. Paste a unified invoice (BIP21 with ?lightning= param)
  3. Verify: Address should be accepted (green checkmark)
  4. Before fix: Shows "Insufficient Savings" error

2. Regression - Pure on-chain address

  1. Paste a plain Bitcoin address
  2. Verify on-chain balance validation still works as expected

3. Regression - Scan flow

  1. Scan a unified QR code
  2. Verify it still routes correctly to Lightning payment

@jvsena42 jvsena42 self-assigned this Jan 19, 2026
@claude

This comment has been minimized.

@claude
Copy link

claude bot commented Jan 19, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

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