unknown-wire-method-hangs-the-deposit-form.md (6197B)
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 # An unknown wire method hangs the add-account form for ever 18 19 Found by the `deposit_methods` scenario in round 12, the first round after the 20 simulator's exchange was given a `payto://cyclos/…` account: the add-account 21 form came up empty and stayed that way. 22 23 **Severity: moderate.** Any exchange that advertises a wire method this version 24 of the app does not know breaks the deposit account form for every wallet of 25 that version — and `cyclos` is not hypothetical, the app has a Cyclos 26 *transfer* screen already. The failure mode is a spinner with no message. 27 28 ## What happens 29 30 Settings → **Bank accounts** → **Add account** shows only the app bar: 31 32 ``` 33 ['Go back', 'Add account', 'Internal event log'] 34 ``` 35 36 no fields, no tabs, no error — the form's `LoadingScreen`, for ever. The log 37 says why: 38 39 ``` 40 E taler-wallet: Error getDepositWireTypes TalerErrorInfo(code=NONE, hint=, 41 message=kotlinx.serialization.SerializationException: 42 net.taler.wallet.deposit.WireType does not contain element with name 'cyclos', 43 extra={}, rawCode=0) 44 ``` 45 46 One unrecognised method makes the whole reply undecodable, so the app has no 47 wire types at all, and `AddBankAccountScreen` shows `LoadingScreen` while 48 `depositWireTypes == null`: 49 50 ```kotlin 51 // wallet/src/main/java/net/taler/wallet/accounts/AddBankAccountScreen.kt:63 52 LaunchedEffect(Unit) { depositWireTypes = depositManager.getDepositWireTypes() } 53 … 54 if (depositWireTypes == null || (bankAccountId != null && bankAccount == null)) { 55 LoadingScreen(Modifier.padding(paddingValues)) 56 } 57 ``` 58 59 and `getDepositWireTypes` returns `null` on error, logging it and nothing else 60 (the same shape as 61 [`a-failed-query-is-shown-as-an-empty-wallet.md`](a-failed-query-is-shown-as-an-empty-wallet.md), 62 with a spinner instead of an empty list). 63 64 ## Why the fallback does not fire 65 66 The enum already has the member it needs: 67 68 ```kotlin 69 // wallet/src/main/java/net/taler/wallet/deposit/DepositManager.kt:296 70 @Serializable 71 enum class WireType { 72 Unknown, 73 @SerialName("iban") IBAN, 74 @SerialName("x-taler-bank") TalerBank, 75 @SerialName("bitcoin") Bitcoin, 76 } 77 ``` 78 79 and `BackendManager.json` is built with `coerceInputValues = true`, which is 80 exactly the switch for "coerce an unrecognised value to the default". But 81 kotlinx only coerces to a declared *default value* (or to null for a nullable 82 property), and the property has neither: 83 84 ```kotlin 85 // …/DepositManager.kt:311 86 val paymentTargetType: WireType, 87 ``` 88 89 So `Unknown` is unreachable, and the decode throws. 90 91 **Two more enums have the same shape**, each with an `Unknown` member that can 92 never be used: 93 94 - `WithdrawalOperationStatusFlag` — `withdraw/WithdrawManager.kt:184`, 95 `val status: WithdrawalOperationStatusFlag` (an unknown status from the bank 96 would break the withdrawal status reply); 97 - `ExchangeTosStatus` — `exchanges/Exchanges.kt:38`, `val tosStatus: 98 ExchangeTosStatus` (an unknown terms status would break the exchange list). 99 100 `InsufficientBalanceHint` is used only through nullable properties, where 101 `coerceInputValues` does fire, so that one is safe. 102 103 ## Reproduce by hand 104 105 Give any exchange a wire method the app does not know — `cyclos` will do, and 106 the wire fee matters because wallet-core hides a method that has none: 107 108 ```bash 109 taler-exchange-offline -c <conf> \ 110 enable-account 'payto://cyclos/cyclos.example.com/exchange?receiver-name=Test' upload 111 taler-exchange-offline -c <conf> \ 112 wire-fee now cyclos EUR:0.01 EUR:0.01 upload 113 ``` 114 115 Then in the wallet: 116 117 1. Settings → **Bank accounts** → **Add account**. 118 2. The screen stays empty. `adb logcat | grep getDepositWireTypes` shows the 119 `SerializationException`. 120 3. The same happens on the **Deposit** flow's account form. 121 122 The simulator can do this for you, but not by default: keeping a Cyclos 123 address signed blocks every deposit scenario, so it is opt-in — 124 125 ```bash 126 SIM_EXTRA_PAYTOS='payto://cyclos/cyclos.example.com/exchange?receiver-name=X' \ 127 backend/stack.sh start 128 ``` 129 130 (it was signed by default for one round, which is how this was found). 131 132 ## Reproduce with the simulator 133 134 ```bash 135 ssh root@tripwire.taler.net 136 cd /opt/taler-sim/backend 137 SIM_EXTRA_PAYTOS='payto://cyclos/cyclos.example.com/exchange?receiver-name=X' \ 138 ./stack.sh start # sign a method the app does not know 139 cd ../driver && python3 stack.py # re-provision after the restart 140 python3 ../findings/repro_unknown_wire_method.py # worker 0 by default 141 ``` 142 143 The reproducer waits twenty seconds on the form and then reports both what is 144 on it and the `SerializationException` from the log. Restart the stack without 145 `SIM_EXTRA_PAYTOS` afterwards to get the deposit scenarios working again. 146 147 ## Suggested fix 148 149 Give each of the three properties the default its enum was written for: 150 151 ```kotlin 152 val paymentTargetType: WireType = WireType.Unknown, 153 ``` 154 155 With `coerceInputValues = true` already set, that is enough to make an 156 unrecognised method decode as `Unknown` instead of throwing; the UI then needs 157 to skip `Unknown` entries when listing tabs (`AddAccountComposable` already 158 has an `else -> {}` branch for them) rather than showing nothing at all. 159 160 Separately: `getDepositWireTypes` returning `null` for both "no answer yet" 161 and "the answer did not parse" is what turns the failure into an endless 162 spinner. An error state would make this visible even when the next unknown 163 method arrives. 164 165 Worth adding `cyclos` to `WireType` as well — the app renders a Cyclos 166 transfer screen, so it already knows the method exists.