32 Commits
Author SHA1 Message Date
MichilisandClaude Opus 5.5 8faab56990 Harden LNURLcash, webhook replay and ticket restarts; add command aliases
- LNURLcash: mint single notes directly when the mint rounds fees to whole
  sats, recover lost direct-note funding, melt to the callback named in the
  note's own withdraw info, and poll for settlement so redeems/reclaims
  finish without waiting on the webhook. Read-only lookups use a pooled
  client; every mutation stays on the no-keep-alive client.
- Webhook: expire replay markers only for payments without an invoice event,
  so an event callback can never run twice.
- Tickets: on restart, enforce tickets that ran out while the bot was down
  unless LNbits says the invoice was paid; drop stale ones without a ban.
- Telegram: register translated /faucet and /tipjar command aliases.
- i18n: load translations from one language list and log broken files.
- Config example: one entry per mint; ignore local docs/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 17:20:52 +00:00
MichilisandClaude Sonnet 5.5 48f8a6c7c9 Send note mutations to the mint's callback and polish LNURLcash UX
- Splits and melts went to the withdraw link, but mints such as
  mint.600.wtf take mutations at the callback named in the note's own
  withdraw info (/w/cb). The mint answered 200 without a status, which
  read as an unknown outcome and left minting stuck in recovery. The
  fake mint now behaves the same way.
- Count the LNbits routing reserve (max 1 sat, 1%) in the balance check.
- Allow several comma separated mints in one url entry.
- Format the LNURLcash help like the other help menus.
- Fix int64 passed to %s in the claimed, reclaimed, redeem and view
  messages.
- Reword the in-progress and insufficient-balance messages in every
  language.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 23:48:14 +00:00
MichilisandClaude Sonnet 5.5 cd511cd7cc Return value stranded by a failed note batch to its owner
A refused split after the funding invoice was paid left the funding or
change note in a bot-held row that nothing melted back. A job now splits off
the whole-sat part if needed and reclaims it to the owner's balance, retrying
hourly and alerting the operator once when it cannot.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 18:27:53 +00:00
MichilisandClaude Sonnet 5.5 b6178e335d Do not fail a funding payment that LNbits may still settle
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 18:25:01 +00:00
MichilisandClaude Sonnet 5.5 82b291a69b Retry a failed fractional redeem from its split note
The split burns the pasted note before the melt. A failed invoice or melt
used to leave the value in a bot-held split note while a second press
answered 'already claimed'. The retry now melts the split note.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 18:24:01 +00:00
MichilisandClaude Sonnet 5.5 7f49e422f4 Fix the low-severity audit findings
- price map: guard with a RWMutex (fatal concurrent map access)
- InvoiceStream: stop on client disconnect, unsubscribe once, cap streams per wallet
- join tickets: key the ticket event per joiner; enforce tickets that
  expired while the bot was down

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 18:22:52 +00:00
MichilisandClaude Sonnet 5.5 6824ef5928 Validate NIP-57 zap requests and refuse ones that do not parse
The bot signs the receipt for whatever p tag the request carries, so the
request must name the paid user, be kind 9734, carry one p tag and match the
amount. A zap request that fails to decode is rejected instead of continuing
with the fields read before the error. Users without a registered nostr
pubkey no longer get zap receipts.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 18:20:45 +00:00
MichilisandClaude Sonnet 5.5 15b95d962b Refuse a banned user's invoice key and keep nsec and k1 out of logs
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 18:19:43 +00:00
MichilisandClaude Sonnet 5.5 8b8b0fa369 Fix the three medium audit findings
- /group ticket del: only the chat creator may remove a group registration
- /node: always dial user-supplied node hosts through the netguard client;
  drop the https://127.0.0.1 prefix exemption
