summaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_exchanges.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/taler-merchant-httpd_exchanges.h')
-rw-r--r--src/backend/taler-merchant-httpd_exchanges.h154
1 files changed, 119 insertions, 35 deletions
diff --git a/src/backend/taler-merchant-httpd_exchanges.h b/src/backend/taler-merchant-httpd_exchanges.h
index df68b9a5..892843f6 100644
--- a/src/backend/taler-merchant-httpd_exchanges.h
+++ b/src/backend/taler-merchant-httpd_exchanges.h
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- (C) 2014-2020 Taler Systems SA
+ (C) 2014-2023 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -31,9 +31,9 @@
/**
- * List of our trusted exchanges in JSON format for inclusion in contracts.
+ * Exchange
*/
-extern json_t *TMH_trusted_exchanges;
+struct TMH_Exchange;
/**
@@ -55,61 +55,145 @@ TMH_EXCHANGES_done (void);
/**
- * Function called with the result of a #TMH_EXCHANGES_find_exchange()
+ * Function called with the result of a #TMH_EXCHANGES_keys4exchange()
* operation.
*
* @param cls closure
- * @param hr HTTP response details
- * @param eh handle to the exchange context
- * @param payto_uri payto://-URI of the exchange
- * @param wire_fee current applicable wire fee for dealing with @a eh, NULL if not available
- * @param exchange_trusted true if this exchange is trusted by config
+ * @param keys the keys of the exchange
+ * @param exchange representation of the exchange
*/
typedef void
-(*TMH_EXCHANGES_FindContinuation)(void *cls,
- const struct TALER_EXCHANGE_HttpResponse *hr,
- struct TALER_EXCHANGE_Handle *eh,
- const char *payto_uri,
- const struct TALER_Amount *wire_fee,
- bool exchange_trusted);
+(*TMH_EXCHANGES_Find2Continuation)(
+ void *cls,
+ struct TALER_EXCHANGE_Keys *keys,
+ struct TMH_Exchange *exchange);
/**
- * Information we keep for a pending #MMH_EXCHANGES_find_exchange() operation.
+ * Information we keep for a pending #MMH_EXCHANGES_keys4exchange() operation.
*/
-struct TMH_EXCHANGES_FindOperation;
+struct TMH_EXCHANGES_KeysOperation;
/**
- * Find a exchange that matches @a chosen_exchange. If we cannot connect
- * to the exchange, or if it is not acceptable, @a fc is called with
- * NULL for the exchange.
+ * Get /keys of the given @a exchange.
*
- * @param chosen_exchange URL of the exchange we would like to talk to
- * @param wire_method the wire method we will use with @a chosen_exchange, NULL for none
- * @param force_reload try to force reloading /keys from the exchange ASAP; note
- * that IF the forced reload fails, it is possible @a fc won't be called at all
- * until a /keys download succeeds; only use #GNUNET_YES if a new /keys request
- * is mandatory. If the force reload request is not allowed due to our rate limiting,
- * then @a fc will be called immediately with the existing /keys data
+ * @param exchange URL of the exchange we would like to talk to
+ * @param force_download force /keys download now
* @param fc function to call with the handles for the exchange
* @param fc_cls closure for @a fc
*/
-struct TMH_EXCHANGES_FindOperation *
-TMH_EXCHANGES_find_exchange (const char *chosen_exchange,
- const char *wire_method,
- int force_reload,
- TMH_EXCHANGES_FindContinuation fc,
- void *fc_cls);
+struct TMH_EXCHANGES_KeysOperation *
+TMH_EXCHANGES_keys4exchange (
+ const char *exchange,
+ bool force_download,
+ TMH_EXCHANGES_Find2Continuation fc,
+ void *fc_cls);
/**
- * Abort pending find operation.
+ * Abort pending keys details lookup operation.
*
* @param fo handle to operation to abort
*/
void
-TMH_EXCHANGES_find_exchange_cancel (struct TMH_EXCHANGES_FindOperation *fo);
+TMH_EXCHANGES_keys4exchange_cancel (struct TMH_EXCHANGES_KeysOperation *fo);
+
+
+/**
+ * Callback on an exchange known to us. Does not warrant
+ * that the "keys" information is actually available for
+ * @a exchange.
+ *
+ * @param cls closure
+ * @param url base URL of the exchange
+ * @param exchange internal handle for the exchange
+ */
+typedef void
+(*TMH_ExchangeCallback)(void *cls,
+ const char *url,
+ const struct TMH_Exchange *exchange);
+
+
+/**
+ * Return all trusted exchanges to @a cb.
+ *
+ * @param cb function to call
+ * @param cb_cls closure for @a cb
+ */
+void
+TMH_exchange_get_trusted (TMH_ExchangeCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Return the master public key of the given @a exchange.
+ * Will be returned from configuration for trusted
+ * exchanges.
+ *
+ * @param exchange exchange to get master public key for
+ * @return the master public key of @a exchange
+ */
+const struct TALER_MasterPublicKeyP *
+TMH_EXCHANGES_get_master_pub (
+ const struct TMH_Exchange *exchange);
+
+
+/**
+ * Return the currency of the given @a exchange.
+ * Will be returned from configuration for trusted
+ * exchanges.
+ *
+ * @param exchange exchange to get master public key for
+ * @return the currency of @a exchange
+ */
+const char *
+TMH_EXCHANGES_get_currency (
+ const struct TMH_Exchange *exchange);
+
+
+/**
+ * Lookup current wire fee by @a exchange_url and @a wire_method.
+ *
+ * @param exchange the exchange to check
+ * @param wire_method wire method to lookup fee by
+ * @param[out] wire_fee set to the wire fee
+ * @return #GNUNET_OK on success
+ * #GNUNET_NO if @a wire_method is not supported
+ * #GNUNET_SYSERR if @a exchange_url did not yet respond properly to our /wire request
+ */
+enum GNUNET_GenericReturnValue
+TMH_EXCHANGES_lookup_wire_fee (
+ const struct TMH_Exchange *exchange,
+ const char *wire_method,
+ struct TALER_Amount *wire_fee);
+
+
+/**
+ * Check if we would trust @a ex to deposit funds into our account @a
+ * wm. Checks that both @a ex is trusted and that @a ex allows wire transfers
+ * into the account given in @a wm.
+ *
+ * @param exchange the exchange to check
+ * @param wm the wire method to check with
+ * @return #GNUNET_OK if such a debit can happen
+ */
+enum GNUNET_GenericReturnValue
+TMH_exchange_check_debit (
+ const struct TMH_Exchange *exchange,
+ const struct TMH_WireMethod *wm);
+
+
+/**
+ * Check if we support the given currency (by having an
+ * exchange configured with it).
+ *
+ * @param currency currency to check
+ * @return true if the currency is supported
+ */
+bool
+TMH_test_exchange_configured_for_currency (
+ const char *currency);
#endif