Files
MichilisandClaude Fable 5.1 74f5ae53a7 Add LNURLcash audit and implementation plan
Phase 1 and 2 documents for LUD-25 bearer note support: an audit of the
bot (routing, locking, money paths, LNURL, storage, i18n, jobs, risks)
and of lnurlcash-go v0.3.0 including the btcec/lnd dependency conflict,
plus a step-by-step plan with open questions. No code changes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-13 21:38:00 +00:00

27 KiB
Raw Permalink Blame History

LNURLcash implementation plan

Implementation plan for LNURLcash notes. Each step compiles and can be merged alone. Amounts are int64 msat inside internal/lnurlcash; sats appear only at the Telegram and LNbits edges. k1 is never logged; h (sha256 of k1) and the note id are safe to log.

Design decisions (deviations from the spec, with reasons)

  • D1. Every bot-minted note is carved by a split so its value is a whole number of sats. LUD-25 requires a melt invoice for exactly the note's value, and LNbits invoices are whole sats (InvoiceParams.Amount int64). With the default mint's fee (1000,100) a directly minted note is almost never whole-sat. So creation always does: pay one mint invoice for the gross → the funding note (secret k1_0, hash h_0) → SplitNoteWithHash(cb, [k1_0], value_msat, h_1, h_2) → the user's note h_1 is exactly value; the change h_2 is dust owned by the bot. A single note is therefore a batch of one with batch_strategy: split. Gross is computed as the smallest whole-sat invoice whose net after the mint fee is at least N·value + N·base_fee_msat + 1 msat (each split costs base_fee_msat on the change and the change must stay positive). The confirm message shows value, mint fee (both parts), total. Alternative (open question Q1): if the running LNbits accepts fractional sats (amount as float, unit: "sat"), melts could be exact without splits; the split path stays necessary for externally minted fractional notes anyway.
  • D2. batch_strategy: invoices is kept but documented as "one invoice per note, then one split per note" (same carving, N invoices). Default remains split.
  • D3. Redeeming a note with a fractional-sat value (possible from other mints): split off S = floor(value_msat/1000) sats to a fresh bot secret (persisted first), retrying with S−1, S−2 on a definitive insufficient value refusal (nothing burned), then melt that whole-sat note. The dust change stays as a bot-owned dust row. Whole-sat notes melt directly.
  • D4. Detection of a note inside the existing /lnurl flow happens in HandleLNURL's withdrawRequest branch by reading mintPubkey from the body with gjson; when present and the feature is enabled it returns a new LNURLCashNoteParams value and lnurlHandler hands it to the redeem flow. Withdraw links without mintPubkey behave exactly as today.
  • D5. Two log lines in t/lnurl.go that print the raw text (:40) and the decoded URL (:217) are changed to go through redactForLog / to drop the query string. This is a log change only; command behaviour is untouched. Required by "never log k1".
  • D6. Secrets are stored AES-256-GCM encrypted (stdlib crypto/aes, random 12-byte nonce, key = secret_encryption_key as 64 hex chars). When lnurlcash.enabled and the key is empty or malformed the bot refuses to start with a clear message. The hash h is stored in clear as the lookup key.
  • D7. New sqlite file database.lnurlcash_path (default data/lnurlcash.db) holding the five new tables, opened in AutoMigration. Keeps the users DB untouched and lets the feature be dropped by deleting one file. Models live in internal/lnurlcash (imports internal/lnbits for Wallet; telegram imports lnurlcash; no cycle).
  • D8. Idempotent "in-flight" rows instead of Bunt objects: all state is in GORM rows with a state column; Bunt is used only for the short-lived confirm dialogs (storage.Base pattern, like /send). Background jobs read rows, never Bunt.
  • D9. Settle detection = webhook event + polling. Redeem/reclaim invoices are created with createInvoiceWithEvent-style events (new InvoiceCallbackLNURLCashSettle), and the recovery job also polls bot.Client.Payment(wallet, hash).Paid, so a lost webhook cannot strand a melt.
  • D10. The per-user Telegram lock is held for the whole creation handler (including the mint invoice and the LNbits pay), matching /pay. Background jobs lock per note id with mutex.Lock(noteID) (plain, not LockWithContext, because of the nLocks caveat) and skip rows whose lock is busy.