- /app/@{username}: accept only username characters, render the greeting as
  text, add basic security headers

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 18:18:41 +00:00
MichilisandClaude Fable 5.1 7f89896a6c Translate the LNURLcash messages into every bot language
All 78 note keys now exist in cs, de, es, fi, fr, id, it, pl, pt-br, ru
and tr as well as en and nl, with indexed verbs where a language orders
the arguments differently. The mint fee line goes through a key instead
of the library's English text. A test localizes every key in every
language and formats it with the English argument list.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-13 22:50:58 +00:00
MichilisandClaude Fable 5.1 e36d522764 Add /lnurlhelp and list the note commands in the advanced help
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-13 22:39:49 +00:00
MichilisandClaude Fable 5.1 1ed809f56c Log the transport cause when a mint check fails
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-13 22:31:45 +00:00
MichilisandClaude Fable 5.1 3c2ccf8d83 Add the LNURLcash Telegram commands
/note, /notes (list and batch), /redeem and /lnurlmints with confirm
dialogs, group posting with private receipts, claim notifications,
batch export as PDF/JSON/CSV, and LNURLcash notes detected inside the
existing /lnurl, paste and QR-photo flows. Plain withdraw links behave
as before. Two /lnurl log lines no longer print k1.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-13 22:12:27 +00:00
MichilisandClaude Fable 5.1 721c923aac Add PDF, CSV and JSON export of note batches
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-13 21:59:26 +00:00
MichilisandClaude Fable 5.1 a92df0d4ef Add the LNURLcash background jobs
Claim watcher, pending recovery (funding, carving, reclaims, redeems),
mint health and auto reclaim, with tests for lost webhooks, failed melts
and carving resumed after a crash.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-13 21:59:01 +00:00
MichilisandClaude Fable 5.1 e695443f7f Add the LNURLcash note service: create, status, reclaim, redeem
Every secret is written encrypted before the first request leaves. Notes
are carved out of one funding note by split so each is a whole number of
sats, which LUD-25's exact-amount melt needs against LNbits' whole-sat
invoices. Tested against an in-memory LUD-25 mint and ledger, including
a dropped connection after an applied split and fractional external notes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-13 21:52:37 +00:00
MichilisandClaude Fable 5.1 1fc9a81cd2 Add the lnurlcash store, models and mint registry
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-13 21:47:52 +00:00
MichilisandClaude Fable 5.1 d04669b6d6 Add lnurlcash-go and the lnurlcash config block
Pin btcec/v2 at v2.3.3: v2.3.4 changed ecdsa.SignCompact's signature and
lnd/keychain (via ln-decodepay) no longer compiles against it. The
lnurlcash package gets its Config with validation and an AES-256-GCM
cipher for note secrets at rest.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-13 21:43:16 +00:00
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
MichilisandClaude Fable 5.1 5a3b4dad7c Make go test ./... run and fix the stale tooltip test
internal/config.go panicked in init without a config.yaml and the i18n
loader only found translations/ from the repository root, so no test in
a package importing them could run. Config checks are skipped in a test
binary, the translation directory is located by walking up, GetAmount
no longer dereferences a nil price watcher, and the tooltip test expects
the text the code actually produces. Adds tests for amount validation.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-13 20:58:30 +00:00
MichilisandClaude Fable 5.1 81af610980 Never pass dynamic strings as format strings
Sixteen log and error calls used a message, an LNURL string or callback
data as the format string. Go vet (printf check, Go 1.24+) fails the
test build on these.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-13 20:51:57 +00:00
MichilisandClaude Fable 5.1 7268fe6d31 Fix LNURL onion detection and go vet findings
A five-character domain was treated as an onion address (strings.Index
returned -1 == len-6) and the lnurlp:// scheme check tested an empty
string. Also: wrong format verb in the AnonID migration log, an error
that was built but never logged, an unreachable return, and the message
log line was passed as a format string.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-13 20:50:26 +00:00
MichilisandClaude Fable 5.1 8514341118 Update the Go toolchain and golang.org/x/net
go run with the host's Go 1.21.6 reached 13 known net/http, crypto/tls
and crypto/x509 vulnerabilities, and golang.org/x/net was from 2021. The
module now asks for go1.26.11 through the toolchain directive (Go 1.21+
downloads it on first run) and uses x/net v0.62.0 and gorilla/websocket
v1.5.3. govulncheck is down to two findings in dependencies with no fix
(imroc/req v0.3.0, lnd v0.15 zpay32) that the bot's code paths do not
exercise.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-13 20:50:26 +00:00
MichilisandClaude Fable 5.1 86b7a8f7bc Fix crashes and the dropped certificate in satdress
Transaction.Send dereferenced a nil error when logging a failed DB save
after a successful transfer. satdress.SetupHttpClient type-asserted a
nil Transport for local nodes. The /node command shadowed the cert
variable, so a supplied certificate was never used and TLS verification
was always disabled for LND nodes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-13 20:41:39 +00:00
MichilisandClaude Fable 5.1 afd1050e57 Keep invoices, LNURLs, ecash tokens and node credentials out of the log
The message interceptor logged every private text at Info, which put
bolt11 invoices, LNURLs, Cashu tokens and '/node add lnd <host>
<macaroon>' into journald. The API middleware logged the submitted key
of banned users. Both are redacted now.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-13 20:41:39 +00:00
MichilisandClaude Fable 5.1 bb1037bcb7 Validate amounts in every GetAmount branch; cap faucet slots
The k and fiat branches returned the float conversion unchecked, so
non-positive, NaN or Inf inputs reached callers that have no guard of
their own (faucet total, ticket price, shop price, satdress amount).
Every branch now rejects non-positive and non-finite amounts and anything
above 10,000,000 sat. A faucet can have at most 1000 slots.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-13 20:41:39 +00:00
MichilisandClaude Fable 5.1 0bcb821b82 Per-payer group ticket ids; deactivate paid objects
The group ticket event was stored under ticket:<groupID>, so a later
/join by another user overwrote the payer and the invite link went to
whoever joined last. The id now includes the payer.

