summaryrefslogtreecommitdiff
path: root/wallet/src/main/java/net/taler/wallet/transactions
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2023-12-05 13:01:40 -0600
committerIván Ávalos <avalos@disroot.org>2024-01-08 14:45:46 -0600
commit8936e2d7adf6bd25a2cacdc18dc9e31db1cec8d2 (patch)
treebe0b4b4baf4f65f6a49ea4097acf3d12f207c90b /wallet/src/main/java/net/taler/wallet/transactions
parentbdd47e0bf1e6491078de84b684476adbc055ec42 (diff)
downloadtaler-android-8936e2d7adf6bd25a2cacdc18dc9e31db1cec8d2.tar.gz
taler-android-8936e2d7adf6bd25a2cacdc18dc9e31db1cec8d2.tar.bz2
taler-android-8936e2d7adf6bd25a2cacdc18dc9e31db1cec8d2.zip
[wallet] Initial implementation of DD36.
Diffstat (limited to 'wallet/src/main/java/net/taler/wallet/transactions')
-rw-r--r--wallet/src/main/java/net/taler/wallet/transactions/TransactionWithdrawalFragment.kt10
-rw-r--r--wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt70
2 files changed, 69 insertions, 11 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/transactions/TransactionWithdrawalFragment.kt b/wallet/src/main/java/net/taler/wallet/transactions/TransactionWithdrawalFragment.kt
index 0cd6d60..234a2dd 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionWithdrawalFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionWithdrawalFragment.kt
@@ -77,13 +77,13 @@ class TransactionWithdrawalFragment : TransactionDetailFragment(), ActionListene
ActionListener.Type.CONFIRM_MANUAL -> {
if (tx !is TransactionWithdrawal) return
if (tx.withdrawalDetails !is ManualTransfer) return
- // TODO what if there's more than one or no URI?
- if (tx.withdrawalDetails.exchangePaytoUris.isEmpty()) return
+ if (tx.withdrawalDetails.exchangeCreditAccountDetails?.isEmpty() != false) return
val status = createManualTransferRequired(
- amount = tx.amountRaw,
- exchangeBaseUrl = tx.exchangeBaseUrl,
- uriStr = tx.withdrawalDetails.exchangePaytoUris[0],
transactionId = tx.transactionId,
+ exchangeBaseUrl = tx.exchangeBaseUrl,
+ amountRaw = tx.amountRaw,
+ amountEffective = tx.amountEffective,
+ withdrawalAccountList = tx.withdrawalDetails.exchangeCreditAccountDetails,
)
withdrawManager.viewManualWithdrawal(status)
findNavController().navigate(
diff --git a/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt b/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt
index e7f17c0..681fadb 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt
@@ -42,6 +42,7 @@ import net.taler.wallet.TAG
import net.taler.wallet.backend.TalerErrorCode
import net.taler.wallet.backend.TalerErrorInfo
import net.taler.wallet.cleanExchange
+import net.taler.wallet.balances.CurrencySpecification
import net.taler.wallet.refund.RefundPaymentInfo
import net.taler.wallet.transactions.TransactionMajorState.None
import net.taler.wallet.transactions.TransactionMajorState.Pending
@@ -182,12 +183,7 @@ sealed class WithdrawalDetails {
@Serializable
@SerialName("manual-transfer")
class ManualTransfer(
- /**
- * Payto URIs that the exchange supports.
- *
- * Already contains the amount and message.
- */
- val exchangePaytoUris: List<String>,
+ val exchangeCreditAccountDetails: List<WithdrawalExchangeAccountDetails>? = null,
) : WithdrawalDetails()
@Serializable
@@ -209,6 +205,68 @@ sealed class WithdrawalDetails {
}
@Serializable
+data class WithdrawalExchangeAccountDetails (
+ /**
+ * Payto URI to credit the exchange.
+ *
+ * Depending on whether the (manual!) withdrawal is accepted or just
+ * being checked, this already includes the subject with the
+ * reserve public key.
+ */
+ val paytoUri: String,
+
+ /**
+ * Transfer amount. Might be in a different currency than the requested
+ * amount for withdrawal.
+ *
+ * Redundant with the amount in paytoUri, just included to avoid parsing.
+ */
+ val transferAmount: Amount? = null,
+
+ /**
+ * Currency specification for the external currency.
+ *
+ * Only included if this account requires a currency conversion.
+ */
+ val currencySpecification: CurrencySpecification? = null,
+
+ /**
+ * Further restrictions for sending money to the
+ * exchange.
+ */
+ val creditRestrictions: List<AccountRestriction>? = null,
+)
+
+@Serializable
+sealed class AccountRestriction {
+ @Serializable
+ @SerialName("deny")
+ data object DenyAllAccount: AccountRestriction()
+
+ @Serializable
+ @SerialName("regex")
+ data class RegexAccount(
+ // Regular expression that the payto://-URI of the
+ // partner account must follow. The regular expression
+ // should follow posix-egrep, but without support for character
+ // classes, GNU extensions, back-references or intervals. See
+ // https://www.gnu.org/software/findutils/manual/html_node/find_html/posix_002degrep-regular-expression-syntax.html
+ // for a description of the posix-egrep syntax. Applications
+ // may support regexes with additional features, but exchanges
+ // must not use such regexes.
+ val paytoRegex: String,
+
+ // Hint for a human to understand the restriction
+ // (that is hopefully easier to comprehend than the regex itself).
+ val humanHint: String,
+
+ // Map from IETF BCP 47 language tags to localized
+ // human hints.
+ val humanHintI18n: Map<String, String>? = null,
+ ): AccountRestriction()
+}
+
+@Serializable
@SerialName("payment")
class TransactionPayment(
override val transactionId: String,