Step 0: branch, docs, dependency (no behaviour change)

  • git checkout -b lnurlcash; add docs/lnurlcash/AUDIT.md, docs/lnurlcash/PLAN.md.
  • go get github.com/lnurlcash/lnurlcash-go@v0.3.0; add replace github.com/btcsuite/btcd/btcec/v2 => github.com/btcsuite/btcd/btcec/v2 v2.3.3 with a comment explaining the lnd SignCompact incompatibility; go mod tidy.
  • Test: go build ./... && go vet ./... && go test ./... && go test github.com/lnurlcash/lnurlcash-go (all verified green in the scratch copy).

Step 1: config and crypto (internal/config.go, internal/lnurlcash/crypto.go)

  • Add to internal/config.go: LNURLCash LnurlcashConfiguration \yaml:"lnurlcash"` with fields mirroring the spec block (Enabled bool, Mints []MintConfiguration{Name, URL, Default bool}, MinNoteSat, MaxNoteSat, MaxOutstandingSatPerUser, MaxOutstandingNotesPerUser, MaxBatchSize, MaxBatchTotalSat, GroupNoteMaxSat, MaxMintFeePpm int64, AutoReclaimDays int, StatusPollInterval, InvoiceWaitTimeout time.Duration, BatchStrategy string, BatchFormats []string, SecretEncryptionKey string) and DatabaseConfiguration.LNURLCashPath `yaml:"lnurlcash_path"`. Add the block to config.yaml.example(disabled by default). AddValidate() error(defaults for zero values: poll 5m, wait 60s, strategy split, formats pdf,json,csv; exactly one default mint; URLs must passlnurlcash.IsAllowedServiceURL; key hex of 32 bytes when enabled). Call it from checkLnbitsConfiguration(skipped in tests byisTestBinary`).
  • internal/lnurlcash/crypto.go: type Cipher struct{aead cipher.AEAD}, NewCipher(hexKey), Seal(plain string) ([]byte, error), Open([]byte) (string, error).
  • Tests: crypto_test.go round-trip, wrong key fails, tamper fails; config_test.go for Validate.

Step 2: models and store (internal/lnurlcash/models.go, store.go; t/database.go)

Tables (GORM, table names via TableName()):

  • lnurlcash_notes: ID string (pk, note-<rand10>), BatchID *string (index), UserName string (index; Telegram id as in lnbits.User.Name), MintID string, MintURL string (withdraw link), MintPubkey string, Hash string (unique index; h), SecretEnc []byte, ValueMsat int64 (requested), ReportedMsat int64 (from the mint), GrossMsat int64, FeeMsat int64, Memo string, State string (index), Kind string (user, funding, dust, redeem_split), InvoicePR string, InvoiceHash string, VerifyURL string, Certificate string, ChatID int64, MessageID string (group post, for edits), ReceiptMessageID string, LanguageCode string, LastProbe time.Time, LastError string, ClaimedAt, ReclaimedAt *time.Time, CreatedAt, UpdatedAt.
  • lnurlcash_batches: ID (batch-<rand10>), UserName, MintID, Memo, Count, ValueMsat, TotalGrossMsat, FeeMsat, State (pending_invoice|pending_settle|carving| live|partial|claimed|reclaimed), FundingNoteID, InvoiceHash, LastDigestAt, timestamps.
  • lnurlcash_redeems: ID (redeem-<rand10>), UserName, MintHost, NoteID string (hex Q from NoteIDOf), NoteURLEnc []byte (full note URL incl. k1, encrypted), ReportedMsat, State (info|confirmed|invoiced|melting|settled|failed|split_pending), InvoicePR, InvoiceHash, SplitNoteID *string, LastError, timestamps, LanguageCode.
  • lnurlcash_user_prefs: UserName (pk), DefaultMintID, UpdatedAt.
  • lnurlcash_mints: ID (config name), URL, PayURL, WithdrawLink, PinnedPubkey, LastSeenPubkey, FeeBaseMsat, FeePpm, CommentAllowed, Healthy bool, Disabled bool, LastCheck, LastError, MinSendableMsat, MaxSendableMsat.
  • store.go: type Store struct{db *gorm.DB}; Open(path) (*Store, error) with the same gorm.Config as the other files + AutoMigrate of the five models; typed accessors (CreateNotes(tx, []Note), UpdateNoteState(id, from, to, patch) as a conditional UPDATE WHERE state = from so two workers cannot both advance a row, NotesByState, OutstandingByUser(user) (count, sumMsat), ListNotes(user, page, size), pagination helpers, NotesInBatch, Redeem*, Mint*, Pref*).
  • t/database.go AutoMigration: open lnurlcash.Open(cfg.LNURLCashPath) when enabled; add Databases.LNURLCash *lnurlcash.Store.
  • Tests: store_test.go with an in-memory sqlite (file::memory:?cache=shared), covering conditional state transitions and outstanding sums.

