diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/Makefile.am | 7 | ||||
-rw-r--r-- | src/include/taler_amount_lib.h | 13 | ||||
-rw-r--r-- | src/include/taler_bank_service.h | 11 | ||||
-rw-r--r-- | src/include/taler_crypto_lib.h | 30 | ||||
-rw-r--r-- | src/include/taler_exchange_service.h (renamed from src/include/taler_mint_service.h) | 678 | ||||
-rw-r--r-- | src/include/taler_exchangedb_lib.h (renamed from src/include/taler_mintdb_lib.h) | 143 | ||||
-rw-r--r-- | src/include/taler_exchangedb_plugin.h (renamed from src/include/taler_mintdb_plugin.h) | 326 | ||||
-rw-r--r-- | src/include/taler_json_lib.h | 131 | ||||
-rw-r--r-- | src/include/taler_pq_lib.h | 1 | ||||
-rw-r--r-- | src/include/taler_signatures.h | 301 | ||||
-rw-r--r-- | src/include/taler_util.h | 73 | ||||
-rw-r--r-- | src/include/taler_wire_plugin.h | 39 |
12 files changed, 859 insertions, 894 deletions
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 4d7ae3cb2..310263f0b 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -13,12 +13,13 @@ else talerinclude_HEADERS = \ platform.h \ taler_amount_lib.h \ + taler_bank_service.h \ taler_crypto_lib.h \ taler_json_lib.h \ taler_util.h \ - taler_mint_service.h \ - taler_mintdb_lib.h \ - taler_mintdb_plugin.h \ + taler_exchange_service.h \ + taler_exchangedb_lib.h \ + taler_exchangedb_plugin.h \ taler_pq_lib.h \ taler_signatures.h \ taler_wire_lib.h \ diff --git a/src/include/taler_amount_lib.h b/src/include/taler_amount_lib.h index 094b96f7f..2fd547196 100644 --- a/src/include/taler_amount_lib.h +++ b/src/include/taler_amount_lib.h @@ -128,6 +128,19 @@ TALER_string_to_amount (const char *str, /** + * Parse denomination description, in the format "T:V.F". + * + * @param str denomination description + * @param denom denomination to write the result to, in NBO + * @return #GNUNET_OK if the string is a valid denomination specification, + * #GNUNET_SYSERR if it is invalid. + */ +int +TALER_string_to_amount_nbo (const char *str, + struct TALER_AmountNBO *denom); + + +/** * Get the value of "zero" in a particular currency. * * @param cur currency description diff --git a/src/include/taler_bank_service.h b/src/include/taler_bank_service.h index a4f33fc97..920ae47fd 100644 --- a/src/include/taler_bank_service.h +++ b/src/include/taler_bank_service.h @@ -22,6 +22,7 @@ #ifndef _TALER_BANK_SERVICE_H #define _TALER_BANK_SERVICE_H +#include <jansson.h> #include "taler_util.h" /* ********************* event loop *********************** */ @@ -117,10 +118,12 @@ struct TALER_BANK_AdminAddIncomingHandle; * @param cls closure * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request * 0 if the bank's reply is bogus (fails to follow the protocol) + * @param json detailed response from the HTTPD, or NULL if reply was not in JSON */ typedef void (*TALER_BANK_AdminAddIncomingResultCallback) (void *cls, - unsigned int http_status); + unsigned int http_status, + json_t *json); /** @@ -133,7 +136,8 @@ typedef void * @param reserve_pub public key of the reserve * @param amount amount that was deposited * @param execution_date when did we receive the amount - * @param account_no account number (53 bits at most) + * @param debit_account_no account number to withdraw from (53 bits at most) + * @param credit_account_no account number to deposit into (53 bits at most) * @param res_cb the callback to call when the final result for this request is available * @param res_cb_cls closure for the above callback * @return NULL @@ -144,7 +148,8 @@ struct TALER_BANK_AdminAddIncomingHandle * TALER_BANK_admin_add_incoming (struct TALER_BANK_Context *bank, const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_Amount *amount, - uint64_t account_no, + uint64_t debit_account_no, + uint64_t credit_account_no, TALER_BANK_AdminAddIncomingResultCallback res_cb, void *res_cb_cls); diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h index 6056270fa..a3275b74d 100644 --- a/src/include/taler_crypto_lib.h +++ b/src/include/taler_crypto_lib.h @@ -140,23 +140,23 @@ struct TALER_TransferPrivateKeyP /** - * @brief Type of online public keys used by the mint to sign + * @brief Type of online public keys used by the exchange to sign * messages. */ -struct TALER_MintPublicKeyP +struct TALER_ExchangePublicKeyP { /** - * Taler uses EdDSA for online mint message signing. + * Taler uses EdDSA for online exchange message signing. */ struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub; }; /** - * @brief Type of online public keys used by the mint to + * @brief Type of online public keys used by the exchange to * sign messages. */ -struct TALER_MintPrivateKeyP +struct TALER_ExchangePrivateKeyP { /** * Taler uses EdDSA for online signatures sessions. @@ -166,9 +166,9 @@ struct TALER_MintPrivateKeyP /** - * @brief Type of signatures used by the mint to sign messages online. + * @brief Type of signatures used by the exchange to sign messages online. */ -struct TALER_MintSignatureP +struct TALER_ExchangeSignatureP { /** * Taler uses EdDSA for online signatures sessions. @@ -178,7 +178,7 @@ struct TALER_MintSignatureP /** - * @brief Type of the offline master public key used by the mint. + * @brief Type of the offline master public key used by the exchange. */ struct TALER_MasterPublicKeyP { @@ -214,7 +214,7 @@ struct TALER_AuditorSignatureP /** - * @brief Type of the offline master public keys used by the mint. + * @brief Type of the offline master public keys used by the exchange. */ struct TALER_MasterPrivateKeyP { @@ -226,7 +226,7 @@ struct TALER_MasterPrivateKeyP /** - * @brief Type of signatures by the offline master public key used by the mint. + * @brief Type of signatures by the offline master public key used by the exchange. */ struct TALER_MasterSignatureP { @@ -299,7 +299,7 @@ struct TALER_DenominationSignature /** * Taler uses RSA for blinding. */ - struct GNUNET_CRYPTO_rsa_Signature *rsa_signature; + struct GNUNET_CRYPTO_RsaSignature *rsa_signature; }; @@ -311,7 +311,7 @@ struct TALER_DenominationPublicKey /** * Taler uses RSA for signing coins. */ - struct GNUNET_CRYPTO_rsa_PublicKey *rsa_public_key; + struct GNUNET_CRYPTO_RsaPublicKey *rsa_public_key; }; @@ -323,7 +323,7 @@ struct TALER_DenominationPrivateKey /** * Taler uses RSA for signing coins. */ - struct GNUNET_CRYPTO_rsa_PrivateKey *rsa_private_key; + struct GNUNET_CRYPTO_RsaPrivateKey *rsa_private_key; }; @@ -464,8 +464,8 @@ struct TALER_WireTransferIdentifierRawP /** * Binary information encoded in Crockford's Base32 in wire transfer * subjects of transfers from Taler to a merchant. The actual value - * is chosen by the mint and has no particular semantics, other than - * being unique so that the mint can lookup details about the wire + * is chosen by the exchange and has no particular semantics, other than + * being unique so that the exchange can lookup details about the wire * transfer when needed. */ struct TALER_WireTransferIdentifierP diff --git a/src/include/taler_mint_service.h b/src/include/taler_exchange_service.h index 1502edfbc..4a1592cf2 100644 --- a/src/include/taler_mint_service.h +++ b/src/include/taler_exchange_service.h @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014, 2015 GNUnet e.V. + Copyright (C) 2014, 2015, 2016 GNUnet e.V. TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software @@ -14,14 +14,15 @@ TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/> */ /** - * @file include/taler_mint_service.h - * @brief C interface of libtalermint, a C library to use mint's HTTP API + * @file include/taler_exchange_service.h + * @brief C interface of libtalerexchange, a C library to use exchange's HTTP API * @author Sree Harsha Totakura <sreeharsha@totakura.in> * @author Christian Grothoff */ -#ifndef _TALER_MINT_SERVICE_H -#define _TALER_MINT_SERVICE_H +#ifndef _TALER_EXCHANGE_SERVICE_H +#define _TALER_EXCHANGE_SERVICE_H +#include <jansson.h> #include "taler_util.h" /* ********************* event loop *********************** */ @@ -30,7 +31,7 @@ * @brief Handle to this library context. This is where the * main event loop logic lives. */ -struct TALER_MINT_Context; +struct TALER_EXCHANGE_Context; /** @@ -39,18 +40,18 @@ struct TALER_MINT_Context; * * @return the context, NULL on error (failure to initialize) */ -struct TALER_MINT_Context * -TALER_MINT_init (void); +struct TALER_EXCHANGE_Context * +TALER_EXCHANGE_init (void); /** * Obtain the information for a select() call to wait until - * #TALER_MINT_perform() is ready again. Note that calling - * any other TALER_MINT-API may also imply that the library - * is again ready for #TALER_MINT_perform(). + * #TALER_EXCHANGE_perform() is ready again. Note that calling + * any other TALER_EXCHANGE-API may also imply that the library + * is again ready for #TALER_EXCHANGE_perform(). * * Basically, a client should use this API to prepare for select(), - * then block on select(), then call #TALER_MINT_perform() and then + * then block on select(), then call #TALER_EXCHANGE_perform() and then * start again until the work with the context is done. * * This function will NOT zero out the sets and assumes that @a max_fd @@ -69,15 +70,15 @@ TALER_MINT_init (void); * to be passed to select().) * @param timeout set to the timeout in milliseconds (!); -1 means * no timeout (NULL, blocking forever is OK), 0 means to - * proceed immediately with #TALER_MINT_perform(). + * proceed immediately with #TALER_EXCHANGE_perform(). */ void -TALER_MINT_get_select_info (struct TALER_MINT_Context *ctx, - fd_set *read_fd_set, - fd_set *write_fd_set, - fd_set *except_fd_set, - int *max_fd, - long *timeout); +TALER_EXCHANGE_get_select_info (struct TALER_EXCHANGE_Context *ctx, + fd_set *read_fd_set, + fd_set *write_fd_set, + fd_set *except_fd_set, + int *max_fd, + long *timeout); /** @@ -86,7 +87,7 @@ TALER_MINT_get_select_info (struct TALER_MINT_Context *ctx, * @param ctx the library context */ void -TALER_MINT_perform (struct TALER_MINT_Context *ctx); +TALER_EXCHANGE_perform (struct TALER_EXCHANGE_Context *ctx); /** @@ -97,7 +98,7 @@ TALER_MINT_perform (struct TALER_MINT_Context *ctx); * @param ctx the library context */ void -TALER_MINT_fini (struct TALER_MINT_Context *ctx); +TALER_EXCHANGE_fini (struct TALER_EXCHANGE_Context *ctx); /* ********************* /keys *********************** */ @@ -105,27 +106,27 @@ TALER_MINT_fini (struct TALER_MINT_Context *ctx); /** * List of possible options to be passed to - * #TALER_MINT_connect(). + * #TALER_EXCHANGE_connect(). */ -enum TALER_MINT_Option +enum TALER_EXCHANGE_Option { /** * Terminator (end of option list). */ - TALER_MINT_OPTION_END = 0 + TALER_EXCHANGE_OPTION_END = 0 }; /** - * @brief Mint's signature key + * @brief Exchange's signature key */ -struct TALER_MINT_SigningPublicKey +struct TALER_EXCHANGE_SigningPublicKey { /** * The signing public key */ - struct TALER_MintPublicKeyP key; + struct TALER_ExchangePublicKeyP key; /** * Validity start time @@ -140,9 +141,9 @@ struct TALER_MINT_SigningPublicKey /** - * @brief Public information about a mint's denomination key + * @brief Public information about a exchange's denomination key */ -struct TALER_MINT_DenomPublicKey +struct TALER_EXCHANGE_DenomPublicKey { /** * The public key @@ -173,7 +174,7 @@ struct TALER_MINT_DenomPublicKey /** * When do signatures with this denomination key become invalid? * After this point, these signatures cannot be used in (legal) - * disputes anymore, as the Mint is then allowed to destroy its side + * disputes anymore, as the Exchange is then allowed to destroy its side * of the evidence. @e expire_legal is expected to be significantly * larger than @e expire_spend (by a year or more). */ @@ -202,24 +203,24 @@ struct TALER_MINT_DenomPublicKey /** - * @brief Information we get from the mint about auditors. + * @brief Information we get from the exchange about auditors. */ -struct TALER_MINT_AuditorInformation +struct TALER_EXCHANGE_AuditorInformation { /** - * Public key of the auditing institution. + * Public key of the auditing institution. Wallets and merchants + * are expected to be configured with a set of public keys of + * auditors that they deem acceptable. These public keys are + * the roots of the Taler PKI. */ struct TALER_AuditorPublicKeyP auditor_pub; /** - * URL of the auditing institution. The application must check that - * this is an acceptable auditor for its purpose and also verify - * that the @a auditor_pub matches the auditor's public key given at - * that website. We expect that in practice software is going to - * often ship with an initial list of accepted auditors, just like - * browsers ship with a CA root store. - * - * This field may be NULL. (#3987). + * URL of the auditing institution. Signed by the auditor's public + * key, this URL is a place where applications can direct users for + * additional information about the auditor. In the future, there + * should also be an auditor API for automated submission about + * claims of misbehaving exchange providers. */ const char *auditor_url; @@ -229,40 +230,40 @@ struct TALER_MINT_AuditorInformation unsigned int num_denom_keys; /** - * Array of length @a denom_keys with the denomination + * Array of length @a num_denom_keys with the denomination * keys audited by this auditor. Note that the array * elements point to the same locations as the entries * in the key's main `denom_keys` array. */ - const struct TALER_MINT_DenomPublicKey **denom_keys; + const struct TALER_EXCHANGE_DenomPublicKey **denom_keys; }; /** - * @brief Information about keys from the mint. + * @brief Information about keys from the exchange. */ -struct TALER_MINT_Keys +struct TALER_EXCHANGE_Keys { /** - * Long-term offline signing key of the mint. + * Long-term offline signing key of the exchange. */ struct TALER_MasterPublicKeyP master_pub; /** - * Array of the mint's online signing keys. + * Array of the exchange's online signing keys. */ - struct TALER_MINT_SigningPublicKey *sign_keys; + struct TALER_EXCHANGE_SigningPublicKey *sign_keys; /** - * Array of the mint's denomination keys. + * Array of the exchange's denomination keys. */ - struct TALER_MINT_DenomPublicKey *denom_keys; + struct TALER_EXCHANGE_DenomPublicKey *denom_keys; /** - * Array of the keys of the auditors of the mint. + * Array of the keys of the auditors of the exchange. */ - struct TALER_MINT_AuditorInformation *auditors; + struct TALER_EXCHANGE_AuditorInformation *auditors; /** * Length of the @e sign_keys array. @@ -284,102 +285,102 @@ struct TALER_MINT_Keys /** * Function called with information about who is auditing - * a particular mint and what key the mint is using. + * a particular exchange and what key the exchange is using. * * @param cls closure * @param keys information about the various keys used - * by the mint + * by the exchange */ typedef void -(*TALER_MINT_CertificationCallback) (void *cls, - const struct TALER_MINT_Keys *keys); +(*TALER_EXCHANGE_CertificationCallback) (void *cls, + const struct TALER_EXCHANGE_Keys *keys); /** - * @brief Handle to the mint. This is where we interact with - * a particular mint and keep the per-mint information. + * @brief Handle to the exchange. This is where we interact with + * a particular exchange and keep the per-exchange information. */ -struct TALER_MINT_Handle; +struct TALER_EXCHANGE_Handle; /** - * Initialise a connection to the mint. Will connect to the - * mint and obtain information about the mint's master public - * key and the mint's auditor. The respective information will + * Initialise a connection to the exchange. Will connect to the + * exchange and obtain information about the exchange's master public + * key and the exchange's auditor. The respective information will * be passed to the @a cert_cb once available, and all future - * interactions with the mint will be checked to be signed + * interactions with the exchange will be checked to be signed * (where appropriate) by the respective master key. * * @param ctx the context - * @param url HTTP base URL for the mint - * @param cert_cb function to call with the mint's certification information + * @param url HTTP base URL for the exchange + * @param cert_cb function to call with the exchange's certification information * @param cert_cb_cls closure for @a cert_cb - * @param ... list of additional arguments, terminated by #TALER_MINT_OPTION_END. - * @return the mint handle; NULL upon error + * @param ... list of additional arguments, terminated by #TALER_EXCHANGE_OPTION_END. + * @return the exchange handle; NULL upon error */ -struct TALER_MINT_Handle * -TALER_MINT_connect (struct TALER_MINT_Context *ctx, - const char *url, - TALER_MINT_CertificationCallback cert_cb, - void *cert_cb_cls, - ...); +struct TALER_EXCHANGE_Handle * +TALER_EXCHANGE_connect (struct TALER_EXCHANGE_Context *ctx, + const char *url, + TALER_EXCHANGE_CertificationCallback cert_cb, + void *cert_cb_cls, + ...); /** - * Disconnect from the mint. + * Disconnect from the exchange. * - * @param mint the mint handle + * @param exchange the exchange handle */ void -TALER_MINT_disconnect (struct TALER_MINT_Handle *mint); +TALER_EXCHANGE_disconnect (struct TALER_EXCHANGE_Handle *exchange); /** - * Obtain the keys from the mint. + * Obtain the keys from the exchange. * - * @param mint the mint handle - * @return the mint's key set + * @param exchange the exchange handle + * @return the exchange's key set */ -const struct TALER_MINT_Keys * -TALER_MINT_get_keys (const struct TALER_MINT_Handle *mint); +const struct TALER_EXCHANGE_Keys * +TALER_EXCHANGE_get_keys (const struct TALER_EXCHANGE_Handle *exchange); /** - * Test if the given @a pub is a the current signing key from the mint + * Test if the given @a pub is a the current signing key from the exchange * according to @a keys. * - * @param keys the mint's key set - * @param pub claimed current online signing key for the mint + * @param keys the exchange's key set + * @param pub claimed current online signing key for the exchange * @return #GNUNET_OK if @a pub is (according to /keys) a current signing key */ int -TALER_MINT_test_signing_key (const struct TALER_MINT_Keys *keys, - const struct TALER_MintPublicKeyP *pub); +TALER_EXCHANGE_test_signing_key (const struct TALER_EXCHANGE_Keys *keys, + const struct TALER_ExchangePublicKeyP *pub); /** - * Obtain the denomination key details from the mint. + * Obtain the denomination key details from the exchange. * - * @param keys the mint's key set + * @param keys the exchange's key set * @param pk public key of the denomination to lookup * @return details about the given denomination key, NULL if the key is not * found */ -const struct TALER_MINT_DenomPublicKey * -TALER_MINT_get_denomination_key (const struct TALER_MINT_Keys *keys, - const struct TALER_DenominationPublicKey *pk); +const struct TALER_EXCHANGE_DenomPublicKey * +TALER_EXCHANGE_get_denomination_key (const struct TALER_EXCHANGE_Keys *keys, + const struct TALER_DenominationPublicKey *pk); /** - * Obtain the denomination key details from the mint. + * Obtain the denomination key details from the exchange. * - * @param keys the mint's key set + * @param keys the exchange's key set * @param hc hash of the public key of the denomination to lookup * @return details about the given denomination key */ -const struct TALER_MINT_DenomPublicKey * -TALER_MINT_get_denomination_key_by_hash (const struct TALER_MINT_Keys *keys, - const struct GNUNET_HashCode *hc); +const struct TALER_EXCHANGE_DenomPublicKey * +TALER_EXCHANGE_get_denomination_key_by_hash (const struct TALER_EXCHANGE_Keys *keys, + const struct GNUNET_HashCode *hc); /* ********************* /wire *********************** */ @@ -388,70 +389,52 @@ TALER_MINT_get_denomination_key_by_hash (const struct TALER_MINT_Keys *keys, /** * @brief A Wire format inquiry handle */ -struct TALER_MINT_WireHandle; +struct TALER_EXCHANGE_WireHandle; /** * Callbacks of this type are used to serve the result of submitting a - * wire format inquiry request to a mint. + * wire format inquiry request to a exchange. * - * The callback is invoked multiple times, once for each supported @a - * method. Finally, it is invoked one more time with cls/0/NULL/NULL - * to indicate the end of the iteration. If any request fails to - * generate a valid response from the mint, @a http_status will also - * be zero and the iteration will also end. Thus, the iteration - * always ends with a final call with an @a http_status of 0. If the - * @a http_status is already 0 on the first call, then the response to - * the /wire request was invalid. Later, clients can tell the - * difference between @a http_status of 0 indicating a failed - * /wire/method request and a regular end of the iteration by @a - * method being non-NULL. If the mint simply correctly asserts that - * it does not support any methods, @a method will be NULL but the @a - * http_status will be #MHD_HTTP_OK for the first call (followed by a - * cls/0/NULL/NULL call to signal the end of the iteration). + * If the request fails to generate a valid response from the + * exchange, @a http_status will also be zero. * * @param cls closure * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful request; - * 0 if the mint's reply is bogus (fails to follow the protocol) - * @param method wire format method supported, i.e. "test" or "sepa", or NULL - * if already the /wire request failed. + * 0 if the exchange's reply is bogus (fails to follow the protocol) * @param obj the received JSON reply, if successful this should be the wire - * format details as provided by /wire/METHOD/, or NULL if the - * reply was not in JSON format (in this case, the client might - * want to do an HTTP request to /wire/METHOD/ with a browser to - * provide more information to the user about the @a method). + * format details as provided by /wire, or NULL if the + * reply was not in JSON format. */ typedef void -(*TALER_MINT_WireResultCallback) (void *cls, - unsigned int http_status, - const char *method, - json_t *obj); +(*TALER_EXCHANGE_WireResultCallback) (void *cls, + unsigned int http_status, + json_t *obj); /** - * Obtain information about a mint's wire instructions. - * A mint may provide wire instructions for creating - * a reserve. The wire instructions also indicate - * which wire formats merchants may use with the mint. - * This API is typically used by a wallet for wiring - * funds, and possibly by a merchant to determine - * supported wire formats. + * Obtain information about a exchange's wire instructions. A + * exchange may provide wire instructions for creating a reserve. The + * wire instructions also indicate which wire formats merchants may + * use with the exchange. This API is typically used by a wallet for + * wiring funds, and possibly by a merchant to determine supported + * wire formats. * * Note that while we return the (main) response verbatim to the * caller for further processing, we do already verify that the * response is well-formed (i.e. that signatures included in the - * response are all valid). If the mint's reply is not well-formed, - * we return an HTTP status code of zero to @a cb. + * response are all valid). If the exchange's reply is not + * well-formed, we return an HTTP status code of zero to @a cb. * - * @param mint the mint handle; the mint must be ready to operate + * @param exchange the exchange handle; the exchange must be ready to operate * @param wire_cb the callback to call when a reply for this request is available * @param wire_cb_cls closure for the above callback * @return a handle for this request */ -struct TALER_MINT_WireHandle * -TALER_MINT_wire (struct TALER_MINT_Handle *mint, - TALER_MINT_WireResultCallback wire_cb, - void *wire_cb_cls); +struct TALER_EXCHANGE_WireHandle * +TALER_EXCHANGE_wire (struct TALER_EXCHANGE_Handle *exchange, + TALER_EXCHANGE_WireResultCallback wire_cb, + void *wire_cb_cls); /** @@ -461,7 +444,7 @@ TALER_MINT_wire (struct TALER_MINT_Handle *mint, * @param wh the wire information request handle */ void -TALER_MINT_wire_cancel (struct TALER_MINT_WireHandle *wh); +TALER_EXCHANGE_wire_cancel (struct TALER_EXCHANGE_WireHandle *wh); /* ********************* /deposit *********************** */ @@ -470,75 +453,75 @@ TALER_MINT_wire_cancel (struct TALER_MINT_WireHandle *wh); /** * @brief A Deposit Handle */ -struct TALER_MINT_DepositHandle; +struct TALER_EXCHANGE_DepositHandle; /** * Callbacks of this type are used to serve the result of submitting a - * deposit permission request to a mint. + * deposit permission request to a exchange. * * @param cls closure * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful deposit; - * 0 if the mint's reply is bogus (fails to follow the protocol) + * 0 if the exchange's reply is bogus (fails to follow the protocol) * @param obj the received JSON reply, should be kept as proof (and, in case of errors, * be forwarded to the customer) */ typedef void -(*TALER_MINT_DepositResultCallback) (void *cls, - unsigned int http_status, - json_t *obj); +(*TALER_EXCHANGE_DepositResultCallback) (void *cls, + unsigned int http_status, + json_t *obj); /** - * Submit a deposit permission to the mint and get the mint's + * Submit a deposit permission to the exchange and get the exchange's * response. This API is typically used by a merchant. Note that * while we return the response verbatim to the caller for further * processing, we do already verify that the response is well-formed * (i.e. that signatures included in the response are all valid). If - * the mint's reply is not well-formed, we return an HTTP status code + * the exchange's reply is not well-formed, we return an HTTP status code * of zero to @a cb. * * We also verify that the @a coin_sig is valid for this deposit * request, and that the @a ub_sig is a valid signature for @a - * coin_pub. Also, the @a mint must be ready to operate (i.e. have + * coin_pub. Also, the @a exchange must be ready to operate (i.e. have * finished processing the /keys reply). If either check fails, we do - * NOT initiate the transaction with the mint and instead return NULL. + * NOT initiate the transaction with the exchange and instead return NULL. * - * @param mint the mint handle; the mint must be ready to operate + * @param exchange the exchange handle; the exchange must be ready to operate * @param amount the amount to be deposited - * @param wire_deadline execution date, until which the merchant would like the mint to settle the balance (advisory, the mint cannot be - * forced to settle in the past or upon very short notice, but of course a well-behaved mint will limit aggregation based on the advice received) - * @param wire_details the merchant’s account details, in a format supported by the mint - * @param h_contract hash of the contact of the merchant with the customer (further details are never disclosed to the mint) + * @param wire_deadline execution date, until which the merchant would like the exchange to settle the balance (advisory, the exchange cannot be + * forced to settle in the past or upon very short notice, but of course a well-behaved exchange will limit aggregation based on the advice received) + * @param wire_details the merchant’s account details, in a format supported by the exchange + * @param h_contract hash of the contact of the merchant with the customer (further details are never disclosed to the exchange) * @param coin_pub coin’s public key * @param denom_pub denomination key with which the coin is signed - * @param denom_sig mint’s unblinded signature of the coin - * @param timestamp timestamp when the contract was finalized, must match approximately the current time of the mint + * @param denom_sig exchange’s unblinded signature of the coin + * @param timestamp timestamp when the contract was finalized, must match approximately the current time of the exchange * @param transaction_id transaction id for the transaction between merchant and customer * @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests) - * @param refund_deadline date until which the merchant can issue a refund to the customer via the mint (can be zero if refunds are not allowed) + * @param refund_deadline date until which the merchant can issue a refund to the customer via the exchange (can be zero if refunds are not allowed) * @param coin_sig the signature made with purpose #TALER_SIGNATURE_WALLET_COIN_DEPOSIT made by the customer with the coin’s private key. * @param cb the callback to call when a reply for this request is available * @param cb_cls closure for the above callback * @return a handle for this request; NULL if the inputs are invalid (i.e. * signatures fail to verify). In this case, the callback is not called. */ -struct TALER_MINT_DepositHandle * -TALER_MINT_deposit (struct TALER_MINT_Handle *mint, - const struct TALER_Amount *amount, - struct GNUNET_TIME_Absolute wire_deadline, - json_t *wire_details, - const struct GNUNET_HashCode *h_contract, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_DenominationSignature *denom_sig, - const struct TALER_DenominationPublicKey *denom_pub, - struct GNUNET_TIME_Absolute timestamp, - uint64_t transaction_id, - const struct TALER_MerchantPublicKeyP *merchant_pub, - struct GNUNET_TIME_Absolute refund_deadline, - const struct TALER_CoinSpendSignatureP *coin_sig, - TALER_MINT_DepositResultCallback cb, - void *cb_cls); +struct TALER_EXCHANGE_DepositHandle * +TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange, + const struct TALER_Amount *amount, + struct GNUNET_TIME_Absolute wire_deadline, + json_t *wire_details, + const struct GNUNET_HashCode *h_contract, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct TALER_DenominationSignature *denom_sig, + const struct TALER_DenominationPublicKey *denom_pub, + struct GNUNET_TIME_Absolute timestamp, + uint64_t transaction_id, + const struct TALER_MerchantPublicKeyP *merchant_pub, + struct GNUNET_TIME_Absolute refund_deadline, + const struct TALER_CoinSpendSignatureP *coin_sig, + TALER_EXCHANGE_DepositResultCallback cb, + void *cb_cls); /** @@ -548,7 +531,7 @@ TALER_MINT_deposit (struct TALER_MINT_Handle *mint, * @param deposit the deposit permission request handle */ void -TALER_MINT_deposit_cancel (struct TALER_MINT_DepositHandle *deposit); +TALER_EXCHANGE_deposit_cancel (struct TALER_EXCHANGE_DepositHandle *deposit); /* ********************* /reserve/status *********************** */ @@ -557,23 +540,23 @@ TALER_MINT_deposit_cancel (struct TALER_MINT_DepositHandle *deposit); /** * @brief A /reserve/status Handle */ -struct TALER_MINT_ReserveStatusHandle; +struct TALER_EXCHANGE_ReserveStatusHandle; /** * Ways how a reserve's balance may change. */ -enum TALER_MINT_ReserveTransactionType { +enum TALER_EXCHANGE_ReserveTransactionType { /** * Deposit into the reserve. */ - TALER_MINT_RTT_DEPOSIT, + TALER_EXCHANGE_RTT_DEPOSIT, /** * Withdrawal from the reserve. */ - TALER_MINT_RTT_WITHDRAWAL + TALER_EXCHANGE_RTT_WITHDRAWAL }; @@ -581,13 +564,13 @@ enum TALER_MINT_ReserveTransactionType { /** * @brief Entry in the reserve's transaction history. */ -struct TALER_MINT_ReserveHistory +struct TALER_EXCHANGE_ReserveHistory { /** * Type of the transaction. */ - enum TALER_MINT_ReserveTransactionType type; + enum TALER_EXCHANGE_ReserveTransactionType type; /** * Amount transferred (in or out). @@ -616,46 +599,46 @@ struct TALER_MINT_ReserveHistory /** * Callbacks of this type are used to serve the result of submitting a - * deposit permission request to a mint. + * reserve status request to a exchange. * * @param cls closure * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request - * 0 if the mint's reply is bogus (fails to follow the protocol) + * 0 if the exchange's reply is bogus (fails to follow the protocol) * @param[in] json original response in JSON format (useful only for diagnostics) * @param balance current balance in the reserve, NULL on error * @param history_length number of entries in the transaction history, 0 on error * @param history detailed transaction history, NULL on error */ typedef void -(*TALER_MINT_ReserveStatusResultCallback) (void *cls, - unsigned int http_status, - json_t *json, - const struct TALER_Amount *balance, - unsigned int history_length, - const struct TALER_MINT_ReserveHistory *history); +(*TALER_EXCHANGE_ReserveStatusResultCallback) (void *cls, + unsigned int http_status, + json_t *json, + const struct TALER_Amount *balance, + unsigned int history_length, + const struct TALER_EXCHANGE_ReserveHistory *history); /** * Submit a request to obtain the transaction history of a reserve - * from the mint. Note that while we return the full response to the + * from the exchange. Note that while we return the full response to the * caller for further processing, we do already verify that the * response is well-formed (i.e. that signatures included in the - * response are all valid and add up to the balance). If the mint's + * response are all valid and add up to the balance). If the exchange's * reply is not well-formed, we return an HTTP status code of zero to * @a cb. * - * @param mint the mint handle; the mint must be ready to operate + * @param exchange the exchange handle; the exchange must be ready to operate * @param reserve_pub public key of the reserve to inspect * @param cb the callback to call when a reply for this request is available * @param cb_cls closure for the above callback * @return a handle for this request; NULL if the inputs are invalid (i.e. * signatures fail to verify). In this case, the callback is not called. */ -struct TALER_MINT_ReserveStatusHandle * -TALER_MINT_reserve_status (struct TALER_MINT_Handle *mint, - const struct TALER_ReservePublicKeyP *reserve_pub, - TALER_MINT_ReserveStatusResultCallback cb, - void *cb_cls); +struct TALER_EXCHANGE_ReserveStatusHandle * +TALER_EXCHANGE_reserve_status (struct TALER_EXCHANGE_Handle *exchange, + const struct TALER_ReservePublicKeyP *reserve_pub, + TALER_EXCHANGE_ReserveStatusResultCallback cb, + void *cb_cls); /** @@ -665,7 +648,7 @@ TALER_MINT_reserve_status (struct TALER_MINT_Handle *mint, * @param wsh the withdraw status request handle */ void -TALER_MINT_reserve_status_cancel (struct TALER_MINT_ReserveStatusHandle *wsh); +TALER_EXCHANGE_reserve_status_cancel (struct TALER_EXCHANGE_ReserveStatusHandle *wsh); /* ********************* /reserve/withdraw *********************** */ @@ -674,35 +657,35 @@ TALER_MINT_reserve_status_cancel (struct TALER_MINT_ReserveStatusHandle *wsh); /** * @brief A /reserve/withdraw Handle */ -struct TALER_MINT_ReserveWithdrawHandle; +struct TALER_EXCHANGE_ReserveWithdrawHandle; /** * Callbacks of this type are used to serve the result of submitting a - * deposit permission request to a mint. + * withdraw request to a exchange. * * @param cls closure * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request - * 0 if the mint's reply is bogus (fails to follow the protocol) + * 0 if the exchange's reply is bogus (fails to follow the protocol) * @param sig signature over the coin, NULL on error - * @param full_response full response from the mint (for logging, in case of errors) + * @param full_response full response from the exchange (for logging, in case of errors) */ typedef void -(*TALER_MINT_ReserveWithdrawResultCallback) (void *cls, - unsigned int http_status, - const struct TALER_DenominationSignature *sig, - json_t *full_response); +(*TALER_EXCHANGE_ReserveWithdrawResultCallback) (void *cls, + unsigned int http_status, + const struct TALER_DenominationSignature *sig, + json_t *full_response); /** - * Withdraw a coin from the mint using a /reserve/withdraw request. This + * Withdraw a coin from the exchange using a /reserve/withdraw request. This * API is typically used by a wallet. Note that to ensure that no * money is lost in case of hardware failures, the caller must have * committed (most of) the arguments to disk before calling, and be * ready to repeat the request with the same arguments in case of * failures. * - * @param mint the mint handle; the mint must be ready to operate + * @param exchange the exchange handle; the exchange must be ready to operate * @param pk kind of coin to create * @param reserve_priv private key of the reserve to withdraw from * @param coin_priv where to store the coin's private key, @@ -712,16 +695,16 @@ typedef void * @param res_cb the callback to call when the final result for this request is available * @param res_cb_cls closure for @a res_cb * @return NULL - * if the inputs are invalid (i.e. denomination key not with this mint). + * if the inputs are invalid (i.e. denomination key not with this exchange). * In this case, the callback is not called. */ -struct TALER_MINT_ReserveWithdrawHandle * -TALER_MINT_reserve_withdraw (struct TALER_MINT_Handle *mint, - const struct TALER_MINT_DenomPublicKey *pk, +struct TALER_EXCHANGE_ReserveWithdrawHandle * +TALER_EXCHANGE_reserve_withdraw (struct TALER_EXCHANGE_Handle *exchange, + const struct TALER_EXCHANGE_DenomPublicKey *pk, const struct TALER_ReservePrivateKeyP *reserve_priv, const struct TALER_CoinSpendPrivateKeyP *coin_priv, const struct TALER_DenominationBlindingKey *blinding_key, - TALER_MINT_ReserveWithdrawResultCallback res_cb, + TALER_EXCHANGE_ReserveWithdrawResultCallback res_cb, void *res_cb_cls); @@ -732,7 +715,7 @@ TALER_MINT_reserve_withdraw (struct TALER_MINT_Handle *mint, * @param sign the withdraw sign request handle */ void -TALER_MINT_reserve_withdraw_cancel (struct TALER_MINT_ReserveWithdrawHandle *sign); +TALER_EXCHANGE_reserve_withdraw_cancel (struct TALER_EXCHANGE_ReserveWithdrawHandle *sign); /* ********************* /refresh/melt+reveal ***************************** */ @@ -748,7 +731,7 @@ TALER_MINT_reserve_withdraw_cancel (struct TALER_MINT_ReserveWithdrawHandle *sig * no money is lost in case of hardware failures, is operation does * not actually initiate the request. Instead, it generates a buffer * which the caller must store before proceeding with the actual call - * to #TALER_MINT_refresh_melt() that will generate the request. + * to #TALER_EXCHANGE_refresh_melt() that will generate the request. * * This function does verify that the given request data is internally * consistent. However, the @a melts_sigs are only verified if @a @@ -775,21 +758,21 @@ TALER_MINT_reserve_withdraw_cancel (struct TALER_MINT_ReserveWithdrawHandle *sig * @param fresh_pks array of @a pks_len denominations of fresh coins to create * @param[out] res_size set to the size of the return value, or 0 on error * @return NULL - * if the inputs are invalid (i.e. denomination key not with this mint). + * if the inputs are invalid (i.e. denomination key not with this exchange). * Otherwise, pointer to a buffer of @a res_size to store persistently - * before proceeding to #TALER_MINT_refresh_melt(). + * before proceeding to #TALER_EXCHANGE_refresh_melt(). * Non-null results should be freed using #GNUNET_free(). */ char * -TALER_MINT_refresh_prepare (unsigned int num_melts, - const struct TALER_CoinSpendPrivateKeyP *melt_privs, - const struct TALER_Amount *melt_amounts, - const struct TALER_DenominationSignature *melt_sigs, - const struct TALER_MINT_DenomPublicKey *melt_pks, - int check_sigs, - unsigned int fresh_pks_len, - const struct TALER_MINT_DenomPublicKey *fresh_pks, - size_t *res_size); +TALER_EXCHANGE_refresh_prepare (unsigned int num_melts, + const struct TALER_CoinSpendPrivateKeyP *melt_privs, + const struct TALER_Amount *melt_amounts, + const struct TALER_DenominationSignature *melt_sigs, + const struct TALER_EXCHANGE_DenomPublicKey *melt_pks, + int check_sigs, + unsigned int fresh_pks_len, + const struct TALER_EXCHANGE_DenomPublicKey *fresh_pks, + size_t *res_size); /* ********************* /refresh/melt ***************************** */ @@ -797,54 +780,54 @@ TALER_MINT_refresh_prepare (unsigned int num_melts, /** * @brief A /refresh/melt Handle */ -struct TALER_MINT_RefreshMeltHandle; +struct TALER_EXCHANGE_RefreshMeltHandle; /** * Callbacks of this type are used to notify the application about the * result of the /refresh/melt stage. If successful, the @a noreveal_index - * should be committed to disk prior to proceeding #TALER_MINT_refresh_reveal(). + * should be committed to disk prior to proceeding #TALER_EXCHANGE_refresh_reveal(). * * @param cls closure * @param http_status HTTP response code, never #MHD_HTTP_OK (200) as for successful intermediate response this callback is skipped. - * 0 if the mint's reply is bogus (fails to follow the protocol) - * @param noreveal_index choice by the mint in the cut-and-choose protocol, + * 0 if the exchange's reply is bogus (fails to follow the protocol) + * @param noreveal_index choice by the exchange in the cut-and-choose protocol, * UINT16_MAX on error - * @param full_response full response from the mint (for logging, in case of errors) + * @param full_response full response from the exchange (for logging, in case of errors) */ typedef void -(*TALER_MINT_RefreshMeltCallback) (void *cls, +(*TALER_EXCHANGE_RefreshMeltCallback) (void *cls, unsigned int http_status, uint16_t noreveal_index, json_t *full_response); /** - * Submit a melt request to the mint and get the mint's + * Submit a refresh melt request to the exchange and get the exchange's * response. * * This API is typically used by a wallet. Note that to ensure that * no money is lost in case of hardware failures, the provided * argument should have been constructed using - * #TALER_MINT_refresh_prepare and committed to persistent storage + * #TALER_EXCHANGE_refresh_prepare and committed to persistent storage * prior to calling this function. * - * @param mint the mint handle; the mint must be ready to operate + * @param exchange the exchange handle; the exchange must be ready to operate * @param refresh_data_length size of the @a refresh_data (returned - * in the `res_size` argument from #TALER_MINT_refresh_prepare()) + * in the `res_size` argument from #TALER_EXCHANGE_refresh_prepare()) * @param refresh_data the refresh data as returned from - #TALER_MINT_refresh_prepare()) + #TALER_EXCHANGE_refresh_prepare()) * @param melt_cb the callback to call with the result * @param melt_cb_cls closure for @a melt_cb * @return a handle for this request; NULL if the argument was invalid. * In this case, neither callback will be called. */ -struct TALER_MINT_RefreshMeltHandle * -TALER_MINT_refresh_melt (struct TALER_MINT_Handle *mint, - size_t refresh_data_length, - const char *refresh_data, - TALER_MINT_RefreshMeltCallback melt_cb, - void *melt_cb_cls); +struct TALER_EXCHANGE_RefreshMeltHandle * +TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange, + size_t refresh_data_length, + const char *refresh_data, + TALER_EXCHANGE_RefreshMeltCallback melt_cb, + void *melt_cb_cls); /** @@ -854,7 +837,7 @@ TALER_MINT_refresh_melt (struct TALER_MINT_Handle *mint, * @param rmh the refresh handle */ void -TALER_MINT_refresh_melt_cancel (struct TALER_MINT_RefreshMeltHandle *rmh); +TALER_EXCHANGE_refresh_melt_cancel (struct TALER_EXCHANGE_RefreshMeltHandle *rmh); /* ********************* /refresh/reveal ***************************** */ @@ -862,7 +845,7 @@ TALER_MINT_refresh_melt_cancel (struct TALER_MINT_RefreshMeltHandle *rmh); /** * Callbacks of this type are used to return the final result of - * submitting a refresh request to a mint. If the operation was + * submitting a refresh request to a exchange. If the operation was * successful, this function returns the signatures over the coins * that were remelted. The @a coin_privs and @a sigs arrays give the * coins in the same order (and should have the same length) in which @@ -870,30 +853,30 @@ TALER_MINT_refresh_melt_cancel (struct TALER_MINT_RefreshMeltHandle *rmh); * * @param cls closure * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request - * 0 if the mint's reply is bogus (fails to follow the protocol) + * 0 if the exchange's reply is bogus (fails to follow the protocol) * @param num_coins number of fresh coins created, length of the @a sigs and @a coin_privs arrays, 0 if the operation failed * @param coin_privs array of @a num_coins private keys for the coins that were created, NULL on error * @param sigs array of signature over @a num_coins coins, NULL on error - * @param full_response full response from the mint (for logging, in case of errors) + * @param full_response full response from the exchange (for logging, in case of errors) */ typedef void -(*TALER_MINT_RefreshRevealCallback) (void *cls, - unsigned int http_status, +(*TALER_EXCHANGE_RefreshRevealCallback) (void *cls, + unsigned int http_status, - unsigned int num_coins, - const struct TALER_CoinSpendPrivateKeyP *coin_privs, - const struct TALER_DenominationSignature *sigs, - json_t *full_response); + unsigned int num_coins, + const struct TALER_CoinSpendPrivateKeyP *coin_privs, + const struct TALER_DenominationSignature *sigs, + json_t *full_response); /** * @brief A /refresh/reveal Handle */ -struct TALER_MINT_RefreshRevealHandle; +struct TALER_EXCHANGE_RefreshRevealHandle; /** - * Submit a /refresh/reval request to the mint and get the mint's + * Submit a /refresh/reval request to the exchange and get the exchange's * response. * * This API is typically used by a wallet. Note that to ensure that @@ -901,26 +884,26 @@ struct TALER_MINT_RefreshRevealHandle; * arguments should have been committed to persistent storage * prior to calling this function. * - * @param mint the mint handle; the mint must be ready to operate + * @param exchange the exchange handle; the exchange must be ready to operate * @param refresh_data_length size of the @a refresh_data (returned - * in the `res_size` argument from #TALER_MINT_refresh_prepare()) + * in the `res_size` argument from #TALER_EXCHANGE_refresh_prepare()) * @param refresh_data the refresh data as returned from - #TALER_MINT_refresh_prepare()) - * @param noreveal_index response from the mint to the - * #TALER_MINT_refresh_melt() invocation + #TALER_EXCHANGE_refresh_prepare()) + * @param noreveal_index response from the exchange to the + * #TALER_EXCHANGE_refresh_melt() invocation * @param reveal_cb the callback to call with the final result of the * refresh operation * @param reveal_cb_cls closure for the above callback * @return a handle for this request; NULL if the argument was invalid. * In this case, neither callback will be called. */ -struct TALER_MINT_RefreshRevealHandle * -TALER_MINT_refresh_reveal (struct TALER_MINT_Handle *mint, - size_t refresh_data_length, - const char *refresh_data, - uint16_t noreveal_index, - TALER_MINT_RefreshRevealCallback reveal_cb, - void *reveal_cb_cls); +struct TALER_EXCHANGE_RefreshRevealHandle * +TALER_EXCHANGE_refresh_reveal (struct TALER_EXCHANGE_Handle *exchange, + size_t refresh_data_length, + const char *refresh_data, + uint16_t noreveal_index, + TALER_EXCHANGE_RefreshRevealCallback reveal_cb, + void *reveal_cb_cls); /** @@ -930,7 +913,7 @@ TALER_MINT_refresh_reveal (struct TALER_MINT_Handle *mint, * @param rrh the refresh reval handle */ void -TALER_MINT_refresh_reveal_cancel (struct TALER_MINT_RefreshRevealHandle *rrh); +TALER_EXCHANGE_refresh_reveal_cancel (struct TALER_EXCHANGE_RefreshRevealHandle *rrh); /* ********************* /refresh/link ***************************** */ @@ -939,53 +922,54 @@ TALER_MINT_refresh_reveal_cancel (struct TALER_MINT_RefreshRevealHandle *rrh); /** * @brief A /refresh/link Handle */ -struct TALER_MINT_RefreshLinkHandle; +struct TALER_EXCHANGE_RefreshLinkHandle; /** * Callbacks of this type are used to return the final result of - * submitting a /refresh/link request to a mint. If the operation was + * submitting a /refresh/link request to a exchange. If the operation was * successful, this function returns the signatures over the coins * that were created when the original coin was melted. * * @param cls closure * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request - * 0 if the mint's reply is bogus (fails to follow the protocol) + * 0 if the exchange's reply is bogus (fails to follow the protocol) * @param num_coins number of fresh coins created, length of the @a sigs and @a coin_privs arrays, 0 if the operation failed * @param coin_privs array of @a num_coins private keys for the coins that were created, NULL on error * @param sigs array of signature over @a num_coins coins, NULL on error * @param pubs array of public keys for the @a sigs, NULL on error - * @param full_response full response from the mint (for logging, in case of errors) + * @param full_response full response from the exchange (for logging, in case of errors) */ typedef void -(*TALER_MINT_RefreshLinkCallback) (void *cls, - unsigned int http_status, - unsigned int num_coins, - const struct TALER_CoinSpendPrivateKeyP *coin_privs, - const struct TALER_DenominationSignature *sigs, - const struct TALER_DenominationPublicKey *pubs, - json_t *full_response); +(*TALER_EXCHANGE_RefreshLinkCallback) (void *cls, + unsigned int http_status, + unsigned int num_coins, + const struct TALER_CoinSpendPrivateKeyP *coin_privs, + const struct TALER_DenominationSignature *sigs, + const struct TALER_DenominationPublicKey *pubs, + json_t *full_response); /** - * Submit a link request to the mint and get the mint's response. + * Submit a refresh link request to the exchange and get the + * exchange's response. * * This API is typically not used by anyone, it is more a threat * against those trying to receive a funds transfer by abusing the * /refresh protocol. * - * @param mint the mint handle; the mint must be ready to operate + * @param exchange the exchange handle; the exchange must be ready to operate * @param coin_priv private key to request link data for * @param link_cb the callback to call with the useful result of the * refresh operation the @a coin_priv was involved in (if any) * @param link_cb_cls closure for @a link_cb * @return a handle for this request */ -struct TALER_MINT_RefreshLinkHandle * -TALER_MINT_refresh_link (struct TALER_MINT_Handle *mint, - const struct TALER_CoinSpendPrivateKeyP *coin_priv, - TALER_MINT_RefreshLinkCallback link_cb, - void *link_cb_cls); +struct TALER_EXCHANGE_RefreshLinkHandle * +TALER_EXCHANGE_refresh_link (struct TALER_EXCHANGE_Handle *exchange, + const struct TALER_CoinSpendPrivateKeyP *coin_priv, + TALER_EXCHANGE_RefreshLinkCallback link_cb, + void *link_cb_cls); /** @@ -995,7 +979,7 @@ TALER_MINT_refresh_link (struct TALER_MINT_Handle *mint, * @param rlh the refresh link handle */ void -TALER_MINT_refresh_link_cancel (struct TALER_MINT_RefreshLinkHandle *rlh); +TALER_EXCHANGE_refresh_link_cancel (struct TALER_EXCHANGE_RefreshLinkHandle *rlh); /* ********************* /admin/add/incoming *********************** */ @@ -1004,31 +988,31 @@ TALER_MINT_refresh_link_cancel (struct TALER_MINT_RefreshLinkHandle *rlh); /** * @brief A /admin/add/incoming Handle */ -struct TALER_MINT_AdminAddIncomingHandle; +struct TALER_EXCHANGE_AdminAddIncomingHandle; /** * Callbacks of this type are used to serve the result of submitting - * information about an incoming transaction to a mint. + * information about an incoming transaction to a exchange. * * @param cls closure * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request - * 0 if the mint's reply is bogus (fails to follow the protocol) - * @param full_response full response from the mint (for logging, in case of errors) + * 0 if the exchange's reply is bogus (fails to follow the protocol) + * @param full_response full response from the exchange (for logging, in case of errors) */ typedef void -(*TALER_MINT_AdminAddIncomingResultCallback) (void *cls, - unsigned int http_status, - json_t *full_response); +(*TALER_EXCHANGE_AdminAddIncomingResultCallback) (void *cls, + unsigned int http_status, + json_t *full_response); /** - * Notify the mint that we have received an incoming transaction + * Notify the exchange that we have received an incoming transaction * which fills a reserve. Note that this API is an administrative - * API and thus not accessible to typical mint clients, but only - * to the operators of the mint. + * API and thus not accessible to typical exchange clients, but only + * to the operators of the exchange. * - * @param mint the mint handle; the mint must be ready to operate + * @param exchange the exchange handle; the exchange must be ready to operate * @param reserve_pub public key of the reserve * @param amount amount that was deposited * @param execution_date when did we receive the amount @@ -1039,14 +1023,14 @@ typedef void * if the inputs are invalid (i.e. invalid amount). * In this case, the callback is not called. */ -struct TALER_MINT_AdminAddIncomingHandle * -TALER_MINT_admin_add_incoming (struct TALER_MINT_Handle *mint, - const struct TALER_ReservePublicKeyP *reserve_pub, - const struct TALER_Amount *amount, - struct GNUNET_TIME_Absolute execution_date, - const json_t *wire, - TALER_MINT_AdminAddIncomingResultCallback res_cb, - void *res_cb_cls); +struct TALER_EXCHANGE_AdminAddIncomingHandle * +TALER_EXCHANGE_admin_add_incoming (struct TALER_EXCHANGE_Handle *exchange, + const struct TALER_ReservePublicKeyP *reserve_pub, + const struct TALER_Amount *amount, + struct GNUNET_TIME_Absolute execution_date, + const json_t *wire, + TALER_EXCHANGE_AdminAddIncomingResultCallback res_cb, + void *res_cb_cls); /** @@ -1056,7 +1040,7 @@ TALER_MINT_admin_add_incoming (struct TALER_MINT_Handle *mint, * @param aai the admin add incoming request handle */ void -TALER_MINT_admin_add_incoming_cancel (struct TALER_MINT_AdminAddIncomingHandle *aai); +TALER_EXCHANGE_admin_add_incoming_cancel (struct TALER_EXCHANGE_AdminAddIncomingHandle *aai); /* ********************* /wire/deposits *********************** */ @@ -1064,12 +1048,12 @@ TALER_MINT_admin_add_incoming_cancel (struct TALER_MINT_AdminAddIncomingHandle * /** * @brief A /wire/deposits Handle */ -struct TALER_MINT_WireDepositsHandle; +struct TALER_EXCHANGE_WireDepositsHandle; /** * Details for one of the /deposit operations that the - * mint combined into a single wire transfer. + * exchange combined into a single wire transfer. */ struct TALER_WireDepositDetails { @@ -1089,7 +1073,7 @@ struct TALER_WireDepositDetails struct TALER_Amount coin_value; /** - * Fee charged by the mint for the deposit. + * Fee charged by the exchange for the deposit. */ struct TALER_Amount coin_fee; @@ -1106,41 +1090,41 @@ struct TALER_WireDepositDetails * of the coin transactions that were combined into the wire transfer. * * @param cls closure - * @param http_status HTTP status code we got, 0 on mint protocol violation + * @param http_status HTTP status code we got, 0 on exchange protocol violation * @param json original json reply (may include signatures, those have then been * validated already) - * @param wtid extracted wire transfer identifier, or NULL if the mint could + * @param wtid extracted wire transfer identifier, or NULL if the exchange could * not provide any (set only if @a http_status is #MHD_HTTP_OK) - * @param total_amount total amount of the wire transfer, or NULL if the mint could + * @param total_amount total amount of the wire transfer, or NULL if the exchange could * not provide any @a wtid (set only if @a http_status is #MHD_HTTP_OK) * @param details_length length of the @a details array * @param details array with details about the combined transactions */ typedef void -(*TALER_MINT_WireDepositsCallback)(void *cls, - unsigned int http_status, - json_t *json, - const struct GNUNET_HashCode *h_wire, - const struct TALER_Amount *total_amount, - unsigned int details_length, - const struct TALER_WireDepositDetails *details); +(*TALER_EXCHANGE_WireDepositsCallback)(void *cls, + unsigned int http_status, + json_t *json, + const struct GNUNET_HashCode *h_wire, + const struct TALER_Amount *total_amount, + unsigned int details_length, + const struct TALER_WireDepositDetails *details); /** - * Query the mint about which transactions were combined + * Query the exchange about which transactions were combined * to create a wire transfer. * - * @param mint mint to query + * @param exchange exchange to query * @param wtid raw wire transfer identifier to get information about * @param cb callback to call * @param cb_cls closure for @a cb * @return handle to cancel operation */ -struct TALER_MINT_WireDepositsHandle * -TALER_MINT_wire_deposits (struct TALER_MINT_Handle *mint, - const struct TALER_WireTransferIdentifierRawP *wtid, - TALER_MINT_WireDepositsCallback cb, - void *cb_cls); +struct TALER_EXCHANGE_WireDepositsHandle * +TALER_EXCHANGE_wire_deposits (struct TALER_EXCHANGE_Handle *exchange, + const struct TALER_WireTransferIdentifierRawP *wtid, + TALER_EXCHANGE_WireDepositsCallback cb, + void *cb_cls); /** @@ -1150,7 +1134,7 @@ TALER_MINT_wire_deposits (struct TALER_MINT_Handle *mint, * @param wdh the wire deposits request handle */ void -TALER_MINT_wire_deposits_cancel (struct TALER_MINT_WireDepositsHandle *wdh); +TALER_EXCHANGE_wire_deposits_cancel (struct TALER_EXCHANGE_WireDepositsHandle *wdh); /* ********************* /deposit/wtid *********************** */ @@ -1159,34 +1143,34 @@ TALER_MINT_wire_deposits_cancel (struct TALER_MINT_WireDepositsHandle *wdh); /** * @brief A /deposit/wtid Handle */ -struct TALER_MINT_DepositWtidHandle; +struct TALER_EXCHANGE_DepositWtidHandle; /** * Function called with detailed wire transfer data. * * @param cls closure - * @param http_status HTTP status code we got, 0 on mint protocol violation + * @param http_status HTTP status code we got, 0 on exchange protocol violation * @param json original json reply (may include signatures, those have then been * validated already) - * @param wtid wire transfer identifier used by the mint, NULL if mint did not + * @param wtid wire transfer identifier used by the exchange, NULL if exchange did not * yet execute the transaction * @param execution_time actual or planned execution time for the wire transfer * @param coin_contribution contribution to the @a total_amount of the deposited coin (may be NULL) */ typedef void -(*TALER_MINT_DepositWtidCallback)(void *cls, - unsigned int http_status, - json_t *json, - const struct TALER_WireTransferIdentifierRawP *wtid, - struct GNUNET_TIME_Absolute execution_time, - const struct TALER_Amount *coin_contribution); +(*TALER_EXCHANGE_DepositWtidCallback)(void *cls, + unsigned int http_status, + json_t *json, + const struct TALER_WireTransferIdentifierRawP *wtid, + struct GNUNET_TIME_Absolute execution_time, + const struct TALER_Amount *coin_contribution); /** * Obtain the wire transfer details for a given deposit. * - * @param mint the mint to query + * @param exchange the exchange to query * @param merchant_priv the merchant's private key * @param h_wire hash of merchant's wire transfer details * @param h_contract hash of the contract @@ -1196,15 +1180,15 @@ typedef void * @param cb_cls closure for @a cb * @return handle to abort request */ -struct TALER_MINT_DepositWtidHandle * -TALER_MINT_deposit_wtid (struct TALER_MINT_Handle *mint, - const struct TALER_MerchantPrivateKeyP *merchant_priv, - const struct GNUNET_HashCode *h_wire, - const struct GNUNET_HashCode *h_contract, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - uint64_t transaction_id, - TALER_MINT_DepositWtidCallback cb, - void *cb_cls); +struct TALER_EXCHANGE_DepositWtidHandle * +TALER_EXCHANGE_deposit_wtid (struct TALER_EXCHANGE_Handle *exchange, + const struct TALER_MerchantPrivateKeyP *merchant_priv, + const struct GNUNET_HashCode *h_wire, + const struct GNUNET_HashCode *h_contract, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + uint64_t transaction_id, + TALER_EXCHANGE_DepositWtidCallback cb, + void *cb_cls); /** @@ -1214,7 +1198,7 @@ TALER_MINT_deposit_wtid (struct TALER_MINT_Handle *mint, * @param dwh the wire deposits request handle */ void -TALER_MINT_deposit_wtid_cancel (struct TALER_MINT_DepositWtidHandle *dwh); +TALER_EXCHANGE_deposit_wtid_cancel (struct TALER_EXCHANGE_DepositWtidHandle *dwh); -#endif /* _TALER_MINT_SERVICE_H */ +#endif /* _TALER_EXCHANGE_SERVICE_H */ diff --git a/src/include/taler_mintdb_lib.h b/src/include/taler_exchangedb_lib.h index 70e314d9a..1f6445212 100644 --- a/src/include/taler_mintdb_lib.h +++ b/src/include/taler_exchangedb_lib.h @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014, 2015 GNUnet e.V. + Copyright (C) 2014, 2015, 2016 Inria & GNUnet e.V. 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 @@ -14,62 +14,56 @@ TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/> */ /** - * @file include/taler_mintdb_lib.h - * @brief IO operations for the mint's private keys + * @file include/taler_exchangedb_lib.h + * @brief IO operations for the exchange's private keys * @author Florian Dold * @author Benedikt Mueller * @author Christian Grothoff */ -#ifndef TALER_MINTDB_LIB_H -#define TALER_MINTDB_LIB_H +#ifndef TALER_EXCHANGEDB_LIB_H +#define TALER_EXCHANGEDB_LIB_H #include "taler_signatures.h" /** - * Subdirectroy under the mint's base directory which contains - * the mint's signing keys. + * Subdirectroy under the exchange's base directory which contains + * the exchange's signing keys. */ -#define TALER_MINTDB_DIR_SIGNING_KEYS "signkeys" +#define TALER_EXCHANGEDB_DIR_SIGNING_KEYS "signkeys" /** - * Subdirectory under the mint's base directory which contains - * the mint's denomination keys. + * Subdirectory under the exchange's base directory which contains + * the exchange's denomination keys. */ -#define TALER_MINTDB_DIR_DENOMINATION_KEYS "denomkeys" - -/** - * Subdirectory under the mint's base directory which contains - * the mint's auditing information. - */ -#define TALER_MINTDB_DIR_AUDITORS "auditors" +#define TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS "denomkeys" GNUNET_NETWORK_STRUCT_BEGIN /** - * @brief On disk format used for a mint signing key. Signing keys are used - * by the mint to affirm its messages, but not to create coins. + * @brief On disk format used for a exchange signing key. Signing keys are used + * by the exchange to affirm its messages, but not to create coins. * Includes the private key followed by the public information about * the signing key. */ -struct TALER_MINTDB_PrivateSigningKeyInformationP +struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP { /** - * Private key part of the mint's signing key. + * Private key part of the exchange's signing key. */ - struct TALER_MintPrivateKeyP signkey_priv; + struct TALER_ExchangePrivateKeyP signkey_priv; /** - * Public information about a mint signing key. + * Public information about a exchange signing key. */ - struct TALER_MintSigningKeyValidityPS issue; + struct TALER_ExchangeSigningKeyValidityPS issue; }; /** * Information about a denomination key. */ -struct TALER_MINTDB_DenominationKeyInformationP +struct TALER_EXCHANGEDB_DenominationKeyInformationP { /** @@ -91,7 +85,7 @@ GNUNET_NETWORK_STRUCT_END * @brief All information about a denomination key (which is used to * sign coins into existence). */ -struct TALER_MINTDB_DenominationKeyIssueInformation +struct TALER_EXCHANGEDB_DenominationKeyIssueInformation { /** * The private key of the denomination. Will be NULL if the private @@ -109,7 +103,7 @@ struct TALER_MINTDB_DenominationKeyIssueInformation /** * Signed public information about a denomination key. */ - struct TALER_MINTDB_DenominationKeyInformationP issue; + struct TALER_EXCHANGEDB_DenominationKeyInformationP issue; }; @@ -124,16 +118,16 @@ struct TALER_MINTDB_DenominationKeyIssueInformation * #GNUNET_SYSERR to abort iteration with error! */ typedef int -(*TALER_MINTDB_SigningKeyIterator)(void *cls, - const char *filename, - const struct TALER_MINTDB_PrivateSigningKeyInformationP *ski); +(*TALER_EXCHANGEDB_SigningKeyIterator)(void *cls, + const char *filename, + const struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP *ski); /** - * Call @a it for each signing key found in the @a mint_base_dir. + * Call @a it for each signing key found in the @a exchange_base_dir. * - * @param mint_base_dir base directory for the mint, - * the signing keys must be in the #TALER_MINTDB_DIR_SIGNING_KEYS + * @param exchange_base_dir base directory for the exchange, + * the signing keys must be in the #TALER_EXCHANGEDB_DIR_SIGNING_KEYS * subdirectory * @param it function to call on each signing key * @param it_cls closure for @a it @@ -142,9 +136,9 @@ typedef int * files are simply skipped), -1 on error */ int -TALER_MINTDB_signing_keys_iterate (const char *mint_base_dir, - TALER_MINTDB_SigningKeyIterator it, - void *it_cls); +TALER_EXCHANGEDB_signing_keys_iterate (const char *exchange_base_dir, + TALER_EXCHANGEDB_SigningKeyIterator it, + void *it_cls); @@ -159,16 +153,16 @@ TALER_MINTDB_signing_keys_iterate (const char *mint_base_dir, * #GNUNET_SYSERR to abort iteration with error! */ typedef int -(*TALER_MINTDB_DenominationKeyIterator)(void *cls, - const char *alias, - const struct TALER_MINTDB_DenominationKeyIssueInformation *dki); +(*TALER_EXCHANGEDB_DenominationKeyIterator)(void *cls, + const char *alias, + const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki); /** - * Call @a it for each denomination key found in the @a mint_base_dir. + * Call @a it for each denomination key found in the @a exchange_base_dir. * - * @param mint_base_dir base directory for the mint, - * the signing keys must be in the #TALER_MINTDB_DIR_DENOMINATION_KEYS + * @param exchange_base_dir base directory for the exchange, + * the signing keys must be in the #TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS * subdirectory * @param it function to call on each denomination key found * @param it_cls closure for @a it @@ -178,9 +172,9 @@ typedef int * as maybe none of the files were well-formed) */ int -TALER_MINTDB_denomination_keys_iterate (const char *mint_base_dir, - TALER_MINTDB_DenominationKeyIterator it, - void *it_cls); +TALER_EXCHANGEDB_denomination_keys_iterate (const char *exchange_base_dir, + TALER_EXCHANGEDB_DenominationKeyIterator it, + void *it_cls); /** @@ -191,8 +185,8 @@ TALER_MINTDB_denomination_keys_iterate (const char *mint_base_dir, * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure. */ int -TALER_MINTDB_denomination_key_write (const char *filename, - const struct TALER_MINTDB_DenominationKeyIssueInformation *dki); +TALER_EXCHANGEDB_denomination_key_write (const char *filename, + const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki); /** @@ -203,8 +197,8 @@ TALER_MINTDB_denomination_key_write (const char *filename, * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure */ int -TALER_MINTDB_denomination_key_read (const char *filename, - struct TALER_MINTDB_DenominationKeyIssueInformation *dki); +TALER_EXCHANGEDB_denomination_key_read (const char *filename, + struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki); /** @@ -212,7 +206,8 @@ TALER_MINTDB_denomination_key_read (const char *filename, * * @param cls closure * @param apub the auditor's public key - * @param mpub the mint's public key (as expected by the auditor) + * @param auditor_url URL of the auditor + * @param mpub the exchange's public key (as expected by the auditor) * @param dki_len length of @a asig and @a dki arrays * @param asigs array of the auditor's signatures over the @a dks, of length @a dki_len * @param dki array of denomination coin data signed by the auditor, of length @a dki_len @@ -221,20 +216,19 @@ TALER_MINTDB_denomination_key_read (const char *filename, * #GNUNET_SYSERR to abort iteration with error! */ typedef int -(*TALER_MINTDB_AuditorIterator)(void *cls, - const struct TALER_AuditorPublicKeyP *apub, - const struct TALER_MasterPublicKeyP *mpub, - unsigned int dki_len, - const struct TALER_AuditorSignatureP *asigs, - const struct TALER_DenominationKeyValidityPS *dki); +(*TALER_EXCHANGEDB_AuditorIterator)(void *cls, + const struct TALER_AuditorPublicKeyP *apub, + const char *auditor_url, + const struct TALER_MasterPublicKeyP *mpub, + unsigned int dki_len, + const struct TALER_AuditorSignatureP *asigs, + const struct TALER_DenominationKeyValidityPS *dki); /** - * Call @a it with information for each auditor found in the @a mint_base_dir. + * Call @a it with information for each auditor found in the @a exchange_base_dir. * - * @param mint_base_dir base directory for the mint, - * the signing keys must be in the #TALER_MINTDB_DIR_DENOMINATION_KEYS - * subdirectory + * @param cfg configuration to use * @param it function to call with auditor information * @param it_cls closure for @a it * @return -1 on error, 0 if no files were found, otherwise @@ -243,9 +237,9 @@ typedef int * as maybe none of the files were well-formed) */ int -TALER_MINTDB_auditor_iterate (const char *mint_base_dir, - TALER_MINTDB_AuditorIterator it, - void *it_cls); +TALER_EXCHANGEDB_auditor_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg, + TALER_EXCHANGEDB_AuditorIterator it, + void *it_cls); /** @@ -253,19 +247,21 @@ TALER_MINTDB_auditor_iterate (const char *mint_base_dir, * * @param filename the file where to write the auditor information to * @param apub the auditor's public key + * @param auditor_url the URL of the auditor * @param asigs the auditor's signatures, array of length @a dki_len - * @param mpub the mint's public key (as expected by the auditor) + * @param mpub the exchange's public key (as expected by the auditor) * @param dki_len length of @a dki and @a asigs arrays * @param dki array of denomination coin data signed by the auditor * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure. */ int -TALER_MINTDB_auditor_write (const char *filename, - const struct TALER_AuditorPublicKeyP *apub, - const struct TALER_AuditorSignatureP *asigs, - const struct TALER_MasterPublicKeyP *mpub, - unsigned int dki_len, - const struct TALER_DenominationKeyValidityPS *dki); +TALER_EXCHANGEDB_auditor_write (const char *filename, + const struct TALER_AuditorPublicKeyP *apub, + const char *auditor_url, + const struct TALER_AuditorSignatureP *asigs, + const struct TALER_MasterPublicKeyP *mpub, + unsigned int dki_len, + const struct TALER_DenominationKeyValidityPS *dki); /** @@ -274,8 +270,8 @@ TALER_MINTDB_auditor_write (const char *filename, * @param cfg configuration to use * @return NULL on failure */ -struct TALER_MINTDB_Plugin * -TALER_MINTDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg); +struct TALER_EXCHANGEDB_Plugin * +TALER_EXCHANGEDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg); /** @@ -284,8 +280,7 @@ TALER_MINTDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg); * @param plugin plugin to unload */ void -TALER_MINTDB_plugin_unload (struct TALER_MINTDB_Plugin *plugin); - +TALER_EXCHANGEDB_plugin_unload (struct TALER_EXCHANGEDB_Plugin *plugin); #endif diff --git a/src/include/taler_mintdb_plugin.h b/src/include/taler_exchangedb_plugin.h index b65b3e4f7..3646981cd 100644 --- a/src/include/taler_mintdb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -14,22 +14,23 @@ TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/> */ /** - * @file include/taler_mintdb_plugin.h - * @brief Low-level (statement-level) database access for the mint + * @file include/taler_exchangedb_plugin.h + * @brief Low-level (statement-level) database access for the exchange * @author Florian Dold * @author Christian Grothoff */ -#ifndef TALER_MINTDB_PLUGIN_H -#define TALER_MINTDB_PLUGIN_H +#ifndef TALER_EXCHANGEDB_PLUGIN_H +#define TALER_EXCHANGEDB_PLUGIN_H +#include <jansson.h> #include <gnunet/gnunet_util_lib.h> -#include "taler_mintdb_lib.h" +#include "taler_exchangedb_lib.h" /** * @brief Information we keep on bank transfer(s) that established a reserve. */ -struct TALER_MINTDB_BankTransfer +struct TALER_EXCHANGEDB_BankTransfer { /** @@ -38,13 +39,13 @@ struct TALER_MINTDB_BankTransfer struct TALER_ReservePublicKeyP reserve_pub; /** - * Amount that was transferred to the mint. + * Amount that was transferred to the exchange. */ struct TALER_Amount amount; /** - * When did the mint receive the incoming transaction? - * (This is the execution date of the mint's database, + * When did the exchange receive the incoming transaction? + * (This is the execution date of the exchange's database, * the execution date of the bank should be in @e wire). */ struct GNUNET_TIME_Absolute execution_date; @@ -60,7 +61,7 @@ struct TALER_MINTDB_BankTransfer /** * @brief A summary of a Reserve */ -struct TALER_MINTDB_Reserve +struct TALER_EXCHANGEDB_Reserve { /** * The reserve's public key. This uniquely identifies the reserve @@ -84,7 +85,7 @@ struct TALER_MINTDB_Reserve * the /withdraw operation if needed, and to have proof * that a reserve was drained by this amount. */ -struct TALER_MINTDB_CollectableBlindcoin +struct TALER_EXCHANGEDB_CollectableBlindcoin { /** @@ -98,7 +99,7 @@ struct TALER_MINTDB_CollectableBlindcoin struct TALER_DenominationPublicKey denom_pub; /** - * Value of the coin being minted (matching the denomination key) + * Value of the coin being exchangeed (matching the denomination key) * plus the transaction fee. We include this in what is being * signed so that we can verify a reserve's remaining total balance * without needing to access the respective denomination key @@ -107,14 +108,14 @@ struct TALER_MINTDB_CollectableBlindcoin struct TALER_Amount amount_with_fee; /** - * Withdrawl fee charged by the mint. This must match the Mint's + * Withdrawl fee charged by the exchange. This must match the Exchange's * denomination key's withdrawl fee. If the client puts in an * invalid withdrawl fee (too high or too low) that does not match - * the Mint's denomination key, the withdraw operation is invalid - * and will be rejected by the mint. The @e amount_with_fee minus + * the Exchange's denomination key, the withdraw operation is invalid + * and will be rejected by the exchange. The @e amount_with_fee minus * the @e withdraw_fee is must match the value of the generated * coin. We include this in what is being signed so that we can - * verify a mint's accounting without needing to access the + * verify a exchange's accounting without needing to access the * respective denomination key information each time. */ struct TALER_Amount withdraw_fee; @@ -142,17 +143,17 @@ struct TALER_MINTDB_CollectableBlindcoin /** * @brief Types of operations on a reserved. */ -enum TALER_MINTDB_ReserveOperation +enum TALER_EXCHANGEDB_ReserveOperation { /** * Money was deposited into the reserve via a bank transfer. */ - TALER_MINTDB_RO_BANK_TO_MINT = 0, + TALER_EXCHANGEDB_RO_BANK_TO_EXCHANGE = 0, /** * A Coin was withdrawn from the reserve using /withdraw. */ - TALER_MINTDB_RO_WITHDRAW_COIN = 1 + TALER_EXCHANGEDB_RO_WITHDRAW_COIN = 1 }; @@ -162,18 +163,18 @@ enum TALER_MINTDB_ReserveOperation * established the reserve and all /withdraw operations we have done * since). */ -struct TALER_MINTDB_ReserveHistory +struct TALER_EXCHANGEDB_ReserveHistory { /** * Next entry in the reserve history. */ - struct TALER_MINTDB_ReserveHistory *next; + struct TALER_EXCHANGEDB_ReserveHistory *next; /** * Type of the event, determins @e details. */ - enum TALER_MINTDB_ReserveOperation type; + enum TALER_EXCHANGEDB_ReserveOperation type; /** * Details of the operation, depending on @e type. @@ -182,14 +183,14 @@ struct TALER_MINTDB_ReserveHistory { /** - * Details about a bank transfer to the mint. + * Details about a bank transfer to the exchange. */ - struct TALER_MINTDB_BankTransfer *bank; + struct TALER_EXCHANGEDB_BankTransfer *bank; /** * Details about a /withdraw operation. */ - struct TALER_MINTDB_CollectableBlindcoin *withdraw; + struct TALER_EXCHANGEDB_CollectableBlindcoin *withdraw; } details; @@ -207,7 +208,7 @@ struct TALER_MINTDB_ReserveHistory * (as determined by transaction ID). (Note: we might want to * fix #3819 and include at least h_contract as well.) */ -struct TALER_MINTDB_Deposit +struct TALER_EXCHANGEDB_Deposit { /** * Information about the coin that is being deposited. @@ -230,14 +231,14 @@ struct TALER_MINTDB_Deposit /** * Hash over the contract between merchant and customer - * (remains unknown to the Mint). + * (remains unknown to the Exchange). */ struct GNUNET_HashCode h_contract; /** * Hash of the (canonical) representation of @e wire, used * to check the signature on the request. Generated by - * the mint from the detailed wire data provided by the + * the exchange from the detailed wire data provided by the * merchant. */ struct GNUNET_HashCode h_wire; @@ -256,12 +257,12 @@ struct TALER_MINTDB_Deposit /** * Time when this request was generated. Used, for example, to * assess when (roughly) the income was achieved for tax purposes. - * Note that the Mint will only check that the timestamp is not "too + * Note that the Exchange will only check that the timestamp is not "too * far" into the future (i.e. several days). The fact that the * timestamp falls within the validity period of the coin's * denomination key is irrelevant for the validity of the deposit * request, as obviously the customer and merchant could conspire to - * set any timestamp. Also, the Mint must accept very old deposit + * set any timestamp. Also, the Exchange must accept very old deposit * requests, as the merchant might have been unable to transmit the * deposit request in a timely fashion (so back-dating is not * prevented). @@ -302,7 +303,7 @@ struct TALER_MINTDB_Deposit * dimensions of the operation, security parameters and * client signatures from "/refresh/melt" and "/refresh/commit". */ -struct TALER_MINTDB_RefreshSession +struct TALER_EXCHANGEDB_RefreshSession { /** @@ -316,7 +317,7 @@ struct TALER_MINTDB_RefreshSession uint16_t num_newcoins; /** - * Index (smaller #TALER_CNC_KAPPA) which the mint has chosen to not + * Index (smaller #TALER_CNC_KAPPA) which the exchange has chosen to not * have revealed during cut and choose. */ uint16_t noreveal_index; @@ -327,7 +328,7 @@ struct TALER_MINTDB_RefreshSession /** * @brief Specification for coin in a /refresh/melt operation. */ -struct TALER_MINTDB_RefreshMelt +struct TALER_EXCHANGEDB_RefreshMelt { /** * Information about the coin that is being melted. @@ -355,11 +356,11 @@ struct TALER_MINTDB_RefreshMelt struct TALER_Amount amount_with_fee; /** - * Melting fee charged by the mint. This must match the Mint's + * Melting fee charged by the exchange. This must match the Exchange's * denomination key's melting fee. If the client puts in an invalid - * melting fee (too high or too low) that does not match the Mint's + * melting fee (too high or too low) that does not match the Exchange's * denomination key, the melting operation is invalid and will be - * rejected by the mint. The @e amount_with_fee minus the @e + * rejected by the exchange. The @e amount_with_fee minus the @e * melt_fee is the amount that will be credited to the melting * session. */ @@ -369,12 +370,12 @@ struct TALER_MINTDB_RefreshMelt /** - * @brief We have as many `struct TALER_MINTDB_RefreshCommitCoin` as there are new + * @brief We have as many `struct TALER_EXCHANGEDB_RefreshCommitCoin` as there are new * coins being created by the refresh (for each of the #TALER_CNC_KAPPA - * sets). These are the coins we ask the mint to sign if the + * sets). These are the coins we ask the exchange to sign if the * respective set is selected. */ -struct TALER_MINTDB_RefreshCommitCoin +struct TALER_EXCHANGEDB_RefreshCommitCoin { /** @@ -399,12 +400,12 @@ struct TALER_MINTDB_RefreshCommitCoin /** * @brief Linked list of refresh information linked to a coin. */ -struct TALER_MINTDB_LinkDataList +struct TALER_EXCHANGEDB_LinkDataList { /** * Information is stored in a NULL-terminated linked list. */ - struct TALER_MINTDB_LinkDataList *next; + struct TALER_EXCHANGEDB_LinkDataList *next; /** * Link data, used to recover the private key of the coin @@ -428,17 +429,17 @@ struct TALER_MINTDB_LinkDataList * @brief Enumeration to classify the different types of transactions * that can be done with a coin. */ -enum TALER_MINTDB_TransactionType +enum TALER_EXCHANGEDB_TransactionType { /** * /deposit operation. */ - TALER_MINTDB_TT_DEPOSIT = 0, + TALER_EXCHANGEDB_TT_DEPOSIT = 0, /** * /refresh/melt operation. */ - TALER_MINTDB_TT_REFRESH_MELT = 1 + TALER_EXCHANGEDB_TT_REFRESH_MELT = 1 }; @@ -446,18 +447,18 @@ enum TALER_MINTDB_TransactionType /** * @brief List of transactions we performed for a particular coin. */ -struct TALER_MINTDB_TransactionList +struct TALER_EXCHANGEDB_TransactionList { /** * Next pointer in the NULL-terminated linked list. */ - struct TALER_MINTDB_TransactionList *next; + struct TALER_EXCHANGEDB_TransactionList *next; /** * Type of the transaction, determines what is stored in @e details. */ - enum TALER_MINTDB_TransactionType type; + enum TALER_EXCHANGEDB_TransactionType type; /** * Details about the transaction, depending on @e type. @@ -468,12 +469,12 @@ struct TALER_MINTDB_TransactionList /** * Details if transaction was a /deposit operation. */ - struct TALER_MINTDB_Deposit *deposit; + struct TALER_EXCHANGEDB_Deposit *deposit; /** * Details if transaction was a /refresh/melt operation. */ - struct TALER_MINTDB_RefreshMelt *melt; + struct TALER_EXCHANGEDB_RefreshMelt *melt; } details; @@ -483,7 +484,7 @@ struct TALER_MINTDB_TransactionList /** * @brief All of the information from a /refresh/melt commitment. */ -struct TALER_MINTDB_MeltCommitment +struct TALER_EXCHANGEDB_MeltCommitment { /** @@ -499,7 +500,7 @@ struct TALER_MINTDB_MeltCommitment /** * Array of @e num_oldcoins melt operation details. */ - struct TALER_MINTDB_RefreshMelt *melts; + struct TALER_EXCHANGEDB_RefreshMelt *melts; /** * Array of @e num_newcoins denomination keys @@ -509,7 +510,7 @@ struct TALER_MINTDB_MeltCommitment /** * 2D-Array of #TALER_CNC_KAPPA and @e num_newcoins commitments. */ - struct TALER_MINTDB_RefreshCommitCoin *commit_coins[TALER_CNC_KAPPA]; + struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coins[TALER_CNC_KAPPA]; /** * 2D-Array of #TALER_CNC_KAPPA and @e new_oldcoins links. @@ -521,7 +522,7 @@ struct TALER_MINTDB_MeltCommitment /** * @brief Handle for a database session (per-thread, for transactions). */ -struct TALER_MINTDB_Session; +struct TALER_EXCHANGEDB_Session; /** @@ -535,7 +536,7 @@ struct TALER_MINTDB_Session; * @param merchant_pub public key of the merchant * @param coin_pub public key of the coin * @param amount_with_fee amount that was deposited including fee - * @param deposit_fee amount the mint gets to keep as transaction fees + * @param deposit_fee amount the exchange gets to keep as transaction fees * @param transaction_id unique transaction ID chosen by the merchant * @param h_contract hash of the contract between merchant and customer * @param wire_deadline by which the merchant adviced that he would like the @@ -544,16 +545,16 @@ struct TALER_MINTDB_Session; * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop */ typedef int -(*TALER_MINTDB_DepositIterator)(void *cls, - unsigned long long rowid, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_Amount *amount_with_fee, - const struct TALER_Amount *deposit_fee, - uint64_t transaction_id, - const struct GNUNET_HashCode *h_contract, - struct GNUNET_TIME_Absolute wire_deadline, - const json_t *wire); +(*TALER_EXCHANGEDB_DepositIterator)(void *cls, + unsigned long long rowid, + const struct TALER_MerchantPublicKeyP *merchant_pub, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct TALER_Amount *amount_with_fee, + const struct TALER_Amount *deposit_fee, + uint64_t transaction_id, + const struct GNUNET_HashCode *h_contract, + struct GNUNET_TIME_Absolute wire_deadline, + const json_t *wire); /** @@ -566,10 +567,10 @@ typedef int * @param shared_secret_enc set to shared secret for the session */ typedef void -(*TALER_MINTDB_TransferDataCallback)(void *cls, - const struct GNUNET_HashCode *session_hash, - const struct TALER_TransferPublicKeyP *transfer_pub, - const struct TALER_EncryptedLinkSecretP *shared_secret_enc); +(*TALER_EXCHANGEDB_TransferDataCallback)(void *cls, + const struct GNUNET_HashCode *session_hash, + const struct TALER_TransferPublicKeyP *transfer_pub, + const struct TALER_EncryptedLinkSecretP *shared_secret_enc); /** @@ -582,16 +583,16 @@ typedef void * if the transaction was not yet done * @param coin_contribution how much did the coin we asked about * contribute to the total transfer value? (deposit value including fee) - * @param coin_fee how much did the mint charge for the deposit fee + * @param coin_fee how much did the exchange charge for the deposit fee * @param execution_time when was the transaction done, or * when we expect it to be done (if @a wtid was NULL) */ typedef void -(*TALER_MINTDB_DepositWtidCallback)(void *cls, - const struct TALER_WireTransferIdentifierRawP *wtid, - const struct TALER_Amount *coin_contribution, - const struct TALER_Amount *coin_fee, - struct GNUNET_TIME_Absolute execution_time); +(*TALER_EXCHANGEDB_DepositWtidCallback)(void *cls, + const struct TALER_WireTransferIdentifierRawP *wtid, + const struct TALER_Amount *coin_contribution, + const struct TALER_Amount *coin_fee, + struct GNUNET_TIME_Absolute execution_time); /** @@ -608,14 +609,14 @@ typedef void * @param coin_fee applicable fee for this coin */ typedef void -(*TALER_MINTDB_WireTransferDataCallback)(void *cls, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct GNUNET_HashCode *h_wire, - const struct GNUNET_HashCode *h_contract, - uint64_t transaction_id, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_Amount *coin_value, - const struct TALER_Amount *coin_fee); +(*TALER_EXCHANGEDB_WireTransferDataCallback)(void *cls, + const struct TALER_MerchantPublicKeyP *merchant_pub, + const struct GNUNET_HashCode *h_wire, + const struct GNUNET_HashCode *h_contract, + uint64_t transaction_id, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct TALER_Amount *coin_value, + const struct TALER_Amount *coin_fee); /** @@ -627,17 +628,17 @@ typedef void * @param buf_size number of bytes in @a buf, 0 on error */ typedef void -(*TALER_MINTDB_WirePreparationCallback) (void *cls, - unsigned long long rowid, - const char *buf, - size_t buf_size); +(*TALER_EXCHANGEDB_WirePreparationCallback) (void *cls, + unsigned long long rowid, + const char *buf, + size_t buf_size); /** * @brief The plugin API, returned from the plugin's "init" function. * The argument given to "init" is simply a configuration handle. */ -struct TALER_MINTDB_Plugin +struct TALER_EXCHANGEDB_Plugin { /** @@ -660,7 +661,7 @@ struct TALER_MINTDB_Plugin * database default one * @param the database connection, or NULL on error */ - struct TALER_MINTDB_Session * + struct TALER_EXCHANGEDB_Session * (*get_session) (void *cls, int temporary); @@ -673,7 +674,7 @@ struct TALER_MINTDB_Plugin */ int (*drop_temporary) (void *cls, - struct TALER_MINTDB_Session *db); + struct TALER_EXCHANGEDB_Session *db); /** @@ -697,7 +698,7 @@ struct TALER_MINTDB_Plugin */ int (*start) (void *cls, - struct TALER_MINTDB_Session *session); + struct TALER_EXCHANGEDB_Session *session); /** @@ -710,7 +711,7 @@ struct TALER_MINTDB_Plugin */ int (*commit) (void *cls, - struct TALER_MINTDB_Session *session); + struct TALER_EXCHANGEDB_Session *session); /** @@ -721,7 +722,7 @@ struct TALER_MINTDB_Plugin */ void (*rollback) (void *cls, - struct TALER_MINTDB_Session *session); + struct TALER_EXCHANGEDB_Session *session); /** @@ -737,9 +738,9 @@ struct TALER_MINTDB_Plugin */ int (*insert_denomination_info) (void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const struct TALER_DenominationPublicKey *denom_pub, - const struct TALER_MINTDB_DenominationKeyInformationP *issue); + const struct TALER_EXCHANGEDB_DenominationKeyInformationP *issue); /** @@ -753,9 +754,9 @@ struct TALER_MINTDB_Plugin */ int (*get_denomination_info) (void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const struct TALER_DenominationPublicKey *denom_pub, - struct TALER_MINTDB_DenominationKeyInformationP *issue); + struct TALER_EXCHANGEDB_DenominationKeyInformationP *issue); /** @@ -770,8 +771,8 @@ struct TALER_MINTDB_Plugin */ int (*reserve_get) (void *cls, - struct TALER_MINTDB_Session *db, - struct TALER_MINTDB_Reserve *reserve); + struct TALER_EXCHANGEDB_Session *db, + struct TALER_EXCHANGEDB_Reserve *reserve); /** @@ -793,7 +794,7 @@ struct TALER_MINTDB_Plugin */ int (*reserves_in_insert) (void *cls, - struct TALER_MINTDB_Session *db, + struct TALER_EXCHANGEDB_Session *db, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_Amount *balance, struct GNUNET_TIME_Absolute execution_time, @@ -816,9 +817,9 @@ struct TALER_MINTDB_Plugin */ int (*get_withdraw_info) (void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *h_blind, - struct TALER_MINTDB_CollectableBlindcoin *collectable); + struct TALER_EXCHANGEDB_CollectableBlindcoin *collectable); /** @@ -835,8 +836,8 @@ struct TALER_MINTDB_Plugin */ int (*insert_withdraw_info) (void *cls, - struct TALER_MINTDB_Session *session, - const struct TALER_MINTDB_CollectableBlindcoin *collectable); + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_CollectableBlindcoin *collectable); /** @@ -848,9 +849,9 @@ struct TALER_MINTDB_Plugin * @param reserve_pub public key of the reserve * @return known transaction history (NULL if reserve is unknown) */ - struct TALER_MINTDB_ReserveHistory * + struct TALER_EXCHANGEDB_ReserveHistory * (*get_reserve_history) (void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const struct TALER_ReservePublicKeyP *reserve_pub); @@ -862,7 +863,7 @@ struct TALER_MINTDB_Plugin */ void (*free_reserve_history) (void *cls, - struct TALER_MINTDB_ReserveHistory *rh); + struct TALER_EXCHANGEDB_ReserveHistory *rh); /** @@ -877,8 +878,8 @@ struct TALER_MINTDB_Plugin */ int (*have_deposit) (void *cls, - struct TALER_MINTDB_Session *session, - const struct TALER_MINTDB_Deposit *deposit); + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_Deposit *deposit); /** @@ -891,8 +892,8 @@ struct TALER_MINTDB_Plugin */ int (*insert_deposit) (void *cls, - struct TALER_MINTDB_Session *session, - const struct TALER_MINTDB_Deposit *deposit); + struct TALER_EXCHANGEDB_Session *session, + const struct TALER_EXCHANGEDB_Deposit *deposit); /** @@ -907,7 +908,7 @@ struct TALER_MINTDB_Plugin */ int (*mark_deposit_tiny) (void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, unsigned long long rowid); @@ -923,7 +924,7 @@ struct TALER_MINTDB_Plugin */ int (*mark_deposit_done) (void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, unsigned long long rowid); @@ -941,11 +942,22 @@ struct TALER_MINTDB_Plugin */ int (*get_ready_deposit) (void *cls, - struct TALER_MINTDB_Session *session, - TALER_MINTDB_DepositIterator deposit_cb, + struct TALER_EXCHANGEDB_Session *session, + TALER_EXCHANGEDB_DepositIterator deposit_cb, void *deposit_cb_cls); +/** + * Maximum number of results we return from iterate_matching_deposits(). + * + * Limit on the number of transactions we aggregate at once. Note + * that the limit must be big enough to ensure that when transactions + * of the smallest possible unit are aggregated, they do surpass the + * "tiny" threshold beyond which we never trigger a wire transaction! + */ +#define TALER_EXCHANGEDB_MATCHING_DEPOSITS_LIMIT 10000 +#define TALER_EXCHANGEDB_MATCHING_DEPOSITS_LIMIT_STR "10000" + /** * Obtain information about other pending deposits for the same * destination. Those deposits must not already be "done". @@ -956,16 +968,18 @@ struct TALER_MINTDB_Plugin * @param merchant_pub public key of the merchant * @param deposit_cb function to call for each deposit * @param deposit_cb_cls closure for @a deposit_cb - * @param limit maximum number of matching deposits to return + * @param limit maximum number of matching deposits to return; should + * be #TALER_EXCHANGEDB_MATCHING_DEPOSITS_LIMIT, larger values + * are not supported, smaller values would be inefficient. * @return number of rows processed, 0 if none exist, * #GNUNET_SYSERR on error */ int (*iterate_matching_deposits) (void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *h_wire, const struct TALER_MerchantPublicKeyP *merchant_pub, - TALER_MINTDB_DepositIterator deposit_cb, + TALER_EXCHANGEDB_DepositIterator deposit_cb, void *deposit_cb_cls, uint32_t limit); @@ -983,9 +997,9 @@ struct TALER_MINTDB_Plugin */ int (*get_refresh_session) (void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *session_hash, - struct TALER_MINTDB_RefreshSession *refresh_session); + struct TALER_EXCHANGEDB_RefreshSession *refresh_session); /** @@ -1000,9 +1014,9 @@ struct TALER_MINTDB_Plugin */ int (*create_refresh_session) (void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *session_hash, - const struct TALER_MINTDB_RefreshSession *refresh_session); + const struct TALER_EXCHANGEDB_RefreshSession *refresh_session); /** @@ -1018,9 +1032,9 @@ struct TALER_MINTDB_Plugin */ int (*insert_refresh_melt) (void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, uint16_t oldcoin_index, - const struct TALER_MINTDB_RefreshMelt *melt); + const struct TALER_EXCHANGEDB_RefreshMelt *melt); /** @@ -1036,10 +1050,10 @@ struct TALER_MINTDB_Plugin */ int (*get_refresh_melt) (void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *session_hash, uint16_t oldcoin_index, - struct TALER_MINTDB_RefreshMelt *melt); + struct TALER_EXCHANGEDB_RefreshMelt *melt); /** @@ -1056,7 +1070,7 @@ struct TALER_MINTDB_Plugin */ int (*insert_refresh_order) (void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *session_hash, uint16_t num_newcoins, const struct TALER_DenominationPublicKey *denom_pubs); @@ -1076,7 +1090,7 @@ struct TALER_MINTDB_Plugin */ int (*get_refresh_order) (void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *session_hash, uint16_t num_newcoins, struct TALER_DenominationPublicKey *denom_pubs); @@ -1097,11 +1111,11 @@ struct TALER_MINTDB_Plugin */ int (*insert_refresh_commit_coins) (void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *session_hash, uint16_t cnc_index, uint16_t num_newcoins, - const struct TALER_MINTDB_RefreshCommitCoin *commit_coins); + const struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coins); /** @@ -1120,11 +1134,11 @@ struct TALER_MINTDB_Plugin */ int (*get_refresh_commit_coins) (void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *session_hash, uint16_t cnc_index, uint16_t num_coins, - struct TALER_MINTDB_RefreshCommitCoin *commit_coins); + struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coins); /** @@ -1141,7 +1155,7 @@ struct TALER_MINTDB_Plugin */ int (*insert_refresh_commit_links) (void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *session_hash, uint16_t cnc_index, uint16_t num_links, @@ -1163,7 +1177,7 @@ struct TALER_MINTDB_Plugin */ int (*get_refresh_commit_links) (void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *session_hash, uint16_t cnc_index, uint16_t num_links, @@ -1179,9 +1193,9 @@ struct TALER_MINTDB_Plugin * @return NULL if the @a session_hash does not correspond to any known melt * operation */ - struct TALER_MINTDB_MeltCommitment * + struct TALER_EXCHANGEDB_MeltCommitment * (*get_melt_commitment) (void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *session_hash); @@ -1193,7 +1207,7 @@ struct TALER_MINTDB_Plugin */ void (*free_melt_commitment) (void *cls, - struct TALER_MINTDB_MeltCommitment *mc); + struct TALER_EXCHANGEDB_MeltCommitment *mc); /** @@ -1211,7 +1225,7 @@ struct TALER_MINTDB_Plugin */ int (*insert_refresh_out) (void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *session_hash, uint16_t newcoin_index, const struct TALER_DenominationSignature *ev_sig); @@ -1226,9 +1240,9 @@ struct TALER_MINTDB_Plugin * @param session_hash session to get linkage data for * @return all known link data for the session */ - struct TALER_MINTDB_LinkDataList * + struct TALER_EXCHANGEDB_LinkDataList * (*get_link_data_list) (void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *session_hash); @@ -1240,7 +1254,7 @@ struct TALER_MINTDB_Plugin */ void (*free_link_data_list) (void *cls, - struct TALER_MINTDB_LinkDataList *ldl); + struct TALER_EXCHANGEDB_LinkDataList *ldl); /** @@ -1261,9 +1275,9 @@ struct TALER_MINTDB_Plugin */ int (*get_transfer) (void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const struct TALER_CoinSpendPublicKeyP *coin_pub, - TALER_MINTDB_TransferDataCallback tdc, + TALER_EXCHANGEDB_TransferDataCallback tdc, void *tdc_cls); @@ -1276,9 +1290,9 @@ struct TALER_MINTDB_Plugin * @param coin_pub coin to investigate * @return list of transactions, NULL if coin is fresh */ - struct TALER_MINTDB_TransactionList * + struct TALER_EXCHANGEDB_TransactionList * (*get_coin_transactions) (void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const struct TALER_CoinSpendPublicKeyP *coin_pub); @@ -1290,7 +1304,7 @@ struct TALER_MINTDB_Plugin */ void (*free_coin_transaction_list) (void *cls, - struct TALER_MINTDB_TransactionList *list); + struct TALER_EXCHANGEDB_TransactionList *list); /** @@ -1307,9 +1321,9 @@ struct TALER_MINTDB_Plugin */ int (*lookup_wire_transfer) (void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const struct TALER_WireTransferIdentifierRawP *wtid, - TALER_MINTDB_WireTransferDataCallback cb, + TALER_EXCHANGEDB_WireTransferDataCallback cb, void *cb_cls); @@ -1332,13 +1346,13 @@ struct TALER_MINTDB_Plugin */ int (*wire_lookup_deposit_wtid)(void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const struct GNUNET_HashCode *h_contract, const struct GNUNET_HashCode *h_wire, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_MerchantPublicKeyP *merchant_pub, uint64_t transaction_id, - TALER_MINTDB_DepositWtidCallback cb, + TALER_EXCHANGEDB_DepositWtidCallback cb, void *cb_cls); @@ -1355,12 +1369,12 @@ struct TALER_MINTDB_Plugin * @param execution_time when did we execute the transaction * @param coin_pub which public key was this payment about * @param coin_value amount contributed by this coin in total - * @param coin_fee deposit fee charged by mint for this coin + * @param coin_fee deposit fee charged by exchange for this coin * @return #GNUNET_OK on success, #GNUNET_SYSERR on DB errors */ int (*insert_aggregation_tracking)(void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_MerchantPublicKeyP *merchant_pub, const struct GNUNET_HashCode *h_wire, @@ -1384,7 +1398,7 @@ struct TALER_MINTDB_Plugin */ int (*wire_prepare_data_insert)(void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const char *type, const char *buf, size_t buf_size); @@ -1400,7 +1414,7 @@ struct TALER_MINTDB_Plugin */ int (*wire_prepare_data_mark_finished)(void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, unsigned long long rowid); @@ -1419,13 +1433,13 @@ struct TALER_MINTDB_Plugin */ int (*wire_prepare_data_get)(void *cls, - struct TALER_MINTDB_Session *session, + struct TALER_EXCHANGEDB_Session *session, const char *type, - TALER_MINTDB_WirePreparationCallback cb, + TALER_EXCHANGEDB_WirePreparationCallback cb, void *cb_cls); }; -#endif /* _TALER_MINT_DB_H */ +#endif /* _TALER_EXCHANGE_DB_H */ diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h index d9fa05188..79589dba7 100644 --- a/src/include/taler_json_lib.h +++ b/src/include/taler_json_lib.h @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014, 2015 GNUnet e.V. + Copyright (C) 2014, 2015, 2016 GNUnet e.V. 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 @@ -17,14 +17,18 @@ * @file include/taler_json_lib.h * @brief helper functions for JSON processing using libjansson * @author Sree Harsha Totakura <sreeharsha@totakura.in> + * @author Christian Grothoff */ -#ifndef TALER_json_LIB_H_ -#define TALER_json_LIB_H_ +#ifndef TALER_JSON_LIB_H_ +#define TALER_JSON_LIB_H_ #include <jansson.h> +#include <gnunet/gnunet_json_lib.h> +#include "taler_util.h" /** * Print JSON parsing related error information + * @deprecated */ #define TALER_json_warn(error) \ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, \ @@ -39,106 +43,42 @@ * @return a json object describing the amount */ json_t * -TALER_json_from_amount (const struct TALER_Amount *amount); +TALER_JSON_from_amount (const struct TALER_Amount *amount); /** - * Convert absolute timestamp to a json string. + * Provide specification to parse given JSON object to an amount. * - * @param stamp the time stamp - * @return a json string with the timestamp in @a stamp - */ -json_t * -TALER_json_from_abs (struct GNUNET_TIME_Absolute stamp); - - -/** - * Convert RSA public key to JSON. - * - * @param pk public key to convert - * @return corresponding JSON encoding - */ -json_t * -TALER_json_from_rsa_public_key (struct GNUNET_CRYPTO_rsa_PublicKey *pk); - - -/** - * Convert RSA signature to JSON. - * - * @param sig signature to convert - * @return corresponding JSON encoding - */ -json_t * -TALER_json_from_rsa_signature (struct GNUNET_CRYPTO_rsa_Signature *sig); - - -/** - * Convert binary data to a JSON string - * with the base32crockford encoding. - * - * @param data binary data - * @param size size of @a data in bytes - * @return json string that encodes @a data - */ -json_t * -TALER_json_from_data (const void *data, - size_t size); - - -/** - * Parse given JSON object to Amount - * - * @param json the json object representing Amount + * @param name name of the amount field in the JSON * @param[out] r_amount where the amount has to be written - * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error */ -int -TALER_json_to_amount (json_t *json, - struct TALER_Amount *r_amount); +struct GNUNET_JSON_Specification +TALER_JSON_spec_amount (const char *name, + struct TALER_Amount *r_amount); -/** - * Parse given JSON object to absolute time. - * - * @param json the json object representing absolute time in seconds - * @param[out] abs where the time has to be written - * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error - */ -int -TALER_json_to_abs (json_t *json, - struct GNUNET_TIME_Absolute *abs); /** - * Parse given JSON object to data + * Generate line in parser specification for denomination public key. * - * @param json the json object representing data - * @param out the pointer to hold the parsed data. - * @param out_size the size of @a out - * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error + * @param field name of the field + * @param[out] pk key to initialize + * @return corresponding field spec */ -int -TALER_json_to_data (json_t *json, - void *out, - size_t out_size); +struct GNUNET_JSON_Specification +TALER_JSON_spec_denomination_public_key (const char *field, + struct TALER_DenominationPublicKey *pk); /** - * Convert JSON to RSA public key. + * Generate line in parser specification for denomination signature. * - * @param json JSON encoding to convert - * @return corresponding public key + * @param field name of the field + * @param sig the signature to initialize + * @return corresponding field spec */ -struct GNUNET_CRYPTO_rsa_PublicKey * -TALER_json_to_rsa_public_key (json_t *json); - - -/** - * Convert JSON to RSA signature. - * - * @param json JSON encoding to convert - * @return corresponding signature - */ -struct GNUNET_CRYPTO_rsa_Signature * -TALER_json_to_rsa_signature (json_t *json); +struct GNUNET_JSON_Specification +TALER_JSON_spec_denomination_signature (const char *field, + struct TALER_DenominationSignature *sig); /** @@ -149,22 +89,9 @@ TALER_json_to_rsa_signature (json_t *json); * @return #GNUNET_OK on success, #GNUNET_SYSERR on error */ int -TALER_hash_json (json_t *json, +TALER_JSON_hash (const json_t *json, struct GNUNET_HashCode *hc); - -/** - * Check if the given wire format JSON object is correctly formatted - * - * @param allowed NULL-terminated array of allowed wire format types - * @param wire the JSON wire format object - * @return #GNUNET_YES if correctly formatted; #GNUNET_NO if not - */ -int -TALER_json_validate_wireformat (const char **allowed, - const json_t *wire); - - -#endif /* TALER_json_LIB_H_ */ +#endif /* TALER_JSON_LIB_H_ */ /* End of taler_json_lib.h */ diff --git a/src/include/taler_pq_lib.h b/src/include/taler_pq_lib.h index 49e067846..dfcea30e1 100644 --- a/src/include/taler_pq_lib.h +++ b/src/include/taler_pq_lib.h @@ -24,6 +24,7 @@ #define TALER_PQ_LIB_H_ #include <libpq-fe.h> +#include <jansson.h> #include <gnunet/gnunet_pq_lib.h> #include "taler_util.h" diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h index 2526597ee..bd892e793 100644 --- a/src/include/taler_signatures.h +++ b/src/include/taler_signatures.h @@ -54,62 +54,68 @@ #define TALER_IDLE_RESERVE_EXPIRATION_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, 5) /*********************************************/ -/* Mint offline signatures (with master key) */ +/* Exchange offline signatures (with master key) */ /*********************************************/ /** - * Purpose for signing public keys signed by the mint master key. + * Purpose for signing public keys signed by the exchange master key. */ #define TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY 1024 /** - * Purpose for denomination keys signed by the mint master key. + * Purpose for denomination keys signed by the exchange master key. */ #define TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY 1025 /** - * Signature where the Mint confirms its SEPA details in - * the /wire/sepa response. + * Signature where the Exchange confirms its SEPA details in + * the /wire response. */ #define TALER_SIGNATURE_MASTER_SEPA_DETAILS 1026 +/** + * Signature where the Exchange confirms its TEST details in + * the /wire response. + */ +#define TALER_SIGNATURE_MASTER_TEST_DETAILS 1027 + /*********************************************/ -/* Mint online signatures (with signing key) */ +/* Exchange online signatures (with signing key) */ /*********************************************/ /** - * Purpose for the state of a reserve, signed by the mint's signing + * Purpose for the state of a reserve, signed by the exchange's signing * key. */ -#define TALER_SIGNATURE_MINT_RESERVE_STATUS 1032 +#define TALER_SIGNATURE_EXCHANGE_RESERVE_STATUS 1032 /** - * Signature where the Mint confirms a deposit request. + * Signature where the Exchange confirms a deposit request. */ -#define TALER_SIGNATURE_MINT_CONFIRM_DEPOSIT 1033 +#define TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT 1033 /** - * Signature where the mint (current signing key) confirms the + * Signature where the exchange (current signing key) confirms the * no-reveal index for cut-and-choose and the validity of the melted * coins. */ -#define TALER_SIGNATURE_MINT_CONFIRM_MELT 1034 +#define TALER_SIGNATURE_EXCHANGE_CONFIRM_MELT 1034 /** - * Signature where the Mint confirms the full /keys response set. + * Signature where the Exchange confirms the full /keys response set. */ -#define TALER_SIGNATURE_MINT_KEY_SET 1035 +#define TALER_SIGNATURE_EXCHANGE_KEY_SET 1035 /** - * Signature where the Mint confirms the /wire response. + * Signature where the Exchange confirms the /deposit/wtid response. */ -#define TALER_SIGNATURE_MINT_WIRE_TYPES 1036 +#define TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE 1036 /** - * Signature where the Mint confirms the /deposit/wtid response. + * Signature where the Exchange confirms the /wire/deposit response. */ -#define TALER_SIGNATURE_MINT_CONFIRM_WIRE 1036 +#define TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT 1037 /*********************/ @@ -118,9 +124,9 @@ /** * Signature where the auditor confirms that he is - * aware of certain denomination keys from the mint. + * aware of certain denomination keys from the exchange. */ -#define TALER_SIGNATURE_AUDITOR_MINT_KEYS 1064 +#define TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS 1064 /***********************/ @@ -176,7 +182,7 @@ /** * EdDSA test signature. */ -#define TALER_SIGNATURE_MINT_TEST_EDDSA 1303 +#define TALER_SIGNATURE_EXCHANGE_TEST_EDDSA 1303 @@ -202,7 +208,7 @@ struct TALER_WithdrawRequestPS struct TALER_ReservePublicKeyP reserve_pub; /** - * Value of the coin being minted (matching the denomination key) + * Value of the coin being exchangeed (matching the denomination key) * plus the transaction fee. We include this in what is being * signed so that we can verify a reserve's remaining total balance * without needing to access the respective denomination key @@ -211,14 +217,14 @@ struct TALER_WithdrawRequestPS struct TALER_AmountNBO amount_with_fee; /** - * Withdrawl fee charged by the mint. This must match the Mint's + * Withdrawl fee charged by the exchange. This must match the Exchange's * denomination key's withdrawl fee. If the client puts in an * invalid withdrawl fee (too high or too low) that does not match - * the Mint's denomination key, the withdraw operation is invalid - * and will be rejected by the mint. The @e amount_with_fee minus + * the Exchange's denomination key, the withdraw operation is invalid + * and will be rejected by the exchange. The @e amount_with_fee minus * the @e withdraw_fee is must match the value of the generated * coin. We include this in what is being signed so that we can - * verify a mint's accounting without needing to access the + * verify a exchange's accounting without needing to access the * respective denomination key information each time. */ struct TALER_AmountNBO withdraw_fee; @@ -229,7 +235,7 @@ struct TALER_WithdrawRequestPS struct GNUNET_HashCode h_denomination_pub GNUNET_PACKED; /** - * Hash of the (blinded) message to be signed by the Mint. + * Hash of the (blinded) message to be signed by the Exchange. */ struct GNUNET_HashCode h_coin_envelope GNUNET_PACKED; }; @@ -260,12 +266,12 @@ struct TALER_DepositRequestPS /** * Time when this request was generated. Used, for example, to * assess when (roughly) the income was achieved for tax purposes. - * Note that the Mint will only check that the timestamp is not "too + * Note that the Exchange will only check that the timestamp is not "too * far" into the future (i.e. several days). The fact that the * timestamp falls within the validity period of the coin's * denomination key is irrelevant for the validity of the deposit * request, as obviously the customer and merchant could conspire to - * set any timestamp. Also, the Mint must accept very old deposit + * set any timestamp. Also, the Exchange must accept very old deposit * requests, as the merchant might have been unable to transmit the * deposit request in a timely fashion (so back-dating is not * prevented). @@ -293,17 +299,17 @@ struct TALER_DepositRequestPS /** * Amount to be deposited, including deposit fee charged by the - * mint. This is the total amount that the coin's value at the mint + * exchange. This is the total amount that the coin's value at the exchange * will be reduced by. */ struct TALER_AmountNBO amount_with_fee; /** - * Depositing fee charged by the mint. This must match the Mint's + * Depositing fee charged by the exchange. This must match the Exchange's * denomination key's depositing fee. If the client puts in an * invalid deposit fee (too high or too low) that does not match the - * Mint's denomination key, the deposit operation is invalid and - * will be rejected by the mint. The @e amount_with_fee minus the + * Exchange's denomination key, the deposit operation is invalid and + * will be rejected by the exchange. The @e amount_with_fee minus the * @e deposit_fee is the amount that will be transferred to the * account identified by @e h_wire. */ @@ -317,7 +323,7 @@ struct TALER_DepositRequestPS /** * The coin's public key. This is the value that must have been - * signed (blindly) by the Mint. The deposit request is to be + * signed (blindly) by the Exchange. The deposit request is to be * signed by the corresponding private key (using EdDSA). */ struct TALER_CoinSpendPublicKeyP coin_pub; @@ -327,13 +333,13 @@ struct TALER_DepositRequestPS /** * @brief Format used to generate the signature on a confirmation - * from the mint that a deposit request succeeded. + * from the exchange that a deposit request succeeded. */ struct TALER_DepositConfirmationPS { /** - * Purpose must be #TALER_SIGNATURE_MINT_CONFIRM_DEPOSIT. Signed - * by a `struct TALER_MintPublicKeyP` using EdDSA. + * Purpose must be #TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT. Signed + * by a `struct TALER_ExchangePublicKeyP` using EdDSA. */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; @@ -362,7 +368,7 @@ struct TALER_DepositConfirmationPS * How much time does the @e merchant have to issue a refund * request? Zero if refunds are not allowed. After this time, the * coin cannot be refunded. Note that the wire transfer will not be - * performed by the mint until the refund deadline. This value + * performed by the exchange until the refund deadline. This value * is taken from the original deposit request. */ struct GNUNET_TIME_AbsoluteNBO refund_deadline; @@ -375,7 +381,7 @@ struct TALER_DepositConfirmationPS /** * The coin's public key. This is the value that must have been - * signed (blindly) by the Mint. The deposit request is to be + * signed (blindly) by the Exchange. The deposit request is to be * signed by the corresponding private key (using EdDSA). */ struct TALER_CoinSpendPublicKeyP coin_pub; @@ -417,11 +423,11 @@ struct TALER_RefreshMeltCoinAffirmationPS struct TALER_AmountNBO amount_with_fee; /** - * Melting fee charged by the mint. This must match the Mint's + * Melting fee charged by the exchange. This must match the Exchange's * denomination key's melting fee. If the client puts in an invalid - * melting fee (too high or too low) that does not match the Mint's + * melting fee (too high or too low) that does not match the Exchange's * denomination key, the melting operation is invalid and will be - * rejected by the mint. The @e amount_with_fee minus the @e + * rejected by the exchange. The @e amount_with_fee minus the @e * melt_fee is the amount that will be credited to the melting * session. */ @@ -429,7 +435,7 @@ struct TALER_RefreshMeltCoinAffirmationPS /** * The coin's public key. This is the value that must have been - * signed (blindly) by the Mint. The deposit request is to be + * signed (blindly) by the Exchange. The deposit request is to be * signed by the corresponding private key (using EdDSA). */ struct TALER_CoinSpendPublicKeyP coin_pub; @@ -437,16 +443,16 @@ struct TALER_RefreshMeltCoinAffirmationPS /** - * @brief Format of the block signed by the Mint in response to a successful - * "/refresh/melt" request. Hereby the mint affirms that all of the - * coins were successfully melted. This also commits the mint to a + * @brief Format of the block signed by the Exchange in response to a successful + * "/refresh/melt" request. Hereby the exchange affirms that all of the + * coins were successfully melted. This also commits the exchange to a * particular index to not be revealed during the refresh. */ struct TALER_RefreshMeltConfirmationPS { /** - * Purpose is #TALER_SIGNATURE_MINT_CONFIRM_MELT. Signed - * by a `struct TALER_MintPublicKeyP` using EdDSA. + * Purpose is #TALER_SIGNATURE_EXCHANGE_CONFIRM_MELT. Signed + * by a `struct TALER_ExchangePublicKeyP` using EdDSA. */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; @@ -469,14 +475,14 @@ struct TALER_RefreshMeltConfirmationPS /** - * @brief Information about a signing key of the mint. Signing keys are used - * to sign mint messages other than coins, i.e. to confirm that a + * @brief Information about a signing key of the exchange. Signing keys are used + * to sign exchange messages other than coins, i.e. to confirm that a * deposit was successful or that a refresh was accepted. */ -struct TALER_MintSigningKeyValidityPS +struct TALER_ExchangeSigningKeyValidityPS { /** - * Signature over the signing key (by the master key of the mint). + * Signature over the signing key (by the master key of the exchange). * * FIXME: should be moved outside of the "PS" struct, this is ugly. * (and makes this struct different from all of the others) @@ -489,8 +495,8 @@ struct TALER_MintSigningKeyValidityPS struct GNUNET_CRYPTO_EccSignaturePurpose purpose; /** - * Master public key of the mint corresponding to @e signature. - * This is the long-term offline master key of the mint. + * Master public key of the exchange corresponding to @e signature. + * This is the long-term offline master key of the exchange. */ struct TALER_MasterPublicKeyP master_public_key; @@ -501,7 +507,7 @@ struct TALER_MintSigningKeyValidityPS /** * When does this signing key expire? Note: This is currently when - * the Mint will definitively stop using it. Signatures made with + * the Exchange will definitively stop using it. Signatures made with * the key remain valid until @e end. When checking validity periods, * clients should allow for some overlap between keys and tolerate * the use of either key during the overlap time (due to the @@ -512,31 +518,31 @@ struct TALER_MintSigningKeyValidityPS /** * When do signatures with this signing key become invalid? After * this point, these signatures cannot be used in (legal) disputes - * anymore, as the Mint is then allowed to destroy its side of the + * anymore, as the Exchange is then allowed to destroy its side of the * evidence. @e end is expected to be significantly larger than @e * expire (by a year or more). */ struct GNUNET_TIME_AbsoluteNBO end; /** - * The public online signing key that the mint will use + * The public online signing key that the exchange will use * between @e start and @e expire. */ - struct TALER_MintPublicKeyP signkey_pub; + struct TALER_ExchangePublicKeyP signkey_pub; }; /** - * @brief Signature made by the mint over the full set of keys, used - * to detect cheating mints that give out different sets to + * @brief Signature made by the exchange over the full set of keys, used + * to detect cheating exchanges that give out different sets to * different users. */ -struct TALER_MintKeySetPS +struct TALER_ExchangeKeySetPS { /** - * Purpose is #TALER_SIGNATURE_MINT_KEY_SET. Signed - * by a `struct TALER_MintPublicKeyP` using EdDSA. + * Purpose is #TALER_SIGNATURE_EXCHANGE_KEY_SET. Signed + * by a `struct TALER_ExchangePublicKeyP` using EdDSA. */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; @@ -565,7 +571,7 @@ struct TALER_DenominationKeyValidityPS struct GNUNET_CRYPTO_EccSignaturePurpose purpose; /** - * The long-term offline master key of the mint that was + * The long-term offline master key of the exchange that was * used to create @e signature. */ struct TALER_MasterPublicKeyP master; @@ -576,14 +582,14 @@ struct TALER_DenominationKeyValidityPS struct GNUNET_TIME_AbsoluteNBO start; /** - * The mint will sign fresh coins between @e start and this time. + * The exchange will sign fresh coins between @e start and this time. * @e expire_withdraw will be somewhat larger than @e start to * ensure a sufficiently large anonymity set, while also allowing - * the Mint to limit the financial damage in case of a key being - * compromised. Thus, mints with low volume are expected to have a - * longer withdraw period (@e expire_withdraw - @e start) than mints + * the Exchange to limit the financial damage in case of a key being + * compromised. Thus, exchanges with low volume are expected to have a + * longer withdraw period (@e expire_withdraw - @e start) than exchanges * with high transaction volume. The period may also differ between - * types of coins. A mint may also have a few denomination keys + * types of coins. A exchange may also have a few denomination keys * with the same value with overlapping validity periods, to address * issues such as clock skew. */ @@ -592,7 +598,7 @@ struct TALER_DenominationKeyValidityPS /** * Coins signed with the denomination key must be spent or refreshed * between @e start and this expiration time. After this time, the - * mint will refuse transactions involving this key as it will + * exchange will refuse transactions involving this key as it will * "drop" the table with double-spending information (shortly after) * this time. Note that wallets should refresh coins significantly * before this time to be on the safe side. @e expire_spend must be @@ -604,7 +610,7 @@ struct TALER_DenominationKeyValidityPS /** * When do signatures with this denomination key become invalid? * After this point, these signatures cannot be used in (legal) - * disputes anymore, as the Mint is then allowed to destroy its side + * disputes anymore, as the Exchange is then allowed to destroy its side * of the evidence. @e expire_legal is expected to be significantly * larger than @e expire_spend (by a year or more). */ @@ -616,19 +622,19 @@ struct TALER_DenominationKeyValidityPS struct TALER_AmountNBO value; /** - * The fee the mint charges when a coin of this type is withdrawn. + * The fee the exchange charges when a coin of this type is withdrawn. * (can be zero). */ struct TALER_AmountNBO fee_withdraw; /** - * The fee the mint charges when a coin of this type is deposited. + * The fee the exchange charges when a coin of this type is deposited. * (can be zero). */ struct TALER_AmountNBO fee_deposit; /** - * The fee the mint charges when a coin of this type is refreshed. + * The fee the exchange charges when a coin of this type is refreshed. * (can be zero). */ struct TALER_AmountNBO fee_refresh; @@ -645,19 +651,24 @@ struct TALER_DenominationKeyValidityPS /** * @brief Information signed by an auditor affirming * the master public key and the denomination keys - * of a mint. + * of a exchange. */ -struct TALER_MintKeyValidityPS +struct TALER_ExchangeKeyValidityPS { /** - * Purpose is #TALER_SIGNATURE_AUDITOR_MINT_KEYS. + * Purpose is #TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS. */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; /** - * The long-term offline master key of the mint, affirmed by the - * auditor. + * Hash of the auditor's URL. + */ + struct GNUNET_HashCode auditor_url_hash; + + /** + * The long-term offline master key of the exchange, affirmed by the + * auditor. Hashed string, including 0-terminator. */ struct TALER_MasterPublicKeyP master; @@ -667,14 +678,14 @@ struct TALER_MintKeyValidityPS struct GNUNET_TIME_AbsoluteNBO start; /** - * The mint will sign fresh coins between @e start and this time. + * The exchange will sign fresh coins between @e start and this time. * @e expire_withdraw will be somewhat larger than @e start to * ensure a sufficiently large anonymity set, while also allowing - * the Mint to limit the financial damage in case of a key being - * compromised. Thus, mints with low volume are expected to have a - * longer withdraw period (@e expire_withdraw - @e start) than mints + * the Exchange to limit the financial damage in case of a key being + * compromised. Thus, exchanges with low volume are expected to have a + * longer withdraw period (@e expire_withdraw - @e start) than exchanges * with high transaction volume. The period may also differ between - * types of coins. A mint may also have a few denomination keys + * types of coins. A exchange may also have a few denomination keys * with the same value with overlapping validity periods, to address * issues such as clock skew. */ @@ -683,7 +694,7 @@ struct TALER_MintKeyValidityPS /** * Coins signed with the denomination key must be spent or refreshed * between @e start and this expiration time. After this time, the - * mint will refuse transactions involving this key as it will + * exchange will refuse transactions involving this key as it will * "drop" the table with double-spending information (shortly after) * this time. Note that wallets should refresh coins significantly * before this time to be on the safe side. @e expire_spend must be @@ -695,7 +706,7 @@ struct TALER_MintKeyValidityPS /** * When do signatures with this denomination key become invalid? * After this point, these signatures cannot be used in (legal) - * disputes anymore, as the Mint is then allowed to destroy its side + * disputes anymore, as the Exchange is then allowed to destroy its side * of the evidence. @e expire_legal is expected to be significantly * larger than @e expire_spend (by a year or more). */ @@ -707,19 +718,19 @@ struct TALER_MintKeyValidityPS struct TALER_AmountNBO value; /** - * The fee the mint charges when a coin of this type is withdrawn. + * The fee the exchange charges when a coin of this type is withdrawn. * (can be zero). */ struct TALER_AmountNBO fee_withdraw; /** - * The fee the mint charges when a coin of this type is deposited. + * The fee the exchange charges when a coin of this type is deposited. * (can be zero). */ struct TALER_AmountNBO fee_deposit; /** - * The fee the mint charges when a coin of this type is refreshed. + * The fee the exchange charges when a coin of this type is refreshed. * (can be zero). */ struct TALER_AmountNBO fee_refresh; @@ -737,7 +748,7 @@ struct TALER_MintKeyValidityPS * @brief For each (old) coin being melted, we have a `struct * RefreshCommitLinkP` that allows the user to find the shared secret * to decrypt the respective refresh links for the new coins in the - * `struct TALER_MINTDB_RefreshCommitCoin`. + * `struct TALER_EXCHANGEDB_RefreshCommitCoin`. * * Part of the construction of the refresh session's hash and * thus of what is signed there. @@ -759,14 +770,15 @@ struct TALER_RefreshCommitLinkP /** - * @brief Information signed by the mint's master - * key affirming the SEPA details for the mint. + * @brief Information signed by the exchange's master + * key affirming the SEPA details for the exchange. */ -struct TALER_MasterWireSepaDetailsPS +struct TALER_MasterWireDetailsPS { /** - * Purpose is #TALER_SIGNATURE_MASTER_SEPA_DETAILS. + * Purpose is #TALER_SIGNATURE_MASTER_SEPA_DETAILS or + * #TALER_SIGNATURE_MASTER_TEST_DETAILS. */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; @@ -780,27 +792,6 @@ struct TALER_MasterWireSepaDetailsPS /** - * @brief Information signed by a mint's online signing key affirming - * the wire formats supported by the mint. - */ -struct TALER_MintWireSupportMethodsPS -{ - - /** - * Purpose is #TALER_SIGNATURE_MINT_WIRE_TYPES. - */ - struct GNUNET_CRYPTO_EccSignaturePurpose purpose; - - /** - * Hash over the various wire formats supported by this mint - * (all as 0-terminated strings). - */ - struct GNUNET_HashCode h_wire_types GNUNET_PACKED; - -}; - - -/** * @brief Format used to generate the signature on a request to obtain * the wire transfer identifier associated with a deposit. */ @@ -841,14 +832,84 @@ struct TALER_DepositTrackPS /** * The coin's public key. This is the value that must have been - * signed (blindly) by the Mint. + * signed (blindly) by the Exchange. + */ + struct TALER_CoinSpendPublicKeyP coin_pub; + +}; + + +/** + * @brief Format internally used for packing the detailed information + * to generate the signature for /wire/deposit signatures. + */ +struct TALER_WireDepositDetailP +{ + + /** + * Hash of the contract + */ + struct GNUNET_HashCode h_contract; + + /** + * Merchant's transaction ID in NBO. + */ + uint64_t transaction_id GNUNET_PACKED; + + /** + * Coin's public key. */ struct TALER_CoinSpendPublicKeyP coin_pub; + /** + * Total value of the coin. + */ + struct TALER_AmountNBO deposit_value; + + /** + * Fees charged by the exchange for the deposit. + */ + struct TALER_AmountNBO deposit_fee; + }; /** + * @brief Format used to generate the signature for /wire/deposit + * replies. + */ +struct TALER_WireDepositDataPS +{ + /** + * Purpose header for the signature over the contract with + * purpose #TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT. + */ + struct GNUNET_CRYPTO_EccSignaturePurpose purpose; + + /** + * Total amount that was transferred. + */ + struct TALER_AmountNBO total; + + /** + * Public key of the merchant (for all aggregated transactions). + */ + struct TALER_MerchantPublicKeyP merchant_pub; + + /** + * Hash of wire details of the merchant. + */ + struct GNUNET_HashCode h_wire; + + /** + * Hash of the individual deposits that were aggregated, + * each in the format of a `struct TALER_WireDepositDetailP`. + */ + struct GNUNET_HashCode h_details; + +}; + +/** * The contract sent by the merchant to the wallet. */ struct TALER_ContractPS @@ -896,14 +957,14 @@ struct TALER_ContractPS /** - * Details affirmed by the mint about a wire transfer the mint + * Details affirmed by the exchange about a wire transfer the exchange * claims to have done with respect to a deposit operation. */ struct TALER_ConfirmWirePS { /** * Purpose header for the signature over the contract with - * purpose #TALER_SIGNATURE_MINT_CONFIRM_WIRE. + * purpose #TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE. */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; @@ -924,7 +985,7 @@ struct TALER_ConfirmWirePS /** * The coin's public key. This is the value that must have been - * signed (blindly) by the Mint. + * signed (blindly) by the Exchange. */ struct TALER_CoinSpendPublicKeyP coin_pub; @@ -941,7 +1002,7 @@ struct TALER_ConfirmWirePS uint64_t transaction_id GNUNET_PACKED; /** - * When did the mint execute this transfer? Note that the + * When did the exchange execute this transfer? Note that the * timestamp may not be exactly the same on the wire, i.e. * because the wire has a different timezone or resolution. */ diff --git a/src/include/taler_util.h b/src/include/taler_util.h index 380901812..0b1d40c85 100644 --- a/src/include/taler_util.h +++ b/src/include/taler_util.h @@ -24,8 +24,6 @@ #include <gnunet/gnunet_util_lib.h> #include "taler_amount_lib.h" #include "taler_crypto_lib.h" -#include "taler_json_lib.h" - /* Define logging functions */ @@ -98,41 +96,6 @@ TALER_b2s (const void *buf, /** - * Round a time value so that it is suitable for transmission - * via JSON encodings. - * - * @param at time to round - * @return #GNUNET_OK if time was already rounded, #GNUNET_NO if - * it was just now rounded - */ -int -TALER_round_abs_time (struct GNUNET_TIME_Absolute *at); - - -/** - * Round a time value so that it is suitable for transmission - * via JSON encodings. - * - * @param rt time to round - * @return #GNUNET_OK if time was already rounded, #GNUNET_NO if - * it was just now rounded - */ -int -TALER_round_rel_time (struct GNUNET_TIME_Relative *rt); - - -/** - * Load configuration by parsing all configuration - * files in the given directory. - * - * @param base_dir directory with the configuration files - * @return NULL on error, otherwise configuration - */ -struct GNUNET_CONFIGURATION_Handle * -TALER_config_load (const char *base_dir); - - -/** * Obtain denomination amount from configuration file. * * @param section section of the configuration to access @@ -147,40 +110,4 @@ TALER_config_get_denom (struct GNUNET_CONFIGURATION_Handle *cfg, struct TALER_Amount *denom); -/** - * Get the path to a specific Taler installation directory or, with - * #GNUNET_OS_IPK_SELF_PREFIX, the current running apps installation - * directory. - * - * @param dirkind what kind of directory is desired? - * @return a pointer to the dir path (to be freed by the caller) - */ -char * -TALER_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind); - - -/** - * Print out details on command line options (implements --help). - * - * @param ctx command line processing context - * @param scls additional closure (points to about text) - * @param option name of the option - * @param value not used (NULL) - * @return #GNUNET_NO (do not continue, not an error) - */ -int -TALER_GETOPT_format_help_ (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, - void *scls, - const char *option, - const char *value); - -/** - * Macro defining the option to print the command line - * help text (-h option). - * - * @param about string with brief description of the application - */ -#define TALER_GETOPT_OPTION_HELP(about) \ - { 'h', "help", (const char *) NULL, gettext_noop("print this help"), 0, &TALER_GETOPT_format_help_, (void *) about } - #endif diff --git a/src/include/taler_wire_plugin.h b/src/include/taler_wire_plugin.h index 8fb194c57..9b2bc8fde 100644 --- a/src/include/taler_wire_plugin.h +++ b/src/include/taler_wire_plugin.h @@ -99,13 +99,50 @@ struct TALER_WIRE_Plugin /** + * Obtain wire transfer details in the plugin-specific format + * from the configuration. + * + * @param cls closure + * @param cfg configuration with details about wire accounts + * @param account_name which section in the configuration should we parse + * @return NULL if @a cfg fails to have valid wire details for @a account_name + */ + json_t * + (*get_wire_details)(void *cls, + const struct GNUNET_CONFIGURATION_Handle *cfg, + const char *account_name); + + + /** + * Sign wire transfer details in the plugin-specific format. + * + * @param cls closure + * @param in wire transfer details in JSON format + * @param key private signing key to use + * @param salt salt to add + * @param[out] sig where to write the signature + * @return #GNUNET_OK on success + */ + int + (*sign_wire_details)(void *cls, + const json_t *in, + const struct TALER_MasterPrivateKeyP *key, + const struct GNUNET_HashCode *salt, + struct TALER_MasterSignatureP *sig); + + + /** * Check if the given wire format JSON object is correctly formatted * + * @param cls the @e cls of this struct with the plugin-specific state * @param wire the JSON wire format object + * @param master_pub public key of the exchange to verify against * @return #GNUNET_YES if correctly formatted; #GNUNET_NO if not */ int - (*wire_validate) (const json_t *wire); + (*wire_validate) (void *cls, + const json_t *wire, + const struct TALER_MasterPublicKeyP *master_pub); /** |