aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/taler_extensions.h101
1 files changed, 84 insertions, 17 deletions
diff --git a/src/include/taler_extensions.h b/src/include/taler_extensions.h
index 646d5a84..d76de25e 100644
--- a/src/include/taler_extensions.h
+++ b/src/include/taler_extensions.h
@@ -25,17 +25,21 @@
#include "taler_crypto_lib.h"
#include "taler_json_lib.h"
#include "taler_mhd_lib.h"
+#include "taler_exchangedb_plugin.h"
#define TALER_EXTENSION_SECTION_PREFIX "exchange-extension-"
enum TALER_Extension_Type
{
- TALER_Extension_AgeRestriction = 0,
- TALER_Extension_PolicyMerchantRefund = 1,
- TALER_Extension_PolicyBrandtVickeryAuction = 2,
- TALER_Extension_PolicyEscrowedPayment = 3,
- TALER_Extension_MaxPredefined = 4 // Must be last of the predefined
+ TALER_Extension_PolicyNull = 0,
+
+ TALER_Extension_AgeRestriction = 1,
+ TALER_Extension_PolicyMerchantRefund = 2,
+ TALER_Extension_PolicyBrandtVickeryAuction = 3,
+ TALER_Extension_PolicyEscrowedPayment = 4,
+
+ TALER_Extension_MaxPredefined = 5 // Must be last of the predefined
};
@@ -50,6 +54,15 @@ struct TALER_Extensions
};
/*
+ * @brief Serial ID under which the policy details to an deposit are stored in
+ * the policy_details table.
+ */
+struct TALER_ExtensionsPolicySerialID
+{
+ struct GNUNET_HashCode hash;
+};
+
+/*
* @brief Represents the implementation of an extension.
*
* An "Extension" is an optional feature for the Exchange.
@@ -151,22 +164,30 @@ struct TALER_Extension
json_t *(*manifest)(
const struct TALER_Extension *ext);
+ /* =========================
+ * Policy related handlers
+ * =========================
+ */
/**
- * @brief Handler for /{batch}-deposit requests. Can be NULL.
+ * @brief Handler to check a policy. Can be NULL;
*
* When a deposit request refers to this extension in its policy
* (see https://docs.taler.net/core/api-exchange.html#deposit), this handler
- * will be called during the deposit operation.
+ * will be called before the deposit transaction.
*
- * @param[in] input The policy/extension specific data, provided by the client in
- * the policy-field of the deposit request.
- * @param[out] output Potential output by the extension to be provided to the
- * client as part of the response to the deposit request. Can be NULL.
+ * @param[in] policy_details Details about the policy, provided by the client
+ * during a deposit request.
+ * @param[out] serial On success, will contain the serial-ID under which the
+ * exchange should save the policy_details in the deposit table.
+ * @param[out] deadline On sucess, set to the deadline until the policy must
+ * be fulfilled. Might be "forever". This value is used by an external
+ * mechanism to detect timeouts.
* @return GNUNET_OK if the data was accepted by the extension.
*/
- enum GNUNET_GenericReturnValue (*deposit_handler)(
- json_t *input,
- json_t **output);
+ enum GNUNET_GenericReturnValue (*parse_policy_details)(
+ const json_t *policy_details,
+ struct TALER_ExtensionsPolicySerialID *serial,
+ struct GNUNET_TIME_Timestamp *deadline);
/**
* @brief Handler for POST-requests to the /policy/$name endpoint. Can be NULL.
@@ -367,18 +388,64 @@ TALER_extensions_get_age_restriction_mask ();
/*
+ * ===================================
+ * Policy extensions related functions
+ * ===================================
+ */
+
+/*
+ * @brief Finds the extension for a given policy
+ *
+ * @param[in] policy_details JSON of the policy detail from a deposit request
+ * @param[out] extension On GNUNET_OK, the exentions handling the given policy
+ * @param[out] error_hint On GNUNET_SYSERR, will contain a hint for the reason why it failed
+ * @return GNUNET_OK on success, with *extension set to the correct extension.
+ * GNUNET_NO, when no extension was found. GNUNET_SYSERR when the JSON was
+ * invalid, with *error_hint maybe non-NULL.
+ */
+enum GNUNET_GenericReturnValue
+TALER_extensions_from_policy_details (
+ const json_t *policy_details,
+ const struct TALER_Extension **extension,
+ char **error_hint);
+
+/*
* ================================
- * Brandt-Vickrey Auctions
+ * Merchant refund policy
+ * ================================
+ */
+struct TALER_ExtensionPolicyMerchantRefundPolicyConfig
+{
+ struct GNUNET_TIME_Relative max_timeout;
+};
+
+/*
+ * ================================
+ * Brandt-Vickrey Auctions policy
* ================================
*/
/*
- * @brief Configuration for Brandt-Vickrey auctions
+ * @brief Configuration for Brandt-Vickrey auctions policy
*/
-struct TALER_BrandtVickreyAuction
+struct TALER_ExtensionPolicyBrandtVickreyAuctionConfig
{
uint16_t max_bidders;
uint16_t max_prices;
struct TALER_Amount auction_fee;
};
+
+/*
+ * ================================
+ * Escrowed Payments policy
+ * ================================
+ */
+/*
+ * @brief Configuration for escrowed payments policy
+ */
+struct TALER_ExtensionPolicyEscrowedPaymentsConfig
+{
+ struct GNUNET_TIME_Relative max_timeout;
+};
+
#endif