aboutsummaryrefslogtreecommitdiff
path: root/src/include/taler_extensions.h
diff options
context:
space:
mode:
authorÖzgür Kesim <oec-taler@kesim.org>2022-10-14 18:56:59 +0200
committerÖzgür Kesim <oec-taler@kesim.org>2022-10-14 18:56:59 +0200
commit054e157af8c768062dd0a8e66614da18407fca28 (patch)
treefcd792c6ed7f4384e9b29f8e200f62837cd00f1e /src/include/taler_extensions.h
parent956e3c3065ddb762dbe01fd720cc5ef403232564 (diff)
WIP: policy_details handling continued
- policy details generated on deposit/batch-deposit requests - insert or update of policy details in the DB - accumulation of amounts of multiple deposits for the same policy_details
Diffstat (limited to 'src/include/taler_extensions.h')
-rw-r--r--src/include/taler_extensions.h201
1 files changed, 16 insertions, 185 deletions
diff --git a/src/include/taler_extensions.h b/src/include/taler_extensions.h
index 5a5841e5..24e0366d 100644
--- a/src/include/taler_extensions.h
+++ b/src/include/taler_extensions.h
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014-2021 Taler Systems SA
+ Copyright (C) 2022 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
@@ -25,7 +25,7 @@
#include "taler_crypto_lib.h"
#include "taler_json_lib.h"
#include "taler_mhd_lib.h"
-#include "taler_exchangedb_plugin.h"
+#include "taler_extensions_policy.h"
#define TALER_EXTENSION_SECTION_PREFIX "exchange-extension-"
@@ -54,8 +54,8 @@ struct TALER_Extensions
};
/* Forward declarations */
-enum TALER_PolicyFulfilmentState;
-struct TALER_PolicyFulfilmentOutcome;
+enum TALER_PolicyFulfillmentState;
+struct TALER_PolicyFulfillmentOutcome;
/*
* @brief Represents the implementation of an extension.
@@ -165,31 +165,23 @@ struct TALER_Extension
*/
/**
- * @brief Handler to check a policy. Can be NULL;
+ * @brief Handler to check an incoming policy and create a
+ * TALER_PolicyDetails. 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 before the deposit transaction.
*
- * @param[in] policy_details Details about the policy, provided by the client
+ * @param[in] policy_json 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 success, set to the deadline until the policy must
- * be fulfilled. Might be "forever". This value is used by an
- * external mechanism to detect timeouts.
- * @param[out] state_on_timeout On GNUNET_OK, which state shall the
- * fulfilment of this policy be put in. MUST be either
- * TALER_PolicyFulfilmentTimeoutTransfer or
- * TALER_PolicyFulfilmentTimeoutRefreshable
+ * @param[out] details On success, will contain the details to the policy,
+ * evaluated by the corresponding policy handler.
* @param[out] error_hint On error, will contain a hint
* @return GNUNET_OK if the data was accepted by the extension.
*/
- enum GNUNET_GenericReturnValue (*parse_policy_details)(
- const json_t *policy_details,
- struct GNUNET_HashCode *serial,
- struct GNUNET_TIME_Timestamp *deadline,
- enum TALER_PolicyFulfilmentState *state_on_timeout,
+ enum GNUNET_GenericReturnValue (*create_policy_details)(
+ const json_t *policy_json,
+ struct TALER_PolicyDetails *details,
const char **error_hint);
/**
@@ -197,18 +189,16 @@ struct TALER_Extension
*
* @param[in] root The JSON body from the request
* @param[in] args Additional query parameters of the request.
- * @param[in] serial_id_check Helper function to check the presence of serial_ids in policy_details. Can be used by the handler to ensure the presence of entries before starting calculations.
- * @param[out] outcome Result of the operation. Must be freed via TALER_policy_fulfilment_outcome_free after use.
+ * @param[in,out] details List of policy details related to the incoming fulfillment proof
+ * @param[in] details_len Size of the list @e details
* @param[out] output JSON output to return to the client
* @return GNUNET_OK on success.
*/
enum GNUNET_GenericReturnValue (*policy_post_handler)(
const json_t *root,
const char *const args[],
- enum GNUNET_GenericReturnValue (*serial_id_check)(struct GNUNET_HashCode
- serial_ids[], size_t
- size),
- struct TALER_PolicyFulfilmentOutcome **outcome,
+ struct TALER_PolicyDetails *details,
+ size_t details_len,
json_t **output);
/**
@@ -395,163 +385,4 @@ TALER_extensions_is_age_restriction_enabled ();
struct TALER_AgeMask
TALER_extensions_get_age_restriction_mask ();
-
-/*
- * ===================================
- * Policy extensions related API
- * ===================================
- */
-
-
-/*
- * @brief Describes the states of fulfilment of a policy bound to a deposit
- */
-enum TALER_PolicyFulfilmentState
-{
- /* Initial state of the policy */
- TALER_PolicyFulfilmentPending = 0,
-
- /*
- * Policy provably fulfilled. The semantics of the policy require that
- * the exchange MUST transfer amount in the associated deposit to the
- * payto-URI */
- TALER_PolicyFulfilmentSuccessTransfer = 1,
-
- /*
- * Policy provably fulfilled. The semantics of the policy require that
- * the coins' value in the associated deposit remains and the owner can
- * refresh them. */
- TALER_PolicyFulfilmentSuccessRefreshable = 2,
-
- /*
- * Policy provably UNfulfilled. The semantics of the policy require
- * that the exchange MUST transfer amount in the associated deposit to
- * the payto-URI. */
- TALER_PolicyFulfilmentFailureTransfer = 3,
-
- /*
- * Policy provably UNfulfilled. The semantics of the policy require that
- * the coins' value in the associated deposit remains and the owner can
- * refresh them. */
- TALER_PolicyFulfilmentFailureRefreshable = 4,
-
- /*
- * Policy timed out. The semantics of the policy require that the
- * exchange MUST transfer amount in the associated deposit to the
- * payto-URI. */
- TALER_PolicyFulfilmentTimeoutTransfer = 5,
-
- /*
- * Policy timed out. The semantics of the policy require that the
- * coins' value in the associated deposit remains and the owner can
- * refresh them. */
- TALER_PolicyFulfilmentTimeoutRefreshable = 6,
-
- TALER_PolicyFulfilmentStateMax = TALER_PolicyFulfilmentTimeoutRefreshable
-};
-
-
-const char *
-TALER_policy_fulfilment_state_str (enum TALER_PolicyFulfilmentState state);
-
-/*
- * @brief Respresents the outcome of a policy fulfilment evaluation
- * returned by a http_post_handler.
- */
-struct TALER_PolicyFulfilmentOutcome
-{
- size_t len;
- struct TALER_PolicyFulfilmentOutcomePosition
- {
- /* Identifies the particular policy in the policy_details */
- struct GNUNET_HashCode serial_id;
-
- /* The state that the policy should be be put into. */
- enum TALER_PolicyFulfilmentState state;
-
- /* If @e has_new_amount is true, the actual amount to be transfered
- * according to the @e state is not taken from the associated deposit
- * entry, but provided with @new_amount
- */
- bool has_new_amount;
- struct TALER_Amount new_amount;
-
- } *positions;
-};
-
-
-/*
- * @brief allocate a TALER_PolicyFulfilmentOutcome
- */
-struct TALER_PolicyFulfilmentOutcome *
-TALER_policy_fulfilment_outcome_new (size_t len);
-
-/*
- * @brief free the content of a TALER_PolicyFulfilmentOutcome
- */
-void
-TALER_policy_fulfilment_outcome_free (
- struct TALER_PolicyFulfilmentOutcome *outcome);
-
-
-/*
- * @brief Extracts meta information from policy_details
- *
- * @param[in] policy_details JSON of the policy detail from a deposit request
- * @param[out] serial On GNUNET_OK, the hash code that should be used to save the policy_details in the policy_details table
- * @param[out] deadline On GNUNET_OK, the deadline that should be saved in the policy_details table
- * @param[out] state_on_timeout On GNUNET_OK, which state shall the fulfilment of this policy be put in
- * @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_extract_meta_data_from_policy_details (
- const json_t *policy_details,
- struct GNUNET_HashCode *serial,
- struct GNUNET_TIME_Timestamp *deadline,
- enum TALER_PolicyFulfilmentState *state_on_timeout,
- const char **error_hint);
-
-
-/*
- * ================================
- * Merchant refund policy
- * ================================
- */
-struct TALER_ExtensionPolicyMerchantRefundPolicyConfig
-{
- struct GNUNET_TIME_Relative max_timeout;
-};
-
-/*
- * ================================
- * Brandt-Vickrey Auctions policy
- * ================================
- */
-/*
- * @brief Configuration for Brandt-Vickrey auctions policy
- */
-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