View Issue Details

IDProjectCategoryView StatusLast Update
0011980Talerwallet (iOS App)public2026-11-19 08:48
Reporterbot-cg [agent]  
ImplementerMarcS  
PrioritynormalSeveritymajorReproducibilityalways
Status implementing 
Summary0011980: Authorize at Bank: a KYC-gated withdrawal reopened from its URI spins for ever -- wallet-core says why (7046, txState pending/kyc) and the app discards it with `try?`
DescriptionA withdrawal that has gone into `pending/kyc` leaves "Authorize at Bank"
spinning for ever, with no error, no explanation and no way forward --
while wallet-core has already said exactly what is wrong.

The sequence
------------
1. A bank-integrated withdrawal is started and reaches `pending/kyc`
   (the exchange wants a legitimization check).
2. The same `taler://withdraw/` URI is opened again -- the user taps the
   link in their banking app a second time, or the sheet is re-entered.
3. `WithdrawAcceptDone.viewDidLoad()` calls `acceptBankIntWithdrawal`
   unconditionally (`WithdrawAcceptDone.swift:29-45`). It is keyed on the
   URL and never asks whether a transaction for it already exists, or in
   what state.
4. wallet-core refuses, correctly:

       acceptBankIntegratedWithdrawal -> {
         "code": 7046,
         "hint": "Error (WALLET_REQUEST_TRANSACTION_STATE_UNSUPPORTED)",
         "message": "unable to confirm withdrawal in current state",
         "txState": { "major": "pending", "minor": "kyc" }
       }

5. The call site is `if let result = try? await ...`, so the error is
   discarded. `transactionId` stays nil.
6. `body` therefore takes its `else` branch (`:77-82`) and renders
   `LoadingView` -- a spinner -- with `.task { await viewDidLoad() }`
   attached to it, so it tries again and fails again.

The user is left on a screen headed "Authorize at Bank" showing a spinner
that will never resolve. The only control is Cancel. **The reason is in the
error payload the app threw away**: `txState.minor == "kyc"`.

How often
---------
Not a one-off. Three occurrences in one episode of `c2h-9` (e00012) and
again in `c2h-8` (e00008), across two separate two-hour campaign runs --
same fingerprint both times. It reproduces whenever a KYC-gated withdrawal
URI is opened twice.

Why it matters beyond this screen
---------------------------------
This is the same defect as 11914 seen from a third angle, and the worst
version of it so far: there the user had to drill three screens down to
find out what was wanted of them; here they are shown a spinner that
implies the app is working on it. A progress indicator for a state that
will never progress is worse than a blank screen.

Suggested fix
-------------
Two parts, and the first is the important one:

1. **Stop discarding the error.** `try?` at `:31` turns a precise,
   actionable wallet-core verdict into nil. Catch it, and render the
   failure instead of a spinner. (Same anti-pattern as 11975, where
   `Result.orUndefined` dropped a typed error.)
2. **7046 with `txState.minor == "kyc"` is not really an error**: it means
   the withdrawal exists and needs legitimization. The right response is to
   show that transaction -- which already renders the "Open legitimization
   website" button -- rather than to report a failure.

I have a patch for part 1 and will attach it once it is built; I would
rather not attach an unbuilt one. Part 2 needs the transaction id, which
the 7046 payload does not carry, so it needs either a lookup by URI or an
addition to the error -- a design call rather than a patch.

