aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Blättler <blatc2@bfh.ch>2024-03-18 20:58:41 +0100
committerChristian Blättler <blatc2@bfh.ch>2024-03-18 20:58:41 +0100
commit3a8e0b0f2f56f31e1a2ae7afca8d1c4f456bca46 (patch)
tree966a564f4069c5c67a4626f666b41cce2ecefa7a
parentf4585ef6c7eb890bf3ec345f032e223505a4e2d3 (diff)
simplify contract structs
-rw-r--r--src/backend/taler-merchant-httpd_contract.h314
1 files changed, 156 insertions, 158 deletions
diff --git a/src/backend/taler-merchant-httpd_contract.h b/src/backend/taler-merchant-httpd_contract.h
index 29abc115..cbc79200 100644
--- a/src/backend/taler-merchant-httpd_contract.h
+++ b/src/backend/taler-merchant-httpd_contract.h
@@ -40,20 +40,20 @@ enum TALER_MerchantContractVersion
};
/**
- * Possible token classes.
+ * Possible token kinds.
*/
-enum TALER_MerchantContractTokenClass
+enum TALER_MerchantContractTokenKind
{
/**
- * Token class subscription
+ * Subscription token kind
*/
- TALER_MCTC_SUBSCRIPTION = 0,
+ TALER_MCTK_SUBSCRIPTION = 0,
/**
- * Token class discount
+ * Discount token kind
*/
- TALER_MCTC_DISCOUNT = 1
+ TALER_MCTK_DISCOUNT = 1
};
/**
@@ -86,20 +86,20 @@ struct TALER_MerchantContractInput
union
{
/**
- * Coin-based input (ration).
+ * Coin-based input (ration). (Future work, only here for reference)
*/
- struct
- {
- /**
- * Price to be paid.
- */
- struct TALER_Amount price;
-
- /**
- * Base URL of the ration authority.
- */
- const char *ration_authority_url;
- } coin;
+ // struct
+ // {
+ // /**
+ // * Price to be paid.
+ // */
+ // struct TALER_Amount price;
+
+ // /**
+ // * Base URL of the ration authority.
+ // */
+ // const char *ration_authority_url;
+ // } coin;
/**
* Token-based input.
@@ -208,38 +208,6 @@ struct TALER_MerchantContractOutput
struct TALER_MerchantContractChoice
{
/**
- * Summary of the order.
- */
- const char *summary;
-
- /**
- * Internationalized summary.
- */
- json_t *summary_i18n;
-
- /**
- * URL that will show that the order was successful
- * after it has been paid for.
- */
- const char *fulfillment_url;
-
- /**
- * Message shown to the customer after paying for the order.
- * Either fulfillment_url or fulfillment_message must be specified.
- */
- const char *fulfillment_message;
-
- /**
- * Map from IETF BCP 47 language tags to localized fulfillment messages.
- */
- json_t *fulfillment_message_i18n;
-
- /**
- * Array of products that are part of the purchase.
- */
- const json_t *products;
-
- /**
* List of inputs the wallet must provision (all of them) to satisfy the
* conditions for the contract.
*/
@@ -254,7 +222,7 @@ struct TALER_MerchantContractChoice
* List of outputs the merchant promises to yield (all of them) once
* the contract is paid.
*/
- struct TALER_MerchantContractOutput *ouputs;
+ struct TALER_MerchantContractOutput *outputs;
/**
* Length of the @e outputs array.
@@ -288,6 +256,104 @@ struct TALER_MerchantContractLimits
struct TALER_Amount max_fee;
};
+struct TALER_MerchantContractTokenAuthority
+{
+ /**
+ * Label of the token authority.
+ */
+ const char *label;
+
+ /**
+ * Human-readable description of the semantics of the tokens issued by
+ * this authority.
+ */
+ const char *summary;
+
+ /**
+ * Map from IETF BCP 47 language tags to localized summaries.
+ */
+ json_t *summary_i18n;
+
+ /**
+ * Public key used to validate tokens signed by this authority.
+ */
+ struct TALER_TokenFamilyPublicKey key;
+
+ /**
+ * When will tokens signed by this key expire?
+ */
+ struct GNUNET_TIME_Timestamp token_expiration;
+
+ /**
+ * Must a wallet understand this token type to process contracts that
+ * consume or yield it?
+ */
+ bool critical;
+
+ /**
+ * Kind of the token.
+ */
+ enum TALER_MerchantContractTokenKind kind;
+
+ /**
+ * Kind-specific information about the token.
+ */
+ union
+ {
+ /**
+ * Subscription token.
+ */
+ struct
+ {
+ /**
+ * When does the subscription period start?
+ */
+ struct GNUNET_TIME_Absolute start_date;
+
+ /**
+ * When does the subscription period end?
+ */
+ struct GNUNET_TIME_Absolute end_date;
+
+ /**
+ * Array of domain names where this subscription can be safely used
+ * (e.g. the issuer warrants that these sites will re-issue tokens of
+ * this type if the respective contract says so). May contain "*" for
+ * any domain or subdomain.
+ */
+ const char **trusted_domains;
+
+ /**
+ * Length of the @e trusted_domains array.
+ */
+ unsigned int trusted_domains_len;
+ } subscription;
+
+ /**
+ * Discount token.
+ */
+ struct
+ {
+ /**
+ * Array of domain names where this discount token is intended to be
+ * used. May contain "*" for any domain or subdomain. Users should be
+ * warned about sites proposing to consume discount tokens of this
+ * type that are not in this list that the merchant is accepting a
+ * coupon from a competitor and thus may be attaching different
+ * semantics (like get 20% discount for my competitors 30% discount
+ * token).
+ */
+ const char **expected_domains;
+
+ /**
+ * Length of the @e expected_domains array.
+ */
+ unsigned int expected_domains_len;
+
+ } discount;
+ } details;
+};
+
/**
* Struct to hold contract terms in v0 and v1 format. v0 contracts are mdoelled
* as a v1 contract with a single choice and no inputs and outputs. Use the
@@ -355,7 +421,39 @@ struct TALER_MerchantContract
struct TALER_Amount brutto;
/**
- * Timestamp of the order.
+ * Summary of the contract.
+ */
+ const char *summary;
+
+ /**
+ * Internationalized summary.
+ */
+ json_t *summary_i18n;
+
+ /**
+ * URL that will show that the contract was successful
+ * after it has been paid for.
+ */
+ const char *fulfillment_url;
+
+ /**
+ * Message shown to the customer after paying for the contract.
+ * Either fulfillment_url or fulfillment_message must be specified.
+ */
+ const char *fulfillment_message;
+
+ /**
+ * Map from IETF BCP 47 language tags to localized fulfillment messages.
+ */
+ json_t *fulfillment_message_i18n;
+
+ /**
+ * Array of products that are part of the purchase.
+ */
+ const json_t *products;
+
+ /**
+ * Timestamp of the contract.
*/
struct GNUNET_TIME_Timestamp timestamp;
@@ -421,104 +519,7 @@ struct TALER_MerchantContract
/**
* Array of token authorities.
*/
- struct
- {
- /**
- * Label of the token authority.
- */
- const char *label;
-
- /**
- * Human-readable description of the semantics of the tokens issued by
- * this authority.
- */
- const char *summary;
-
- /**
- * Map from IETF BCP 47 language tags to localized summaries.
- */
- json_t *summary_i18n;
-
- /**
- * Public key used to validate tokens signed by this authority.
- */
- struct TALER_TokenFamilyPublicKey key;
-
- /**
- * When will tokens signed by this key expire?
- */
- struct GNUNET_TIME_Timestamp token_expiration;
-
- /**
- * Must a wallet understand this token type to process contracts that
- * consume or yield it?
- */
- bool critical;
-
- /**
- * Class of token the token.
- */
- enum TALER_MerchantContractTokenClass token_class;
-
- /**
- * Class-specific information about the token.
- */
- union
- {
- /**
- * Subscription token.
- */
- struct
- {
- /**
- * When does the subscription period start?
- */
- struct GNUNET_TIME_Absolute start_date;
-
- /**
- * When does the subscription period end?
- */
- struct GNUNET_TIME_Absolute end_date;
-
- /**
- * Array of domain names where this subscription can be safely used
- * (e.g. the issuer warrants that these sites will re-issue tokens of
- * this type if the respective contract says so). May contain "*" for
- * any domain or subdomain.
- */
- const char **trusted_domains;
-
- /**
- * Length of the @e trusted_domains array.
- */
- unsigned int trusted_domains_len;
- } subscription;
-
- /**
- * Discount token.
- */
- struct
- {
- /**
- * Array of domain names where this discount token is intended to be
- * used. May contain "*" for any domain or subdomain. Users should be
- * warned about sites proposing to consume discount tokens of this
- * type that are not in this list that the merchant is accepting a
- * coupon from a competitor and thus may be attaching different
- * semantics (like get 20% discount for my competitors 30% discount
- * token).
- */
- const char **expected_domains;
-
- /**
- * Length of the @e expected_domains array.
- */
- unsigned int expected_domains_len;
-
- } discount;
- } details;
-
- } *token_authorities;
+ struct TALER_MerchantContractTokenAuthority *token_authorities;
/**
* Length of the @e token_authorities array.
@@ -526,14 +527,11 @@ struct TALER_MerchantContract
unsigned int token_authorities_len;
/**
- * Array of fee limits and wire account details by currency.
- */
- struct TALER_MerchantContractLimits *limits;
+ * Maximum fee as given by the client request.
+ */
+ struct TALER_Amount max_fee;
- /**
- * Length of the @e limits array;
- */
- unsigned int limits_len;
+ // TODO: Add exchanges array
};
/**