payto-link-only-accepts-iban.diff (2106B)
1 diff --git a/wallet/src/main/java/net/taler/wallet/deposit/DepositManager.kt b/wallet/src/main/java/net/taler/wallet/deposit/DepositManager.kt 2 index 821bf471..0b19306a 100644 3 --- a/wallet/src/main/java/net/taler/wallet/deposit/DepositManager.kt 4 +++ b/wallet/src/main/java/net/taler/wallet/deposit/DepositManager.kt 5 @@ -29,6 +29,7 @@ import kotlinx.serialization.json.jsonPrimitive 6 import net.taler.common.Amount 7 import net.taler.wallet.main.TAG 8 import net.taler.wallet.accounts.KnownBankAccountInfo 9 +import net.taler.wallet.accounts.PaytoUri 10 import net.taler.wallet.accounts.PaytoUriBitcoin 11 import net.taler.wallet.accounts.PaytoUriIban 12 import net.taler.wallet.accounts.PaytoUriTalerBank 13 @@ -39,7 +40,6 @@ import net.taler.wallet.backend.WalletResponse 14 import net.taler.wallet.balances.BalanceManager 15 import net.taler.wallet.balances.ScopeInfo 16 import org.json.JSONObject 17 -import androidx.core.net.toUri 18 19 class DepositManager( 20 private val api: WalletBackendApi, 21 @@ -50,12 +50,17 @@ class DepositManager( 22 private val mDepositState = MutableStateFlow<DepositState>(DepositState.Start) 23 internal val depositState = mDepositState.asStateFlow() 24 25 - fun isSupportedPayToUri(uriString: String): Boolean { 26 - if (!uriString.startsWith("payto://")) return false 27 - val u = uriString.toUri() 28 - if (!u.authority.equals("iban", ignoreCase = true)) return false 29 - return u.pathSegments.isNotEmpty() 30 - } 31 + /** 32 + * Whether a payto URI names an account this wallet can deposit to. 33 + * 34 + * Every target type the app models counts, not just IBAN: the 35 + * add-account form offers x-taler-bank, IBAN and Bitcoin, the transfer 36 + * screens render all four, and a deposit to an x-taler-bank account 37 + * chosen from the account list succeeds -- so refusing the same account 38 + * as a *link* told the user their link was invalid when it was not. 39 + */ 40 + fun isSupportedPayToUri(uriString: String): Boolean = 41 + PaytoUri.parse(uriString) != null 42 43 @UiThread 44 fun selectAccount(account: KnownBankAccountInfo) = scope.launch {