Step 3: mint registry (internal/lnurlcash/mints.go)

  • type Registry struct{cfg, store, client *lnurlcash.Client, alert func(string), mu}. NewRegistry(...); Check(ctx, mint): ResolveMintInput(url) → FetchPayRequest → require NamesMintOutput(), WithdrawLink != "", HasMintFee with FeePpm ≤ max_mint_fee_ppm (absent fee = 0), then FetchNoteInfoByHash is not possible without a note, so the pubkey is read from the payRequest's MintPubkey and, when empty, from the mint address at MintAddressURL(payURL) (FetchMintAddress, best effort), and finally verified on the first real note info (WithdrawInfo.MintPubkey). Pin on first non-empty value; a later different value → Disabled=true, alert("mint X changed pubkey …").
  • Default() *Mint, ByID, Enabled() []Mint, ForUser(user) (pref → default).
  • RunHealth(ctx): at startup and every 5 min (time.NewTicker), each mint checked with a 10 s context; logs host + outcome only.
  • HTTP client: lnurlcash.NewClient() but with HTTP.Transport built from network.directTransport()-equivalent (netguard dialer, SOCKS proxy from config) plus DisableKeepAlives: true, no redirects; expose newHTTPClient() in internal/network (NewNoKeepAliveClient(timeout)), so netguard and the proxy apply to mint traffic.
  • Tests: mints_test.go with httptest.Server serving payRequest JSON: fee cap, comment size, pubkey pin and change detection.

