commit b2d7bb32aa25f01b73b213f433147328e1f2c8a8
parent 70994304ed12d6a595c2a79b251f6f7fae364065
Author: Christian Grothoff <christian@grothoff.org>
Date: Thu, 2 Jan 2025 12:52:30 +0100
-add convenience function TALER_EXCHANGE_keys_test_account_allowed
Diffstat:
3 files changed, 51 insertions(+), 1 deletion(-)
diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h
@@ -1041,6 +1041,28 @@ TALER_EXCHANGE_test_account_allowed (
/**
+ * Check if a wire transfer is allowed between the exchange
+ * and an account identified by @a payto_uri.
+ *
+ * @param keys exchange /keys response to check against
+ * @param check_credit true for credit (sending money
+ * to the exchange), false for debit (receiving money
+ * from the exchange)
+ * @param payto_uri other bank account (merchant, customer)
+ * @return
+ * #GNUNET_YES if the exchange would allow this
+ * #GNUNET_NO if this is not allowed
+ * #GNUNET_SYSERR if data in @a account is malformed
+ * or we experienced internal errors
+ */
+enum GNUNET_GenericReturnValue
+TALER_EXCHANGE_keys_test_account_allowed (
+ const struct TALER_EXCHANGE_Keys *keys,
+ bool check_credit,
+ const struct TALER_NormalizedPayto payto_uri);
+
+
+/**
* Check the hard limits in @a keys for the given
* @a event and lower @a limit to the lowest applicable
* limit independent (!) of the timeframe. Useful
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
@@ -18,7 +18,7 @@ lib_LTLIBRARIES = \
libtalerexchange.la
libtalerexchange_la_LDFLAGS = \
- -version-info 14:0:0 \
+ -version-info 15:0:1 \
-no-undefined
libtalerexchange_la_SOURCES = \
exchange_api_add_aml_decision.c \
diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c
@@ -651,4 +651,32 @@ TALER_EXCHANGE_free_accounts (
}
+enum GNUNET_GenericReturnValue
+TALER_EXCHANGE_keys_test_account_allowed (
+ const struct TALER_EXCHANGE_Keys *keys,
+ bool check_credit,
+ const struct TALER_NormalizedPayto payto_uri)
+{
+ /* For all accounts of the exchange */
+ for (unsigned int i = 0; i<keys->accounts_len; i++)
+ {
+ const struct TALER_EXCHANGE_WireAccount *account
+ = &keys->accounts[i];
+
+ /* KYC auth transfers are never supported with conversion */
+ if (NULL != account->conversion_url)
+ continue;
+ /* filter by source account by credit_restrictions */
+ if (GNUNET_YES !=
+ TALER_EXCHANGE_test_account_allowed (account,
+ check_credit,
+ payto_uri))
+ continue;
+ /* exchange account is allowed, add it */
+ return true;
+ }
+ return false;
+}
+
+
/* end of exchange_api_common.c */