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>
27 KiB
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.k1is 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 (secretk1_0, hashh_0) →SplitNoteWithHash(cb, [k1_0], value_msat, h_1, h_2)→ the user's noteh_1is exactlyvalue; the changeh_2is dust owned by the bot. A single note is therefore a batch of one withbatch_strategy: split. Gross is computed as the smallest whole-sat invoice whose net after the mint fee is at leastN·value + N·base_fee_msat + 1 msat(each split costsbase_fee_msaton 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 (amountas float,unit: "sat"), melts could be exact without splits; the split path stays necessary for externally minted fractional notes anyway. - D2.
batch_strategy: invoicesis kept but documented as "one invoice per note, then one split per note" (same carving, N invoices). Default remainssplit. - 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 withS−1,S−2on a definitiveinsufficient valuerefusal (nothing burned), then melt that whole-sat note. The dust change stays as a bot-owneddustrow. Whole-sat notes melt directly. - D4. Detection of a note inside the existing
/lnurlflow happens inHandleLNURL'swithdrawRequestbranch by readingmintPubkeyfrom the body with gjson; when present and the feature is enabled it returns a newLNURLCashNoteParamsvalue andlnurlHandlerhands it to the redeem flow. Withdraw links withoutmintPubkeybehave exactly as today. - D5. Two log lines in
t/lnurl.gothat print the raw text (:40) and the decoded URL (:217) are changed to go throughredactForLog/ 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_keyas 64 hex chars). Whenlnurlcash.enabledand the key is empty or malformed the bot refuses to start with a clear message. The hashhis stored in clear as the lookup key. - D7. New sqlite file
database.lnurlcash_path(defaultdata/lnurlcash.db) holding the five new tables, opened inAutoMigration. Keeps the users DB untouched and lets the feature be dropped by deleting one file. Models live ininternal/lnurlcash(importsinternal/lnbitsforWallet;telegramimportslnurlcash; no cycle). - D8. Idempotent "in-flight" rows instead of Bunt objects: all state is in GORM rows with
a
statecolumn; Bunt is used only for the short-lived confirm dialogs (storage.Basepattern, like/send). Background jobs read rows, never Bunt. - D9. Settle detection = webhook event + polling. Redeem/reclaim invoices are created
with
createInvoiceWithEvent-style events (newInvoiceCallbackLNURLCashSettle), and the recovery job also pollsbot.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 withmutex.Lock(noteID)(plain, notLockWithContext, because of the nLocks caveat) and skip rows whose lock is busy.
Step 0: branch, docs, dependency (no behaviour change)
git checkout -b lnurlcash; adddocs/lnurlcash/AUDIT.md,docs/lnurlcash/PLAN.md.go get github.com/lnurlcash/lnurlcash-go@v0.3.0; addreplace github.com/btcsuite/btcd/btcec/v2 => github.com/btcsuite/btcd/btcec/v2 v2.3.3with a comment explaining the lndSignCompactincompatibility;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) andDatabaseConfiguration.LNURLCashPath `yaml:"lnurlcash_path"`. Add the block toconfig.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 fromcheckLnbitsConfiguration(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.goround-trip, wrong key fails, tamper fails;config_test.goforValidate.
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 inlnbits.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 fromNoteIDOf),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 samegorm.Configas the other files +AutoMigrateof the five models; typed accessors (CreateNotes(tx, []Note),UpdateNoteState(id, from, to, patch)as a conditional UPDATEWHERE state = fromso 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: openlnurlcash.Open(cfg.LNURLCashPath)when enabled; addDatabases.LNURLCash *lnurlcash.Store.- Tests:
store_test.gowith 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→ requireNamesMintOutput(),WithdrawLink != "",HasMintFeewithFeePpm ≤ max_mint_fee_ppm(absent fee = 0), thenFetchNoteInfoByHashis not possible without a note, so the pubkey is read from the payRequest'sMintPubkeyand, when empty, from the mint address atMintAddressURL(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 withHTTP.Transportbuilt fromnetwork.directTransport()-equivalent (netguard dialer, SOCKS proxy from config) plusDisableKeepAlives: true, no redirects; exposenewHTTPClient()ininternal/network(NewNoKeepAliveClient(timeout)), so netguard and the proxy apply to mint traffic. - Tests:
mints_test.gowithhttptest.Serverserving 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 int/lnurlcash.goby a thin adapter aroundbot.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 → checkMinSendable/MaxSendable.Create(ctx, user *lnbits.User, q Quote, memo, chat, lang) (*Batch, []Note, error)(one note = batch of one):- caps:
min/max_note_sat, outstanding count/sum per user (live + pending rows),max_batch_size,max_batch_total_sat, balance ≥ gross (viaBalanceMsat). - In one DB transaction: generate
k1_0(funding) andk1_1..N(+ one dust secret per split, N of them) withGenerateNoteSecret, hash them, insert the batch (pending_invoice) and all N+1+N rows (fundingpending_invoice, user notespending_carve, dustpending_carve) with encrypted secrets. Commit before any network call. RequestMintInvoiceWithHash(payCallback, grossMsat, h_0); store PR + verify URL on the funding note and the batch →pending_settle(conditional update).ledger.Pay(user.Wallet, pr); on a definitive LNbits error → batchfailed, rowsfailed, return the error; on ambiguous error (timeout) → leavepending_settlefor recovery.- Wait up to
invoice_wait_timeout: loopFetchInvoiceStatus(verifyURL)(if present) andFetchNoteInfoByHash(withdrawLink, h_0); found → fundinglive, storeReportedMsat. Timeout → leave for recovery and tell the user "still settling". Carve(ctx, batch): for i in 1..N:SplitNoteWithHash(cb, [k1_current], valueMsat, h_i, h_dust_i); on success note i →live, verify byFetchNoteInfoByHash(h_i)(ReportedMsat), current = dust_i; last dust →duststatelive. Partial failure: keep the live ones, the remainder stays in the current change note (bot-owned,fundingstatelivewith its reported value) and the batch ispartial; 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.- Build
NoteURL = BuildNoteURL(withdrawLink, k1_i, ReportedMsat);ToBech32Lnurlfor display;ToLud17wfor the lnurlw form; QR viaqrcode.Encode. The URL is built on demand from the decrypted secret and never stored.
- caps:
Status(ctx, note) (NoteStatus, error):FetchNoteInfoByHash→livewith value;IsSpent→ markclaimed(conditional update) and returnclaimed;IsUnknownNoteon a note that waslive→claimedas well (LUD-25: unknown and burned are one answer); transport errors → unchanged.- On any mutation error:
IsAmbiguous→ row stateunknownwithLastError; the secrets were persisted in step 2 soNewSecretsis empty by construction, but the code still calls it and logs a warning if non-empty.ProbeBurnedNoteis used by recovery only. - Tests:
service_test.gowith 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 fee1000,100, carve partial failure, status transitions, the ambiguity path.
Step 5: reclaim and redeem (internal/lnurlcash/melt.go)
Reclaim(ctx, note): lockmutex.Lock(note.ID);Statusfirst (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→ stayreclaiming(another melt is in flight; recovery resolves);IsSpent→claimed; definitive refusal → back tolivewithLastError; ambiguous →unknown. Success → stayreclaiminguntil the invoice is paid (InvoiceCallbackLNURLCashSettleor poll) →reclaimed.RedeemInfo(ctx, input string) (RedeemPreview, error):ResolveNoteInput(also acceptslightning:),FetchNoteInfo(noteURL)(echo check), requireMintPubkey; preview = value, host, whether the host is an admin mint,NoteIDOf(k1); insertlnurlcash_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 →settledand the balance is simply LNbits' new balance.- Never auto-retry a melt. A second
MeltNoteon the same note only after recovery has classified the first (ProbeBurnedNote→NoteLiveand 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 int/lnurlcash.go.Jobs.Start(ctx): goroutines withtime.NewTicker, each run guarded by async.Mutexso runs never overlap, each row undermutex.Lock(id)/Unlock:- claim watcher (
status_poll_interval):Statusfor everyliveuser note, oldestLastProbefirst, capped per run; onclaimed:Notifier.NoteClaimed(single notes),GroupNoteState(claimed)ifMessageID != "", batches collected into oneBatchDigestper batch per hour (LastDigestAt). - pending recovery (startup + 1 min):
pending_settle→ checkledger.Paid/ verify URL /FetchNoteInfoByHash, finishCarveor markfailedafter the LNbits payment is known to have failed;pending_carvewith a live funding/change note →Carveresumes from the last live change;reclaiming/melting→ledger.Paid(hash)settled →reclaimed/settled; not settled and the noteStatusis 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):Reclaimfor live notes older than N days, notifying the owner.
- claim watcher (
- Started from
bot.Start()afterinitInvoiceEventCallbackswith acontext.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 withif bot.LNURLCash == nil { send lnurlcashDisabledMessage; return }), theLedgeradapter, theNotifier(usesi18n.Translate(note.LanguageCode, …),bot.Telegram.Editwithtb.StoredMessagefor group posts,trySendMessage(&tb.User{ID:…})for DMs), the invoice callbackInvoiceCallbackLNURLCashSettle = 8registered ininitInvoiceEventCallbacks(the event'sCallbackDatacarries the note/redeem id), andmustHavePrivateChat(ctx): send a probe-free DM viatrySendMessageEditable(user.Telegram, …); if the returned message is nil (telebotErrNotStartedByUser/ErrBlockedByUser, now surfaced by extendingtrySendMessageto also return the error through a newtrySendMessageErr), reply in the group withlnurlcashStartPrivateFirstMessageand create nothing./note <amount> [memo](noteHandler): registered like/send(localizer, logMessage, requireUser, lock+unlock); amount viaGetAmount; memo viaGetMemoFromCommand(m.Text, 2). Private:Quote→ confirm message (value, mint fee, total, mint name, memo) withNoteConfirm{*storage.Base, UserName, Quote, Memo, LanguageCode}in Bunt (idlnurlcash-note-<tgid>-<rand5>) and buttonslnc_create,lnc_mint,lnc_cancelbuilt on a fresh&tb.ReplyMarkup{}.lnc_createhandler: object lock, owner,Active,Inactivate,Create, then send the QR photo (caption = bech32 LNURL in backticks, likeinvoice.go:180) and a second message with thelnurlw://text and buttonslnc_reclaim,lnc_status(data = note id).lnc_mint: cycles through enabled mints and re-quotes. Group:group_note_max_satcheck first,mustHavePrivateChat, no confirm,CreatewithChatID, post QR + LNURL in the group (tryReplyMessage), storeMessageID, DM the receipt with fee and the two buttons. Errors go to the DM; the group command is deleted withNewMessage(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
# LNURLCASHsection toen.tomlandnl.toml(keys below).
Step 8: /lnurlmints (t/lnurlmints.go)
- Lists enabled mints with fee (
DescribeMintFee), health and alnc_setmintbutton per mint (data = mint id); writeslnurlcash_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; buttonslnc_page(data<listid>|<page>),lnc_open(note id) andlnc_openb(batch id). The list object isNotesList{*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, buttonslnc_exp_pdf,lnc_exp_json,lnc_exp_csv,lnc_refresh,lnc_reclaimb. /notes <amount> x <count> [memo]: parsex/×; caps;Quote(count); confirm with the total; progress message edited throughtryEditStackafter each carve step (progress callback onCreate); then a format picker with the configuredbatch_formats.export/pdf.go(go-pdf/fpdf, A4, 2×4 grid = 8 notes per page: QR PNG fromqrcode.EncodeviaImageOptionswith abytes.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,claimednotes excluded) and write to anio.Writer. Sent withtb.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) withlnc_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 viamustHavePrivateChat.HandleLNURL(t/lnurl.go:267): in thewithdrawRequestbody branch, ifj.Get("mintPubkey").String() != ""andbot.LNURLCash != nil, returnLNURLCashNoteParams{URL: rawurl, Body: b};lnurlHandleradds 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 (pastedlnurlw://…andLNURL1…already route tolnurlHandler); add a case-preserving pass: whenIsLnurlmatches, pass the originalm.Text(notanyText) for the note path so paths keep their case. Groups: unchanged (the text handler is private-only already).photoHandler: unchanged (hands tolnurlHandler); groups unchanged (private-only).
Step 11: hardening and docs
redactForLog: also redactlnurlw://,lnurlp://and?k1=tokens (regex).- README section;
botfather-setcommands.txtentries for/note,/notes,/redeem,/lnurlmints; help text keys. - Admin alerts:
AlertDMslnbits.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_settleand duringreclaimingand check recovery; change the mint pubkey in config to see the disable + alert. go test ./...stays green at every step;go vetclean.
Open questions for the user
- Fractional values vs LNbits (D1/D3): does the production LNbits accept a fractional
amountin sats (LNbits ≥ 0.12CreateInvoice.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. - Dust: the per-split base fee and sub-sat remainders leave small bot-owned
dustnotes. Accept and ignore, or add a periodic merge/melt into the bot wallet (initBotWallet)? - Dependency pin: accept the
replace … btcec/v2 v2.3.3pin (recommended, tested), or removeln-decodepay/lnd by decoding bolt11 amounts another way (changes/payinternals)? - Admin alerts: DM to the Telegram user behind
lnbits.admin_idis not derivable (admin_id is an LNbits user id). Addlnurlcash.admin_telegram_idto config, or log only? - New sqlite file (
database.lnurlcash_path) vs tables insidebot.db? - Group
/redeemwithout delete rights: continue privately anyway (proposed) or refuse? - PDF library:
github.com/go-pdf/fpdf v0.9.0acceptable (adds 4 small deps)? - Minimum note value: the default mint's
minWithdrawableis 10 sat andminSendable12 sat;min_note_sat: 1cannot be honoured there. Clamp to the mint's minimum at quote time (proposed) or reject? /lnurl <note>log fixes (D5): OK to change those two existing log lines?- Batch strategy
invoices: keep (N invoices + N splits) or drop from the first version?