Step 4: note service, creation and status (internal/lnurlcash/service.go)

  • Interfaces so the service is testable without LNbits: type Ledger interface { Invoice(w lnbits.Wallet, sat int64, memo, webhook string) (lnbits.Invoice, error); Pay(w lnbits.Wallet, bolt11 string) (lnbits.Invoice, error); Paid(w lnbits.Wallet, hash string) (bool, error); BalanceMsat(w lnbits.Wallet) (int64, error) } implemented in t/lnurlcash.go by a thin adapter around bot.Client.
  • type Service struct{cfg, store, mints, ledger, cipher, client, log}.
  • Quote(ctx, mint, valueMsat, count) (Quote{GrossMsat, FeeMsat, PerNoteMsat, FundingNeededMsat, Mint}, error): FetchPayRequest → fee → needed = count·value + count·base + 1000 → GrossUpForMintFee(needed, fee) → round up to whole sat → check MinSendable/MaxSendable.
  • Create(ctx, user *lnbits.User, q Quote, memo, chat, lang) (*Batch, []Note, error) (one note = batch of one):
    1. caps: min/max_note_sat, outstanding count/sum per user (live + pending rows), max_batch_size, max_batch_total_sat, balance ≥ gross (via BalanceMsat).
    2. In one DB transaction: generate k1_0 (funding) and k1_1..N (+ one dust secret per split, N of them) with GenerateNoteSecret, hash them, insert the batch (pending_invoice) and all N+1+N rows (funding pending_invoice, user notes pending_carve, dust pending_carve) with encrypted secrets. Commit before any network call.
    3. RequestMintInvoiceWithHash(payCallback, grossMsat, h_0); store PR + verify URL on the funding note and the batch → pending_settle (conditional update).
    4. ledger.Pay(user.Wallet, pr); on a definitive LNbits error → batch failed, rows failed, return the error; on ambiguous error (timeout) → leave pending_settle for recovery.
    5. Wait up to invoice_wait_timeout: loop FetchInvoiceStatus(verifyURL) (if present) and FetchNoteInfoByHash(withdrawLink, h_0); found → funding live, store ReportedMsat. Timeout → leave for recovery and tell the user "still settling".
    6. Carve(ctx, batch): for i in 1..N: SplitNoteWithHash(cb, [k1_current], valueMsat, h_i, h_dust_i); on success note i → live, verify by FetchNoteInfoByHash(h_i) (ReportedMsat), current = dust_i; last dust → dust state live. Partial failure: keep the live ones, the remainder stays in the current change note (bot-owned, funding state live with its reported value) and the batch is partial; the un-carved value is returned to the user by melting that change note into a fresh LNbits invoice for the user (whole-sat part; sub-sat remainder stays as dust), via the reclaim path.
    7. Build NoteURL = BuildNoteURL(withdrawLink, k1_i, ReportedMsat); ToBech32Lnurl for display; ToLud17w for the lnurlw form; QR via qrcode.Encode. The URL is built on demand from the decrypted secret and never stored.
  • Status(ctx, note) (NoteStatus, error): FetchNoteInfoByHash → live with value; IsSpent → mark claimed (conditional update) and return claimed; IsUnknownNote on a note that was live → claimed as well (LUD-25: unknown and burned are one answer); transport errors → unchanged.
  • On any mutation error: IsAmbiguous → row state unknown with LastError; the secrets were persisted in step 2 so NewSecrets is empty by construction, but the code still calls it and logs a warning if non-empty. ProbeBurnedNote is used by recovery only.
  • Tests: service_test.go with a fake mint (httptest) implementing payRequest, mint invoice, ?p= lookup, split, melt (including "pending", "already in use", dropped connection after apply) and a fake ledger. Covers: secrets persisted before the first request, gross-up math against the live fee 1000,100, carve partial failure, status transitions, the ambiguity path.

Step 5: reclaim and redeem (internal/lnurlcash/melt.go)

  • Reclaim(ctx, note): lock mutex.Lock(note.ID); Status first (claimed → stop); ledger.Invoice(user.Wallet, ReportedMsat/1000, "LNURLcash reclaim <id>", webhook) (whole sat by D1; otherwise D3 split first); store PR/hash on the note; live → reclaiming (conditional); MeltNote(cb, k1, pr): ErrNotePending → stay reclaiming (another melt is in flight; recovery resolves); IsSpent → claimed; definitive refusal → back to live with LastError; ambiguous → unknown. Success → stay reclaiming until the invoice is paid (InvoiceCallbackLNURLCashSettle or poll) → reclaimed.
  • RedeemInfo(ctx, input string) (RedeemPreview, error): ResolveNoteInput (also accepts lightning:), FetchNoteInfo(noteURL) (echo check), require MintPubkey; preview = value, host, whether the host is an admin mint, NoteIDOf(k1); insert lnurlcash_redeems (info) with the encrypted note URL; no secret in the preview message.
  • Redeem(ctx, redeemID, user): info → confirmed (owner), invoice for the whole-sat value (or D3), invoiced → melting, MeltNote; same error mapping; settle → settled and the balance is simply LNbits' new balance.
  • Never auto-retry a melt. A second MeltNote on the same note only after recovery has classified the first (ProbeBurnedNote → NoteLive and no LNbits payment).
  • Tests: fake-mint melt happy path, pending, spent, ambiguous; redeem of a fractional note (D3) and of a note from an unknown mint.

