Skip to content

fix: lnurl and quickpay msat amount conversion#514

Merged
ovitrif merged 4 commits intofix/msat-invoice-precisionfrom
fix/lnurl-amount-rounding
Apr 7, 2026
Merged

fix: lnurl and quickpay msat amount conversion#514
ovitrif merged 4 commits intofix/msat-invoice-precisionfrom
fix/lnurl-amount-rounding

Conversation

@ovitrif
Copy link
Copy Markdown
Collaborator

@ovitrif ovitrif commented Apr 6, 2026

Summary

Stacked on:

This PR:

  • Ports Android's LNURL amount helpers (isFixedAmount, callbackAmountMsats, minSendableSat, maxSendableSat) to iOS as extensions on LnurlPayData and LnurlWithdrawData
  • Fixes sub-sat edge cases where min/max msat values map to an inverted sat range after rounding (e.g. min=222222, max=222538minSat=223, maxSat=222) — these are now correctly treated as fixed-amount requests
  • Fixes LNURL quickpay: the guard required scannedLightningInvoice (always nil for LNURL pay), and the amount wasn't displayed on the quickpay screen

Preview

Script:

  1. LNURL-Pay minSendable=222222&maxSendable=222538 QuickPay=OFF
  2. LNURL-Pay minSendable=222222&maxSendable=222538 QuickPay=ON
Simulator.2026-04-06.004948.mp4

Test plan

Use synonymdev/bitkit-docker#6:

  • LNURL-Pay (QuickPay ON & OFF) msat range:
    http://localhost:3000/generate/pay?minSendable=222222&maxSendable=222538
    
  • LNURL-Withdraw msat range:
    http://localhost:3000/generate/withdraw?minWithdrawable=22222&maxWithdrawable=22522
    
  • Bolt11 with msat amount (QuickPay ON & OFF)
    ./bitcoin-cli bolt11 33333 --msat
    
  • regression: Bolt11 zero-amount invoice
    ./bitcoin-cli bolt11
    

🤖 Generated with Claude Code

@ovitrif ovitrif added this to the 2.2.0 milestone Apr 6, 2026
@ovitrif ovitrif self-assigned this Apr 6, 2026
@ovitrif ovitrif changed the title fix: LNURL amount rounding and quickpay for sub-sat ranges fix: lnurl and quickpay msat amount rounding and comparison Apr 6, 2026
@ovitrif ovitrif changed the title fix: lnurl and quickpay msat amount rounding and comparison fix: lnurl and quickpay msat amount conversion Apr 6, 2026
@claude

This comment has been minimized.

ovitrif and others added 3 commits April 6, 2026 03:16
Port Android's LNURL amount helpers (isFixedAmount, callbackAmountMsats,
minSendableSat, maxSendableSat, etc.) to iOS via extensions on
LnurlPayData and LnurlWithdrawData.

This fixes sub-sat edge cases where min/max msat values map to an
inverted sat range after rounding (e.g. min=222222, max=222538 →
minSat=223, maxSat=222). These are now correctly treated as fixed-amount
requests and routed to the confirm screen instead of the amount picker.

Also fixes LNURL quickpay guard that required scannedLightningInvoice
(always nil for LNURL pay flows), and centralizes all msat→sat
conversions for LNURL amounts in the new extension file.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The quickpay view only displayed the amount for bolt11 invoices
(scannedLightningInvoice). For LNURL pay, the invoice doesn't exist
yet at that point — the amount comes from lnurlPayData.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ovitrif ovitrif force-pushed the fix/lnurl-amount-rounding branch from aaa2240 to e2d0056 Compare April 6, 2026 01:16
@claude

This comment has been minimized.

@piotr-iohk
Copy link
Copy Markdown
Collaborator

Found an issue, I suppose not related to that change, but I think easy fix that could be included, since it is a stacked PR already. lnurl-pay is missing the amount on SendSuccess screen:

Screen.Recording.2026-04-07.at.12.53.46.mov

@claude
Copy link
Copy Markdown

claude bot commented Apr 7, 2026

Code review

1 issue found.


Missing CHANGELOG.md entry

This is a fix: PR, and per CLAUDE.md:

ALWAYS add exactly ONE entry per PR under ## [Unreleased] in CHANGELOG.md for feat: and fix: PRs

CHANGELOG.md was not modified in this PR. Please add a single ### Fixed entry under ## [Unreleased], e.g.:

```markdown

Fixed

Copy link
Copy Markdown
Collaborator

@piotr-iohk piotr-iohk left a comment

Choose a reason for hiding this comment

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

tACK

Copy link
Copy Markdown
Collaborator Author

@ovitrif ovitrif left a comment

Choose a reason for hiding this comment

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

reviewed c17ee16

@ovitrif ovitrif merged commit b987e7c into fix/msat-invoice-precision Apr 7, 2026
8 of 9 checks passed
@ovitrif ovitrif deleted the fix/lnurl-amount-rounding branch April 7, 2026 12:16
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