aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-09-22 11:23:19 -0700
committerAdam Soltys <[email protected]>2026-09-22 11:27:15 -0700
commit802eea628fb77fed305de555995cf323174b0394 (patch)
tree2c9d1a74f5f94dda032b3c346a15f1dff2daffb4 /src/lib
parent6735d9ec73949046932716dba90ebd9cd63b513d (diff)
downloadcoinos-ui-802eea628fb77fed305de555995cf323174b0394.tar.gz
coinos-ui-802eea628fb77fed305de555995cf323174b0394.zip
invoice: a reusable bolt12 offer has no terminal paid state
A bolt12 offer is a standing payment code. CLN derives the same offer_id from the same (amount, description), so re-creating one hands back the original record, whose `received` has accumulated over the offer's whole lifetime. The invoice layout read that as "this invoice was paid" and redirected to the success screen, so reopening a long-lived offer never showed the QR and left no way to copy the lno. Treat a payment as celebratory only when it arrives while the page is open: the socket handler now passes the amount of that payment as `?paid=<amount>`, and the layout uses it in place of the lifetime total for reusable offers. Single-use invoices keep the existing logic, so a partly-paid invoice still stays on the QR rather than celebrating early. The success screen showed lifetime `received` for the same reason, which misreported a single payment to a long-lived offer; it now renders the amount the socket reported, which is already net of tip. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/socket.ts7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lib/socket.ts b/src/lib/socket.ts
index b87cc165..b28b1060 100644
--- a/src/lib/socket.ts
+++ b/src/lib/socket.ts
@@ -57,7 +57,12 @@ export const messages = (data) => ({
pathname.includes("/receive") ||
pathname.includes("/invoice")
) {
- if (!get(navigating)) goto(`/invoice/${iid}`);
+ // `paid=<amount>` marks this as a payment that arrived just now, and
+ // carries the amount of THIS payment. A reusable bolt12 offer needs
+ // both: its `received` is a lifetime total, so the invoice layout
+ // can't tell a live payment from an old one, and the success screen
+ // would otherwise show the accumulated figure.
+ if (!get(navigating)) goto(`/invoice/${iid}?paid=${amount}`);
} else success(`${confirmed ? "Received" : "Detected"} ⚡️${s(amount)}!`);
}
},