commit 31393db45b4b2508b1acac9ee6b27775e8625d07
parent 46290ddbb3a777b24ce931963ef26936c2e9d3ad
Author: Marc Stibane <marc@taler.net>
Date: Mon, 10 Aug 2026 19:42:14 +0200
make KYCauth like manual withdraw
Diffstat:
4 files changed, 21 insertions(+), 98 deletions(-)
diff --git a/TalerWallet1/Model/Model+Withdraw.swift b/TalerWallet1/Model/Model+Withdraw.swift
@@ -47,7 +47,7 @@ struct TransferOption: Codable, Hashable {
struct ExchangeAccountDetails: Codable, Hashable {
var status: String // "OK" or "error" - then conversionError
- var paytoUri: String
+// var paytoUri: String // deprecated, use transferOptions
var transferAmount: Amount? // only if "OK"
var transferOptions: [TransferOption]?
var transferExpiry: Timestamp?
diff --git a/TalerWallet1/Model/Transaction.swift b/TalerWallet1/Model/Transaction.swift
@@ -334,10 +334,12 @@ enum TransactionType: String, Codable {
struct KycAuthTransferInfo: Decodable, Sendable {
/// The KYC auth transfer will *not* work if it originates from a different account.
- var debitPaytoUri: String /// Payto URI of the account that must make the transfer
- var accountPub: String /// Account public key that must be included in the subject
+ var debitPaytoUri: String /// Payto URI of the account that must make the transfer
+ var accountPub: String /// Account public key that must be included in the subject
+ var transferOptionsExt: AccountDetailsArray /// Options for making the KYC auth transfer payment to the exchange
+ var transferExpiry: Timestamp? /// Validity of the transferOptions if they might expire
var amount: Amount
- var creditPaytoUris: [String] /// Possible target payto URIs
+// var creditPaytoUris: [String] /// deprecated
}
struct TransactionCommon: Decodable, Sendable {
@@ -449,17 +451,6 @@ struct WithdrawalDetails: Codable {
var reservePub: String
var reserveIsReady: Bool
var exchangeCreditAccountDetails: [ExchangeAccountDetails]?
- var validDetails: [ExchangeAccountDetails]? {
- if let details = exchangeCreditAccountDetails {
- let result = details.filter { detail in
- detail.status.lowercased() == "ok"
- }
- if !result.isEmpty {
- return result // guaranteed to have at least 1 item
- }
- }
- return nil
- }
/// Details for manual withdrawals:
var reserveClosingDelay: Duration?
diff --git a/TalerWallet1/Views/Transactions/KYCauth.swift b/TalerWallet1/Views/Transactions/KYCauth.swift
@@ -7,95 +7,27 @@
*/
import SwiftUI
import SymLog
+import taler_swift
+// pretty much the same as ManualDetailsV
struct KYCauth: View {
let stack: CallStack
let common: TransactionCommon
- @AppStorage("minimalistic") var minimalistic: Bool = false
- @State private var accountID = 0
- @State private var listID = UUID()
-
- func redraw(_ newAccount: Int) -> Void {
- if newAccount != accountID {
- accountID = newAccount
- withAnimation { listID = UUID() }
- }
- }
-
- func validDetails(_ paytoUris: [String]) -> [ExchangeAccountDetails] {
- var details: [ExchangeAccountDetails] = []
- for paytoUri in paytoUris {
- let payTo = PayTo(paytoUri)
- let amount = common.kycAuthTransferInfo?.amount
- let detail = ExchangeAccountDetails(status: "ok",
- paytoUri: paytoUri,
- transferAmount: amount,
- scope: common.scopes[0])
- details.append(detail)
- }
- return details
- }
-
var body: some View {
if let info = common.kycAuthTransferInfo {
let debitPayTo = PayTo(info.debitPaytoUri)
- let amount = info.amount
- let amountStr = amount.formatted(specs: nil,
- isNegative: false,
- scope: common.scopes[0])
- let amountValue = amount.valueStr
- let creditPaytoUris = info.creditPaytoUris
- let validDetails = validDetails(creditPaytoUris)
- if !validDetails.isEmpty {
- let countPaytos = creditPaytoUris.count
- let account = validDetails[accountID]
-
- Text("You need to prove having control over the bank account for the deposit.")
- .bold()
- .fixedSize(horizontal: false, vertical: true) // wrap in scrollview
- .multilineTextAlignment(.leading) // otherwise
- .listRowSeparator(.hidden)
-
- if countPaytos > 1 {
- if countPaytos > 3 { // too many for SegmentControl
- AccountPicker(title: String(localized: "Bank"),
- value: $accountID,
- accountDetails: validDetails,
- action: redraw)
- .listRowSeparator(.hidden)
- .pickerStyle(.menu)
- } else {
- SegmentControl(value: $accountID,
- accountDetails: validDetails,
- action: redraw)
- .listRowSeparator(.hidden)
- }
- } else if let creditPaytoUri = creditPaytoUris.first {
- if let bankName = account.bankLabel {
- Text(bankName + ": " + amountStr.0)
- .accessibilityLabel(bankName + ": " + amountStr.1)
-// } else {
-// Text(amountStr)
- }
- }
- let payto = PayTo(account.paytoUri)
- if let receiverStr = payto.receiver {
- let wireDetails = ManualDetailsWireV(stack: stack.push(),
- reservePub: info.accountPub,
- payto: payto,
- restrictions: account.creditRestrictions,
- amountValue: amountValue,
- amountStr: amountStr,
- obtainStr: nil, // only for withdrawal
- debitIBAN: debitPayTo.iban)
- NavigationLink(destination: wireDetails) {
- Text(minimalistic ? "Instructions"
- : "Wire transfer instructions")
- .talerFont(.title3)
- }
- }
- }
- }
+ let accountDetails = info.transferOptionsExt
+ if let validDetails = accountDetails.validDetails {
+ WireTransferView(stack: stack.push(),
+ title: String(localized: "You need to prove having control over the bank account for the deposit.", comment: ""),
+ isKYC: true,
+ reservePub: info.accountPub,
+ amountRaw: info.amount,
+ amountEffective: nil,
+ debitIBAN: debitPayTo.iban,
+ validDetails: validDetails)
+ } else { ErrorView(stack.push(), title: "KYC Error", message: "No valid details") }
+ } else { ErrorView(stack.push(), title: "KYC Error", message: "No KYC infos") }
} // body
}
diff --git a/TalerWallet1/Views/Transactions/TransactionTypeDetail.swift b/TalerWallet1/Views/Transactions/TransactionTypeDetail.swift
@@ -101,7 +101,7 @@ struct TransactionTypeDetail: View {
summary: nil)
if developerMode {
let withdrawalDetails = details.withdrawalDetails
- if let validDetails = withdrawalDetails.validDetails {
+ if let validDetails = withdrawalDetails.exchangeCreditAccountDetails?.validDetails {
let validCount = validDetails.count
if validCount > 0 {
ForEach(validDetails, id: \.self) { detail in