diff --git a/TalerWallet1/Model/Model+Deposit.swift b/TalerWallet1/Model/Model+Deposit.swift index fd35b932..4a246b24 100644 --- a/TalerWallet1/Model/Model+Deposit.swift +++ b/TalerWallet1/Model/Model+Deposit.swift @@ -175,19 +175,41 @@ fileprivate struct AmountResponse: Codable { fileprivate struct GetMaxDepositAmount: WalletBackendFormattedRequest { typealias Response = AmountResponse var operation: String { "getMaxDepositAmount" } - func args() -> Args { Args(currency: scope.currency, restrictScope: scope) } + func args() -> Args { Args(currency: scope.currency, restrictScope: scope, + depositPaytoUri: depositPaytoUri) } var scope: ScopeInfo + /// The account the money is going to, when one has been chosen. + /// + /// wallet-core derives `restrictWireMethod` from it and filters the + /// eligible exchanges by it (`getMaxDepositAmount` -> + /// `getDepositExchangeEligibilityInTx`). Without it the answer is the + /// most that could be deposited *somewhere*, which the amount screen + /// then presents as the most that can be deposited *here*. + /// + /// Measured 2026-11-09 on a KUDOS 25 wallet with an IBAN account: the + /// screen offered "Available: KUDOS 25.00" and an enabled + /// "Deposit KUDOS 5.00", and `createDepositGroup` refused with 7026, + /// `maximumPayableAmount: KUDOS:0`, + /// `reasons: [{wire-method-unsupported, iban}]` -- the demo exchange + /// settles over x-taler-bank. Issue 11984. + /// + /// Optional, and the synthesized encoder omits a nil one, so a caller + /// that has no account yet sends exactly the request it sent before. + var depositPaytoUri: String? struct Args: Encodable { var currency: String var restrictScope: ScopeInfo -// var depositPaytoUri: String + var depositPaytoUri: String? } } extension WalletModel { - nonisolated func getMaxDepositAmount(_ scope: ScopeInfo, viewHandles: Bool = false) + nonisolated func getMaxDepositAmount(_ scope: ScopeInfo, + depositPaytoUri: String? = nil, + viewHandles: Bool = false) async throws -> Amount { - let request = GetMaxDepositAmount(scope: scope) + let request = GetMaxDepositAmount(scope: scope, + depositPaytoUri: depositPaytoUri) let (response, _) = try await sendRequest(request, viewHandles: viewHandles) return response.available.rawAmount } diff --git a/TalerWallet1/Views/Actions/Banking/DepositAmountAction.swift b/TalerWallet1/Views/Actions/Banking/DepositAmountAction.swift index a10d7759..05cfdd76 100644 --- a/TalerWallet1/Views/Actions/Banking/DepositAmountAction.swift +++ b/TalerWallet1/Views/Actions/Banking/DepositAmountAction.swift @@ -67,7 +67,11 @@ struct DepositAmountAction: View { amountToTransfer.setCurrency(scope.currency) currencyInfo = controller.info(for: scope, controller.currencyTicker) do { - amountAvailable = try await model.getMaxDepositAmount(scope) + // The destination, so the maximum is the one the user is + // actually held to rather than the most this wallet could + // deposit anywhere (11984). + amountAvailable = try await model.getMaxDepositAmount( + scope, depositPaytoUri: paytoUri) } catch { // TODO: Error amountAvailable = balance.available