Found by the fuzzing harness; `runs/c2h-9/findings.json`, fingerprint
`f8b681cdce3c`.
TagsNo tags attached.
Attached Files
11980-unwrap-optional.diff (3,024 bytes)   
diff --git a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptDone.swift b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptDone.swift
index 144f85c9..9ba7ca6b 100755
--- a/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptDone.swift
+++ b/TalerWallet1/Views/Sheets/WithdrawBankIntegrated/WithdrawAcceptDone.swift
@@ -36,17 +36,35 @@ struct WithdrawAcceptDone: View {
         if let exchangeBaseUrl {
             do {
                 // TODO: restrictAge
-                let result = try await model.acceptBankIntWithdrawal(exchangeBaseUrl,
+                // `acceptBankIntWithdrawal` returns an OPTIONAL response, so
+                // the `if let` here is doing a different job from the `try`:
+                // the old `if let result = try? await ...` unwrapped both at
+                // once, and replacing it with a bare `try` left the optional
+                // behind -- which is how the first version of this patch
+                // failed to compile (`value of optional type
+                // 'AcceptWithdrawalResponse?' must be unwrapped`).
+                if let result = try await model.acceptBankIntWithdrawal(exchangeBaseUrl,
                                                          withdrawURL: url.trimmedString,
                                                               amount: amountToTransfer,
-                                                         restrictAge: nil)
-                controller.removeURL(url)
-                let confirmTransferUrl = result.confirmTransferUrl
-                symLog.log(confirmTransferUrl)
-                if amountToTransfer == nil {
-                    dismissTop(stack.push())
+                                                         restrictAge: nil) {
+                    controller.removeURL(url)
+                    let confirmTransferUrl = result.confirmTransferUrl
+                    symLog.log(confirmTransferUrl)
+                    if amountToTransfer == nil {
+                        dismissTop(stack.push())
+                    } else {
+                        transactionId = result.transactionId
+                    }
                 } else {
-                    transactionId = result.transactionId
+                    // Success with no body. Not observed, and handled
+                    // explicitly anyway: letting it fall through is how the
+                    // spinner this patch exists to remove gets back in.
+                    // `deserializationError` is the nearest existing case --
+                    // there is no response value to work with -- and adding
+                    // an enum case would widen a shared type for a path
+                    // nobody has seen.
+                    symLog.log("acceptBankIntWithdrawal returned no response")
+                    acceptError = WalletBackendError.deserializationError
                 }
             } catch {
                 // This used to be `try?`.  The failure that matters is 7046
11980-unwrap-optional.diff (3,024 bytes)   

Required notifications

Address or linkRemarkAdded byNotifiedActions

Activities

bot-cg [agent]

2026-11-09 22:32

updater   ~0030355

Correction: **the patch attached earlier does not compile.** Replacement
attached as `11980-unwrap-optional.diff`.

`acceptBankIntWithdrawal` returns an *optional*
(`Model+Withdraw.swift:330-343`), so the original `if let result = try?
await ...` was unwrapping two things at once -- the throw and the optional.
Replacing it with a bare `try` inside `do/catch` left the optional behind:

    WithdrawAcceptDone.swift:44:42: error: value of optional type
    'AcceptWithdrawalResponse?' must be unwrapped to refer to member
    'confirmTransferUrl' of wrapped base type 'AcceptWithdrawalResponse'
    WithdrawAcceptDone.swift:49:37: error: ... 'transactionId' ...

The replacement keeps the `if let` for the optional and the `do/catch` for
the throw, and gives the nil case its own branch rather than letting it
fall through to the spinner this patch exists to remove -- a success with
no body is not success. `WalletBackendError.deserializationError` is the
nearest existing case; adding an enum case would widen a shared type for a
path nobody has seen.

Built against iOS 27.2, Xcode 27.2, scheme GNU_Taler: the app compiles and
the literal `acceptBankIntWithdrawal returned no response` is present in
the resulting binary. The behaviour is still unverified -- reaching it
needs a withdrawal in `pending/kyc`, which this harness cannot drive yet
because the bank authorization needs a daemon pressing the bank's button.
Compiled is not observed, and I would rather say so.

Issue History

Date ModifiedUsernameFieldChange
2026-11-09 12:40bot-cgNew Issue
2026-11-09 13:20Christian GrothoffImplementer => MarcS
2026-11-09 13:20Christian GrothoffReviewer => Bohdan
2026-11-09 13:20Christian GrothoffRelease signed by => MarcS
2026-11-09 13:20Christian GrothoffDeployed by => MarcS
2026-11-09 13:20Christian GrothoffVerifier => avalos
2026-11-09 13:20Christian GrothoffStatusnew => planning
2026-11-09 22:32bot-cgFile Added: 11980-unwrap-optional.diff
2026-11-09 22:32bot-cgNote Added: 0030355
2026-11-19 08:48Christian GrothoffStatusplanning => implementing