Repository navigation
Custom memo for Credit/Debit flows. - #4162
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #4162 +/- ##
===========================================
+ Coverage 56.50% 67.08% +10.57%
===========================================
Files 123 164 +41
Lines 16914 25551 +8637
===========================================
+ Hits 9557 17140 +7583
- Misses 7357 8411 +1054 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
|
LGTM, but unit test fails. |
The superuser endpoint PUT /users/api/v1/balance always created the internal payment with a hardcoded "Admin credit" or "Admin debit" memo, leaving no way to tell the affected user why their balance changed. - add an optional memo field to UpdateBalance (max 640 chars, same cap as invoice memos) and pass it through update_wallet_balance for both the credit and the debit path - tag these payments with extra.tag = "admin" so the payment list shows the #admin badge, exactly like extension payments; provenance is carried by the tag, so the default memos slim down to "Credit" and "Debit" instead of duplicating the badge - include the memo in the balance_update admin notification
Extend the superuser credit/debit popup with an optional memo input and polish the interaction: - popup opens below its trigger button with a soft jump-down transition instead of covering it - visible sign-aware action button: shows Credit (primary) and flips to Debit (negative) when the amount is negative, with Enter kept as the keyboard shortcut; submission is guarded against empty and zero amounts - amount field starts empty instead of a prefilled 0 that had to be deleted before typing a negative value, and both popup variants use a numeric input - remove the decorative pencil icon that suggested an action it did not have - emit credit-value on success so the users page refreshes the wallets table, and show the parsed amount in the success notification
- limit memos to 639 bytes, the bolt11 description limit; a 640 character or multibyte memo crashed invoice encoding with a cryptic error at the previously advertised maximum - trim whitespace-only memos before falling back to the default - report the post-update balance in the admin notification instead of the pre-update snapshot
- guard against a second submit while a request is in flight and show the loading state on the action button - clear the memo when the popup closes without submitting so it cannot attach to a later balance update - declare the credit-value emit and listen for it on the wallet page, replacing an unused callback prop, so the displayed balance also refreshes after a debit
motorina0
approved these changes
Sep 14, 2026
motorina0
added a commit
to dsbaars/lnbits
that referenced
this pull request
Oct 16, 2026
Co-authored-by: Vlad Stan <[email protected]>
UniSyncInc2212
added a commit
to UniSyncInc2212/lnbits
that referenced
this pull request
Nov 6, 2026
* Remove a user wallet on the second delete instead of returning 404 (lnbits#4150) * Custom memo for Credit/Debit flows. (lnbits#4162) Co-authored-by: Vlad Stan <[email protected]> * Merge commit from fork * Delete cliche (lnbits#4118) * feat: asset refactor, phoenixd/sparkl2 included, add dmg (lnbits#4167) * fix: posgres export (lnbits#4187) * chore(deps): bump nanoid from 3.3.16 to 3.3.19 (lnbits#4181) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix: paid install QR code never shown for WASM extensions with permissions (lnbits#4195) Co-authored-by: bitkarrot <[email protected]> * feat: support sending to BOLT12 offers (lnbits#2581) Pay lno1 offers through the existing /api/v1/payments path. Offers are validated fail-closed, require an explicit sat amount, and reuse the BOLT11 external-payment lock/fee-reserve/timeout flow instead of a parallel pay path. CLN and CLN REST fetch an invoice then pay it; Phoenixd and Eclair use payoffer. Unsupported funding sources are rejected before a payment row is created. Co-authored-by: UniSyncInc2212 <[email protected]> * test: start app fixture for BOLT12 payment tests Request the session app fixture so isolated pytest runs migrate the database before paying offers. Co-authored-by: UniSyncInc2212 <[email protected]> * fix: address BOLT12 send review notes Move EclairWallet private helpers to the bottom of the class, document the unique placeholder payment hash for reusable offers, add Feature.bolt12 and pay_offer on LNbitsWallet, disable Pay when offer amount is 0, and name supported BOLT12 funding sources in the error and docs. Co-authored-by: UniSyncInc2212 <[email protected]> * fix: disable BOLT12 Pay using the amount field directly Bind q-btn disable to parse.data.amount so a zero offer amount cannot submit, and skip payInvoice when the offer amount is missing. Co-authored-by: UniSyncInc2212 <[email protected]> * fix: render a statically disabled Pay button when offer amount is 0 Use a separate always-disabled q-btn when bolt12AmountMissing so the control cannot submit, instead of binding disable with a greater-than expression in the in-DOM template. Co-authored-by: UniSyncInc2212 <[email protected]> * Squashed commit of the following: commit d2a4e66 Author: Vlad Stan <[email protected]> Date: Wed Sep 16 13:21:35 2026 +0300 refactor: extract check commit d3423c3 Author: Vlad Stan <[email protected]> Date: Wed Sep 16 13:00:01 2026 +0300 refactor: extract `_pay_from_wallet` commit 1a868bb Author: Vlad Stan <[email protected]> Date: Wed Sep 16 12:41:08 2026 +0300 fix: param name commit 96568e3 Author: Vlad Stan <[email protected]> Date: Wed Sep 16 12:25:53 2026 +0300 refactor: extract validation * refactor: move bolt12 logic to utils * refactor: use payment_request for invoice and offer inputs * test: add bot12 regtest commit 4cb82a6 Author: alan <[email protected]> Date: Thu Sep 17 07:45:01 2026 +0000 chore: make bundle [skip ci] commit 010ef37 Author: Vlad Stan <[email protected]> Date: Thu Sep 17 10:35:34 2026 +0300 fix: more fee rate fixes commit b7f40d6 Author: Vlad Stan <[email protected]> Date: Thu Sep 17 10:30:38 2026 +0300 test: fix feerate commit 63066f8 Author: Vlad Stan <[email protected]> Date: Thu Sep 17 10:24:05 2026 +0300 test: partial eclair regtest fix commit fdbcd98 Author: Vlad Stan <[email protected]> Date: Thu Sep 17 09:54:33 2026 +0300 test: fix test filter commit 01ff9df Author: Vlad Stan <[email protected]> Date: Wed Sep 16 19:37:05 2026 +0300 test: add bolt12 regtest * feat: add bolt12 payer_note (memo) commit 3f80ecd Author: Vlad Stan <[email protected]> Date: Fri Sep 18 11:01:28 2026 +0300 chore: clean-up commit af9b7ab Author: Vlad Stan <[email protected]> Date: Thu Sep 17 15:30:40 2026 +0300 feat: show offer memo and amount if present commit b237802 Author: Vlad Stan <[email protected]> Date: Thu Sep 17 15:09:22 2026 +0300 chore: make bundle commit 5fe3cc8 Author: Vlad Stan <[email protected]> Date: Thu Sep 17 14:56:43 2026 +0300 feat: show offer on ui commit f7c7c93 Author: Vlad Stan <[email protected]> Date: Thu Sep 17 14:47:22 2026 +0300 test: fix tests commit 4f49729 Author: Vlad Stan <[email protected]> Date: Thu Sep 17 14:18:22 2026 +0300 refactor: use `memo` for public api commit 2307dfe Author: alan <[email protected]> Date: Thu Sep 17 11:08:54 2026 +0000 chore: make bundle [skip ci] commit 5ef286b Author: Vlad Stan <[email protected]> Date: Thu Sep 17 13:56:57 2026 +0300 test: payer_note regtest commit 3551e85 Author: Vlad Stan <[email protected]> Date: Thu Sep 17 13:25:29 2026 +0300 fix: optional payer_note for eclair commit a803991 Author: Vlad Stan <[email protected]> Date: Thu Sep 17 13:23:09 2026 +0300 feat: payer_note first * feat: save the bolt12 invoice when available commit c4f9601 Author: Vlad Stan <[email protected]> Date: Fri Sep 18 12:55:16 2026 +0300 refactor: remove un-necessary type commit b60f43f Author: Vlad Stan <[email protected]> Date: Fri Sep 18 12:02:11 2026 +0300 doc: clean-up commit 6f40071 Author: Vlad Stan <[email protected]> Date: Thu Sep 17 19:15:28 2026 +0300 feat: save `payment_request` for bolt12 invoices commit 422332a Author: Vlad Stan <[email protected]> Date: Thu Sep 17 15:38:13 2026 +0300 Squashed commit of the following: commit af9b7ab Author: Vlad Stan <[email protected]> Date: Thu Sep 17 15:30:40 2026 +0300 feat: show offer memo and amount if present commit b237802 Author: Vlad Stan <[email protected]> Date: Thu Sep 17 15:09:22 2026 +0300 chore: make bundle commit 5fe3cc8 Author: Vlad Stan <[email protected]> Date: Thu Sep 17 14:56:43 2026 +0300 feat: show offer on ui commit f7c7c93 Author: Vlad Stan <[email protected]> Date: Thu Sep 17 14:47:22 2026 +0300 test: fix tests commit 4f49729 Author: Vlad Stan <[email protected]> Date: Thu Sep 17 14:18:22 2026 +0300 refactor: use `memo` for public api commit 2307dfe Author: alan <[email protected]> Date: Thu Sep 17 11:08:54 2026 +0000 chore: make bundle [skip ci] commit 5ef286b Author: Vlad Stan <[email protected]> Date: Thu Sep 17 13:56:57 2026 +0300 test: payer_note regtest commit 3551e85 Author: Vlad Stan <[email protected]> Date: Thu Sep 17 13:25:29 2026 +0300 fix: optional payer_note for eclair commit a803991 Author: Vlad Stan <[email protected]> Date: Thu Sep 17 13:23:09 2026 +0300 feat: payer_note first * fix: cln amount change * fix: prevent BOLT12 payments from being refunded after timeout * fix: keep ambiguous CLNRest offer payments pending * fix: wallet fees and fake wallet commit d12c0fe Author: Vlad Stan <[email protected]> Date: Mon Sep 21 16:09:10 2026 +0300 feat: create fake bolt12 invoice commit 393ab9d Author: Vlad Stan <[email protected]> Date: Mon Sep 21 15:45:55 2026 +0300 feat: add `lnbits_funding_source_pay_offer_wait_seconds` settings commit 04ebf30 Author: Vlad Stan <[email protected]> Date: Mon Sep 21 13:34:06 2026 +0300 fix: safer phoenixd status check commit 88b3072 Author: Vlad Stan <[email protected]> Date: Mon Sep 21 13:15:36 2026 +0300 fix: eclair fee * chore: make bundle --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: monasco <[email protected]> Co-authored-by: DrShift <[email protected]> Co-authored-by: Vlad Stan <[email protected]> Co-authored-by: Arc <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Bitkarrot <[email protected]> Co-authored-by: bitkarrot <[email protected]> Co-authored-by: Cursor Agent <[email protected]> Co-authored-by: UniSyncInc2212 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4155
Custom memo for superuser credit/debit
Superusers could not set a custom memo when crediting or debiting a wallet —
the memo was hardcoded to "Admin credit" / "Admin debit", and users had no
way of knowing why their balance changed.
API
PUT /users/api/v1/balancenow accepts an optionalmemo(max 640 chars, same cap as invoice memos):
{ "id": "wallet_id", "amount": 1000, "memo": "Beer for the Horde" }Omitting
memokeeps a sensible default, so existing calls work unchanged.Recognition in the user's wallet
Admin credit/debit payments are now tagged (
extra.tag = "admin"), so thepayment list shows the familiar yellow
#adminbadge — the same mechanismextensions use. Since the badge carries the provenance, the default memos are
now simply "Credit" / "Debit" instead of repeating it; with a custom memo the
row reads
#admin Beer for the Horde. The tag is searchable and included inCSV exports and
extra.tagfor API consumers.UI
The credit/debit popup (users area + wallet page) now has a memo field, plus
some small UX fixes:
when the amount is negative — Enter still submits
0that had to bedeleted before typing a negative value; empty/zero submits are blocked
The admin notification for balance updates now includes the memo as well.
Tests cover default and custom memos on both credit and debit, the
admintag, and memo length validation.