Repository navigation
feat(payments): payment requests as messages, handed to the user's wallet - #50
Merged
Merged
Conversation
…nded to the user's wallet A contact can send a Bitcoin address, a Lightning invoice (BOLT11) or a Monero address, with an optional amount and note. The chat shows it as a card with a QR code generated on the device, a copy button and "Pay". "Pay" asks first, shows the sender, the full address in groups of four and the amount, and only a second tap hands a bitcoin:/lightning:/monero: link to the system. Without a matching app there is a clear hint to copy the address instead. BitDM holds no money and no keys and asks no server. Validation is strict and offline: Bech32/Bech32m and Base58Check checksums, SegWit v0 and Taproot only, Lightning invoices with exactly one payment hash and secret, Monero with the Keccak checksum and network byte. Testnet, regtest and stagenet are rejected, as are expired invoices, homoglyphs, amounts beyond supply or precision, and anything that looks like recovery words. Bidi and other control characters are removed from notes. Wire format: an ordinary text payload (kind 1) whose text is a readable, bilingual version with the payment link, plus the data in a new field "z". 2.0.1 ignores the field and shows the text; a new kind would have been dropped silently. "z" is validated on receipt; anything that does not pass stays a text message. Stored as MessageKind.zahlung (index 3) without a schema change; backups write it as text with the data beside it, so an older app restoring one does not hit an unknown kind. Payment requests cannot be edited. Pay is disabled for a contact that has not been accepted. Tests use the official BIP173/BIP350 and BOLT11 vectors and vectors made with independent libraries (tool/zahlung/vektoren.py). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Proof from the real app (30.11.2026, CT 107) —
Images are with Henrik (local drop folder); not attached here. The end-to-end protocol (two/three real cores, real relay, libsignal) is covered by |
…oup senders must be contacts From the review of this PR: - On Linux and Windows launchUrl reports success for any scheme (xdg-open, ShellExecute), so "No wallet found" never showed. Ask xdg-mime / the registry for a handler first. - An expired Lightning invoice is refused again when Pay is pressed and before the hand-off; the card only checked while drawing. - In groups the sender, not the group, must be an accepted contact. - "Valid until" shows the year when it is not the current one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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.


What
Stages 1 and 2 of the crypto plan: a payment request as an end-to-end encrypted message, and handing it to the wallet app the user already has. BitDM holds no money, no private keys, and asks no server about balances.
+→ Request payment. Currency (Bitcoin on-chain, Lightning, Monero), address or invoice (paste button; a pastedbitcoin:…?amount=link is split up), optional amount and note. Pasting an address of another currency switches the currency.bitcoin:/lightning:/monero:link (amount filled in, note not passed on) to the system. Nothing opens without that second tap. If no app takes the link: "No wallet found … copy the address".Validation (
lib/core/zahlung/, pure Dart, offline)lnbconly (lnbcrtis checked beforelnbc), Bech32 checksum, amount multipliers incl. pico with the sub-msat rule, exactly onepand ones,nlength, expiry. The signature is not verified (the wallet does that; we do not know the node).а) fail. Notes: same filter, one line, ≤ 140 chars.lib/core/zahlung/imports key derivation, the secret store or the lock; a test reads the import lines.Compatibility
z. 2.0.1 ignoreszand shows the text. A new payload kind would have been dropped silently by every older app.zis validated on receipt (vmust be 1); anything else stays a text message. A futurev: 2therefore arrives as text, not as a half-understood card.MessageKind.zahlung(index 3) in the existingkindcolumn, no schema bump (no clash with schema 17 in fix(groups): a member who left can be added back by the admin #33).zahlungkey). An older app inserts only its known columns and gets readable text instead of an unknown kind; this app turns it back into a card. Unknown kinds from a later version become text on restore.kind = text), so an address cannot be swapped after the recipient has checked it.Tests
test/zahlung/zahlungsanfrage_test.dart: official BIP173/BIP350 and BOLT11 vectors (valid and invalid), plus vectors from independent libraries (tool/zahlung/vektoren.py: bech32, embit, base58, monero, pycryptodomex), typo detection, amounts, notes, recovery words, format round trip, QR round trip through the app's own reader for all three currencies. Side note: PyPIbech321.2.0 has no Bech32m and produces an invalid Taproot address; the validator rejected it, it is now a negative vector.test/zahlung/zahlung_nutzlast_test.dart: wire format, the 2.0.1 view of the same bytes, invalidz, mirror/group wrapping, resend, no editing, backup both ways.test/zahlung/zahlung_ende_zu_ende_test.dart: two/three real cores, real relay, real libsignal, 1:1 and group.test/zahlung/zahlung_ohne_identitaet_test.dart: no identity imports.test/oberflaeche/zahlung_ui_test.dart: create (typo, recovery words, auto-switch), card, confirmation with full address, wallet hand-off, no-wallet hint, pending contact, expired and fresh Lightning invoice.test/core/fremde_eingaben_test.dart: the resend loop over all kinds now uses a valid request for the new kind.Run in CT 107 (Flutter 3.44.8, Linux):
flutter analyzeonly the 29 known infos; whole suite before the last fixes 1637 passed, 2 skipped, 3 failed (two font-scan tests about invisible characters in a regex literal and the resend loop above); all three fixed and re-run green together with the 81 new tests. Proof from the real app on Linux and Android follows as a comment.Not in this PR
A built-in wallet and paying from the chat (stages 3/4) come in a separate PR: they carry real risk and need an independent audit before anything is released.
🤖 Generated with Claude Code