mailbox-payment-only-actionable-for-one-scheme.md (7826B)
1 <!-- 2 This file is part of GNU Taler 3 (C) 2026 Taler Systems S.A. 4 5 GNU Taler is free software; you can redistribute it and/or modify it under the 6 terms of the GNU General Public License as published by the Free Software 7 Foundation; either version 3, or (at your option) any later version. 8 9 GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 13 You should have received a copy of the GNU General Public License along with 14 GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 --> 16 17 # Mailbox payments work only if the URI says "taler://" — in and out 18 19 Found by the `mailbox_roundtrip` scenario, the first thing in this campaign to 20 put a real message in the wallet's mailbox: the message arrived, the row showed 21 the URI as plain text, and there was no way to act on it. The same test, 22 written later for the *sending* side, found the identical mistake there. 23 24 **Severity: low-moderate.** The scheme that fails is `taler+http://`, which is 25 what every development and test deployment uses — exactly where someone would 26 first try the feature. The same rows also fail for the `ext+taler://` form the 27 app accepts everywhere else. 28 29 On the sending side it is worse than a scheme mismatch: the button that 30 forwards a payment to a contact is shown **only in developer mode**, and the 31 scheme it insists on is the one developer mode does not produce, so the feature 32 cancels itself out (below). 33 34 ## What happens 35 36 Another wallet sends a push payment to this wallet's mailbox address. The 37 message is received and listed: 38 39 ``` 40 taler+http://pay-push/localhost:8081/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 41 From: http://localhost:11000 42 Received: October 18, 2026 at 6:38 AM 43 [Delete] 44 ``` 45 46 The URI is printed as text and the only button is **Delete**. With a 47 `taler://` URI, the same row shows an **"Accept payment"** button that opens 48 the payment. 49 50 Both at once, from one run — two messages sent to the same mailbox differing 51 only in the scheme: 52 53 ``` 54 after two real messages: ['Accept payment', 55 'From: http://localhost:11000', 56 'Received: October 18, 2026 at 6:42 AM', 57 'Delete', 58 'taler+http://pay-push/localhost:8081/AAAA…', 59 'From: http://localhost:11000', 60 'Received: October 18, 2026 at 6:42 AM', …] 61 rows offering an action: 1 62 rows showing a raw URI: ['taler+http://pay-push/localhost:8081/AAAA…'] 63 ``` 64 65 ## Why 66 67 The row decides by exact prefix: 68 69 ```kotlin 70 // wallet/src/main/java/net/taler/wallet/mailbox/MailboxScreen.kt:245 71 val isPayPush = message.talerUri.startsWith("taler://pay-push") 72 val isPayPull = message.talerUri.startsWith("taler://pay-pull") 73 … 74 if (isPayPush || isPayPull) { 75 Button(onClick = { onNavigate(WalletDestination.HandleUri(message.talerUri), false) }) { 76 Text(if (isPayPush) "Accept payment" else "Pay invoice") 77 } 78 } else { 79 Text(message.talerUri, style = MaterialTheme.typography.bodyMedium) 80 } 81 ``` 82 83 Three URIs the app handles elsewhere fall into the `else`: 84 85 * `taler+http://pay-push/…` — the developer-mode scheme, which is the only one 86 that works against a local deployment; 87 * `ext+taler://pay-push/…` — the browser-extension form; 88 * `TALER://PAY-PUSH/…` — schemes are case-insensitive per RFC 3986. 89 90 Everywhere else the app is careful about this. `HandleUriScreen` lowercases 91 the whole URI and strips `taler://`, `ext+taler://` or `taler+http://` before 92 matching the action: 93 94 ```kotlin 95 // wallet/src/main/java/net/taler/wallet/HandleUriScreen.kt:60 96 val normalizedURL = u.lowercase(Locale.ROOT) 97 … 98 if (normalizedURL.startsWith("taler://", ignoreCase = true)) … 99 else if (normalizedURL.startsWith("ext+taler://", ignoreCase = true)) … 100 else if (normalizedURL.startsWith("taler+http://", ignoreCase = true) && devMode) … 101 ``` 102 103 so the mailbox row is *not* the only place that knows about one of the three. 104 105 ### The same prefix test hides the forward button 106 107 The way *out* of the wallet has it too. A peer-push transaction's QR screen 108 offers a button that forwards the payment to a contact's mailbox — the only 109 caller of `sendTalerUriMailboxMessage` — and it is gated the same way: 110 111 ```kotlin 112 // wallet/src/main/java/net/taler/wallet/compose/QrCodeUriComposable.kt:183 113 if (devMode && onForward != null && 114 (qrData.startsWith("taler://pay-push") || qrData.startsWith("taler://pay-pull"))) { 115 ForwardButton(onClick = { onForward(qrData) }, …) 116 } 117 ``` 118 119 Note the first condition: the button exists **only in developer mode**. But in 120 developer mode against a local deployment the wallet's own push URI is 121 `taler+http://pay-push/…`, so the prefix test fails and the button is never 122 drawn. Measured, with developer mode on: 123 124 ``` 125 forward_payment_to_contact: 126 Scan this QR code to receive €5.00 127 Alternatively, copy and send this URI: 128 taler+http://pay-push/localhost:8081/3ZTJWX7HJ0G1J8R64Z6VFXGG35SX9R9XFMK4BPF79WMV5CNCYDH0 129 -> no forward button on the push screen 130 ``` 131 132 The two conditions contradict each other: one restricts the feature to 133 developer mode, the other to the scheme developer mode does not produce. It 134 survives only when a dev-mode wallet talks to an `https://` exchange. 135 136 ## Reproduce by hand 137 138 Needs a mailbox service and a second wallet; against the simulator's stack 139 (`simulator/backend/services/README.md` has the deployment): 140 141 1. In the wallet, Settings → **Mailbox** → the gear icon → type 142 `http://localhost:11000` → OK. The wallet registers itself; the info icon 143 shows its address. 144 2. From another wallet, send a push payment URI to that address. With 145 `taler-wallet-cli`: 146 147 ```bash 148 taler-wallet-cli --wallet-db /tmp/sender.sqlite3 advanced api \ 149 sendTalerUriMailboxMessage '{"contact":{"alias":"x@example.com","aliasType":"email", 150 "mailboxBaseUri":"http://127.0.0.1:11000/","mailboxAddress":"<THE ADDRESS>", 151 "source":"local","petname":"test","originMailboxBaseUrl":"http://127.0.0.1:11000/", 152 "downloadedAt":{"t_s":0},"talerUri":"","transactionId":""}, 153 "talerUri":"taler+http://pay-push/localhost:8081/AAAA…"}' 154 ``` 155 156 3. Tap **Refresh** in the mailbox screen. The message appears with its URI as 157 text and no action. 158 4. Send the same thing again with `taler://` instead of `taler+http://`: that 159 row has an "Accept payment" button. 160 161 ## Reproduce with the simulator 162 163 ```bash 164 ssh root@tripwire.taler.net 165 cd /opt/taler-sim/driver 166 SIM_WORKER=4 python3 suite.py mailbox_roundtrip 167 ``` 168 169 The scenario sends one message of each scheme and reports how many rows offer 170 an action and which ones show a bare URI. 171 172 For the forward button, which fails for the same reason: 173 174 ```bash 175 SIM_WORKER=4 python3 suite.py forward_payment_to_contact 176 ``` 177 178 It makes a push payment with developer mode on and looks for the button on the 179 QR screen; its note says what the screen offered instead. 180 181 ## Suggested fix 182 183 Decide the action the way `HandleUriScreen` does — normalise the scheme first, 184 and match the action case-insensitively: 185 186 ```kotlin 187 val action = message.talerUri.lowercase(Locale.ROOT) 188 .removePrefix("ext+taler://").removePrefix("taler+http://").removePrefix("taler://") 189 val isPayPush = action.startsWith("pay-push") 190 val isPayPull = action.startsWith("pay-pull") 191 ``` 192 193 and the same in `QrCodeUriComposable`'s forward-button condition. 194 195 A shared helper would be better than a fourth copy of that logic: the 196 normalisation is already written out in `HandleUriScreen` and partly again in 197 `ContactScreen`'s `fillFromUri`. One `talerUriAction(uri): String?` used by all 198 four would have made both of these impossible.