Step 6: background jobs (internal/lnurlcash/jobs.go)

  • type Notifier interface { NoteClaimed(note); BatchDigest(batch, claimedSince []Note); GroupNoteState(note, state); Alert(msg) } implemented in t/lnurlcash.go.
  • Jobs.Start(ctx): goroutines with time.NewTicker, each run guarded by a sync.Mutex so runs never overlap, each row under mutex.Lock(id)/Unlock:
    • claim watcher (status_poll_interval): Status for every live user note, oldest LastProbe first, capped per run; on claimed: Notifier.NoteClaimed (single notes), GroupNoteState(claimed) if MessageID != "", batches collected into one BatchDigest per batch per hour (LastDigestAt).
    • pending recovery (startup + 1 min): pending_settle → check ledger.Paid / verify URL / FetchNoteInfoByHash, finish Carve or mark failed after the LNbits payment is known to have failed; pending_carve with a live funding/change note → Carve resumes from the last live change; reclaiming/melting → ledger.Paid(hash) settled → reclaimed/settled; not settled and the note Status is live again → melt failed → live/failed; still "pending" → wait; unknown → ProbeBurnedNote (NoteGone + payment settled → final; NoteLive → back to the previous state).
    • mint health: Step 3's RunHealth.
    • auto reclaim (daily, only when auto_reclaim_days > 0): Reclaim for live notes older than N days, notifying the owner.
  • Started from bot.Start() after initInvoiceEventCallbacks with a context.Background() (the bot has no shutdown context; jobs are restart-safe by design).
  • Tests: table tests driving RunOnce() of each job against the fake mint and the in-memory store.