The pay, LNURL-withdraw and group-ticket confirm handlers left their
object Active after success, so a second press repeated the request.
They now deactivate it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-13 20:41:39 +00:00
MichilisandClaude Fable 5.1 b27b0b7bcb Make the named mutex atomic
Lock did a get-then-set on the map without holding mutexMapSync, and
Unlock removed the entry before unlocking it. Two handlers that arrived
for a name not yet in the map each got their own mutex, and a waiter
could end up holding a mutex that later callers could not see. Both let
two button presses run the same faucet or inline object at once.

Entries are now created and looked up under one lock and reference
counted, so they are only removed when the last holder unlocks. Tests
run 200 goroutines through Lock and LockWithContext under -race.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-13 20:41:39 +00:00
MichilisandClaude Fable 5.1 f040b67597 Verify webhook payments with LNbits before acting on them
The webhook listener accepted any POST as proof of payment and fired the
invoice callbacks (inline receive, group tickets, satdress payout, DALL-E
refund) for whatever payment hash the body named. It now:

- limits the body to 1 MB and only accepts a 64-hex payment hash,
- asks LNbits whether the named wallet really received a settled
  incoming payment for that hash, and uses the amount LNbits reports,
- handles every payment hash once (bunt key "webhook:<hash>"),
- refuses to dispatch an invoice event registered for another wallet,
- runs the callback with a recover, so a panic can't take the bot down.

The pure checks live in internal/lnbits/webhook/verify, which does not
depend on the bot configuration and is unit tested.

Port of kravens/BitTipBot b7e56da and 27eb079 onto our simpler handler.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-13 20:36:48 +00:00
MichilisandClaude Fable 5.1 e010b31fd5 Ignore build artefacts, toolchain tarballs and node_modules
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-13 20:34:56 +00:00
MichilisandClaude Fable 5.1 1a3815902a Keep the ban state when an old copy of a user is saved
UpdateUserRecord wrote every column of the user it was given, so saving
a copy taken before a ban (cached user, stored inline object, invoice
event) lifted the ban. The banned flag and the admin key now always come
from the database row and are left out of the save; only the new
UpdateUserBan changes them, and the admin API uses it.

Manual port of kravens/BitTipBot 05c0a4e and dfc8d13.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-13 20:34:56 +00:00
MichilisandClaude Fable 5.1 39bddc2cb5 Only publish zap receipts to public wss relays
Relay URLs come from the zap request. Keep at most 10 of them, only
wss://, and make the websocket dialer refuse non-public addresses.

Manual port of kravens/BitTipBot efe2fa2 (the only conflict was the
hard-coded default relay list, which is kept as is).

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