Step 7: Telegram wiring, single note (t/lnurlcash.go, t/note.go)

  • t/lnurlcash.go: TipBot.LNURLCash *lnurlcash.Service (nil when disabled; every handler starts with if bot.LNURLCash == nil { send lnurlcashDisabledMessage; return }), the Ledger adapter, the Notifier (uses i18n.Translate(note.LanguageCode, …), bot.Telegram.Edit with tb.StoredMessage for group posts, trySendMessage(&tb.User{ID:…}) for DMs), the invoice callback InvoiceCallbackLNURLCashSettle = 8 registered in initInvoiceEventCallbacks (the event's CallbackData carries the note/redeem id), and mustHavePrivateChat(ctx): send a probe-free DM via trySendMessageEditable(user.Telegram, …); if the returned message is nil (telebot ErrNotStartedByUser/ErrBlockedByUser, now surfaced by extending trySendMessage to also return the error through a new trySendMessageErr), reply in the group with lnurlcashStartPrivateFirstMessage and create nothing.
  • /note <amount> [memo] (noteHandler): registered like /send (localizer, logMessage, requireUser, lock + unlock); amount via GetAmount; memo via GetMemoFromCommand(m.Text, 2). Private: Quote → confirm message (value, mint fee, total, mint name, memo) with NoteConfirm{*storage.Base, UserName, Quote, Memo, LanguageCode} in Bunt (id lnurlcash-note-<tgid>-<rand5>) and buttons lnc_create, lnc_mint, lnc_cancel built on a fresh &tb.ReplyMarkup{}. lnc_create handler: object lock, owner, Active, Inactivate, Create, then send the QR photo (caption = bech32 LNURL in backticks, like invoice.go:180) and a second message with the lnurlw:// text and buttons lnc_reclaim, lnc_status (data = note id). lnc_mint: cycles through enabled mints and re-quotes. Group: group_note_max_sat check first, mustHavePrivateChat, no confirm, Create with ChatID, post QR + LNURL in the group (tryReplyMessage), store MessageID, DM the receipt with fee and the two buttons. Errors go to the DM; the group command is deleted with NewMessage(m, WithDuration(0, bot)) only on error.
  • lnc_status: Status → edit the receipt line; lnc_reclaim: Reclaim → message "reclaim requested"; settle notification via callback 8.
  • Translations: add an # LNURLCASH section to en.toml and nl.toml (keys below).

Step 8: /lnurlmints (t/lnurlmints.go)

  • Lists enabled mints with fee (DescribeMintFee), health and a lnc_setmint button per mint (data = mint id); writes lnurlcash_user_prefs. In a group: delete the command (admin permitting), answer privately.

Step 9: /notes list and batches (t/notes_list.go, t/notes_batch.go, internal/lnurlcash/export/)

  • /notes (private; in a group answered privately): paginated list (10 per page) of the user's single notes and batches, newest first, state emoji + value + memo + short id; buttons lnc_page (data <listid>|<page>), lnc_open (note id) and lnc_openb (batch id). The list object is NotesList{*storage.Base, UserName, Page, …} in Bunt keyed by its own id (not by user name) and keyboards are built fresh per message; page math fixed (start = page*size, exclusive end).
  • Note view: value (reported), state, mint, memo, created; buttons lnc_qr, lnc_status, lnc_reclaim. Batch view: counts by state, buttons lnc_exp_pdf, lnc_exp_json, lnc_exp_csv, lnc_refresh, lnc_reclaimb.
  • /notes <amount> x <count> [memo]: parse x/×; caps; Quote(count); confirm with the total; progress message edited through tryEditStack after each carve step (progress callback on Create); then a format picker with the configured batch_formats.
  • export/pdf.go (go-pdf/fpdf, A4, 2×4 grid = 8 notes per page: QR PNG from qrcode.Encode via ImageOptions with a bytes.Reader, value, memo, mint name, short id), export/csv.go (index,id,amount_sat,lnurl,lnurlw_url,mint,memo,created_at), export/json.go ({batch_id, mint_url, mint_pubkey, memo, created_at, notes:[{index, id, amount_msat, lnurl, lnurlw, certificate}]}); all take []ExportNote (decrypted URLs built in memory by the service, claimed notes excluded) and write to an io.Writer. Sent with tb.Document{File: tb.File{FileReader: buf}, FileName: "notes-<batchid>.<ext>"} in private chat only. Re-export regenerates from the DB.
  • Tests: golden tests for CSV/JSON; PDF test checks page count and that the file starts with %PDF.

Step 10: redeem entry points (t/note_redeem.go, t/lnurl.go, t/text.go, t/photo.go)

  • /redeem <note>: private → RedeemInfo → preview (value, mint host, warning if not an admin mint) with lnc_redeem_ok / lnc_cancel; lnc_redeem_ok → Redeem. Group → delete the command immediately (tryDeleteMessage; if the bot lacks delete rights, still continue privately and tell the user the message could not be removed), then the same flow in the DM via mustHavePrivateChat.
  • HandleLNURL (t/lnurl.go:267): in the withdrawRequest body branch, if j.Get("mintPubkey").String() != "" and bot.LNURLCash != nil, return LNURLCashNoteParams{URL: rawurl, Body: b}; lnurlHandler adds a case that calls the redeem preview with the original input. Everything else unchanged; feature disabled → old path. D5 log fixes: :40 → redactForLog(m.Text), :217 → log scheme+host only.
  • anyTextHandler: nothing to add (pasted lnurlw://… and LNURL1… already route to lnurlHandler); add a case-preserving pass: when IsLnurl matches, pass the original m.Text (not anyText) for the note path so paths keep their case. Groups: unchanged (the text handler is private-only already).
  • photoHandler: unchanged (hands to lnurlHandler); groups unchanged (private-only).

Step 11: hardening and docs

  • redactForLog: also redact lnurlw://, lnurlp:// and ?k1= tokens (regex).
  • README section; botfather-setcommands.txt entries for /note, /notes, /redeem, /lnurlmints; help text keys.
  • Admin alerts: Alert DMs lnbits.admin_id's Telegram user if resolvable, else logs at Error level (open question Q4).

Translation keys (en + nl, all under # LNURLCASH)

lnurlcashDisabledMessage, lnurlcashStartPrivateFirstMessage, noteHelpMessage, noteConfirmMessage (value, fee, total, mint, memo), noteCreateButton, noteChangeMintButton, noteCancelButton, noteCreatingMessage, noteCreatedMessage, noteGroupMessage, noteGroupClaimedMessage, noteGroupWithdrawnMessage, noteReceiptMessage, noteReclaimButton, noteStatusButton, noteShowQrButton, noteStatusLiveMessage, noteStatusClaimedMessage, noteStatusPendingMessage, noteReclaimRequestedMessage, noteReclaimedMessage, noteClaimedNotifyMessage, noteBatchDigestMessage, noteCapMessage (several: min/max/outstanding/group/batch), noteInsufficientFundsMessage, noteMintUnavailableMessage, noteErrorMessage, notesListHeader, notesListEmpty, notesListItem, notesBatchItem, notesOpenMessage, notesBatchOpenMessage, notesExportPdfButton, notesExportJsonButton, notesExportCsvButton, notesRefreshButton, notesReclaimUnclaimedButton, notesBatchConfirmMessage, notesBatchProgressMessage, notesBatchPartialMessage, notesBatchFormatMessage, redeemHelpMessage, redeemPreviewMessage, redeemUnknownMintWarning, redeemAddButton, redeemInFlightMessage, redeemDoneMessage, redeemSpentMessage, redeemPendingMessage, redeemFailedMessage, redeemGroupDeletedMessage, lnurlmintsHeader, lnurlmintsItem, lnurlmintsSetButton, lnurlmintsSetMessage, lnurlcashMintPubkeyChangedAlert.

Testing strategy overall

  • Unit: internal/lnurlcash/** with a fake mint (httptest) and a fake ledger; no Telegram.
  • Integration (manual, documented in PLAN.md): a testnet/regtest LNbits + the live default mint with 10–20 sat notes: create single (private and group), claim with lnurl-wallet, observe the group edit and DM; reclaim; batch of 3 with PDF/CSV/JSON; redeem a note minted by another wallet; kill the bot during pending_settle and during reclaiming and check recovery; change the mint pubkey in config to see the disable + alert.
  • go test ./... stays green at every step; go vet clean.

Open questions for the user

  1. Fractional values vs LNbits (D1/D3): does the production LNbits accept a fractional amount in sats (LNbits ≥ 0.12 CreateInvoice.amount: float)? If yes, do you prefer msat-exact melts over the split carving? The configured LNbits (100.64.131.43:5000) was not reachable from this machine, so the version is unknown. Carving is the safe default.
  2. Dust: the per-split base fee and sub-sat remainders leave small bot-owned dust notes. Accept and ignore, or add a periodic merge/melt into the bot wallet (initBotWallet)?
  3. Dependency pin: accept the replace … btcec/v2 v2.3.3 pin (recommended, tested), or remove ln-decodepay/lnd by decoding bolt11 amounts another way (changes /pay internals)?
  4. Admin alerts: DM to the Telegram user behind lnbits.admin_id is not derivable (admin_id is an LNbits user id). Add lnurlcash.admin_telegram_id to config, or log only?
  5. New sqlite file (database.lnurlcash_path) vs tables inside bot.db?
  6. Group /redeem without delete rights: continue privately anyway (proposed) or refuse?
  7. PDF library: github.com/go-pdf/fpdf v0.9.0 acceptable (adds 4 small deps)?
  8. Minimum note value: the default mint's minWithdrawable is 10 sat and minSendable 12 sat; min_note_sat: 1 cannot be honoured there. Clamp to the mint's minimum at quote time (proposed) or reject?
  9. /lnurl <note> log fixes (D5): OK to change those two existing log lines?
  10. Batch strategy invoices: keep (N invoices + N splits) or drop from the first version?