diff options
Diffstat (limited to 'src')
194 files changed, 9068 insertions, 7752 deletions
diff --git a/src/auditor/taler-auditor-exchange.c b/src/auditor/taler-auditor-exchange.c index 04c13fd0..3cd6edf0 100644 --- a/src/auditor/taler-auditor-exchange.c +++ b/src/auditor/taler-auditor-exchange.c @@ -66,13 +66,14 @@ main (int argc, char *cfgfile = NULL; const struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_option_cfgfile (&cfgfile), - GNUNET_GETOPT_option_help ("Add or remove exchange to list of audited exchanges"), + GNUNET_GETOPT_option_help ( + "Add or remove exchange to list of audited exchanges"), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_base32_auto ('m', - "exchange-key", - "KEY", - "public key of the exchange (Crockford base32 encoded)", - &master_public_key)), + (GNUNET_GETOPT_option_base32_auto ('m', + "exchange-key", + "KEY", + "public key of the exchange (Crockford base32 encoded)", + &master_public_key)), GNUNET_GETOPT_option_string ('u', "exchange-url", "URL", @@ -108,7 +109,7 @@ main (int argc, cfgfile)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Malformed configuration file `%s', exit ...\n"), + _ ("Malformed configuration file `%s', exit ...\n"), cfgfile); GNUNET_free_non_null (cfgfile); return 1; @@ -120,22 +121,22 @@ main (int argc, if (NULL == exchange_url) { FPRINTF (stderr, - _("Missing either `%s' or `%s'.\n"), - "-u URL", - "--remove"); + _ ("Missing either `%s' or `%s'.\n"), + "-u URL", + "--remove"); return 1; } if ( (0 == strlen (exchange_url)) || - ( (0 != strncasecmp ("http://", - exchange_url, - strlen ("http://"))) && - (0 != strncasecmp ("https://", - exchange_url, - strlen ("https://"))) ) || - ('/' != exchange_url[strlen(exchange_url)-1]) ) + ( (0 != strncasecmp ("http://", + exchange_url, + strlen ("http://"))) && + (0 != strncasecmp ("https://", + exchange_url, + strlen ("https://"))) ) || + ('/' != exchange_url[strlen (exchange_url) - 1]) ) { fprintf (stderr, - "Exchange URL must begin with `http://` or `https://` and end with `/'\n"); + "Exchange URL must begin with `http://` or `https://` and end with `/'\n"); return 1; } } diff --git a/src/auditor/taler-auditor-httpd.c b/src/auditor/taler-auditor-httpd.c index c7c2589c..967a084e 100644 --- a/src/auditor/taler-auditor-httpd.c +++ b/src/auditor/taler-auditor-httpd.c @@ -232,10 +232,10 @@ signal_loop (void) break; } if (EINTR == errno) - { - ret = 2; - continue; - } + { + ret = 2; + continue; + } switch (c) { case SIGTERM: @@ -325,7 +325,8 @@ handle_version (struct TAH_RequestHandler *rh, ver = json_pack ("{s:s, s:s, s:o}", "version", AUDITOR_PROTOCOL_VERSION, "currency", currency, - "auditor_public_key", GNUNET_JSON_from_data_auto (&auditor_pub)); + "auditor_public_key", GNUNET_JSON_from_data_auto ( + &auditor_pub)); } if (NULL == ver) { @@ -361,44 +362,42 @@ handle_mhd_request (void *cls, size_t *upload_data_size, void **con_cls) { - static struct TAH_RequestHandler handlers[] = - { - /* Our most popular handler (thus first!), used by merchants to - probabilistically report us their deposit confirmations. */ - { "/deposit-confirmation", MHD_HTTP_METHOD_PUT, "application/json", - NULL, 0, - &TAH_DEPOSIT_CONFIRMATION_handler, MHD_HTTP_OK }, - { "/exchanges", MHD_HTTP_METHOD_GET, "application/json", - NULL, 0, - &TAH_EXCHANGES_handler, MHD_HTTP_OK }, - { "/version", MHD_HTTP_METHOD_GET, "application/json", - NULL, 0, - &handle_version, MHD_HTTP_OK }, - /* Landing page, for now tells humans to go away (FIXME: replace - with auditor's welcome page!) */ - { "/", MHD_HTTP_METHOD_GET, "text/plain", - "Hello, I'm the Taler auditor. This HTTP server is not for humans.\n", 0, - &TAH_MHD_handler_static_response, MHD_HTTP_OK }, - /* /robots.txt: disallow everything */ - { "/robots.txt", MHD_HTTP_METHOD_GET, "text/plain", - "User-agent: *\nDisallow: /\n", 0, - &TAH_MHD_handler_static_response, MHD_HTTP_OK }, - /* AGPL licensing page, redirect to source. As per the AGPL-license, - every deployment is required to offer the user a download of the - source. We make this easy by including a redirect to the source - here. */ - { "/agpl", MHD_HTTP_METHOD_GET, "text/plain", - NULL, 0, - &TAH_MHD_handler_agpl_redirect, MHD_HTTP_FOUND }, - - { NULL, NULL, NULL, NULL, 0, 0 } - }; - static struct TAH_RequestHandler h404 = - { - "", NULL, "text/html", - "<html><title>404: not found</title></html>", 0, - &TAH_MHD_handler_static_response, MHD_HTTP_NOT_FOUND - }; + static struct TAH_RequestHandler handlers[] = { + /* Our most popular handler (thus first!), used by merchants to + probabilistically report us their deposit confirmations. */ + { "/deposit-confirmation", MHD_HTTP_METHOD_PUT, "application/json", + NULL, 0, + &TAH_DEPOSIT_CONFIRMATION_handler, MHD_HTTP_OK }, + { "/exchanges", MHD_HTTP_METHOD_GET, "application/json", + NULL, 0, + &TAH_EXCHANGES_handler, MHD_HTTP_OK }, + { "/version", MHD_HTTP_METHOD_GET, "application/json", + NULL, 0, + &handle_version, MHD_HTTP_OK }, + /* Landing page, for now tells humans to go away (FIXME: replace + with auditor's welcome page!) */ + { "/", MHD_HTTP_METHOD_GET, "text/plain", + "Hello, I'm the Taler auditor. This HTTP server is not for humans.\n", 0, + &TAH_MHD_handler_static_response, MHD_HTTP_OK }, + /* /robots.txt: disallow everything */ + { "/robots.txt", MHD_HTTP_METHOD_GET, "text/plain", + "User-agent: *\nDisallow: /\n", 0, + &TAH_MHD_handler_static_response, MHD_HTTP_OK }, + /* AGPL licensing page, redirect to source. As per the AGPL-license, + every deployment is required to offer the user a download of the + source. We make this easy by including a redirect to the source + here. */ + { "/agpl", MHD_HTTP_METHOD_GET, "text/plain", + NULL, 0, + &TAH_MHD_handler_agpl_redirect, MHD_HTTP_FOUND }, + + { NULL, NULL, NULL, NULL, 0, 0 } + }; + static struct TAH_RequestHandler h404 = { + "", NULL, "text/html", + "<html><title>404: not found</title></html>", 0, + &TAH_MHD_handler_static_response, MHD_HTTP_NOT_FOUND + }; struct TAH_RequestHandler *rh; GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -407,7 +406,7 @@ handle_mhd_request (void *cls, if (0 == strcasecmp (method, MHD_HTTP_METHOD_HEAD)) method = MHD_HTTP_METHOD_GET; /* treat HEAD as GET here, MHD will do the rest */ - for (unsigned int i=0;NULL != handlers[i].url;i++) + for (unsigned int i = 0; NULL != handlers[i].url; i++) { rh = &handlers[i]; if ( (0 == strcasecmp (url, @@ -802,7 +801,8 @@ main (int argc, "SECONDS", "after how long do connections timeout by default (in seconds)", &connection_timeout), - GNUNET_GETOPT_option_help ("HTTP server providing a RESTful API to access a Taler auditor"), + GNUNET_GETOPT_option_help ( + "HTTP server providing a RESTful API to access a Taler auditor"), GNUNET_GETOPT_option_loglevel (&loglev), GNUNET_GETOPT_option_logfile (&logfile), GNUNET_GETOPT_option_version (VERSION "-" VCS_VERSION), @@ -830,7 +830,7 @@ main (int argc, cfgfile)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Malformed configuration file `%s', exit ...\n"), + _ ("Malformed configuration file `%s', exit ...\n"), cfgfile); GNUNET_free_non_null (cfgfile); return 1; @@ -846,9 +846,9 @@ main (int argc, listen_fds = getenv ("LISTEN_FDS"); if ( (NULL != listen_pid) && (NULL != listen_fds) && - (getpid() == strtol (listen_pid, - NULL, - 10)) && + (getpid () == strtol (listen_pid, + NULL, + 10)) && (1 == strtoul (listen_fds, NULL, 10)) ) @@ -885,7 +885,10 @@ main (int argc, } mhd - = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_PIPE_FOR_SHUTDOWN | MHD_USE_DEBUG | MHD_USE_DUAL_STACK | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TCP_FASTOPEN, + = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_PIPE_FOR_SHUTDOWN + | MHD_USE_DEBUG | MHD_USE_DUAL_STACK + | MHD_USE_INTERNAL_POLLING_THREAD + | MHD_USE_TCP_FASTOPEN, (-1 == fh) ? serve_port : 0, NULL, NULL, &handle_mhd_request, NULL, @@ -893,7 +896,8 @@ main (int argc, MHD_OPTION_LISTEN_BACKLOG_SIZE, (unsigned int) 1024, MHD_OPTION_LISTEN_SOCKET, fh, MHD_OPTION_EXTERNAL_LOGGER, &handle_mhd_logs, NULL, - MHD_OPTION_NOTIFY_COMPLETED, &handle_mhd_completion_callback, NULL, + MHD_OPTION_NOTIFY_COMPLETED, + &handle_mhd_completion_callback, NULL, MHD_OPTION_CONNECTION_TIMEOUT, connection_timeout, MHD_OPTION_END); if (NULL == mhd) @@ -960,7 +964,8 @@ main (int argc, close it here */ GNUNET_break (0 == close (sock)); while (0 != MHD_get_daemon_info (mhd, - MHD_DAEMON_INFO_CURRENT_CONNECTIONS)->num_connections) + MHD_DAEMON_INFO_CURRENT_CONNECTIONS)-> + num_connections) sleep (1); /* Now we're really done, practice clean shutdown */ MHD_stop_daemon (mhd); diff --git a/src/auditor/taler-auditor-httpd_db.c b/src/auditor/taler-auditor-httpd_db.c index 84682955..e0ab8f2e 100644 --- a/src/auditor/taler-auditor-httpd_db.c +++ b/src/auditor/taler-auditor-httpd_db.c @@ -51,9 +51,9 @@ int TAH_DB_run_transaction (struct MHD_Connection *connection, const char *name, - int *mhd_ret, - TAH_DB_TransactionCallback cb, - void *cb_cls) + int *mhd_ret, + TAH_DB_TransactionCallback cb, + void *cb_cls) { struct TALER_AUDITORDB_Session *session; @@ -64,46 +64,47 @@ TAH_DB_run_transaction (struct MHD_Connection *connection, GNUNET_break (0); if (NULL != mhd_ret) *mhd_ret = TAH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_DB_SETUP_FAILED); + TALER_EC_DB_SETUP_FAILED); return GNUNET_SYSERR; } // TAH_plugin->preflight (TAH_plugin->cls, session); // FIXME: needed? - for (unsigned int retries = 0;retries < MAX_TRANSACTION_COMMIT_RETRIES; retries++) + for (unsigned int retries = 0; retries < MAX_TRANSACTION_COMMIT_RETRIES; + retries++) { enum GNUNET_DB_QueryStatus qs; if (GNUNET_OK != - TAH_plugin->start (TAH_plugin->cls, - session)) + TAH_plugin->start (TAH_plugin->cls, + session)) { GNUNET_break (0); if (NULL != mhd_ret) - *mhd_ret = TAH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_DB_START_FAILED); + *mhd_ret = TAH_RESPONSE_reply_internal_db_error (connection, + TALER_EC_DB_START_FAILED); return GNUNET_SYSERR; } qs = cb (cb_cls, - connection, - session, - mhd_ret); + connection, + session, + mhd_ret); if (0 > qs) TAH_plugin->rollback (TAH_plugin->cls, - session); + session); if (GNUNET_DB_STATUS_HARD_ERROR == qs) return GNUNET_SYSERR; if (0 <= qs) qs = TAH_plugin->commit (TAH_plugin->cls, - session); + session); if (GNUNET_DB_STATUS_HARD_ERROR == qs) { if (NULL != mhd_ret) - *mhd_ret = TAH_RESPONSE_reply_commit_error (connection, - TALER_EC_DB_COMMIT_FAILED_HARD); + *mhd_ret = TAH_RESPONSE_reply_commit_error (connection, + TALER_EC_DB_COMMIT_FAILED_HARD); return GNUNET_SYSERR; } /* make sure callback did not violate invariants! */ GNUNET_assert ( (NULL == mhd_ret) || - (-1 == *mhd_ret) ); + (-1 == *mhd_ret) ); if (0 <= qs) return GNUNET_OK; } @@ -112,7 +113,7 @@ TAH_DB_run_transaction (struct MHD_Connection *connection, MAX_TRANSACTION_COMMIT_RETRIES); if (NULL != mhd_ret) *mhd_ret = TAH_RESPONSE_reply_commit_error (connection, - TALER_EC_DB_COMMIT_FAILED_ON_RETRY); + TALER_EC_DB_COMMIT_FAILED_ON_RETRY); return GNUNET_SYSERR; } diff --git a/src/auditor/taler-auditor-httpd_db.h b/src/auditor/taler-auditor-httpd_db.h index 9aad86c1..1f702c81 100644 --- a/src/auditor/taler-auditor-httpd_db.h +++ b/src/auditor/taler-auditor-httpd_db.h @@ -41,9 +41,9 @@ */ typedef enum GNUNET_DB_QueryStatus (*TAH_DB_TransactionCallback)(void *cls, - struct MHD_Connection *connection, - struct TALER_AUDITORDB_Session *session, - int *mhd_ret); + struct MHD_Connection *connection, + struct TALER_AUDITORDB_Session *session, + int *mhd_ret); /** @@ -63,9 +63,9 @@ typedef enum GNUNET_DB_QueryStatus int TAH_DB_run_transaction (struct MHD_Connection *connection, const char *name, - int *mhd_ret, - TAH_DB_TransactionCallback cb, - void *cb_cls); + int *mhd_ret, + TAH_DB_TransactionCallback cb, + void *cb_cls); #endif diff --git a/src/auditor/taler-auditor-httpd_deposit-confirmation.c b/src/auditor/taler-auditor-httpd_deposit-confirmation.c index af86378c..2b73a910 100644 --- a/src/auditor/taler-auditor-httpd_deposit-confirmation.c +++ b/src/auditor/taler-auditor-httpd_deposit-confirmation.c @@ -75,7 +75,7 @@ store_exchange_signing_key_transaction (void *cls, { TALER_LOG_WARNING ("Failed to store exchange signing key in database\n"); *mhd_ret = TAH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_AUDITOR_EXCHANGE_STORE_DB_ERROR); + TALER_EC_AUDITOR_EXCHANGE_STORE_DB_ERROR); } return qs; } @@ -109,9 +109,10 @@ deposit_confirmation_transaction (void *cls, dc); if (GNUNET_DB_STATUS_HARD_ERROR == qs) { - TALER_LOG_WARNING ("Failed to store /deposit-confirmation information in database\n"); + TALER_LOG_WARNING ( + "Failed to store /deposit-confirmation information in database\n"); *mhd_ret = TAH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_DEPOSIT_CONFIRMATION_STORE_DB_ERROR); + TALER_EC_DEPOSIT_CONFIRMATION_STORE_DB_ERROR); } return qs; } @@ -130,8 +131,10 @@ deposit_confirmation_transaction (void *cls, */ static int verify_and_execute_deposit_confirmation (struct MHD_Connection *connection, - const struct TALER_AUDITORDB_DepositConfirmation *dc, - const struct TALER_AUDITORDB_ExchangeSigningKey *es) + const struct + TALER_AUDITORDB_DepositConfirmation *dc, + const struct + TALER_AUDITORDB_ExchangeSigningKey *es) { struct TALER_ExchangeSigningKeyValidityPS skv; struct TALER_DepositConfirmationPS dcs; diff --git a/src/auditor/taler-auditor-httpd_exchanges.c b/src/auditor/taler-auditor-httpd_exchanges.c index 866e4c7b..881c45a2 100644 --- a/src/auditor/taler-auditor-httpd_exchanges.c +++ b/src/auditor/taler-auditor-httpd_exchanges.c @@ -109,7 +109,7 @@ list_exchanges (void *cls, { TALER_LOG_WARNING ("Failed to handle /exchanges in database\n"); *mhd_ret = TAH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_LIST_EXCHANGES_DB_ERROR); + TALER_EC_LIST_EXCHANGES_DB_ERROR); } return qs; } @@ -139,9 +139,9 @@ TAH_EXCHANGES_handler (struct TAH_RequestHandler *rh, if (GNUNET_OK != TAH_DB_run_transaction (connection, "list exchanges", - &mhd_ret, - &list_exchanges, - (void *) ja)) + &mhd_ret, + &list_exchanges, + (void *) ja)) return mhd_ret; return reply_exchanges_success (connection, ja); diff --git a/src/auditor/taler-auditor-httpd_mhd.c b/src/auditor/taler-auditor-httpd_mhd.c index b8fc65af..5f13691f 100644 --- a/src/auditor/taler-auditor-httpd_mhd.c +++ b/src/auditor/taler-auditor-httpd_mhd.c @@ -45,10 +45,10 @@ */ int TAH_MHD_handler_static_response (struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { struct MHD_Response *response; int ret; @@ -142,16 +142,16 @@ TAH_MHD_handler_agpl_redirect (struct TAH_RequestHandler *rh, */ int TAH_MHD_handler_send_json_pack_error (struct TAH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { return TAH_RESPONSE_reply_json_pack (connection, - rh->response_code, - "{s:s}", - "error", - rh->data); + rh->response_code, + "{s:s}", + "error", + rh->data); } diff --git a/src/auditor/taler-auditor-httpd_parsing.c b/src/auditor/taler-auditor-httpd_parsing.c index 36ae4a16..bac338cc 100644 --- a/src/auditor/taler-auditor-httpd_parsing.c +++ b/src/auditor/taler-auditor-httpd_parsing.c @@ -33,7 +33,7 @@ /** * Maximum POST request size. */ -#define REQUEST_BUFFER_MAX (1024*1024) +#define REQUEST_BUFFER_MAX (1024 * 1024) @@ -82,17 +82,17 @@ TAH_PARSE_post_json (struct MHD_Connection *connection, TAH_RESPONSE_reply_internal_error (connection, TALER_EC_PARSER_OUT_OF_MEMORY, "out of memory")) - ? GNUNET_SYSERR : GNUNET_NO; + ? GNUNET_SYSERR : GNUNET_NO; case GNUNET_JSON_PR_CONTINUE: return GNUNET_YES; case GNUNET_JSON_PR_REQUEST_TOO_LARGE: return (MHD_NO == TAH_RESPONSE_reply_request_too_large (connection)) - ? GNUNET_SYSERR : GNUNET_NO; + ? GNUNET_SYSERR : GNUNET_NO; case GNUNET_JSON_PR_JSON_INVALID: return (MHD_YES == TAH_RESPONSE_reply_invalid_json (connection)) - ? GNUNET_NO : GNUNET_SYSERR; + ? GNUNET_NO : GNUNET_SYSERR; case GNUNET_JSON_PR_SUCCESS: GNUNET_break (NULL != *json); return GNUNET_YES; @@ -147,9 +147,9 @@ TAH_PARSE_mhd_request_arg_data (struct MHD_Connection *connection, { return (MHD_NO == TAH_RESPONSE_reply_arg_missing (connection, - TALER_EC_PARAMETER_MISSING, - param_name)) - ? GNUNET_SYSERR : GNUNET_NO; + TALER_EC_PARAMETER_MISSING, + param_name)) + ? GNUNET_SYSERR : GNUNET_NO; } if (GNUNET_OK != GNUNET_STRINGS_string_to_data (str, @@ -158,9 +158,9 @@ TAH_PARSE_mhd_request_arg_data (struct MHD_Connection *connection, out_size)) return (MHD_NO == TAH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_PARAMETER_MALFORMED, - param_name)) - ? GNUNET_SYSERR : GNUNET_NO; + TALER_EC_PARAMETER_MALFORMED, + param_name)) + ? GNUNET_SYSERR : GNUNET_NO; return GNUNET_OK; } @@ -201,10 +201,12 @@ TAH_PARSE_json_data (struct MHD_Connection *connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:I, s:s, s:I}", "error", "parse error", - "code", (json_int_t) TALER_EC_JSON_INVALID_WITH_DETAILS, + "code", + (json_int_t) + TALER_EC_JSON_INVALID_WITH_DETAILS, "field", error_json_name, "line", (json_int_t) error_line)) - ? GNUNET_NO : GNUNET_SYSERR; + ? GNUNET_NO : GNUNET_SYSERR; return ret; } return GNUNET_YES; @@ -255,7 +257,7 @@ TAH_PARSE_json_array (struct MHD_Connection *connection, "{s:s, s:I}", "error", "parse error", "dimension", dim)) - ? GNUNET_NO : GNUNET_SYSERR; + ? GNUNET_NO : GNUNET_SYSERR; return ret; } ret = GNUNET_JSON_parse (root, @@ -273,7 +275,7 @@ TAH_PARSE_json_array (struct MHD_Connection *connection, "error", "parse error", "field", error_json_name, "line", (json_int_t) error_line)) - ? GNUNET_NO : GNUNET_SYSERR; + ? GNUNET_NO : GNUNET_SYSERR; return ret; } return GNUNET_YES; diff --git a/src/auditor/taler-auditor-httpd_responses.c b/src/auditor/taler-auditor-httpd_responses.c index 045a7777..4c7b429e 100644 --- a/src/auditor/taler-auditor-httpd_responses.c +++ b/src/auditor/taler-auditor-httpd_responses.c @@ -65,22 +65,22 @@ TAH_RESPONSE_can_compress (struct MHD_Connection *connection) const char *de; ae = MHD_lookup_connection_value (connection, - MHD_HEADER_KIND, - MHD_HTTP_HEADER_ACCEPT_ENCODING); + MHD_HEADER_KIND, + MHD_HTTP_HEADER_ACCEPT_ENCODING); if (NULL == ae) return MHD_NO; if (0 == strcmp (ae, "*")) return MHD_YES; de = strstr (ae, - "deflate"); + "deflate"); if (NULL == de) return MHD_NO; if ( ( (de == ae) || - (de[-1] == ',') || - (de[-1] == ' ') ) && + (de[-1] == ',') || + (de[-1] == ' ') ) && ( (de[strlen ("deflate")] == '\0') || - (de[strlen ("deflate")] == ',') || + (de[strlen ("deflate")] == ',') || (de[strlen ("deflate")] == ';') ) ) return MHD_YES; return MHD_NO; @@ -96,7 +96,7 @@ TAH_RESPONSE_can_compress (struct MHD_Connection *connection) */ int TAH_RESPONSE_body_compress (void **buf, - size_t *buf_size) + size_t *buf_size) { Bytef *cbuf; uLongf cbuf_size; @@ -107,9 +107,9 @@ TAH_RESPONSE_body_compress (void **buf, if (NULL == cbuf) return MHD_NO; ret = compress (cbuf, - &cbuf_size, - (const Bytef *) *buf, - *buf_size); + &cbuf_size, + (const Bytef *) *buf, + *buf_size); if ( (Z_OK != ret) || (cbuf_size >= *buf_size) ) { @@ -144,7 +144,7 @@ TAH_RESPONSE_reply_json (struct MHD_Connection *connection, int comp; json_str = json_dumps (json, - JSON_INDENT(2)); + JSON_INDENT (2)); if (NULL == json_str) { /** @@ -163,7 +163,7 @@ TAH_RESPONSE_reply_json (struct MHD_Connection *connection, if (MHD_YES == TAH_RESPONSE_can_compress (connection)) comp = TAH_RESPONSE_body_compress (&json_str, - &json_len); + &json_len); resp = MHD_create_response_from_buffer (json_len, json_str, MHD_RESPMEM_MUST_FREE); @@ -181,9 +181,9 @@ TAH_RESPONSE_reply_json (struct MHD_Connection *connection, { /* Need to indicate to client that body is compressed */ if (MHD_NO == - MHD_add_response_header (resp, - MHD_HTTP_HEADER_CONTENT_ENCODING, - "deflate")) + MHD_add_response_header (resp, + MHD_HTTP_HEADER_CONTENT_ENCODING, + "deflate")) { GNUNET_break (0); MHD_destroy_response (resp); @@ -249,14 +249,14 @@ TAH_RESPONSE_reply_json_pack (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_arg_invalid (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name) { return TAH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:I, s:s}", "error", "invalid parameter", - "code", (json_int_t) ec, + "code", (json_int_t) ec, "parameter", param_name); } @@ -273,14 +273,14 @@ TAH_RESPONSE_reply_arg_invalid (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_arg_unknown (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name) { return TAH_RESPONSE_reply_json_pack (connection, MHD_HTTP_NOT_FOUND, "{s:s, s:I, s:s}", "error", "unknown entity referenced", - "code", (json_int_t) ec, + "code", (json_int_t) ec, "parameter", param_name); } @@ -295,14 +295,14 @@ TAH_RESPONSE_reply_arg_unknown (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_signature_invalid (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name) { return TAH_RESPONSE_reply_json_pack (connection, MHD_HTTP_UNAUTHORIZED, "{s:s, s:I, s:s}", "error", "invalid signature", - "code", (json_int_t) ec, + "code", (json_int_t) ec, "parameter", param_name); } @@ -317,14 +317,14 @@ TAH_RESPONSE_reply_signature_invalid (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_arg_missing (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name) { return TAH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:I, s:s}", "error", "missing parameter", - "code", (json_int_t) ec, + "code", (json_int_t) ec, "parameter", param_name); } @@ -339,14 +339,14 @@ TAH_RESPONSE_reply_arg_missing (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_permission_denied (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *hint) { return TAH_RESPONSE_reply_json_pack (connection, MHD_HTTP_FORBIDDEN, "{s:s, s:I, s:s}", "error", "permission denied", - "code", (json_int_t) ec, + "code", (json_int_t) ec, "hint", hint); } @@ -361,14 +361,14 @@ TAH_RESPONSE_reply_permission_denied (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_internal_error (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *hint) { return TAH_RESPONSE_reply_json_pack (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, "{s:s, s:I, s:s}", "error", "internal error", - "code", (json_int_t) ec, + "code", (json_int_t) ec, "hint", hint); } @@ -383,14 +383,14 @@ TAH_RESPONSE_reply_internal_error (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_external_error (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *hint) { return TAH_RESPONSE_reply_json_pack (connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:I, s:s}", "error", "client error", - "code", (json_int_t) ec, + "code", (json_int_t) ec, "hint", hint); } @@ -405,13 +405,13 @@ TAH_RESPONSE_reply_external_error (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_commit_error (struct MHD_Connection *connection, - enum TALER_ErrorCode ec) + enum TALER_ErrorCode ec) { return TAH_RESPONSE_reply_json_pack (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, "{s:s, s:I}", "error", "commit failure", - "code", (json_int_t) ec); + "code", (json_int_t) ec); } @@ -425,10 +425,10 @@ TAH_RESPONSE_reply_commit_error (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_internal_db_error (struct MHD_Connection *connection, - enum TALER_ErrorCode ec) + enum TALER_ErrorCode ec) { return TAH_RESPONSE_reply_internal_error (connection, - ec, + ec, "Failure in database interaction"); } @@ -472,7 +472,8 @@ TAH_RESPONSE_reply_invalid_json (struct MHD_Connection *connection) MHD_HTTP_BAD_REQUEST, "{s:s, s:I}", "error", "invalid json", - "code", (json_int_t) TALER_EC_JSON_INVALID); + "code", + (json_int_t) TALER_EC_JSON_INVALID); } diff --git a/src/auditor/taler-auditor-httpd_responses.h b/src/auditor/taler-auditor-httpd_responses.h index 95e6183e..1cb5faa8 100644 --- a/src/auditor/taler-auditor-httpd_responses.h +++ b/src/auditor/taler-auditor-httpd_responses.h @@ -53,7 +53,7 @@ TAH_RESPONSE_add_global_headers (struct MHD_Response *response); */ int TAH_RESPONSE_body_compress (void **buf, - size_t *buf_size); + size_t *buf_size); /** @@ -107,7 +107,7 @@ TAH_RESPONSE_reply_json_pack (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_signature_invalid (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name); @@ -121,7 +121,7 @@ TAH_RESPONSE_reply_signature_invalid (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_arg_invalid (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name); @@ -137,7 +137,7 @@ TAH_RESPONSE_reply_arg_invalid (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_arg_unknown (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name); @@ -151,7 +151,7 @@ TAH_RESPONSE_reply_arg_unknown (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_arg_missing (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name); @@ -165,7 +165,7 @@ TAH_RESPONSE_reply_arg_missing (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_permission_denied (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *hint); @@ -179,7 +179,7 @@ TAH_RESPONSE_reply_permission_denied (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_internal_error (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *hint); @@ -193,7 +193,7 @@ TAH_RESPONSE_reply_internal_error (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_external_error (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *hint); @@ -207,7 +207,7 @@ TAH_RESPONSE_reply_external_error (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_commit_error (struct MHD_Connection *connection, - enum TALER_ErrorCode ec); + enum TALER_ErrorCode ec); /** * Send a response indicating a failure to talk to the Auditor's @@ -219,7 +219,7 @@ TAH_RESPONSE_reply_commit_error (struct MHD_Connection *connection, */ int TAH_RESPONSE_reply_internal_db_error (struct MHD_Connection *connection, - enum TALER_ErrorCode ec); + enum TALER_ErrorCode ec); /** diff --git a/src/auditor/taler-auditor-sign.c b/src/auditor/taler-auditor-sign.c index 0636900f..1bd7e908 100644 --- a/src/auditor/taler-auditor-sign.c +++ b/src/auditor/taler-auditor-sign.c @@ -86,14 +86,14 @@ print_dk (const struct TALER_DenominationKeyValidityPS *dk) "Value: %s\n", s = TALER_amount_to_string (&a)); GNUNET_free (s); - TALER_amount_ntoh (&a, - &dk->fee_withdraw); + TALER_amount_ntoh (&a, + &dk->fee_withdraw); fprintf (stdout, "Withdraw fee: %s\n", s = TALER_amount_to_string (&a)); GNUNET_free (s); - TALER_amount_ntoh (&a, - &dk->fee_deposit); + TALER_amount_ntoh (&a, + &dk->fee_deposit); fprintf (stdout, "Deposit fee: %s\n", s = TALER_amount_to_string (&a)); @@ -113,16 +113,20 @@ print_dk (const struct TALER_DenominationKeyValidityPS *dk) fprintf (stdout, "Validity start time: %s\n", - GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh (dk->start))); + GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh ( + dk->start))); fprintf (stdout, "Withdraw end time: %s\n", - GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh (dk->expire_withdraw))); + GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh ( + dk->expire_withdraw))); fprintf (stdout, "Deposit end time: %s\n", - GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh (dk->expire_deposit))); + GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh ( + dk->expire_deposit))); fprintf (stdout, "Legal dispute end time: %s\n", - GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh (dk->expire_legal))); + GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh ( + dk->expire_legal))); fprintf (stdout, "\n"); @@ -153,22 +157,22 @@ main (int argc, GNUNET_GETOPT_option_cfgfile (&cfgfile), GNUNET_GETOPT_option_help ("Sign denomination keys of an exchange"), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_base32_auto ('m', - "exchange-key", - "KEY", - "public key of the exchange (Crockford base32 encoded)", - &master_public_key)), + (GNUNET_GETOPT_option_base32_auto ('m', + "exchange-key", + "KEY", + "public key of the exchange (Crockford base32 encoded)", + &master_public_key)), GNUNET_GETOPT_option_string ('u', "auditor-url", "URL", "URL of the auditor (informative link for the user)", &auditor_url), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_filename ('r', - "exchange-request", - "FILENAME", - "set of keys the exchange requested the auditor to sign", - &exchange_request_file)), + (GNUNET_GETOPT_option_filename ('r', + "exchange-request", + "FILENAME", + "set of keys the exchange requested the auditor to sign", + &exchange_request_file)), GNUNET_GETOPT_option_filename ('o', "output", "FILENAME", @@ -203,7 +207,7 @@ main (int argc, cfgfile)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Malformed configuration file `%s', exit ...\n"), + _ ("Malformed configuration file `%s', exit ...\n"), cfgfile); GNUNET_free_non_null (cfgfile); return 1; @@ -325,7 +329,7 @@ main (int argc, return 1; } GNUNET_DISK_file_close (fh); - for (unsigned int i=0;i<dks_len;i++) + for (unsigned int i = 0; i<dks_len; i++) { struct TALER_DenominationKeyValidityPS *dk = &dks[i]; @@ -383,20 +387,20 @@ main (int argc, if (NULL == session) { fprintf (stderr, - "Failed to initialize database session\n"); + "Failed to initialize database session\n"); TALER_AUDITORDB_plugin_unload (adb); GNUNET_free (dks); GNUNET_free (sigs); GNUNET_free (eddsa_priv); return 3; } - for (unsigned int i=0;i<dks_len;i++) + for (unsigned int i = 0; i<dks_len; i++) { const struct TALER_DenominationKeyValidityPS *dk = &dks[i]; qs = adb->insert_denomination_info (adb->cls, - session, - dk); + session, + dk); if (0 > qs) { fprintf (stderr, diff --git a/src/auditor/taler-auditor.c b/src/auditor/taler-auditor.c index dbc33794..536a5cab 100644 --- a/src/auditor/taler-auditor.c +++ b/src/auditor/taler-auditor.c @@ -342,12 +342,12 @@ static struct TALER_Amount total_refresh_hanging; */ static void report (json_t *array, - json_t *object) + json_t *object) { GNUNET_assert (NULL != object); GNUNET_assert (0 == - json_array_append_new (array, - object)); + json_array_append_new (array, + object)); } @@ -363,21 +363,25 @@ report (json_t *array, * @param risk maximum risk that might have just become real (coins created by this @a dki) */ static void -report_emergency_by_amount (const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki, +report_emergency_by_amount (const struct + TALER_EXCHANGEDB_DenominationKeyInformationP *dki, const struct TALER_Amount *risk) { report (report_emergencies, - json_pack ("{s:o, s:o, s:s, s:s, s:o}", - "denompub_hash", - GNUNET_JSON_from_data_auto (&dki->properties.denom_hash), - "denom_risk", - TALER_JSON_from_amount (risk), - "start", - GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh (dki->properties.start)), - "deposit_end", - GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh (dki->properties.expire_deposit)), - "value", - TALER_JSON_from_amount_nbo (&dki->properties.value))); + json_pack ("{s:o, s:o, s:s, s:s, s:o}", + "denompub_hash", + GNUNET_JSON_from_data_auto (&dki->properties.denom_hash), + "denom_risk", + TALER_JSON_from_amount (risk), + "start", + GNUNET_STRINGS_absolute_time_to_string ( + GNUNET_TIME_absolute_ntoh (dki->properties.start)), + "deposit_end", + GNUNET_STRINGS_absolute_time_to_string ( + GNUNET_TIME_absolute_ntoh ( + dki->properties.expire_deposit)), + "value", + TALER_JSON_from_amount_nbo (&dki->properties.value))); GNUNET_assert (GNUNET_OK == TALER_amount_add (&reported_emergency_sum, &reported_emergency_sum, @@ -400,27 +404,31 @@ report_emergency_by_amount (const struct TALER_EXCHANGEDB_DenominationKeyInforma * @param risk amount that is at risk */ static void -report_emergency_by_count (const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki, +report_emergency_by_count (const struct + TALER_EXCHANGEDB_DenominationKeyInformationP *dki, uint64_t num_issued, uint64_t num_known, const struct TALER_Amount *risk) { report (report_emergencies, - json_pack ("{s:o, s:I, s:I, s:o, s:s, s:s, s:o}", - "denompub_hash", - GNUNET_JSON_from_data_auto (&dki->properties.denom_hash), - "num_issued", - (json_int_t) num_issued, - "num_known", - (json_int_t) num_known, - "denom_risk", - TALER_JSON_from_amount (risk), - "start", - GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh (dki->properties.start)), - "deposit_end", - GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh (dki->properties.expire_deposit)), - "value", - TALER_JSON_from_amount_nbo (&dki->properties.value))); + json_pack ("{s:o, s:I, s:I, s:o, s:s, s:s, s:o}", + "denompub_hash", + GNUNET_JSON_from_data_auto (&dki->properties.denom_hash), + "num_issued", + (json_int_t) num_issued, + "num_known", + (json_int_t) num_known, + "denom_risk", + TALER_JSON_from_amount (risk), + "start", + GNUNET_STRINGS_absolute_time_to_string ( + GNUNET_TIME_absolute_ntoh (dki->properties.start)), + "deposit_end", + GNUNET_STRINGS_absolute_time_to_string ( + GNUNET_TIME_absolute_ntoh ( + dki->properties.expire_deposit)), + "value", + TALER_JSON_from_amount_nbo (&dki->properties.value))); GNUNET_assert (GNUNET_OK == TALER_amount_add (&reported_emergency_sum, &reported_emergency_sum, @@ -463,7 +471,7 @@ report_amount_arithmetic_inconsistency (const char *operation, else { /* auditor < exchange */ - profitable = - profitable; + profitable = -profitable; GNUNET_break (GNUNET_OK == TALER_amount_subtract (&delta, auditor, @@ -479,8 +487,8 @@ report_amount_arithmetic_inconsistency (const char *operation, if (0 != profitable) { target = (1 == profitable) - ? &total_arithmetic_delta_plus - : &total_arithmetic_delta_minus; + ? &total_arithmetic_delta_plus + : &total_arithmetic_delta_minus; GNUNET_break (GNUNET_OK == TALER_amount_add (target, target, @@ -504,7 +512,8 @@ report_amount_arithmetic_inconsistency (const char *operation, */ static void report_coin_arithmetic_inconsistency (const char *operation, - const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct + TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_Amount *exchange, const struct TALER_Amount *auditor, int profitable) @@ -524,7 +533,7 @@ report_coin_arithmetic_inconsistency (const char *operation, else { /* auditor < exchange */ - profitable = - profitable; + profitable = -profitable; GNUNET_break (GNUNET_OK == TALER_amount_subtract (&delta, auditor, @@ -540,8 +549,8 @@ report_coin_arithmetic_inconsistency (const char *operation, if (0 != profitable) { target = (1 == profitable) - ? &total_coin_delta_plus - : &total_coin_delta_minus; + ? &total_coin_delta_plus + : &total_coin_delta_minus; GNUNET_break (GNUNET_OK == TALER_amount_add (target, target, @@ -563,10 +572,10 @@ report_row_inconsistency (const char *table, const char *diagnostic) { report (report_row_inconsistencies, - json_pack ("{s:s, s:I, s:s}", - "table", table, - "row", (json_int_t) rowid, - "diagnostic", diagnostic)); + json_pack ("{s:s, s:I, s:s}", + "table", table, + "row", (json_int_t) rowid, + "diagnostic", diagnostic)); } @@ -588,7 +597,9 @@ static struct GNUNET_CONTAINER_MultiHashMap *denominations; */ static enum GNUNET_DB_QueryStatus get_denomination_info_by_hash (const struct GNUNET_HashCode *dh, - const struct TALER_EXCHANGEDB_DenominationKeyInformationP **dki) + const struct + TALER_EXCHANGEDB_DenominationKeyInformationP ** + dki) { struct TALER_EXCHANGEDB_DenominationKeyInformationP *dkip; enum GNUNET_DB_QueryStatus qs; @@ -646,7 +657,8 @@ get_denomination_info_by_hash (const struct GNUNET_HashCode *dh, */ static enum GNUNET_DB_QueryStatus get_denomination_info (const struct TALER_DenominationPublicKey *denom_pub, - const struct TALER_EXCHANGEDB_DenominationKeyInformationP **dki, + const struct + TALER_EXCHANGEDB_DenominationKeyInformationP **dki, struct GNUNET_HashCode *dh) { struct GNUNET_HashCode hc; @@ -997,9 +1009,11 @@ handle_reserve_out (void *cls, report (denomination_key_validity_withdraw_inconsistencies, json_pack ("{s:I, s:s, s:o, s:o}", "row", (json_int_t) rowid, - "execution_date", GNUNET_STRINGS_absolute_time_to_string (execution_date), + "execution_date", + GNUNET_STRINGS_absolute_time_to_string (execution_date), "reserve_pub", GNUNET_JSON_from_data_auto (reserve_pub), - "denompub_h", GNUNET_JSON_from_data_auto (&wsrd.h_denomination_pub))); + "denompub_h", GNUNET_JSON_from_data_auto ( + &wsrd.h_denomination_pub))); } /* check reserve_sig */ @@ -1106,7 +1120,8 @@ handle_payback_by_reserve (void *cls, const struct TALER_CoinPublicInfo *coin, const struct TALER_DenominationPublicKey *denom_pub, const struct TALER_CoinSpendSignatureP *coin_sig, - const struct TALER_DenominationBlindingKeyP *coin_blind) + const struct + TALER_DenominationBlindingKeyP *coin_blind) { struct ReserveContext *rc = cls; struct GNUNET_HashCode key; @@ -1138,7 +1153,8 @@ handle_payback_by_reserve (void *cls, "operation", "payback", "row", (json_int_t) rowid, "loss", TALER_JSON_from_amount (amount), - "key_pub", GNUNET_JSON_from_data_auto (&coin->coin_pub))); + "key_pub", GNUNET_JSON_from_data_auto ( + &coin->coin_pub))); GNUNET_break (GNUNET_OK == TALER_amount_add (&total_bad_sig_loss, &total_bad_sig_loss, @@ -1175,14 +1191,16 @@ handle_payback_by_reserve (void *cls, /* verify msig */ struct TALER_MasterDenominationKeyRevocationPS kr; - kr.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED); + kr.purpose.purpose = htonl ( + TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED); kr.purpose.size = htonl (sizeof (kr)); kr.h_denom_pub = pr.h_denom_pub; if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED, - &kr.purpose, - &msig.eddsa_signature, - &master_pub.eddsa_pub)) + GNUNET_CRYPTO_eddsa_verify ( + TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED, + &kr.purpose, + &msig.eddsa_signature, + &master_pub.eddsa_pub)) { rev = "master signature invalid"; } @@ -1287,7 +1305,8 @@ handle_reserve_closed (void *cls, const struct TALER_Amount *closing_fee, const struct TALER_ReservePublicKeyP *reserve_pub, const char *receiver_account, - const struct TALER_WireTransferIdentifierRawP *transfer_details) + const struct + TALER_WireTransferIdentifierRawP *transfer_details) { struct ReserveContext *rc = cls; struct GNUNET_HashCode key; @@ -1468,7 +1487,8 @@ verify_reserve_balance (void *cls, /* Check that reserve is being closed if it is past its expiration date */ if ( (CLOSING_GRACE_PERIOD.rel_value_us > - GNUNET_TIME_absolute_get_duration (rs->a_expiration_date).rel_value_us) && + GNUNET_TIME_absolute_get_duration ( + rs->a_expiration_date).rel_value_us) && ( (0 != balance.value) || (0 != balance.fraction) ) ) { @@ -1483,7 +1503,8 @@ verify_reserve_balance (void *cls, "balance", TALER_JSON_from_amount (&balance), "expiration_time", - GNUNET_STRINGS_absolute_time_to_string (rs->a_expiration_date))); + GNUNET_STRINGS_absolute_time_to_string ( + rs->a_expiration_date))); } /* Add withdraw fees we encountered to totals */ @@ -1578,7 +1599,7 @@ verify_reserve_balance (void *cls, ret = GNUNET_SYSERR; rc->qs = qs; } - cleanup: + cleanup: GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (rc->reserves, key, @@ -1616,12 +1637,13 @@ analyze_reserves (void *cls) if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsp) { GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, - _("First analysis using this auditor, starting audit from scratch\n")); + _ ( + "First analysis using this auditor, starting audit from scratch\n")); } else { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Resuming reserve audit at %llu/%llu/%llu/%llu\n"), + _ ("Resuming reserve audit at %llu/%llu/%llu/%llu\n"), (unsigned long long) ppr.last_reserve_in_serial_id, (unsigned long long) ppr.last_reserve_out_serial_id, (unsigned long long) ppr.last_reserve_payback_serial_id, @@ -1675,7 +1697,8 @@ analyze_reserves (void *cls) } qs = edb->select_reserve_closed_above_serial_id (edb->cls, esession, - ppr.last_reserve_close_serial_id, + ppr. + last_reserve_close_serial_id, &handle_reserve_closed, &rc); if (qs < 0) @@ -1729,12 +1752,12 @@ analyze_reserves (void *cls) if (0 >= qs) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Failed to update auditor DB, not recording progress\n"); + "Failed to update auditor DB, not recording progress\n"); GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Concluded reserve audit step at %llu/%llu/%llu/%llu\n"), + _ ("Concluded reserve audit step at %llu/%llu/%llu/%llu\n"), (unsigned long long) ppr.last_reserve_in_serial_id, (unsigned long long) ppr.last_reserve_out_serial_id, (unsigned long long) ppr.last_reserve_payback_serial_id, @@ -1939,11 +1962,17 @@ struct WireCheckContext * @return #GNUNET_OK on success, #GNUNET_SYSERR on error */ static int -check_transaction_history_for_deposit (const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki, - const struct TALER_EXCHANGEDB_TransactionList *tl_head, +check_transaction_history_for_deposit (const struct + TALER_CoinSpendPublicKeyP *coin_pub, + const struct + GNUNET_HashCode *h_contract_terms, + const struct + TALER_MerchantPublicKeyP *merchant_pub, + const struct + TALER_EXCHANGEDB_DenominationKeyInformationP + *dki, + const struct + TALER_EXCHANGEDB_TransactionList *tl_head, struct TALER_Amount *merchant_gain) { struct TALER_Amount expenditures; @@ -1987,7 +2016,8 @@ check_transaction_history_for_deposit (const struct TALER_CoinSpendPublicKeyP *c const struct TALER_AmountNBO *fee_dki; struct TALER_Amount tmp; - switch (tl->type) { + switch (tl->type) + { case TALER_EXCHANGEDB_TT_DEPOSIT: amount_with_fee = &tl->details.deposit->amount_with_fee; fee = &tl->details.deposit->deposit_fee; @@ -2241,12 +2271,14 @@ check_transaction_history_for_deposit (const struct TALER_CoinSpendPublicKeyP *c static void wire_transfer_information_cb (void *cls, uint64_t rowid, - const struct TALER_MerchantPublicKeyP *merchant_pub, + const struct + TALER_MerchantPublicKeyP *merchant_pub, const struct GNUNET_HashCode *h_wire, const json_t *account_details, struct GNUNET_TIME_Absolute exec_time, const struct GNUNET_HashCode *h_contract_terms, - const struct TALER_DenominationPublicKey *denom_pub, + const struct + TALER_DenominationPublicKey *denom_pub, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_Amount *coin_value, const struct TALER_Amount *deposit_fee) @@ -2343,7 +2375,8 @@ wire_transfer_information_cb (void *cls, "operation", "wire", "row", (json_int_t) rowid, "loss", TALER_JSON_from_amount (coin_value), - "key_pub", GNUNET_JSON_from_data_auto (&dki->properties.denom_hash))); + "key_pub", GNUNET_JSON_from_data_auto ( + &dki->properties.denom_hash))); GNUNET_break (GNUNET_OK == TALER_amount_add (&total_bad_sig_loss, &total_bad_sig_loss, @@ -2434,8 +2467,8 @@ wire_transfer_information_cb (void *cls, /* Add coin's contribution to total aggregate value */ if (GNUNET_OK != TALER_amount_add (&wcc->total_deposits, - &wcc->total_deposits, - &coin_value_without_fee)) + &wcc->total_deposits, + &coin_value_without_fee)) { GNUNET_break (0); wcc->qs = GNUNET_DB_STATUS_HARD_ERROR; @@ -2542,7 +2575,8 @@ get_wire_fee (struct AggregationContext *ac, json_pack ("{s:s, s:s, s:s}", "type", type, "diagnostic", "start date before previous end date", - "time", GNUNET_STRINGS_absolute_time_to_string (wfi->start_date))); + "time", GNUNET_STRINGS_absolute_time_to_string ( + wfi->start_date))); } if ( (NULL != wfi->next) && (wfi->next->start_date.abs_value_us >= wfi->end_date.abs_value_us) ) @@ -2551,7 +2585,8 @@ get_wire_fee (struct AggregationContext *ac, json_pack ("{s:s, s:s, s:s}", "type", type, "diagnostic", "end date date after next start date", - "time", GNUNET_STRINGS_absolute_time_to_string (wfi->end_date))); + "time", GNUNET_STRINGS_absolute_time_to_string ( + wfi->end_date))); } return &wfi->wire_fee; } @@ -2572,11 +2607,11 @@ get_wire_fee (struct AggregationContext *ac, static int check_wire_out_cb (void *cls, - uint64_t rowid, - struct GNUNET_TIME_Absolute date, - const struct TALER_WireTransferIdentifierRawP *wtid, - const json_t *wire, - const struct TALER_Amount *amount) + uint64_t rowid, + struct GNUNET_TIME_Absolute date, + const struct TALER_WireTransferIdentifierRawP *wtid, + const json_t *wire, + const struct TALER_Amount *amount) { struct AggregationContext *ac = cls; struct WireCheckContext wcc; @@ -2659,10 +2694,10 @@ check_wire_out_cb report_amount_arithmetic_inconsistency ("wire out (fee structure)", - rowid, - &wcc.total_deposits, - wire_fee, - -1); + rowid, + &wcc.total_deposits, + wire_fee, + -1); GNUNET_free (method); return GNUNET_OK; @@ -2670,8 +2705,8 @@ check_wire_out_cb /* Round down to amount supported by wire method */ plugin = get_wire_plugin - (ac, - TALER_WIRE_get_plugin_from_method (method)); + (ac, + TALER_WIRE_get_plugin_from_method (method)); if (NULL == plugin) { GNUNET_break (0); @@ -2786,12 +2821,13 @@ analyze_aggregations (void *cls) if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsp) { GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, - _("First analysis using this auditor, starting audit from scratch\n")); + _ ( + "First analysis using this auditor, starting audit from scratch\n")); } else { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Resuming aggregation audit at %llu\n"), + _ ("Resuming aggregation audit at %llu\n"), (unsigned long long) ppa.last_wire_out_serial_id); } @@ -2799,9 +2835,9 @@ analyze_aggregations (void *cls) 0, sizeof (ac)); qsx = adb->get_wire_fee_summary (adb->cls, - asession, - &master_pub, - &total_aggregation_fee_income); + asession, + &master_pub, + &total_aggregation_fee_income); if (0 > qsx) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qsx); @@ -2809,10 +2845,10 @@ analyze_aggregations (void *cls) } ac.qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; qs = edb->select_wire_out_above_serial_id (edb->cls, - esession, - ppa.last_wire_out_serial_id, - &check_wire_out_cb, - &ac); + esession, + ppa.last_wire_out_serial_id, + &check_wire_out_cb, + &ac); if (0 > qs) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); @@ -2867,12 +2903,12 @@ analyze_aggregations (void *cls) if (0 >= qs) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Failed to update auditor DB, not recording progress\n"); + "Failed to update auditor DB, not recording progress\n"); GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Concluded aggregation audit step at %llu\n"), + _ ("Concluded aggregation audit step at %llu\n"), (unsigned long long) ppa.last_wire_out_serial_id); return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; @@ -3006,14 +3042,16 @@ init_denomination (const struct GNUNET_HashCode *denom_hash, /* check revocation signature */ struct TALER_MasterDenominationKeyRevocationPS rm; - rm.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED); + rm.purpose.purpose = htonl ( + TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED); rm.purpose.size = htonl (sizeof (rm)); rm.h_denom_pub = *denom_hash; if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED, - &rm.purpose, - &msig.eddsa_signature, - &master_pub.eddsa_pub)) + GNUNET_CRYPTO_eddsa_verify ( + TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED, + &rm.purpose, + &msig.eddsa_signature, + &master_pub.eddsa_pub)) { report_row_inconsistency ("denomination revocation table", rowid, @@ -3051,7 +3089,8 @@ init_denomination (const struct GNUNET_HashCode *denom_hash, */ static struct DenominationSummary * get_denomination_summary (struct CoinContext *cc, - const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki, + const struct + TALER_EXCHANGEDB_DenominationKeyInformationP *dki, const struct GNUNET_HashCode *dh) { struct DenominationSummary *ds; @@ -3112,8 +3151,8 @@ sync_denomination (void *cls, outstanding coins as revenue; and reduce cc->risk exposure. */ if (ds->in_db) qs = adb->del_denomination_balance (adb->cls, - asession, - denom_hash); + asession, + denom_hash); else qs = GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; if ( (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) && @@ -3372,7 +3411,7 @@ reveal_data_cb (void *cls, rctx->num_newcoins = num_newcoins; rctx->new_dps = GNUNET_new_array (num_newcoins, struct TALER_DenominationPublicKey); - for (unsigned int i=0;i<num_newcoins;i++) + for (unsigned int i = 0; i<num_newcoins; i++) rctx->new_dps[i].rsa_public_key = GNUNET_CRYPTO_rsa_public_key_dup (rrcs[i].denom_pub.rsa_public_key); } @@ -3502,12 +3541,14 @@ refresh_session_cb (void *cls, } { - const struct TALER_EXCHANGEDB_DenominationKeyInformationP *new_dkis[reveal_ctx.num_newcoins]; + const struct + TALER_EXCHANGEDB_DenominationKeyInformationP *new_dkis[reveal_ctx. + num_newcoins]; /* Update outstanding amounts for all new coin's denominations, and check that the resulting amounts are consistent with the value being refreshed. */ err = GNUNET_NO; - for (unsigned int i=0;i<reveal_ctx.num_newcoins;i++) + for (unsigned int i = 0; i<reveal_ctx.num_newcoins; i++) { /* lookup new coin denomination key */ qs = get_denomination_info (&reveal_ctx.new_dps[i], @@ -3519,7 +3560,8 @@ refresh_session_cb (void *cls, cc->qs = qs; err = GNUNET_YES; } - GNUNET_CRYPTO_rsa_public_key_free (reveal_ctx.new_dps[i].rsa_public_key); + GNUNET_CRYPTO_rsa_public_key_free ( + reveal_ctx.new_dps[i].rsa_public_key); reveal_ctx.new_dps[i].rsa_public_key = NULL; } GNUNET_free (reveal_ctx.new_dps); @@ -3529,7 +3571,7 @@ refresh_session_cb (void *cls, return GNUNET_SYSERR; /* calculate total refresh cost */ - for (unsigned int i=0;i<reveal_ctx.num_newcoins;i++) + for (unsigned int i = 0; i<reveal_ctx.num_newcoins; i++) { /* update cost of refresh */ struct TALER_Amount fee; @@ -3585,7 +3627,7 @@ refresh_session_cb (void *cls, } /* update outstanding denomination amounts */ - for (unsigned int i=0;i<reveal_ctx.num_newcoins;i++) + for (unsigned int i = 0; i<reveal_ctx.num_newcoins; i++) { struct DenominationSummary *dsi; struct TALER_Amount value; @@ -4066,7 +4108,8 @@ check_payback (struct CoinContext *cc, "operation", "payback", "row", (json_int_t) rowid, "loss", TALER_JSON_from_amount (amount), - "key_pub", GNUNET_JSON_from_data_auto (&pr.h_denom_pub))); + "key_pub", GNUNET_JSON_from_data_auto ( + &pr.h_denom_pub))); GNUNET_break (GNUNET_OK == TALER_amount_add (&total_bad_sig_loss, &total_bad_sig_loss, @@ -4098,7 +4141,8 @@ check_payback (struct CoinContext *cc, "operation", "payback", "row", (json_int_t) rowid, "loss", TALER_JSON_from_amount (amount), - "coin_pub", GNUNET_JSON_from_data_auto (&coin->coin_pub))); + "coin_pub", GNUNET_JSON_from_data_auto ( + &coin->coin_pub))); GNUNET_break (GNUNET_OK == TALER_amount_add (&total_bad_sig_loss, &total_bad_sig_loss, @@ -4116,7 +4160,8 @@ check_payback (struct CoinContext *cc, "operation", "payback (denomination not revoked)", "row", (json_int_t) rowid, "loss", TALER_JSON_from_amount (amount), - "coin_pub", GNUNET_JSON_from_data_auto (&coin->coin_pub))); + "coin_pub", GNUNET_JSON_from_data_auto ( + &coin->coin_pub))); } GNUNET_break (GNUNET_OK == TALER_amount_add (&ds->denom_payback, @@ -4231,12 +4276,13 @@ analyze_coins (void *cls) if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsp) { GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, - _("First analysis using this auditor, starting audit from scratch\n")); + _ ( + "First analysis using this auditor, starting audit from scratch\n")); } else { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Resuming coin audit at %llu/%llu/%llu/%llu/%llu\n"), + _ ("Resuming coin audit at %llu/%llu/%llu/%llu/%llu\n"), (unsigned long long) ppc.last_deposit_serial_id, (unsigned long long) ppc.last_melt_serial_id, (unsigned long long) ppc.last_refund_serial_id, @@ -4267,7 +4313,8 @@ analyze_coins (void *cls) if (0 > (qs = edb->select_reserves_out_above_serial_id (edb->cls, esession, - ppc.last_withdraw_serial_id, + ppc. + last_withdraw_serial_id, &withdraw_cb, &cc)) ) { @@ -4325,7 +4372,8 @@ analyze_coins (void *cls) if (0 > (qs = edb->select_payback_refresh_above_serial_id (edb->cls, esession, - ppc.last_payback_refresh_serial_id, + ppc. + last_payback_refresh_serial_id, &payback_refresh_cb, &cc))) { @@ -4383,12 +4431,12 @@ analyze_coins (void *cls) if (0 >= qs) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Failed to update auditor DB, not recording progress\n"); + "Failed to update auditor DB, not recording progress\n"); GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Concluded coin audit step at %llu/%llu/%llu/%llu/%llu\n"), + _ ("Concluded coin audit step at %llu/%llu/%llu/%llu/%llu\n"), (unsigned long long) ppc.last_deposit_serial_id, (unsigned long long) ppc.last_melt_serial_id, (unsigned long long) ppc.last_refund_serial_id, @@ -4528,12 +4576,13 @@ analyze_deposit_confirmations (void *cls) if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsp) { GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, - _("First analysis using this auditor, starting audit from scratch\n")); + _ ( + "First analysis using this auditor, starting audit from scratch\n")); } else { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Resuming deposit confirmation audit at %llu\n"), + _ ("Resuming deposit confirmation audit at %llu\n"), (unsigned long long) ppdc.last_deposit_confirmation_serial_id); } @@ -4579,7 +4628,7 @@ analyze_deposit_confirmations (void *cls) if (0 >= qs) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Failed to update auditor DB, not recording progress\n"); + "Failed to update auditor DB, not recording progress\n"); GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } @@ -4587,7 +4636,7 @@ analyze_deposit_confirmations (void *cls) total_missed_deposit_confirmations = dcc.missed_amount; GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Concluded deposit confirmation audit step at %llu\n"), + _ ("Concluded deposit confirmation audit step at %llu\n"), (unsigned long long) ppdc.last_deposit_confirmation_serial_id); return qs; } @@ -4657,10 +4706,10 @@ transact (Analysis analysis, else { qs = adb->commit (adb->cls, - asession); + asession); if (0 > qs) { - GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); + GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Auditor DB commit failed!\n"); } @@ -4781,7 +4830,8 @@ run (void *cls, } if (GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (master_public_key_str, - strlen (master_public_key_str), + strlen ( + master_public_key_str), &master_pub.eddsa_pub)) { fprintf (stderr, @@ -4807,9 +4857,9 @@ run (void *cls, } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, - "exchangedb", - "IDLE_RESERVE_EXPIRATION_TIME", - &idle_reserve_expiration_time)) + "exchangedb", + "IDLE_RESERVE_EXPIRATION_TIME", + &idle_reserve_expiration_time)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "exchangedb", @@ -4946,33 +4996,36 @@ run (void *cls, TALER_amount_get_zero (currency, &total_refresh_hanging)); GNUNET_assert (NULL != - (report_emergencies = json_array ())); + (report_emergencies = json_array ())); GNUNET_assert (NULL != - (report_row_inconsistencies = json_array ())); + (report_row_inconsistencies = json_array ())); GNUNET_assert (NULL != - (denomination_key_validity_withdraw_inconsistencies = json_array ())); + (denomination_key_validity_withdraw_inconsistencies = + json_array ())); GNUNET_assert (NULL != - (report_reserve_balance_summary_wrong_inconsistencies = json_array ())); + (report_reserve_balance_summary_wrong_inconsistencies = + json_array ())); GNUNET_assert (NULL != - (report_reserve_balance_insufficient_inconsistencies = json_array ())); + (report_reserve_balance_insufficient_inconsistencies = + json_array ())); GNUNET_assert (NULL != - (report_reserve_not_closed_inconsistencies = json_array ())); + (report_reserve_not_closed_inconsistencies = json_array ())); GNUNET_assert (NULL != - (report_wire_out_inconsistencies = json_array ())); + (report_wire_out_inconsistencies = json_array ())); GNUNET_assert (NULL != - (report_deposit_confirmation_inconsistencies = json_array ())); + (report_deposit_confirmation_inconsistencies = json_array ())); GNUNET_assert (NULL != - (report_coin_inconsistencies = json_array ())); + (report_coin_inconsistencies = json_array ())); GNUNET_assert (NULL != - (report_aggregation_fee_balances = json_array ())); + (report_aggregation_fee_balances = json_array ())); GNUNET_assert (NULL != - (report_amount_arithmetic_inconsistencies = json_array ())); + (report_amount_arithmetic_inconsistencies = json_array ())); GNUNET_assert (NULL != - (report_bad_sig_losses = json_array ())); + (report_bad_sig_losses = json_array ())); GNUNET_assert (NULL != - (report_refreshs_hanging = json_array ())); + (report_refreshs_hanging = json_array ())); GNUNET_assert (NULL != - (report_fee_time_inconsistencies = json_array ())); + (report_fee_time_inconsistencies = json_array ())); setup_sessions_and_run (); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Audit complete\n"); @@ -5008,9 +5061,11 @@ run (void *cls, "reserve_balance_summary_wrong_inconsistencies", report_reserve_balance_summary_wrong_inconsistencies, "total_balance_summary_delta_plus", - TALER_JSON_from_amount (&total_balance_summary_delta_plus), + TALER_JSON_from_amount ( + &total_balance_summary_delta_plus), "total_balance_summary_delta_minus", - TALER_JSON_from_amount (&total_balance_summary_delta_minus), + TALER_JSON_from_amount ( + &total_balance_summary_delta_minus), /* block */ "total_escrow_balance", TALER_JSON_from_amount (&total_escrow_balance), @@ -5035,7 +5090,8 @@ run (void *cls, report_reserve_not_closed_inconsistencies, /* block */ "total_balance_reserve_not_closed", - TALER_JSON_from_amount (&total_balance_reserve_not_closed), + TALER_JSON_from_amount ( + &total_balance_reserve_not_closed), "wire_out_inconsistencies", report_wire_out_inconsistencies, "total_wire_out_delta_plus", @@ -5079,14 +5135,15 @@ run (void *cls, (json_int_t) number_missed_deposit_confirmations, /* block */ "missing_deposit_confirmation_total", - TALER_JSON_from_amount (&total_missed_deposit_confirmations), + TALER_JSON_from_amount ( + &total_missed_deposit_confirmations), "total_payback_loss", TALER_JSON_from_amount (&total_payback_loss) ); GNUNET_break (NULL != report); json_dumpf (report, - stdout, - JSON_INDENT (2)); + stdout, + JSON_INDENT (2)); json_decref (report); } diff --git a/src/auditor/taler-wire-auditor.c b/src/auditor/taler-wire-auditor.c index f0b11853..a94cd5f6 100644 --- a/src/auditor/taler-wire-auditor.c +++ b/src/auditor/taler-wire-auditor.c @@ -90,7 +90,7 @@ struct WireAccount * Number of bytes in #in_wire_off and #out_wire_off. */ size_t wire_off_size; - + /** * We should check for inbound transactions to this account. */ @@ -556,7 +556,7 @@ commit (enum GNUNET_DB_QueryStatus qs) GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } - } + } if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qsx) qs = adb->update_wire_auditor_progress (adb->cls, asession, @@ -652,7 +652,8 @@ wire_missing_cb (void *cls, json_pack ("{s:I, s:o, s:s, s:s, s:o, s:O}", "row", (json_int_t) rowid, "amount", TALER_JSON_from_amount (amount), - "deadline", GNUNET_STRINGS_absolute_time_to_string (deadline), + "deadline", GNUNET_STRINGS_absolute_time_to_string ( + deadline), "claimed_done", (done) ? "yes" : "no", "coin_pub", GNUNET_JSON_from_data_auto (coin_pub), "account", wire)); @@ -663,7 +664,7 @@ wire_missing_cb (void *cls, /** * Checks that all wire transfers that should have happened * (based on deposits) have indeed happened. - * + * * FIXME: this check _might_ rather belong with the * taler-auditor logic. */ @@ -672,7 +673,7 @@ check_for_required_transfers () { struct GNUNET_TIME_Absolute next_timestamp; enum GNUNET_DB_QueryStatus qs; - + next_timestamp = GNUNET_TIME_absolute_get (); (void) GNUNET_TIME_round_abs (&next_timestamp); /* Subtract #GRACE_PERIOD, so we can be a bit behind in processing @@ -761,7 +762,8 @@ wire_out_cb (void *cls, "amount_wired", TALER_JSON_from_amount (&zero), "amount_justified", TALER_JSON_from_amount (amount), "wtid", GNUNET_JSON_from_data_auto (wtid), - "timestamp", GNUNET_STRINGS_absolute_time_to_string (date), + "timestamp", GNUNET_STRINGS_absolute_time_to_string ( + date), "diagnostic", "wire transfer not made (yet?)")); GNUNET_break (GNUNET_OK == TALER_amount_add (&total_bad_amount_out_minus, @@ -782,10 +784,12 @@ wire_out_cb (void *cls, report (report_wire_out_inconsistencies, json_pack ("{s:I, s:o, s:o, s:o, s:s, s:s}", "row", (json_int_t) rowid, - "amount_wired", TALER_JSON_from_amount (&roi->details.amount), + "amount_wired", TALER_JSON_from_amount ( + &roi->details.amount), "amount_justified", TALER_JSON_from_amount (&zero), "wtid", GNUNET_JSON_from_data_auto (wtid), - "timestamp", GNUNET_STRINGS_absolute_time_to_string (date), + "timestamp", GNUNET_STRINGS_absolute_time_to_string ( + date), "diagnostic", "recevier account missmatch")); GNUNET_break (GNUNET_OK == TALER_amount_add (&total_bad_amount_out_plus, @@ -797,7 +801,8 @@ wire_out_cb (void *cls, "amount_wired", TALER_JSON_from_amount (&zero), "amount_justified", TALER_JSON_from_amount (amount), "wtid", GNUNET_JSON_from_data_auto (wtid), - "timestamp", GNUNET_STRINGS_absolute_time_to_string (date), + "timestamp", GNUNET_STRINGS_absolute_time_to_string ( + date), "diagnostic", "receiver account missmatch")); GNUNET_break (GNUNET_OK == TALER_amount_add (&total_bad_amount_out_minus, @@ -815,9 +820,11 @@ wire_out_cb (void *cls, json_pack ("{s:I, s:o, s:o, s:o, s:s, s:s}", "row", (json_int_t) rowid, "amount_justified", TALER_JSON_from_amount (amount), - "amount_wired", TALER_JSON_from_amount (&roi->details.amount), + "amount_wired", TALER_JSON_from_amount ( + &roi->details.amount), "wtid", GNUNET_JSON_from_data_auto (wtid), - "timestamp", GNUNET_STRINGS_absolute_time_to_string (date), + "timestamp", GNUNET_STRINGS_absolute_time_to_string ( + date), "diagnostic", "wire amount does not match")); if (0 < TALER_amount_cmp (amount, &roi->details.amount)) @@ -859,7 +866,7 @@ wire_out_cb (void *cls, "row", (json_int_t) rowid, "diagnostic", "execution date missmatch")); } -cleanup: + cleanup: GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_remove (out_map, &key, @@ -894,13 +901,16 @@ complain_out_not_found (void *cls, report (report_wire_out_inconsistencies, json_pack ("{s:I, s:o, s:o, s:o, s:s, s:s}", "row", (json_int_t) 0, - "amount_wired", TALER_JSON_from_amount (&roi->details.amount), + "amount_wired", TALER_JSON_from_amount ( + &roi->details.amount), "amount_justified", TALER_JSON_from_amount (&zero), "wtid", (NULL == roi->details.wtid_s) ? GNUNET_JSON_from_data_auto (&roi->details.wtid) : json_string (roi->details.wtid_s), - "timestamp", GNUNET_STRINGS_absolute_time_to_string (roi->details.execution_date), - "diagnostic", "justification for wire transfer not found")); + "timestamp", GNUNET_STRINGS_absolute_time_to_string ( + roi->details.execution_date), + "diagnostic", + "justification for wire transfer not found")); GNUNET_break (GNUNET_OK == TALER_amount_add (&total_bad_amount_out_plus, &total_bad_amount_out_plus, @@ -937,7 +947,8 @@ check_exchange_wire_out (struct WireAccount *wa) qs = edb->select_wire_out_above_serial_id_by_account (edb->cls, esession, wa->section_name, - wa->pp.last_wire_out_serial_id, + wa->pp. + last_wire_out_serial_id, &wire_out_cb, wa); if (0 > qs) @@ -1093,7 +1104,7 @@ process_debits (void *cls) struct WireAccount *wa = cls; struct TALER_WIRE_Plugin *wp; - /* skip accounts where DEBIT is not enabled */ + /* skip accounts where DEBIT is not enabled */ while ( (NULL != wa) && (GNUNET_NO == wa->watch_debit) ) wa = wa->next; @@ -1193,8 +1204,8 @@ reserve_in_cb (void *cls, TALER_B2S (reserve_pub)); rii = GNUNET_new (struct ReserveInInfo); GNUNET_CRYPTO_hash (wire_reference, - wire_reference_size, - &rii->row_off_hash); + wire_reference_size, + &rii->row_off_hash); rii->row_off_size = wire_reference_size; rii->details.amount = *credit; rii->details.execution_date = execution_date; @@ -1216,7 +1227,8 @@ reserve_in_cb (void *cls, json_pack ("{s:s, s:I, s:o, s:s}", "table", "reserves_in", "row", (json_int_t) rowid, - "wire_offset_hash", GNUNET_JSON_from_data_auto (&rii->row_off_hash), + "wire_offset_hash", GNUNET_JSON_from_data_auto ( + &rii->row_off_hash), "diagnostic", "duplicate wire offset")); GNUNET_free (rii->details.account_url); GNUNET_free_non_null (rii->details.wtid_s); /* field not used (yet) */ @@ -1248,11 +1260,14 @@ complain_in_not_found (void *cls, report (report_reserve_in_inconsistencies, json_pack ("{s:I, s:o, s:o, s:o, s:s, s:s}", "row", (json_int_t) rii->rowid, - "amount_expected", TALER_JSON_from_amount (&rii->details.amount), + "amount_expected", TALER_JSON_from_amount ( + &rii->details.amount), "amount_wired", TALER_JSON_from_amount (&zero), "wtid", GNUNET_JSON_from_data_auto (&rii->details.wtid), - "timestamp", GNUNET_STRINGS_absolute_time_to_string (rii->details.execution_date), - "diagnostic", "incoming wire transfer claimed by exchange not found")); + "timestamp", GNUNET_STRINGS_absolute_time_to_string ( + rii->details.execution_date), + "diagnostic", + "incoming wire transfer claimed by exchange not found")); GNUNET_break (GNUNET_OK == TALER_amount_add (&total_bad_amount_in_minus, &total_bad_amount_in_minus, @@ -1334,7 +1349,8 @@ history_credit_cb (void *cls, { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Failed to find wire transfer at `%s' in exchange database. Audit ends at this point in time.\n", - GNUNET_STRINGS_absolute_time_to_string (details->execution_date)); + GNUNET_STRINGS_absolute_time_to_string ( + details->execution_date)); wa->hh = NULL; process_credits (wa->next); return GNUNET_SYSERR; /* not an error, just end of processing */ @@ -1376,10 +1392,12 @@ history_credit_cb (void *cls, report (report_reserve_in_inconsistencies, json_pack ("{s:I, s:o, s:o, s:o, s:s, s:s}", "row", GNUNET_JSON_from_data (row_off, row_off_size), - "amount_exchange_expected", TALER_JSON_from_amount (&rii->details.amount), + "amount_exchange_expected", TALER_JSON_from_amount ( + &rii->details.amount), "amount_wired", TALER_JSON_from_amount (&zero), "wtid", GNUNET_JSON_from_data_auto (&rii->details.wtid), - "timestamp", GNUNET_STRINGS_absolute_time_to_string (rii->details.execution_date), + "timestamp", GNUNET_STRINGS_absolute_time_to_string ( + rii->details.execution_date), "diagnostic", "wire subject does not match")); GNUNET_break (GNUNET_OK == TALER_amount_add (&total_bad_amount_in_minus, @@ -1388,10 +1406,13 @@ history_credit_cb (void *cls, report (report_reserve_in_inconsistencies, json_pack ("{s:I, s:o, s:o, s:o, s:s, s:s}", "row", GNUNET_JSON_from_data (row_off, row_off_size), - "amount_exchange_expected", TALER_JSON_from_amount (&zero), - "amount_wired", TALER_JSON_from_amount (&details->amount), + "amount_exchange_expected", TALER_JSON_from_amount ( + &zero), + "amount_wired", TALER_JSON_from_amount ( + &details->amount), "wtid", GNUNET_JSON_from_data_auto (&details->wtid), - "timestamp", GNUNET_STRINGS_absolute_time_to_string (details->execution_date), + "timestamp", GNUNET_STRINGS_absolute_time_to_string ( + details->execution_date), "diagnostic", "wire subject does not match")); GNUNET_break (GNUNET_OK == @@ -1406,10 +1427,13 @@ history_credit_cb (void *cls, report (report_reserve_in_inconsistencies, json_pack ("{s:I, s:o, s:o, s:o, s:s, s:s}", "row", GNUNET_JSON_from_data (row_off, row_off_size), - "amount_exchange_expected", TALER_JSON_from_amount (&rii->details.amount), - "amount_wired", TALER_JSON_from_amount (&details->amount), + "amount_exchange_expected", TALER_JSON_from_amount ( + &rii->details.amount), + "amount_wired", TALER_JSON_from_amount ( + &details->amount), "wtid", GNUNET_JSON_from_data_auto (&details->wtid), - "timestamp", GNUNET_STRINGS_absolute_time_to_string (details->execution_date), + "timestamp", GNUNET_STRINGS_absolute_time_to_string ( + details->execution_date), "diagnostic", "wire amount does not match")); if (0 < TALER_amount_cmp (&details->amount, &rii->details.amount)) @@ -1449,7 +1473,8 @@ history_credit_cb (void *cls, json_pack ("{s:s, s:o, s:o}", "amount", TALER_JSON_from_amount (&rii->details.amount), "row", GNUNET_JSON_from_data (row_off, row_off_size), - "wtid", GNUNET_JSON_from_data_auto (&rii->details.wtid))); + "wtid", GNUNET_JSON_from_data_auto ( + &rii->details.wtid))); GNUNET_break (GNUNET_OK == TALER_amount_add (&total_missattribution_in, &total_missattribution_in, @@ -1464,7 +1489,7 @@ history_credit_cb (void *cls, "row", GNUNET_JSON_from_data (row_off, row_off_size), "diagnostic", "execution date missmatch")); } - cleanup: + cleanup: GNUNET_assert (GNUNET_OK == free_rii (NULL, &key, @@ -1505,7 +1530,8 @@ process_credits (void *cls) qs = edb->select_reserves_in_above_serial_id_by_account (edb->cls, esession, wa->section_name, - wa->pp.last_reserve_in_serial_id, + wa->pp. + last_reserve_in_serial_id, &reserve_in_cb, wa); if (0 > qs) @@ -1542,7 +1568,7 @@ process_credits (void *cls) /** * Begin audit of CREDITs to the exchange. - */ + */ static void begin_credit_audit () { @@ -1555,7 +1581,7 @@ begin_credit_audit () /** * Start the database transactions and begin the audit. - */ + */ static void begin_transaction () { @@ -1617,7 +1643,8 @@ begin_transaction () if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qsx) { GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, - _("First analysis using this auditor, starting audit from scratch\n")); + _ ( + "First analysis using this auditor, starting audit from scratch\n")); } else { @@ -1739,7 +1766,8 @@ run (void *cls, } if (GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (master_public_key_str, - strlen (master_public_key_str), + strlen ( + master_public_key_str), &master_pub.eddsa_pub)) { fprintf (stderr, @@ -1821,19 +1849,19 @@ run (void *cls, return; } GNUNET_assert (NULL != - (report_wire_out_inconsistencies = json_array ())); + (report_wire_out_inconsistencies = json_array ())); GNUNET_assert (NULL != - (report_reserve_in_inconsistencies = json_array ())); + (report_reserve_in_inconsistencies = json_array ())); GNUNET_assert (NULL != - (report_row_minor_inconsistencies = json_array ())); + (report_row_minor_inconsistencies = json_array ())); GNUNET_assert (NULL != - (report_wire_format_inconsistencies = json_array ())); + (report_wire_format_inconsistencies = json_array ())); GNUNET_assert (NULL != - (report_row_inconsistencies = json_array ())); + (report_row_inconsistencies = json_array ())); GNUNET_assert (NULL != - (report_missattribution_in_inconsistencies = json_array ())); + (report_missattribution_in_inconsistencies = json_array ())); GNUNET_assert (NULL != - (report_lags = json_array ())); + (report_lags = json_array ())); GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (currency, &total_bad_amount_out_plus)); diff --git a/src/auditordb/auditordb_plugin.c b/src/auditordb/auditordb_plugin.c index 6aa0274f..51ae77c1 100644 --- a/src/auditordb/auditordb_plugin.c +++ b/src/auditordb/auditordb_plugin.c @@ -55,7 +55,7 @@ TALER_AUDITORDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg) GNUNET_free (plugin_name); cfg_dup = GNUNET_CONFIGURATION_dup (cfg); plugin = GNUNET_PLUGIN_load (lib_name, - cfg_dup); + cfg_dup); if (NULL != plugin) plugin->library_name = lib_name; else diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c index f1eaa6f2..555c3058 100644 --- a/src/auditordb/plugin_auditordb_postgres.c +++ b/src/auditordb/plugin_auditordb_postgres.c @@ -27,7 +27,8 @@ #include <libpq-fe.h> -#define LOG(kind,...) GNUNET_log_from (kind, "taler-auditordb-postgres", __VA_ARGS__) +#define LOG(kind,...) GNUNET_log_from (kind, "taler-auditordb-postgres", \ + __VA_ARGS__) /** @@ -37,7 +38,8 @@ * @param field name of the database field to fetch amount from * @param amountp[out] pointer to amount to set */ -#define TALER_PQ_RESULT_SPEC_AMOUNT(field,amountp) TALER_PQ_result_spec_amount(field,pg->currency,amountp) +#define TALER_PQ_RESULT_SPEC_AMOUNT(field,amountp) TALER_PQ_result_spec_amount ( \ + field,pg->currency,amountp) /** * Wrapper macro to add the currency from the plugin's state @@ -46,7 +48,9 @@ * @param field name of the database field to fetch amount from * @param amountp[out] pointer to amount to set */ -#define TALER_PQ_RESULT_SPEC_AMOUNT_NBO(field,amountp) TALER_PQ_result_spec_amount_nbo(field,pg->currency,amountp) +#define TALER_PQ_RESULT_SPEC_AMOUNT_NBO(field, \ + amountp) TALER_PQ_result_spec_amount_nbo ( \ + field,pg->currency,amountp) /** @@ -166,19 +170,25 @@ postgres_drop_tables (void *cls, struct GNUNET_PQ_ExecuteStatement es[] = { GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_predicted_result;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_historic_ledger;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_historic_denomination_revenue;"), + GNUNET_PQ_make_execute ( + "DROP TABLE IF EXISTS auditor_historic_denomination_revenue;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_balance_summary;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_denomination_pending;"), + GNUNET_PQ_make_execute ( + "DROP TABLE IF EXISTS auditor_denomination_pending;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_reserve_balance;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_wire_fee_balance;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_reserves;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_progress_reserve;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_progress_aggregation;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_progress_deposit_confirmation;"), + GNUNET_PQ_make_execute ( + "DROP TABLE IF EXISTS auditor_progress_aggregation;"), + GNUNET_PQ_make_execute ( + "DROP TABLE IF EXISTS auditor_progress_deposit_confirmation;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS auditor_progress_coin;"), GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS wire_auditor_progress;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS wire_auditor_account_progress;"), - GNUNET_PQ_make_execute ("DROP TABLE IF EXISTS deposit_confirmations CASCADE;"), + GNUNET_PQ_make_execute ( + "DROP TABLE IF EXISTS wire_auditor_account_progress;"), + GNUNET_PQ_make_execute ( + "DROP TABLE IF EXISTS deposit_confirmations CASCADE;"), GNUNET_PQ_EXECUTE_STATEMENT_END }; struct GNUNET_PQ_ExecuteStatement esx[] = { @@ -225,14 +235,15 @@ postgres_create_tables (void *cls) ",exchange_url VARCHAR NOT NULL" ")"), /* Table with list of signing keys of exchanges we are auditing */ - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_exchange_signkeys" - "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" - ",ep_start INT8 NOT NULL" - ",ep_expire INT8 NOT NULL" - ",ep_end INT8 NOT NULL" - ",exchange_pub BYTEA NOT NULL CHECK (LENGTH(exchange_pub)=32)" - ",master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64)" - ")"), + GNUNET_PQ_make_execute ( + "CREATE TABLE IF NOT EXISTS auditor_exchange_signkeys" + "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" + ",ep_start INT8 NOT NULL" + ",ep_expire INT8 NOT NULL" + ",ep_end INT8 NOT NULL" + ",exchange_pub BYTEA NOT NULL CHECK (LENGTH(exchange_pub)=32)" + ",master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64)" + ")"), /* Table with all of the denomination keys that the auditor is aware of. */ GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_denominations" @@ -260,21 +271,24 @@ postgres_create_tables (void *cls) processed. Thus, we need to select those table entries that are strictly larger (and process in monotonically increasing order). */ - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_progress_reserve" - "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" - ",last_reserve_in_serial_id INT8 NOT NULL DEFAULT 0" - ",last_reserve_out_serial_id INT8 NOT NULL DEFAULT 0" - ",last_reserve_payback_serial_id INT8 NOT NULL DEFAULT 0" - ",last_reserve_close_serial_id INT8 NOT NULL DEFAULT 0" - ")"), - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_progress_aggregation" - "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" - ",last_wire_out_serial_id INT8 NOT NULL DEFAULT 0" - ")"), - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_progress_deposit_confirmation" - "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" - ",last_deposit_confirmation_serial_id INT8 NOT NULL DEFAULT 0" - ")"), + GNUNET_PQ_make_execute ( + "CREATE TABLE IF NOT EXISTS auditor_progress_reserve" + "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" + ",last_reserve_in_serial_id INT8 NOT NULL DEFAULT 0" + ",last_reserve_out_serial_id INT8 NOT NULL DEFAULT 0" + ",last_reserve_payback_serial_id INT8 NOT NULL DEFAULT 0" + ",last_reserve_close_serial_id INT8 NOT NULL DEFAULT 0" + ")"), + GNUNET_PQ_make_execute ( + "CREATE TABLE IF NOT EXISTS auditor_progress_aggregation" + "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" + ",last_wire_out_serial_id INT8 NOT NULL DEFAULT 0" + ")"), + GNUNET_PQ_make_execute ( + "CREATE TABLE IF NOT EXISTS auditor_progress_deposit_confirmation" + "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" + ",last_deposit_confirmation_serial_id INT8 NOT NULL DEFAULT 0" + ")"), GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_progress_coin" "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" ",last_withdraw_serial_id INT8 NOT NULL DEFAULT 0" @@ -284,15 +298,16 @@ postgres_create_tables (void *cls) ",last_payback_serial_id INT8 NOT NULL DEFAULT 0" ",last_payback_refresh_serial_id INT8 NOT NULL DEFAULT 0" ")"), - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS wire_auditor_account_progress" - "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" - ",account_name TEXT NOT NULL" - ",last_wire_reserve_in_serial_id INT8 NOT NULL DEFAULT 0" - ",last_wire_wire_out_serial_id INT8 NOT NULL DEFAULT 0" - ",wire_in_off BYTEA" - ",wire_out_off BYTEA" - ")"), - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS wire_auditor_progress" + GNUNET_PQ_make_execute ( + "CREATE TABLE IF NOT EXISTS wire_auditor_account_progress" + "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" + ",account_name TEXT NOT NULL" + ",last_wire_reserve_in_serial_id INT8 NOT NULL DEFAULT 0" + ",last_wire_wire_out_serial_id INT8 NOT NULL DEFAULT 0" + ",wire_in_off BYTEA" + ",wire_out_off BYTEA" + ")"), + GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS wire_auditor_progress" "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" ",last_timestamp INT8 NOT NULL" ")"), @@ -325,28 +340,30 @@ postgres_create_tables (void *cls) ")"), /* Table with the sum of the balances of all wire fees (by exchange's master public key) */ - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_wire_fee_balance" - "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" - ",wire_fee_balance_val INT8 NOT NULL" - ",wire_fee_balance_frac INT4 NOT NULL" - ")"), + GNUNET_PQ_make_execute ( + "CREATE TABLE IF NOT EXISTS auditor_wire_fee_balance" + "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" + ",wire_fee_balance_val INT8 NOT NULL" + ",wire_fee_balance_frac INT4 NOT NULL" + ")"), /* Table with all of the outstanding denomination coins that the exchange is aware of and what the respective balances are (outstanding as well as issued overall which implies the maximum value at risk). We also count the number of coins issued (withdraw, refresh-reveal) and the number of coins seen at the exchange (refresh-commit, deposit), not just the amounts. */ - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_denomination_pending" - "(denom_pub_hash BYTEA PRIMARY KEY" - " REFERENCES auditor_denominations (denom_pub_hash) ON DELETE CASCADE" - ",denom_balance_val INT8 NOT NULL" - ",denom_balance_frac INT4 NOT NULL" - ",num_issued INT8 NOT NULL" - ",denom_risk_val INT8 NOT NULL" - ",denom_risk_frac INT4 NOT NULL" - ",payback_loss_val INT8 NOT NULL" - ",payback_loss_frac INT4 NOT NULL" - ")"), + GNUNET_PQ_make_execute ( + "CREATE TABLE IF NOT EXISTS auditor_denomination_pending" + "(denom_pub_hash BYTEA PRIMARY KEY" + " REFERENCES auditor_denominations (denom_pub_hash) ON DELETE CASCADE" + ",denom_balance_val INT8 NOT NULL" + ",denom_balance_frac INT4 NOT NULL" + ",num_issued INT8 NOT NULL" + ",denom_risk_val INT8 NOT NULL" + ",denom_risk_frac INT4 NOT NULL" + ",payback_loss_val INT8 NOT NULL" + ",payback_loss_frac INT4 NOT NULL" + ")"), /* Table with the sum of the outstanding coins from "auditor_denomination_pending" (denom_pubs must belong to the respective's exchange's master public key); it represents the @@ -377,27 +394,30 @@ postgres_create_tables (void *cls) historic_reserve_revenue); the deposit, melt and refund fees are given individually; the delta to the revenue_balance is from coins that were withdrawn but never deposited prior to expiration. */ - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_historic_denomination_revenue" - "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" - ",denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64)" - ",revenue_timestamp INT8 NOT NULL" - ",revenue_balance_val INT8 NOT NULL" - ",revenue_balance_frac INT4 NOT NULL" - ",loss_balance_val INT8 NOT NULL" - ",loss_balance_frac INT4 NOT NULL" - ")"), + GNUNET_PQ_make_execute ( + "CREATE TABLE IF NOT EXISTS auditor_historic_denomination_revenue" + "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" + ",denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64)" + ",revenue_timestamp INT8 NOT NULL" + ",revenue_balance_val INT8 NOT NULL" + ",revenue_balance_frac INT4 NOT NULL" + ",loss_balance_val INT8 NOT NULL" + ",loss_balance_frac INT4 NOT NULL" + ")"), /* Table with historic profits from reserves; we eventually GC "auditor_historic_reserve_revenue", and then store the totals in here (by time intervals). */ - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_historic_reserve_summary" - "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" - ",start_date INT8 NOT NULL" - ",end_date INT8 NOT NULL" - ",reserve_profits_val INT8 NOT NULL" - ",reserve_profits_frac INT4 NOT NULL" - ")"), - GNUNET_PQ_make_try_execute ("CREATE INDEX auditor_historic_reserve_summary_by_master_pub_start_date " - "ON auditor_historic_reserve_summary(master_pub,start_date)"), + GNUNET_PQ_make_execute ( + "CREATE TABLE IF NOT EXISTS auditor_historic_reserve_summary" + "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" + ",start_date INT8 NOT NULL" + ",end_date INT8 NOT NULL" + ",reserve_profits_val INT8 NOT NULL" + ",reserve_profits_frac INT4 NOT NULL" + ")"), + GNUNET_PQ_make_try_execute ( + "CREATE INDEX auditor_historic_reserve_summary_by_master_pub_start_date " + "ON auditor_historic_reserve_summary(master_pub,start_date)"), /* Table with deposit confirmation sent to us by merchants; we must check that the exchange reported these properly. */ @@ -437,17 +457,19 @@ postgres_create_tables (void *cls) ",balance_val INT8 NOT NULL" ",balance_frac INT4 NOT NULL" ")"), - GNUNET_PQ_make_try_execute ("CREATE INDEX history_ledger_by_master_pub_and_time " - "ON auditor_historic_ledger(master_pub,timestamp)"), + GNUNET_PQ_make_try_execute ( + "CREATE INDEX history_ledger_by_master_pub_and_time " + "ON auditor_historic_ledger(master_pub,timestamp)"), /* Table with the sum of the ledger, auditor_historic_revenue and the auditor_reserve_balance. This is the final amount that the exchange should have in its bank account right now. */ - GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS auditor_predicted_result" - "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" - ",balance_val INT8 NOT NULL" - ",balance_frac INT4 NOT NULL" - ")"), + GNUNET_PQ_make_execute ( + "CREATE TABLE IF NOT EXISTS auditor_predicted_result" + "(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE" + ",balance_val INT8 NOT NULL" + ",balance_frac INT4 NOT NULL" + ")"), GNUNET_PQ_EXECUTE_STATEMENT_END }; PGconn *conn; @@ -1042,7 +1064,7 @@ postgres_get_session (void *cls) * DB. Needed after the database server restarts as we need to * properly reconnect. */ GNUNET_assert (0 == pthread_setspecific (pc->db_conn_threadlocal, - NULL)); + NULL)); PQfinish (session->conn); GNUNET_free (session); } @@ -1358,7 +1380,8 @@ postgres_list_exchanges (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_exchange_signkey (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_AUDITORDB_ExchangeSigningKey *sk) + const struct + TALER_AUDITORDB_ExchangeSigningKey *sk) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (&sk->master_public_key), @@ -1387,7 +1410,8 @@ postgres_insert_exchange_signkey (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_deposit_confirmation (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_AUDITORDB_DepositConfirmation *dc) + const struct + TALER_AUDITORDB_DepositConfirmation *dc) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (&dc->master_public_key), @@ -1459,7 +1483,7 @@ deposit_confirmation_cb (void *cls, { struct DepositConfirmationContext *dcc = cls; struct PostgresClosure *pg = dcc->pg; - + for (unsigned int i = 0; i < num_results; i++) { uint64_t serial_id; @@ -1494,8 +1518,8 @@ deposit_confirmation_cb (void *cls, if (GNUNET_OK != GNUNET_PQ_extract_result (result, - rs, - i)) + rs, + i)) { GNUNET_break (0); dcc->qs = GNUNET_DB_STATUS_HARD_ERROR; @@ -1524,9 +1548,11 @@ deposit_confirmation_cb (void *cls, static enum GNUNET_DB_QueryStatus postgres_get_deposit_confirmations (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_public_key, + const struct + TALER_MasterPublicKeyP *master_public_key, uint64_t start_id, - TALER_AUDITORDB_DepositConfirmationCallback cb, + TALER_AUDITORDB_DepositConfirmationCallback + cb, void *cb_cls) { struct PostgresClosure *pg = cls; @@ -1544,10 +1570,10 @@ postgres_get_deposit_confirmations (void *cls, enum GNUNET_DB_QueryStatus qs; qs = GNUNET_PQ_eval_prepared_multi_select (session->conn, - "auditor_deposit_confirmation_select", - params, - &deposit_confirmation_cb, - &dcc); + "auditor_deposit_confirmation_select", + params, + &deposit_confirmation_cb, + &dcc); if (qs > 0) return dcc.qs; GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); @@ -1569,7 +1595,8 @@ postgres_get_deposit_confirmations (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_denomination_info (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_DenominationKeyValidityPS *issue) + const struct + TALER_DenominationKeyValidityPS *issue) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (&issue->denom_hash), @@ -1598,7 +1625,7 @@ postgres_insert_denomination_info (void *cls, &issue->fee_refresh)); GNUNET_assert (GNUNET_YES == TALER_amount_cmp_currency_nbo (&issue->value, - &issue->fee_refund)); + &issue->fee_refund)); return GNUNET_PQ_eval_prepared_non_select (session->conn, "auditor_denominations_insert", params); @@ -1630,7 +1657,7 @@ struct DenominationInfoContext * Plugin context. */ struct PostgresClosure *pg; - + /** * Query status to return. */ @@ -1661,11 +1688,15 @@ denomination_info_cb (void *cls, .master = *dic->master_pub }; struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash", &issue.denom_hash), + GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash", + &issue.denom_hash), TALER_PQ_result_spec_absolute_time_nbo ("valid_from", &issue.start), - TALER_PQ_result_spec_absolute_time_nbo ("expire_withdraw", &issue.expire_withdraw), - TALER_PQ_result_spec_absolute_time_nbo ("expire_deposit", &issue.expire_deposit), - TALER_PQ_result_spec_absolute_time_nbo ("expire_legal", &issue.expire_legal), + TALER_PQ_result_spec_absolute_time_nbo ("expire_withdraw", + &issue.expire_withdraw), + TALER_PQ_result_spec_absolute_time_nbo ("expire_deposit", + &issue.expire_deposit), + TALER_PQ_result_spec_absolute_time_nbo ("expire_legal", + &issue.expire_legal), TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("coin", &issue.value), TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("fee_withdraw", &issue.fee_withdraw), TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("fee_deposit", &issue.fee_deposit), @@ -1676,8 +1707,8 @@ denomination_info_cb (void *cls, if (GNUNET_OK != GNUNET_PQ_extract_result (result, - rs, - i)) + rs, + i)) { GNUNET_break (0); dic->qs = GNUNET_DB_STATUS_HARD_ERROR; @@ -1685,8 +1716,8 @@ denomination_info_cb (void *cls, } dic->qs = i + 1; if (GNUNET_OK != - dic->cb (dic->cb_cls, - &issue)) + dic->cb (dic->cb_cls, + &issue)) return; } } @@ -1705,8 +1736,10 @@ denomination_info_cb (void *cls, static enum GNUNET_DB_QueryStatus postgres_select_denomination_info (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - TALER_AUDITORDB_DenominationInfoDataCallback cb, + const struct + TALER_MasterPublicKeyP *master_pub, + TALER_AUDITORDB_DenominationInfoDataCallback + cb, void *cb_cls) { struct PostgresClosure *pg = cls; @@ -1723,10 +1756,10 @@ postgres_select_denomination_info (void *cls, enum GNUNET_DB_QueryStatus qs; qs = GNUNET_PQ_eval_prepared_multi_select (session->conn, - "auditor_denominations_select", - params, - &denomination_info_cb, - &dic); + "auditor_denominations_select", + params, + &denomination_info_cb, + &dic); if (qs > 0) return dic.qs; GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); @@ -1746,9 +1779,13 @@ postgres_select_denomination_info (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_insert_auditor_progress_reserve (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointReserve *ppr) + struct TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_ProgressPointReserve * + ppr) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -1777,9 +1814,13 @@ postgres_insert_auditor_progress_reserve (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_update_auditor_progress_reserve (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointReserve *ppr) + struct TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_ProgressPointReserve * + ppr) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&ppr->last_reserve_in_serial_id), @@ -1808,8 +1849,10 @@ postgres_update_auditor_progress_reserve (void *cls, static enum GNUNET_DB_QueryStatus postgres_get_auditor_progress_reserve (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - struct TALER_AUDITORDB_ProgressPointReserve *ppr) + const struct + TALER_MasterPublicKeyP *master_pub, + struct + TALER_AUDITORDB_ProgressPointReserve *ppr) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -1846,9 +1889,13 @@ postgres_get_auditor_progress_reserve (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_insert_auditor_progress_aggregation (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointAggregation *ppa) + struct TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_ProgressPointAggregation + *ppa) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -1874,9 +1921,13 @@ postgres_insert_auditor_progress_aggregation (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_update_auditor_progress_aggregation (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointAggregation *ppa) + struct TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_ProgressPointAggregation + *ppa) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&ppa->last_wire_out_serial_id), @@ -1901,9 +1952,13 @@ postgres_update_auditor_progress_aggregation (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_get_auditor_progress_aggregation (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - struct TALER_AUDITORDB_ProgressPointAggregation *ppa) + struct TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP *master_pub, + struct + TALER_AUDITORDB_ProgressPointAggregation + *ppa) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -1934,9 +1989,15 @@ postgres_get_auditor_progress_aggregation (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_insert_auditor_progress_deposit_confirmation (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc) + struct + TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP * + master_pub, + const struct + TALER_AUDITORDB_ProgressPointDepositConfirmation + *ppdc) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -1962,9 +2023,15 @@ postgres_insert_auditor_progress_deposit_confirmation (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_update_auditor_progress_deposit_confirmation (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc) + struct + TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP * + master_pub, + const struct + TALER_AUDITORDB_ProgressPointDepositConfirmation + *ppdc) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&ppdc->last_deposit_confirmation_serial_id), @@ -1989,9 +2056,15 @@ postgres_update_auditor_progress_deposit_confirmation (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_get_auditor_progress_deposit_confirmation (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - struct TALER_AUDITORDB_ProgressPointDepositConfirmation *ppdc) + struct + TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP * + master_pub, + struct + TALER_AUDITORDB_ProgressPointDepositConfirmation + *ppdc) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -2023,8 +2096,10 @@ postgres_get_auditor_progress_deposit_confirmation (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_auditor_progress_coin (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointCoin *ppc) + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_ProgressPointCoin *ppc) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -2056,8 +2131,10 @@ postgres_insert_auditor_progress_coin (void *cls, static enum GNUNET_DB_QueryStatus postgres_update_auditor_progress_coin (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_ProgressPointCoin *ppc) + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_ProgressPointCoin *ppc) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&ppc->last_withdraw_serial_id), @@ -2088,8 +2165,10 @@ postgres_update_auditor_progress_coin (void *cls, static enum GNUNET_DB_QueryStatus postgres_get_auditor_progress_coin (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - struct TALER_AUDITORDB_ProgressPointCoin *ppc) + const struct + TALER_MasterPublicKeyP *master_pub, + struct TALER_AUDITORDB_ProgressPointCoin * + ppc) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -2130,10 +2209,15 @@ postgres_get_auditor_progress_coin (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_insert_wire_auditor_account_progress (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + struct TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP * + master_pub, const char *account_name, - const struct TALER_AUDITORDB_WireAccountProgressPoint *pp, + const struct + TALER_AUDITORDB_WireAccountProgressPoint + *pp, const void *in_wire_off, const void *out_wire_off, size_t wire_off_size) @@ -2168,10 +2252,15 @@ postgres_insert_wire_auditor_account_progress (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_update_wire_auditor_account_progress (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + struct TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP * + master_pub, const char *account_name, - const struct TALER_AUDITORDB_WireAccountProgressPoint *pp, + const struct + TALER_AUDITORDB_WireAccountProgressPoint + *pp, const void *in_wire_off, const void *out_wire_off, size_t wire_off_size) @@ -2209,10 +2298,14 @@ postgres_update_wire_auditor_account_progress (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_get_wire_auditor_account_progress (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + struct TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP *master_pub, const char *account_name, - struct TALER_AUDITORDB_WireAccountProgressPoint *pp, + struct + TALER_AUDITORDB_WireAccountProgressPoint + *pp, void **in_wire_off, void **out_wire_off, size_t *wire_off_size) @@ -2265,8 +2358,10 @@ postgres_get_wire_auditor_account_progress (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_wire_auditor_progress (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_WireProgressPoint *pp) + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_WireProgressPoint *pp) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -2293,8 +2388,10 @@ postgres_insert_wire_auditor_progress (void *cls, static enum GNUNET_DB_QueryStatus postgres_update_wire_auditor_progress (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_AUDITORDB_WireProgressPoint *pp) + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + TALER_AUDITORDB_WireProgressPoint *pp) { struct GNUNET_PQ_QueryParam params[] = { TALER_PQ_query_param_absolute_time (&pp->last_timestamp), @@ -2320,7 +2417,8 @@ postgres_update_wire_auditor_progress (void *cls, static enum GNUNET_DB_QueryStatus postgres_get_wire_auditor_progress (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterPublicKeyP *master_pub, struct TALER_AUDITORDB_WireProgressPoint *pp) { struct GNUNET_PQ_QueryParam params[] = { @@ -2329,7 +2427,7 @@ postgres_get_wire_auditor_progress (void *cls, }; struct GNUNET_PQ_ResultSpec rs[] = { TALER_PQ_result_spec_absolute_time ("last_timestamp", - &pp->last_timestamp), + &pp->last_timestamp), GNUNET_PQ_result_spec_end }; @@ -2511,9 +2609,11 @@ postgres_get_reserve_info (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_reserve_summary (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *reserve_balance, - const struct TALER_Amount *withdraw_fee_balance) + const struct + TALER_Amount *withdraw_fee_balance) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -2547,9 +2647,11 @@ postgres_insert_reserve_summary (void *cls, static enum GNUNET_DB_QueryStatus postgres_update_reserve_summary (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *reserve_balance, - const struct TALER_Amount *withdraw_fee_balance) + const struct + TALER_Amount *withdraw_fee_balance) { struct GNUNET_PQ_QueryParam params[] = { TALER_PQ_query_param_amount (reserve_balance), @@ -2614,7 +2716,8 @@ postgres_get_reserve_summary (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_wire_fee_summary (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *wire_fee_balance) { struct GNUNET_PQ_QueryParam params[] = { @@ -2642,7 +2745,8 @@ postgres_insert_wire_fee_summary (void *cls, static enum GNUNET_DB_QueryStatus postgres_update_wire_fee_summary (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *wire_fee_balance) { struct GNUNET_PQ_QueryParam params[] = { @@ -2706,7 +2810,8 @@ postgres_get_wire_fee_summary (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_denomination_balance (void *cls, struct TALER_AUDITORDB_Session *session, - const struct GNUNET_HashCode *denom_pub_hash, + const struct + GNUNET_HashCode *denom_pub_hash, const struct TALER_Amount *denom_balance, const struct TALER_Amount *denom_risk, const struct TALER_Amount *payback_loss, @@ -2743,7 +2848,8 @@ postgres_insert_denomination_balance (void *cls, static enum GNUNET_DB_QueryStatus postgres_update_denomination_balance (void *cls, struct TALER_AUDITORDB_Session *session, - const struct GNUNET_HashCode *denom_pub_hash, + const struct + GNUNET_HashCode *denom_pub_hash, const struct TALER_Amount *denom_balance, const struct TALER_Amount *denom_risk, const struct TALER_Amount *payback_loss, @@ -2823,7 +2929,8 @@ postgres_get_denomination_balance (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_balance_summary (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *denom_balance, const struct TALER_Amount *deposit_fee_balance, const struct TALER_Amount *melt_fee_balance, @@ -2878,7 +2985,8 @@ postgres_insert_balance_summary (void *cls, static enum GNUNET_DB_QueryStatus postgres_update_balance_summary (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *denom_balance, const struct TALER_Amount *deposit_fee_balance, const struct TALER_Amount *melt_fee_balance, @@ -2967,10 +3075,14 @@ postgres_get_balance_summary (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_historic_denom_revenue (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - const struct GNUNET_HashCode *denom_pub_hash, - struct GNUNET_TIME_Absolute revenue_timestamp, - const struct TALER_Amount *revenue_balance, + const struct + TALER_MasterPublicKeyP *master_pub, + const struct + GNUNET_HashCode *denom_pub_hash, + struct GNUNET_TIME_Absolute + revenue_timestamp, + const struct + TALER_Amount *revenue_balance, const struct TALER_Amount *loss_balance) { struct GNUNET_PQ_QueryParam params[] = { @@ -2983,8 +3095,8 @@ postgres_insert_historic_denom_revenue (void *cls, }; return GNUNET_PQ_eval_prepared_non_select (session->conn, - "auditor_historic_denomination_revenue_insert", - params); + "auditor_historic_denomination_revenue_insert", + params); } @@ -3005,7 +3117,7 @@ struct HistoricDenomRevenueContext /** * Plugin context. - */ + */ struct PostgresClosure *pg; /** @@ -3031,7 +3143,7 @@ historic_denom_revenue_cb (void *cls, { struct HistoricDenomRevenueContext *hrc = cls; struct PostgresClosure *pg = hrc->pg; - + for (unsigned int i = 0; i < num_results; i++) { struct GNUNET_HashCode denom_pub_hash; @@ -3040,7 +3152,8 @@ historic_denom_revenue_cb (void *cls, struct TALER_Amount loss; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash", &denom_pub_hash), - TALER_PQ_result_spec_absolute_time ("revenue_timestamp", &revenue_timestamp), + TALER_PQ_result_spec_absolute_time ("revenue_timestamp", + &revenue_timestamp), TALER_PQ_RESULT_SPEC_AMOUNT ("revenue_balance", &revenue_balance), TALER_PQ_RESULT_SPEC_AMOUNT ("loss_balance", &loss), GNUNET_PQ_result_spec_end @@ -3082,8 +3195,10 @@ historic_denom_revenue_cb (void *cls, static enum GNUNET_DB_QueryStatus postgres_select_historic_denom_revenue (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - TALER_AUDITORDB_HistoricDenominationRevenueDataCallback cb, + const struct + TALER_MasterPublicKeyP *master_pub, + TALER_AUDITORDB_HistoricDenominationRevenueDataCallback + cb, void *cb_cls) { struct PostgresClosure *pg = cls; @@ -3122,11 +3237,15 @@ postgres_select_historic_denom_revenue (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_insert_historic_reserve_revenue (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - struct GNUNET_TIME_Absolute start_time, + struct TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP *master_pub, + struct GNUNET_TIME_Absolute + start_time, struct GNUNET_TIME_Absolute end_time, - const struct TALER_Amount *reserve_profits) + const struct + TALER_Amount *reserve_profits) { struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (master_pub), @@ -3185,7 +3304,7 @@ historic_reserve_revenue_cb (void *cls, { struct HistoricReserveRevenueContext *hrc = cls; struct PostgresClosure *pg = hrc->pg; - + for (unsigned int i = 0; i < num_results; i++) { struct GNUNET_TIME_Absolute start_date; @@ -3200,8 +3319,8 @@ historic_reserve_revenue_cb (void *cls, if (GNUNET_OK != GNUNET_PQ_extract_result (result, - rs, - i)) + rs, + i)) { GNUNET_break (0); hrc->qs = GNUNET_DB_STATUS_HARD_ERROR; @@ -3230,9 +3349,12 @@ historic_reserve_revenue_cb (void *cls, */ static enum GNUNET_DB_QueryStatus postgres_select_historic_reserve_revenue (void *cls, - struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, - TALER_AUDITORDB_HistoricReserveRevenueDataCallback cb, + struct TALER_AUDITORDB_Session * + session, + const struct + TALER_MasterPublicKeyP *master_pub, + TALER_AUDITORDB_HistoricReserveRevenueDataCallback + cb, void *cb_cls) { struct PostgresClosure *pg = cls; @@ -3271,7 +3393,8 @@ postgres_select_historic_reserve_revenue (void *cls, static enum GNUNET_DB_QueryStatus postgres_insert_predicted_result (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *balance) { struct GNUNET_PQ_QueryParam params[] = { @@ -3299,7 +3422,8 @@ postgres_insert_predicted_result (void *cls, static enum GNUNET_DB_QueryStatus postgres_update_predicted_result (void *cls, struct TALER_AUDITORDB_Session *session, - const struct TALER_MasterPublicKeyP *master_pub, + const struct + TALER_MasterPublicKeyP *master_pub, const struct TALER_Amount *balance) { struct GNUNET_PQ_QueryParam params[] = { @@ -3423,21 +3547,32 @@ libtaler_plugin_auditordb_postgres_init (void *cls) plugin->insert_denomination_info = &postgres_insert_denomination_info; plugin->get_auditor_progress_reserve = &postgres_get_auditor_progress_reserve; - plugin->update_auditor_progress_reserve = &postgres_update_auditor_progress_reserve; - plugin->insert_auditor_progress_reserve = &postgres_insert_auditor_progress_reserve; - plugin->get_auditor_progress_aggregation = &postgres_get_auditor_progress_aggregation; - plugin->update_auditor_progress_aggregation = &postgres_update_auditor_progress_aggregation; - plugin->insert_auditor_progress_aggregation = &postgres_insert_auditor_progress_aggregation; - plugin->get_auditor_progress_deposit_confirmation = &postgres_get_auditor_progress_deposit_confirmation; - plugin->update_auditor_progress_deposit_confirmation = &postgres_update_auditor_progress_deposit_confirmation; - plugin->insert_auditor_progress_deposit_confirmation = &postgres_insert_auditor_progress_deposit_confirmation; + plugin->update_auditor_progress_reserve = + &postgres_update_auditor_progress_reserve; + plugin->insert_auditor_progress_reserve = + &postgres_insert_auditor_progress_reserve; + plugin->get_auditor_progress_aggregation = + &postgres_get_auditor_progress_aggregation; + plugin->update_auditor_progress_aggregation = + &postgres_update_auditor_progress_aggregation; + plugin->insert_auditor_progress_aggregation = + &postgres_insert_auditor_progress_aggregation; + plugin->get_auditor_progress_deposit_confirmation = + &postgres_get_auditor_progress_deposit_confirmation; + plugin->update_auditor_progress_deposit_confirmation = + &postgres_update_auditor_progress_deposit_confirmation; + plugin->insert_auditor_progress_deposit_confirmation = + &postgres_insert_auditor_progress_deposit_confirmation; plugin->get_auditor_progress_coin = &postgres_get_auditor_progress_coin; plugin->update_auditor_progress_coin = &postgres_update_auditor_progress_coin; plugin->insert_auditor_progress_coin = &postgres_insert_auditor_progress_coin; - plugin->get_wire_auditor_account_progress = &postgres_get_wire_auditor_account_progress; - plugin->update_wire_auditor_account_progress = &postgres_update_wire_auditor_account_progress; - plugin->insert_wire_auditor_account_progress = &postgres_insert_wire_auditor_account_progress; + plugin->get_wire_auditor_account_progress = + &postgres_get_wire_auditor_account_progress; + plugin->update_wire_auditor_account_progress = + &postgres_update_wire_auditor_account_progress; + plugin->insert_wire_auditor_account_progress = + &postgres_insert_wire_auditor_account_progress; plugin->get_wire_auditor_progress = &postgres_get_wire_auditor_progress; plugin->update_wire_auditor_progress = &postgres_update_wire_auditor_progress; plugin->insert_wire_auditor_progress = &postgres_insert_wire_auditor_progress; @@ -3463,11 +3598,15 @@ libtaler_plugin_auditordb_postgres_init (void *cls) plugin->update_balance_summary = &postgres_update_balance_summary; plugin->insert_balance_summary = &postgres_insert_balance_summary; - plugin->select_historic_denom_revenue = &postgres_select_historic_denom_revenue; - plugin->insert_historic_denom_revenue = &postgres_insert_historic_denom_revenue; + plugin->select_historic_denom_revenue = + &postgres_select_historic_denom_revenue; + plugin->insert_historic_denom_revenue = + &postgres_insert_historic_denom_revenue; - plugin->select_historic_reserve_revenue = &postgres_select_historic_reserve_revenue; - plugin->insert_historic_reserve_revenue = &postgres_insert_historic_reserve_revenue; + plugin->select_historic_reserve_revenue = + &postgres_select_historic_reserve_revenue; + plugin->insert_historic_reserve_revenue = + &postgres_insert_historic_reserve_revenue; plugin->get_predicted_balance = &postgres_get_predicted_balance; plugin->update_predicted_result = &postgres_update_predicted_result; diff --git a/src/auditordb/test_auditordb.c b/src/auditordb/test_auditordb.c index 68aa4564..8f226266 100644 --- a/src/auditordb/test_auditordb.c +++ b/src/auditordb/test_auditordb.c @@ -33,10 +33,10 @@ static int result = -1; * Report line of error if @a cond is true, and jump to label "drop". */ #define FAILIF(cond) \ - do { \ - if (!(cond)){ break;} \ - GNUNET_break (0); \ - goto drop; \ + do { \ + if (! (cond)) { break;} \ + GNUNET_break (0); \ + goto drop; \ } while (0) @@ -66,7 +66,8 @@ static struct TALER_AUDITORDB_Plugin *plugin; static int select_denomination_info_result (void *cls, - const struct TALER_DenominationKeyValidityPS *issue2) + const struct + TALER_DenominationKeyValidityPS *issue2) { const struct TALER_DenominationKeyValidityPS *issue1 = cls; @@ -159,26 +160,29 @@ run (void *cls) struct TALER_DenominationPublicKey denom_pub; struct GNUNET_HashCode denom_pub_hash; denom_priv.rsa_private_key = GNUNET_CRYPTO_rsa_private_key_create (1024); - denom_pub.rsa_public_key = GNUNET_CRYPTO_rsa_private_key_get_public (denom_priv.rsa_private_key); + denom_pub.rsa_public_key = GNUNET_CRYPTO_rsa_private_key_get_public ( + denom_priv.rsa_private_key); GNUNET_CRYPTO_rsa_public_key_hash (denom_pub.rsa_public_key, &denom_pub_hash); struct GNUNET_TIME_Absolute now, past, future, date; now = GNUNET_TIME_absolute_get (); (void) GNUNET_TIME_round_abs (&now); past = GNUNET_TIME_absolute_subtract (now, - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, - 4)); + GNUNET_TIME_relative_multiply ( + GNUNET_TIME_UNIT_HOURS, + 4)); future = GNUNET_TIME_absolute_add (now, - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, - 4)); + GNUNET_TIME_relative_multiply ( + GNUNET_TIME_UNIT_HOURS, + 4)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test: auditor_insert_exchange\n"); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->insert_exchange (plugin->cls, - session, - &master_pub, - "https://exchange/")); + plugin->insert_exchange (plugin->cls, + session, + &master_pub, + "https://exchange/")); GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -190,16 +194,18 @@ run (void *cls) issue.start = GNUNET_TIME_absolute_hton (now); issue.expire_withdraw = GNUNET_TIME_absolute_hton - (GNUNET_TIME_absolute_add (now, - GNUNET_TIME_UNIT_HOURS)); + (GNUNET_TIME_absolute_add (now, + GNUNET_TIME_UNIT_HOURS)); issue.expire_deposit = GNUNET_TIME_absolute_hton - (GNUNET_TIME_absolute_add - (now, - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 2))); + (GNUNET_TIME_absolute_add + (now, + GNUNET_TIME_relative_multiply ( + GNUNET_TIME_UNIT_HOURS, 2))); issue.expire_legal = GNUNET_TIME_absolute_hton - (GNUNET_TIME_absolute_add - (now, - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 3))); + (GNUNET_TIME_absolute_add + (now, + GNUNET_TIME_relative_multiply ( + GNUNET_TIME_UNIT_HOURS, 3))); TALER_amount_hton (&issue.value, &value); TALER_amount_hton (&issue.fee_withdraw, &fee_withdraw); TALER_amount_hton (&issue.fee_deposit, &fee_deposit); @@ -318,7 +324,8 @@ run (void *cls) FAILIF (0 != GNUNET_memcmp (&date, &future) || 0 != GNUNET_memcmp (&reserve_balance2, &reserve_balance) - || 0 != GNUNET_memcmp (&withdraw_fee_balance2, &withdraw_fee_balance)); + || 0 != GNUNET_memcmp (&withdraw_fee_balance2, + &withdraw_fee_balance)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test: insert_reserve_summary\n"); @@ -355,8 +362,8 @@ run (void *cls) FAILIF ( (0 != GNUNET_memcmp (&reserve_balance2, &reserve_balance) || - (0 != GNUNET_memcmp (&withdraw_fee_balance2, - &withdraw_fee_balance)) ) ); + (0 != GNUNET_memcmp (&withdraw_fee_balance2, + &withdraw_fee_balance)) ) ); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test: insert_denomination_balance\n"); @@ -476,23 +483,23 @@ run (void *cls) FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->get_balance_summary (plugin->cls, - session, - &master_pub, - &denom_balance2, - &deposit_fee_balance2, - &melt_fee_balance2, - &refund_fee_balance2, - &rbalance2, - &loss2)); + session, + &master_pub, + &denom_balance2, + &deposit_fee_balance2, + &melt_fee_balance2, + &refund_fee_balance2, + &rbalance2, + &loss2)); FAILIF ( (0 != GNUNET_memcmp (&denom_balance2, &denom_balance) ) || - (0 != GNUNET_memcmp (&deposit_fee_balance2, - &deposit_fee_balance) ) || - (0 != GNUNET_memcmp (&melt_fee_balance2, - &melt_fee_balance) ) || - (0 != GNUNET_memcmp (&refund_fee_balance2, - &refund_fee_balance)) ); + (0 != GNUNET_memcmp (&deposit_fee_balance2, + &deposit_fee_balance) ) || + (0 != GNUNET_memcmp (&melt_fee_balance2, + &melt_fee_balance) ) || + (0 != GNUNET_memcmp (&refund_fee_balance2, + &refund_fee_balance)) ); FAILIF (0 != GNUNET_memcmp (&rbalance2, &rbalance)); FAILIF (0 != GNUNET_memcmp (&loss2, @@ -525,9 +532,12 @@ run (void *cls) int select_historic_denom_revenue_result (void *cls, - const struct GNUNET_HashCode *denom_pub_hash2, - struct GNUNET_TIME_Absolute revenue_timestamp2, - const struct TALER_Amount *revenue_balance2, + const struct + GNUNET_HashCode *denom_pub_hash2, + struct GNUNET_TIME_Absolute + revenue_timestamp2, + const struct + TALER_Amount *revenue_balance2, const struct TALER_Amount *loss2) { static int n = 0; @@ -535,19 +545,19 @@ run (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "select_historic_denom_revenue_result: row %u\n", n); - if (2 <= n++ - || cls != NULL - || (0 != GNUNET_memcmp (&revenue_timestamp2, &past) - && 0 != GNUNET_memcmp (&revenue_timestamp2, &now)) - || (0 != GNUNET_memcmp (denom_pub_hash2, &denom_pub_hash) - && 0 != GNUNET_memcmp (denom_pub_hash2, &rnd_hash)) - || 0 != GNUNET_memcmp (revenue_balance2, &rbalance) - || 0 != GNUNET_memcmp (loss2, &loss)) + if ((2 <= n++) + || (cls != NULL) + || ((0 != GNUNET_memcmp (&revenue_timestamp2, &past)) + && (0 != GNUNET_memcmp (&revenue_timestamp2, &now))) + || ((0 != GNUNET_memcmp (denom_pub_hash2, &denom_pub_hash)) + && (0 != GNUNET_memcmp (denom_pub_hash2, &rnd_hash))) + || (0 != GNUNET_memcmp (revenue_balance2, &rbalance)) + || (0 != GNUNET_memcmp (loss2, &loss))) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "select_historic_denom_revenue_result: result does not match\n"); - GNUNET_break (0); - return GNUNET_SYSERR; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "select_historic_denom_revenue_result: result does not match\n"); + GNUNET_break (0); + return GNUNET_SYSERR; } return GNUNET_OK; } @@ -556,7 +566,8 @@ run (void *cls) plugin->select_historic_denom_revenue (plugin->cls, session, &master_pub, - &select_historic_denom_revenue_result, + & + select_historic_denom_revenue_result, NULL)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -588,26 +599,28 @@ run (void *cls) int select_historic_reserve_revenue_result (void *cls, - struct GNUNET_TIME_Absolute start_time2, + struct GNUNET_TIME_Absolute + start_time2, struct GNUNET_TIME_Absolute end_time2, - const struct TALER_Amount *reserve_profits2) + const struct + TALER_Amount *reserve_profits2) { static int n = 0; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "select_historic_reserve_revenue_result: row %u\n", n); - if (2 <= n++ - || cls != NULL - || (0 != GNUNET_memcmp (&start_time2, &past) - && 0 != GNUNET_memcmp (&start_time2, &now)) - || 0 != GNUNET_memcmp (&end_time2, &future) - || 0 != GNUNET_memcmp (reserve_profits2, &reserve_profits)) + if ((2 <= n++) + || (cls != NULL) + || ((0 != GNUNET_memcmp (&start_time2, &past)) + && (0 != GNUNET_memcmp (&start_time2, &now))) + || (0 != GNUNET_memcmp (&end_time2, &future)) + || (0 != GNUNET_memcmp (reserve_profits2, &reserve_profits))) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "select_historic_reserve_revenue_result: result does not match\n"); - GNUNET_break (0); - return GNUNET_SYSERR; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "select_historic_reserve_revenue_result: result does not match\n"); + GNUNET_break (0); + return GNUNET_SYSERR; } return GNUNET_OK; } @@ -700,7 +713,7 @@ run (void *cls) result = 0; -drop: + drop: if (NULL != session) { plugin->rollback (plugin->cls, @@ -721,7 +734,7 @@ drop: GNUNET_break (GNUNET_OK == plugin->drop_tables (plugin->cls, GNUNET_YES)); - unload: + unload: TALER_AUDITORDB_plugin_unload (plugin); plugin = NULL; } diff --git a/src/bank-lib/bank_api_admin.c b/src/bank-lib/bank_api_admin.c index 4a66d329..72b1d773 100644 --- a/src/bank-lib/bank_api_admin.c +++ b/src/bank-lib/bank_api_admin.c @@ -94,7 +94,7 @@ handle_admin_add_incoming_finished (void *cls, &row_id), GNUNET_JSON_spec_absolute_time ("timestamp", ×tamp), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -217,8 +217,8 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx, GNUNET_assert (NULL != (aai->post_ctx.headers = curl_slist_append - (aai->post_ctx.headers, - "Content-Type: application/json"))); + (aai->post_ctx.headers, + "Content-Type: application/json"))); eh = curl_easy_init (); @@ -248,7 +248,8 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx, * @param aai the admin add incoming request handle */ void -TALER_BANK_admin_add_incoming_cancel (struct TALER_BANK_AdminAddIncomingHandle *aai) +TALER_BANK_admin_add_incoming_cancel (struct + TALER_BANK_AdminAddIncomingHandle *aai) { if (NULL != aai->job) { diff --git a/src/bank-lib/bank_api_common.c b/src/bank-lib/bank_api_common.c index ad116007..50769dae 100644 --- a/src/bank-lib/bank_api_common.c +++ b/src/bank-lib/bank_api_common.c @@ -130,7 +130,7 @@ TALER_BANK_parse_ec_ (const json_t *json) struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_uint32 ("ec", &ec), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; if (GNUNET_OK != diff --git a/src/bank-lib/bank_api_history.c b/src/bank-lib/bank_api_history.c index 36e5724d..6bc53cd5 100644 --- a/src/bank-lib/bank_api_history.c +++ b/src/bank-lib/bank_api_history.c @@ -88,7 +88,7 @@ parse_account_history (struct TALER_BANK_HistoryHandle *hh, GNUNET_break_op (0); return GNUNET_SYSERR; } - for (unsigned int i=0;i<json_array_size (history_array);i++) + for (unsigned int i = 0; i<json_array_size (history_array); i++) { struct TALER_BANK_TransferDetails td; const char *sign; @@ -108,7 +108,7 @@ parse_account_history (struct TALER_BANK_HistoryHandle *hh, (const char **) &td.wire_transfer_subject), GNUNET_JSON_spec_uint64 ("counterpart", &other_account), - GNUNET_JSON_spec_end() + GNUNET_JSON_spec_end () }; json_t *transaction = json_array_get (history_array, i); @@ -147,7 +147,7 @@ parse_account_history (struct TALER_BANK_HistoryHandle *hh, bank_hostname += 3; GNUNET_asprintf (&td.account_url, - ('/' == bank_hostname[strlen(bank_hostname)-1]) + ('/' == bank_hostname[strlen (bank_hostname) - 1]) ? "payto://x-taler-bank/%s%llu" : "payto://x-taler-bank/%s/%llu", bank_hostname, @@ -456,12 +456,12 @@ TALER_BANK_history (struct GNUNET_CURL_Context *ctx, if (UINT64_MAX == start_row) GNUNET_asprintf (&url, - "/history?auth=basic&account_number=%llu&delta=%lld&direction=%s&cancelled=%s&ordering=%s", - (unsigned long long) account_number, - (long long) num_results, - conv_direction (direction), - conv_cancel (direction), - (GNUNET_YES == ascending) ? "ascending" : "descending"); + "/history?auth=basic&account_number=%llu&delta=%lld&direction=%s&cancelled=%s&ordering=%s", + (unsigned long long) account_number, + (long long) num_results, + conv_direction (direction), + conv_cancel (direction), + (GNUNET_YES == ascending) ? "ascending" : "descending"); else GNUNET_asprintf (&url, "/history?auth=basic&account_number=%llu&delta=%lld&direction=%s&cancelled=%s&ordering=%s&start=%llu", diff --git a/src/bank-lib/bank_api_parse.c b/src/bank-lib/bank_api_parse.c index 6de9e5e1..582e2a7d 100644 --- a/src/bank-lib/bank_api_parse.c +++ b/src/bank-lib/bank_api_parse.c @@ -36,7 +36,8 @@ TALER_BANK_auth_parse_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, struct TALER_BANK_AuthenticationData *auth) { - const struct { + const struct + { const char *m; enum TALER_BANK_AuthenticationMethod e; } methods[] = { @@ -57,7 +58,7 @@ TALER_BANK_auth_parse_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, "TALER_BANK_AUTH_METHOD"); return GNUNET_SYSERR; } - for (unsigned int i=0; NULL != methods[i].m;i++) + for (unsigned int i = 0; NULL != methods[i].m; i++) { if (0 == strcasecmp (method, methods[i].m)) diff --git a/src/bank-lib/bank_api_reject.c b/src/bank-lib/bank_api_reject.c index cfedec4c..3f181bc3 100644 --- a/src/bank-lib/bank_api_reject.c +++ b/src/bank-lib/bank_api_reject.c @@ -194,8 +194,8 @@ TALER_BANK_reject (struct GNUNET_CURL_Context *ctx, } eh = curl_easy_init (); GNUNET_assert (NULL != (rh->json_enc = - json_dumps (reject_obj, - JSON_COMPACT))); + json_dumps (reject_obj, + JSON_COMPACT))); json_decref (reject_obj); GNUNET_assert (CURLE_OK == curl_easy_setopt (eh, diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c index b6aee7f4..19c088d8 100644 --- a/src/bank-lib/fakebank.c +++ b/src/bank-lib/fakebank.c @@ -30,7 +30,7 @@ /** * Maximum POST request size (for /admin/add/incoming) */ -#define REQUEST_BUFFER_MAX (4*1024) +#define REQUEST_BUFFER_MAX (4 * 1024) /** @@ -318,7 +318,7 @@ create_bank_error (struct MHD_Connection *connection, "ec", (json_int_t) ec); json_str = json_dumps (json, - JSON_INDENT(2)); + JSON_INDENT (2)); json_decref (json); if (NULL == json_str) { @@ -471,7 +471,7 @@ handle_admin_add_incoming (struct TALER_FAKEBANK_Handle *h, "timestamp", "/Date(0)/"); /*dummy tmp */ json_str = json_dumps (json, - JSON_INDENT(2)); + JSON_INDENT (2)); json_decref (json); if (NULL == json_str) { @@ -574,10 +574,10 @@ handle_reject (struct TALER_FAKEBANK_Handle *h, if (GNUNET_OK != found) return create_bank_error - (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_BANK_REJECT_TRANSACTION_NOT_FOUND, - "transaction unknown"); + (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_BANK_REJECT_TRANSACTION_NOT_FOUND, + "transaction unknown"); /* finally build regular response */ resp = MHD_create_response_from_buffer (0, NULL, @@ -608,9 +608,9 @@ handle_home_page (struct TALER_FAKEBANK_Handle *h, #define HELLOMSG "Hello, Fakebank!" resp = MHD_create_response_from_buffer - (strlen (HELLOMSG), - HELLOMSG, - MHD_RESPMEM_MUST_COPY); + (strlen (HELLOMSG), + HELLOMSG, + MHD_RESPMEM_MUST_COPY); ret = MHD_queue_response (connection, MHD_HTTP_OK, @@ -654,11 +654,11 @@ handle_history (struct TALER_FAKEBANK_Handle *h, MHD_GET_ARGUMENT_KIND, "delta"); if ( ((NULL != start) && (1 != sscanf (start, - "%llu", - &hri.start))) || - (NULL == delta) || (1 != sscanf (delta, - "%lld", - &hri.count)) ) + "%llu", + &hri.start))) || + (NULL == delta) || (1 != sscanf (delta, + "%lld", + &hri.count)) ) { GNUNET_break (0); return MHD_NO; @@ -667,7 +667,7 @@ handle_history (struct TALER_FAKEBANK_Handle *h, if (NULL == start) pos = 0 > hri.count ? - h->transactions_tail : h->transactions_head; + h->transactions_tail : h->transactions_head; else if (NULL != h->transactions_head) { @@ -728,7 +728,7 @@ handle_history_range (struct TALER_FAKEBANK_Handle *h, struct Transaction *pos; if (GNUNET_OK != TFH_parse_history_common_args (connection, - &ha)) + &ha)) { GNUNET_break (0); return MHD_NO; @@ -743,9 +743,9 @@ handle_history_range (struct TALER_FAKEBANK_Handle *h, if ( (NULL == start) || (1 != sscanf (start, "%llu", &start_stamp)) || - (NULL == end) || (1 != sscanf (end, - "%lld", - &end_stamp)) ) + (NULL == end) || (1 != sscanf (end, + "%lld", + &end_stamp)) ) { GNUNET_break (0); return MHD_NO; @@ -875,7 +875,7 @@ schedule_httpd (struct TALER_FAKEBANK_Handle *h) struct GNUNET_TIME_Relative tv; haveto = MHD_get_timeout (h->mhd_bank, - &timeout); + &timeout); if (MHD_YES == haveto) tv.rel_value_us = (uint64_t) timeout * 1000LL; else @@ -884,9 +884,9 @@ schedule_httpd (struct TALER_FAKEBANK_Handle *h) GNUNET_SCHEDULER_cancel (h->mhd_task); h->mhd_task = GNUNET_SCHEDULER_add_read_net (tv, - h->mhd_rfd, - &run_mhd, - h); + h->mhd_rfd, + &run_mhd, + h); } #else /** @@ -981,17 +981,18 @@ TALER_FAKEBANK_start (uint16_t port) h = GNUNET_new (struct TALER_FAKEBANK_Handle); h->mhd_bank = MHD_start_daemon (MHD_USE_DEBUG #if EPOLL_SUPPORT - | MHD_USE_EPOLL_INTERNAL_THREAD + | MHD_USE_EPOLL_INTERNAL_THREAD #else | MHD_USE_INTERNAL_POLLING_THREAD #endif - | MHD_USE_DUAL_STACK, + | MHD_USE_DUAL_STACK, port, NULL, NULL, &handle_mhd_request, h, MHD_OPTION_NOTIFY_COMPLETED, &handle_mhd_completion_callback, h, - MHD_OPTION_LISTEN_BACKLOG_SIZE, (unsigned int) 1024, + MHD_OPTION_LISTEN_BACKLOG_SIZE, (unsigned + int) 1024, MHD_OPTION_END); if (NULL == h->mhd_bank) { @@ -1000,7 +1001,7 @@ TALER_FAKEBANK_start (uint16_t port) } #if EPOLL_SUPPORT h->mhd_fd = MHD_get_daemon_info (h->mhd_bank, - MHD_DAEMON_INFO_EPOLL_FD)->epoll_fd; + MHD_DAEMON_INFO_EPOLL_FD)->epoll_fd; h->mhd_rfd = GNUNET_NETWORK_socket_box_native (h->mhd_fd); #endif schedule_httpd (h); diff --git a/src/bank-lib/fakebank.h b/src/bank-lib/fakebank.h index ff8ea716..321bc133 100644 --- a/src/bank-lib/fakebank.h +++ b/src/bank-lib/fakebank.h @@ -198,27 +198,24 @@ struct HistoryArgs * @param pos current position. * @return GNUNET_YES if the iteration shuold go on. */ -typedef int (*CheckAdvance) - (const struct HistoryArgs *ha, - const struct Transaction *pos); +typedef int (*CheckAdvance)(const struct HistoryArgs *ha, + const struct Transaction *pos); /** * Type for a function that steps over the next element * in the list of all transactions, after the current @a pos * _got_ included in the result. */ -typedef struct Transaction * (*Step) - (const struct HistoryArgs *ha, - const struct Transaction *pos); +typedef struct Transaction * (*Step)(const struct HistoryArgs *ha, + const struct Transaction *pos); /* * Type for a function that steps over the next element * in the list of all transactions, after the current @a pos * did _not_ get included in the result. */ -typedef struct Transaction * (*Skip) - (const struct HistoryArgs *ha, - const struct Transaction *pos); +typedef struct Transaction * (*Skip)(const struct HistoryArgs *ha, + const struct Transaction *pos); /** * Actual history response builder. diff --git a/src/bank-lib/fakebank_history.c b/src/bank-lib/fakebank_history.c index 4cd0dc4c..b1770bb8 100644 --- a/src/bank-lib/fakebank_history.c +++ b/src/bank-lib/fakebank_history.c @@ -110,7 +110,7 @@ TFH_handle_history_range_advance (const struct HistoryArgs *ha, const struct HistoryRangeDates *hrd = ha->range; if ( (NULL != pos) && - (pos->date.abs_value_us <= hrd->end.abs_value_us) ) + (pos->date.abs_value_us <= hrd->end.abs_value_us) ) return GNUNET_YES; return GNUNET_NO; @@ -196,16 +196,16 @@ TFH_build_history_response (struct MHD_Connection *connection, ? (pos->rejected ? "cancel-" : "-") : (pos->rejected ? "cancel+" : "+"); trans = json_pack - ("{s:I, s:o, s:o, s:s, s:I, s:s}", - "row_id", (json_int_t) pos->row_id, - "date", GNUNET_JSON_from_time_abs (pos->date), - "amount", TALER_JSON_from_amount (&pos->amount), - "sign", sign, - "counterpart", (json_int_t) - ( (ha->account_number == pos->debit_account) - ? pos->credit_account - : pos->debit_account), - "wt_subject", subject); + ("{s:I, s:o, s:o, s:s, s:I, s:s}", + "row_id", (json_int_t) pos->row_id, + "date", GNUNET_JSON_from_time_abs (pos->date), + "amount", TALER_JSON_from_amount (&pos->amount), + "sign", sign, + "counterpart", (json_int_t) + ( (ha->account_number == pos->debit_account) + ? pos->credit_account + : pos->debit_account), + "wt_subject", subject); GNUNET_assert (NULL != trans); GNUNET_free (subject); @@ -244,9 +244,9 @@ TFH_build_history_response (struct MHD_Connection *connection, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Returning empty transaction history\n"); resp = MHD_create_response_from_buffer - (0, - "", - MHD_RESPMEM_PERSISTENT); + (0, + "", + MHD_RESPMEM_PERSISTENT); ret = MHD_queue_response (connection, MHD_HTTP_NO_CONTENT, resp); @@ -270,7 +270,7 @@ TFH_build_history_response (struct MHD_Connection *connection, size_t json_len; json_str = json_dumps (jresponse, - JSON_INDENT(2)); + JSON_INDENT (2)); json_decref (jresponse); if (NULL == json_str) { @@ -339,9 +339,9 @@ TFH_parse_history_common_args (struct MHD_Connection *connection, MHD_GET_ARGUMENT_KIND, "ordering"); account_number = MHD_lookup_connection_value - (connection, - MHD_GET_ARGUMENT_KIND, - "account_number"); + (connection, + MHD_GET_ARGUMENT_KIND, + "account_number"); /* Fail if one of the above failed. */ if ( (NULL == direction) || @@ -356,11 +356,11 @@ TFH_parse_history_common_args (struct MHD_Connection *connection, "CREDIT")) && (0 != strcasecmp (direction, "DEBIT")) ) || - (1 != sscanf (account_number, - "%llu", - &ha->account_number)) || - ( (NULL == auth) || (0 != strcasecmp (auth, - "basic")) ) ) + (1 != sscanf (account_number, + "%llu", + &ha->account_number)) || + ( (NULL == auth) || (0 != strcasecmp (auth, + "basic")) ) ) { /* Invalid request, given that this is fakebank we impolitely * just kill the connection instead of returning a nice error. @@ -396,8 +396,9 @@ TFH_parse_history_common_args (struct MHD_Connection *connection, "OMIT")) { /* nothing */ - } else if (0 == strcasecmp (cancelled, - "SHOW")) + } + else if (0 == strcasecmp (cancelled, + "SHOW")) { ha->direction |= TALER_BANK_DIRECTION_CANCEL; } @@ -410,8 +411,8 @@ TFH_parse_history_common_args (struct MHD_Connection *connection, } if ((NULL != ordering) - && 0 == strcmp ("ascending", - ordering)) + && (0 == strcmp ("ascending", + ordering))) ha->ascending = GNUNET_YES; else ha->ascending = GNUNET_NO; diff --git a/src/bank-lib/taler-bank-transfer.c b/src/bank-lib/taler-bank-transfer.c index 2729b7ee..6297d650 100644 --- a/src/bank-lib/taler-bank-transfer.c +++ b/src/bank-lib/taler-bank-transfer.c @@ -203,48 +203,48 @@ main (int argc, char *const *argv) { const struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_option_mandatory - (TALER_getopt_get_amount ('a', - "amount", - "VALUE", - "value to transfer", - &amount)), + (TALER_getopt_get_amount ('a', + "amount", + "VALUE", + "value to transfer", + &amount)), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_string ('b', - "bank", - "URL", - "base URL of the bank", - &bank_url)), + (GNUNET_GETOPT_option_string ('b', + "bank", + "URL", + "base URL of the bank", + &bank_url)), GNUNET_GETOPT_option_help ("Deposit funds into a Taler reserve"), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_ulong ('C', - "credit", - "ACCOUNT", - "number of the bank account to credit", - &credit_account_no)), + (GNUNET_GETOPT_option_ulong ('C', + "credit", + "ACCOUNT", + "number of the bank account to credit", + &credit_account_no)), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_ulong ('D', - "debit", - "ACCOUNT", - "number of the bank account to debit", - &debit_account_no)), + (GNUNET_GETOPT_option_ulong ('D', + "debit", + "ACCOUNT", + "number of the bank account to debit", + &debit_account_no)), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_string ('s', - "subject", - "STRING", - "specifies the wire transfer subject", - &subject)), + (GNUNET_GETOPT_option_string ('s', + "subject", + "STRING", + "specifies the wire transfer subject", + &subject)), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_string ('u', - "user", - "USERNAME", - "username to use for authentication", - &username)), + (GNUNET_GETOPT_option_string ('u', + "user", + "USERNAME", + "username to use for authentication", + &username)), GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_string ('p', - "pass", - "PASSPHRASE", - "passphrase to use for authentication", - &password)), + (GNUNET_GETOPT_option_string ('p', + "pass", + "PASSPHRASE", + "passphrase to use for authentication", + &password)), GNUNET_GETOPT_OPTION_END }; @@ -256,9 +256,9 @@ main (int argc, char *const *argv) if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "taler-bank-transfer", - "Execute bank transfer", - options, - &run, NULL)) + "Execute bank transfer", + options, + &run, NULL)) return 1; return global_ret; } diff --git a/src/bank-lib/taler-fakebank-run.c b/src/bank-lib/taler-fakebank-run.c index 599ca85d..51d054bc 100644 --- a/src/bank-lib/taler-fakebank-run.c +++ b/src/bank-lib/taler-fakebank-run.c @@ -65,13 +65,13 @@ main (int argc, const struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; - + if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "taler-fakebank-run", - "Runs the fakebank", - options, - &run, + "Runs the fakebank", + options, + &run, NULL)) return 1; diff --git a/src/bank-lib/test_bank_api.c b/src/bank-lib/test_bank_api.c index b1b94377..04323456 100644 --- a/src/bank-lib/test_bank_api.c +++ b/src/bank-lib/test_bank_api.c @@ -41,8 +41,7 @@ static void run (void *cls) { int *resultp = cls; - static struct TBI_Command commands[] = - { + static struct TBI_Command commands[] = { /* Ask complete history of 'Exchange' user (number 2) */ { .oc = TBI_OC_HISTORY, .label = "history-0", @@ -113,7 +112,8 @@ run (void *cls) { .oc = TBI_OC_HISTORY, .label = "history-r3", .details.history.account_number = 2, - .details.history.direction = TALER_BANK_DIRECTION_BOTH | TALER_BANK_DIRECTION_CANCEL, + .details.history.direction = TALER_BANK_DIRECTION_BOTH + | TALER_BANK_DIRECTION_CANCEL, .details.history.start_row_ref = NULL, .details.history.num_results = 5 }, { .oc = TBI_OC_END } @@ -133,7 +133,7 @@ run (void *cls) */ int main (int argc, - char * const *argv) + char *const *argv) { struct GNUNET_OS_Process *bankd; unsigned int cnt; @@ -143,11 +143,11 @@ main (int argc, if (GNUNET_OK != GNUNET_NETWORK_test_port_free (IPPROTO_TCP, - 8081)) + 8081)) { fprintf (stderr, "Required port %u not available, skipping.\n", - 8081); + 8081); return 77; } GNUNET_log_setup ("test-bank-api", @@ -157,13 +157,14 @@ main (int argc, if (NULL == (dbconn = getenv ("TALER_EXCHANGEDB_POSTGRES_CONFIG"))) dbconn = defaultdb; char *purgedb_cmd; - GNUNET_asprintf (&purgedb_cmd, "taler-bank-manage -c bank.conf --with-db=%s django flush --no-input", + GNUNET_asprintf (&purgedb_cmd, + "taler-bank-manage -c bank.conf --with-db=%s django flush --no-input", dbconn); if (0 != system (purgedb_cmd)) { - fprintf (stderr, - "Could not purge database\n"); - return 77; + fprintf (stderr, + "Could not purge database\n"); + return 77; } bankd = GNUNET_OS_start_process (GNUNET_NO, @@ -188,14 +189,15 @@ main (int argc, "Waiting for taler-bank-manage to be ready\n"); cnt = 0; do - { - fprintf (stderr, "."); - sleep (1); - cnt++; - if (cnt > 30) - break; - } - while (0 != system ("wget -q -t 1 -T 1 http://127.0.0.1:8080/ -o /dev/null -O /dev/null")); + { + fprintf (stderr, "."); + sleep (1); + cnt++; + if (cnt > 30) + break; + } + while (0 != system ( + "wget -q -t 1 -T 1 http://127.0.0.1:8080/ -o /dev/null -O /dev/null")); fprintf (stderr, "\n"); diff --git a/src/bank-lib/test_bank_api_new.c b/src/bank-lib/test_bank_api_new.c index 4a89c193..17acac9b 100644 --- a/src/bank-lib/test_bank_api_new.c +++ b/src/bank-lib/test_bank_api_new.c @@ -49,8 +49,8 @@ #define ADDSECS(base, secs) \ GNUNET_TIME_absolute_add \ (base, \ - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ - secs)) + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ + secs)) /** * Subtract seconds. * @@ -61,8 +61,8 @@ #define SUBSECS(base, secs) \ GNUNET_TIME_absolute_subtract \ (base, \ - GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ - secs)) + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, \ + secs)) /** * Bank process. */ @@ -96,35 +96,35 @@ run (void *cls, 5), TALER_TESTING_cmd_bank_history_range_with_dates ("history-0-range", - bank_url, - EXCHANGE_ACCOUNT_NUMBER, - TALER_BANK_DIRECTION_BOTH, - GNUNET_NO, - SUBSECS (now, - 5), - ADDSECS (now, - 5)), + bank_url, + EXCHANGE_ACCOUNT_NUMBER, + TALER_BANK_DIRECTION_BOTH, + GNUNET_NO, + SUBSECS (now, + 5), + ADDSECS (now, + 5)), TALER_TESTING_cmd_fakebank_transfer_with_subject ("deposit-1", - "KUDOS:5.01", - bank_url, - BANK_ACCOUNT_NUMBER, - EXCHANGE_ACCOUNT_NUMBER, - AUTHS[BANK_ACCOUNT_NUMBER -1].details.basic.username, - AUTHS[BANK_ACCOUNT_NUMBER -1].details.basic.password, - "subject 1", - "http://exchange.com/"), + "KUDOS:5.01", + bank_url, + BANK_ACCOUNT_NUMBER, + EXCHANGE_ACCOUNT_NUMBER, + AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.username, + AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.password, + "subject 1", + "http://exchange.com/"), /* bank gives to exchange */ TALER_TESTING_cmd_fakebank_transfer_with_subject ("deposit-2", - "KUDOS:5.01", - bank_url, - BANK_ACCOUNT_NUMBER, - EXCHANGE_ACCOUNT_NUMBER, - AUTHS[BANK_ACCOUNT_NUMBER -1].details.basic.username, - AUTHS[BANK_ACCOUNT_NUMBER -1].details.basic.password, - "subject 2", - "http://exchange.com/"), + "KUDOS:5.01", + bank_url, + BANK_ACCOUNT_NUMBER, + EXCHANGE_ACCOUNT_NUMBER, + AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.username, + AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.password, + "subject 2", + "http://exchange.com/"), TALER_TESTING_cmd_bank_history ("history-1c", bank_url, EXCHANGE_ACCOUNT_NUMBER, @@ -158,14 +158,14 @@ run (void *cls, */ TALER_TESTING_cmd_bank_history_range_with_dates ("history-2-range", - bank_url, - EXCHANGE_ACCOUNT_NUMBER, - TALER_BANK_DIRECTION_BOTH, - GNUNET_NO, - SUBSECS (now, - 50), - ADDSECS (now, - 5)), + bank_url, + EXCHANGE_ACCOUNT_NUMBER, + TALER_BANK_DIRECTION_BOTH, + GNUNET_NO, + SUBSECS (now, + 50), + ADDSECS (now, + 5)), TALER_TESTING_cmd_bank_reject ("reject-1", bank_url, "deposit-1"), @@ -182,8 +182,8 @@ run (void *cls, /* Pacifies "make check" */ int -main(int argc, - char * const *argv) +main (int argc, + char *const *argv) { unsigned int ret; /* These environment variables get in the way... */ @@ -192,11 +192,11 @@ main(int argc, GNUNET_log_setup ("test-bank-api-new", "DEBUG", NULL); if (NULL == - (bank_url = TALER_TESTING_prepare_bank (CONFIG_FILE))) + (bank_url = TALER_TESTING_prepare_bank (CONFIG_FILE))) return 77; if (NULL == (bankd = - TALER_TESTING_run_bank (CONFIG_FILE, bank_url))) + TALER_TESTING_run_bank (CONFIG_FILE, bank_url))) return 77; ret = TALER_TESTING_setup (&run, diff --git a/src/bank-lib/test_bank_api_twisted.c b/src/bank-lib/test_bank_api_twisted.c index 3bb149fd..a8f60c5e 100644 --- a/src/bank-lib/test_bank_api_twisted.c +++ b/src/bank-lib/test_bank_api_twisted.c @@ -115,7 +115,7 @@ purge_process (struct GNUNET_OS_Process *process) int main (int argc, - char * const *argv) + char *const *argv) { unsigned int ret; /* These environment variables get in the way... */ @@ -127,19 +127,19 @@ main (int argc, NULL); if (NULL == (bank_url = TALER_TESTING_prepare_bank - (CONFIG_FILE))) + (CONFIG_FILE))) return 77; if (NULL == (bankd = TALER_TESTING_run_bank - (CONFIG_FILE, - bank_url))) + (CONFIG_FILE, + bank_url))) { GNUNET_free (bank_url); return 77; } if (NULL == (twister_url = TALER_TESTING_prepare_twister - (CONFIG_FILE))) + (CONFIG_FILE))) { purge_process (bankd); GNUNET_free (bank_url); diff --git a/src/bank-lib/test_bank_api_with_fakebank.c b/src/bank-lib/test_bank_api_with_fakebank.c index 5c940d78..33196812 100644 --- a/src/bank-lib/test_bank_api_with_fakebank.c +++ b/src/bank-lib/test_bank_api_with_fakebank.c @@ -37,8 +37,7 @@ static void run (void *cls) { int *resultp = cls; - static struct TBI_Command commands[] = - { + static struct TBI_Command commands[] = { { .oc = TBI_OC_HISTORY, .label = "history-0", .details.history.account_number = 1, @@ -134,7 +133,8 @@ run (void *cls) { .oc = TBI_OC_HISTORY, .label = "history-r1c", .details.history.account_number = 1, - .details.history.direction = TALER_BANK_DIRECTION_BOTH | TALER_BANK_DIRECTION_CANCEL, + .details.history.direction = TALER_BANK_DIRECTION_BOTH + | TALER_BANK_DIRECTION_CANCEL, .details.history.start_row_ref = NULL, .details.history.num_results = 5 }, { .oc = TBI_OC_EXPECT_TRANSFER, @@ -160,7 +160,7 @@ run (void *cls) */ int main (int argc, - char * const *argv) + char *const *argv) { int result; diff --git a/src/bank-lib/test_bank_api_with_fakebank_new.c b/src/bank-lib/test_bank_api_with_fakebank_new.c index 8865cc40..046248ad 100644 --- a/src/bank-lib/test_bank_api_with_fakebank_new.c +++ b/src/bank-lib/test_bank_api_with_fakebank_new.c @@ -76,14 +76,14 @@ run (void *cls, * the parameters, although it was always set as '200 OK' */ TALER_TESTING_cmd_fakebank_transfer_with_subject ("debit-1", - "KUDOS:5.01", - fakebank_url, - EXCHANGE_ACCOUNT_NUMBER, - BANK_ACCOUNT_NUMBER, - AUTHS[EXCHANGE_ACCOUNT_NUMBER -1].details.basic.username, - AUTHS[EXCHANGE_ACCOUNT_NUMBER -1].details.basic.password, - "subject 1", - "http://exchange.com/"), + "KUDOS:5.01", + fakebank_url, + EXCHANGE_ACCOUNT_NUMBER, + BANK_ACCOUNT_NUMBER, + AUTHS[EXCHANGE_ACCOUNT_NUMBER - 1].details.basic.username, + AUTHS[EXCHANGE_ACCOUNT_NUMBER - 1].details.basic.password, + "subject 1", + "http://exchange.com/"), TALER_TESTING_cmd_bank_history ("history-1c", fakebank_url, @@ -103,25 +103,25 @@ run (void *cls, TALER_TESTING_cmd_fakebank_transfer_with_subject ("debit-2", - "KUDOS:3.21", - fakebank_url, - EXCHANGE_ACCOUNT_NUMBER, // debit account. - USER_ACCOUNT_NUMBER, - AUTHS[EXCHANGE_ACCOUNT_NUMBER -1].details.basic.username, - AUTHS[EXCHANGE_ACCOUNT_NUMBER -1].details.basic.password, - "subject 2", - "http://exchange.org/"), + "KUDOS:3.21", + fakebank_url, + EXCHANGE_ACCOUNT_NUMBER, // debit account. + USER_ACCOUNT_NUMBER, + AUTHS[EXCHANGE_ACCOUNT_NUMBER - 1].details.basic.username, + AUTHS[EXCHANGE_ACCOUNT_NUMBER - 1].details.basic.password, + "subject 2", + "http://exchange.org/"), TALER_TESTING_cmd_fakebank_transfer_with_subject ("credit-2", - "KUDOS:3.22", - fakebank_url, - USER_ACCOUNT_NUMBER, // debit account. - EXCHANGE_ACCOUNT_NUMBER, - AUTHS[USER_ACCOUNT_NUMBER -1].details.basic.username, - AUTHS[USER_ACCOUNT_NUMBER -1].details.basic.password, - "credit 2", - "http://exchange.org/"), + "KUDOS:3.22", + fakebank_url, + USER_ACCOUNT_NUMBER, // debit account. + EXCHANGE_ACCOUNT_NUMBER, + AUTHS[USER_ACCOUNT_NUMBER - 1].details.basic.username, + AUTHS[USER_ACCOUNT_NUMBER - 1].details.basic.password, + "credit 2", + "http://exchange.org/"), TALER_TESTING_cmd_bank_history ("history-2b", fakebank_url, @@ -152,18 +152,18 @@ run (void *cls, TALER_TESTING_cmd_fakebank_transfer_with_subject ("credit-for-reject-1", - "KUDOS:5.01", - fakebank_url, - BANK_ACCOUNT_NUMBER, - EXCHANGE_ACCOUNT_NUMBER, - AUTHS[BANK_ACCOUNT_NUMBER -1].details.basic.username, - AUTHS[BANK_ACCOUNT_NUMBER -1].details.basic.password, - "subject 3", - "http://exchange.net/"), - - TALER_TESTING_cmd_bank_reject ("reject-1", - fakebank_url, - "credit-for-reject-1"), + "KUDOS:5.01", + fakebank_url, + BANK_ACCOUNT_NUMBER, + EXCHANGE_ACCOUNT_NUMBER, + AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.username, + AUTHS[BANK_ACCOUNT_NUMBER - 1].details.basic.password, + "subject 3", + "http://exchange.net/"), + + TALER_TESTING_cmd_bank_reject ("reject-1", + fakebank_url, + "credit-for-reject-1"), TALER_TESTING_cmd_bank_history ("history-r1", fakebank_url, @@ -176,15 +176,15 @@ run (void *cls, TALER_TESTING_cmd_bank_history ("history-r1c", fakebank_url, BANK_ACCOUNT_NUMBER, - TALER_BANK_DIRECTION_BOTH | - TALER_BANK_DIRECTION_CANCEL, + TALER_BANK_DIRECTION_BOTH + | TALER_BANK_DIRECTION_CANCEL, GNUNET_YES, NULL, 5), TALER_TESTING_cmd_check_bank_transfer_with_ref ("expect-credit-reject-1", - "credit-for-reject-1"), + "credit-for-reject-1"), TALER_TESTING_cmd_check_bank_empty ("expect-empty-2"), @@ -202,7 +202,7 @@ run (void *cls, int main (int argc, - char * const *argv) + char *const *argv) { /* These environment variables get in the way... */ unsetenv ("XDG_DATA_HOME"); diff --git a/src/bank-lib/test_bank_api_with_fakebank_twisted.c b/src/bank-lib/test_bank_api_with_fakebank_twisted.c index 162eb5df..8c5b90a1 100644 --- a/src/bank-lib/test_bank_api_with_fakebank_twisted.c +++ b/src/bank-lib/test_bank_api_with_fakebank_twisted.c @@ -115,7 +115,7 @@ purge_process (struct GNUNET_OS_Process *process) int main (int argc, - char * const *argv) + char *const *argv) { unsigned int ret; @@ -128,12 +128,12 @@ main (int argc, NULL); if (NULL == (fakebank_url = TALER_TESTING_prepare_fakebank - (CONFIG_FILE, - "account-1"))) + (CONFIG_FILE, + "account-1"))) return 77; if (NULL == (twister_url = TALER_TESTING_prepare_twister - (CONFIG_FILE))) + (CONFIG_FILE))) { GNUNET_free (fakebank_url); return 77; diff --git a/src/bank-lib/test_bank_interpreter.c b/src/bank-lib/test_bank_interpreter.c index 9430e84b..7f30f505 100644 --- a/src/bank-lib/test_bank_interpreter.c +++ b/src/bank-lib/test_bank_interpreter.c @@ -118,7 +118,7 @@ find_command (const struct InterpreterState *is, "Attempt to lookup command for empty label\n"); return NULL; } - for (unsigned int i=0;TBI_OC_END != (cmd = &is->commands[i])->oc;i++) + for (unsigned int i = 0; TBI_OC_END != (cmd = &is->commands[i])->oc; i++) if ( (NULL != cmd->label) && (0 == strcmp (cmd->label, label)) ) @@ -144,7 +144,7 @@ test_cancelled (struct InterpreterState *is, { const struct TBI_Command *cmd = &is->commands[off]; - for (unsigned int i=0;i<is->ip;i++) + for (unsigned int i = 0; i<is->ip; i++) { const struct TBI_Command *c = &is->commands[i]; @@ -238,7 +238,7 @@ build_history (struct InterpreterState *is, ok = GNUNET_NO; if (NULL == ref) ok = GNUNET_YES; - for (unsigned int off = start;off != end + inc; off += inc) + for (unsigned int off = start; off != end + inc; off += inc) { const struct TBI_Command *pos = &is->commands[off]; int cancelled; @@ -262,10 +262,12 @@ build_history (struct InterpreterState *is, if ( (GNUNET_YES == cancelled) && (0 == (cmd->details.history.direction & TALER_BANK_DIRECTION_CANCEL)) ) continue; - if ( ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_CREDIT)) && + if ( ( (0 != (cmd->details.history.direction + & TALER_BANK_DIRECTION_CREDIT)) && (cmd->details.history.account_number == pos->details.admin_add_incoming.credit_account_no)) || - ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_DEBIT)) && + ( (0 != (cmd->details.history.direction + & TALER_BANK_DIRECTION_DEBIT)) && (cmd->details.history.account_number == pos->details.admin_add_incoming.debit_account_no)) ) total++; /* found matching record */ @@ -283,7 +285,7 @@ build_history (struct InterpreterState *is, ok = GNUNET_NO; if (NULL == ref) ok = GNUNET_YES; - for (unsigned int off = start;off != end + inc; off += inc) + for (unsigned int off = start; off != end + inc; off += inc) { const struct TBI_Command *pos = &is->commands[off]; int cancelled; @@ -302,10 +304,12 @@ build_history (struct InterpreterState *is, continue; /* skip until we find the marker */ if (total >= cmd->details.history.num_results * inc) break; /* hit limit specified by command */ - if ( ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_CREDIT)) && + if ( ( (0 != (cmd->details.history.direction + & TALER_BANK_DIRECTION_CREDIT)) && (cmd->details.history.account_number == pos->details.admin_add_incoming.credit_account_no)) && - ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_DEBIT)) && + ( (0 != (cmd->details.history.direction + & TALER_BANK_DIRECTION_DEBIT)) && (cmd->details.history.account_number == pos->details.admin_add_incoming.debit_account_no)) ) { @@ -319,7 +323,8 @@ build_history (struct InterpreterState *is, (0 == (cmd->details.history.direction & TALER_BANK_DIRECTION_CANCEL)) ) continue; - if ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_CREDIT)) && + if ( (0 != (cmd->details.history.direction + & TALER_BANK_DIRECTION_CREDIT)) && (cmd->details.history.account_number == pos->details.admin_add_incoming.credit_account_no)) { @@ -329,11 +334,12 @@ build_history (struct InterpreterState *is, GNUNET_asprintf (&h[total].details.account_url, "payto://x-taler-bank/%s/%llu", "localhost:8080", - (unsigned long long) pos->details.admin_add_incoming.debit_account_no); + (unsigned long + long) pos->details.admin_add_incoming.debit_account_no); } if ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_DEBIT)) && - (cmd->details.history.account_number == - pos->details.admin_add_incoming.debit_account_no)) + (cmd->details.history.account_number == + pos->details.admin_add_incoming.debit_account_no)) { h[total].direction = TALER_BANK_DIRECTION_DEBIT; if (GNUNET_YES == cancelled) @@ -341,18 +347,22 @@ build_history (struct InterpreterState *is, GNUNET_asprintf (&h[total].details.account_url, "payto://x-taler-bank/%s/%llu", "localhost:8080", - (unsigned long long) pos->details.admin_add_incoming.credit_account_no); + (unsigned long + long) pos->details.admin_add_incoming.credit_account_no); } - if ( ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_CREDIT)) && + if ( ( (0 != (cmd->details.history.direction + & TALER_BANK_DIRECTION_CREDIT)) && (cmd->details.history.account_number == pos->details.admin_add_incoming.credit_account_no)) || - ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_DEBIT)) && + ( (0 != (cmd->details.history.direction + & TALER_BANK_DIRECTION_DEBIT)) && (cmd->details.history.account_number == pos->details.admin_add_incoming.debit_account_no)) ) { GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (pos->details.admin_add_incoming.amount, - &h[total].details.amount)); + TALER_string_to_amount ( + pos->details.admin_add_incoming.amount, + &h[total].details.amount)); /* h[total].execution_date; // unknown here */ h[total].row_id = pos->details.admin_add_incoming.row_id; @@ -386,7 +396,7 @@ print_expected (struct History *h, (unsigned long long) h_len); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Expected history:\n"); - for (uint64_t i=0;i<h_len;i++) + for (uint64_t i = 0; i<h_len; i++) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "H(%llu): %s%s (serial: %llu, subject: %s, to: %s)\n", @@ -410,7 +420,7 @@ static void free_history (struct History *h, uint64_t h_len) { - for (uint64_t off = 0;off<h_len;off++) + for (uint64_t off = 0; off<h_len; off++) { GNUNET_free (h[off].details.wire_transfer_subject); GNUNET_free (h[off].details.account_url); @@ -747,11 +757,14 @@ interpreter_run (void *cls) = TALER_BANK_admin_add_incoming (is->ctx, "http://localhost:8080", &auth, - cmd->details.admin_add_incoming.exchange_base_url, + cmd->details.admin_add_incoming. + exchange_base_url, cmd->details.admin_add_incoming.subject, &amount, - cmd->details.admin_add_incoming.debit_account_no, - cmd->details.admin_add_incoming.credit_account_no, + cmd->details.admin_add_incoming. + debit_account_no, + cmd->details.admin_add_incoming. + credit_account_no, &add_incoming_cb, is); if (NULL == cmd->details.admin_add_incoming.aih) @@ -813,8 +826,9 @@ interpreter_run (void *cls) cmd->details.expect_transfer.cmd_ref); GNUNET_assert (NULL != ref); GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (ref->details.admin_add_incoming.amount, - &amount)); + TALER_string_to_amount ( + ref->details.admin_add_incoming.amount, + &amount)); { char *subject; @@ -822,8 +836,10 @@ interpreter_run (void *cls) TALER_FAKEBANK_check (is->fakebank, &amount, ref->details.admin_add_incoming.debit_account_no, - ref->details.admin_add_incoming.credit_account_no, - ref->details.admin_add_incoming.exchange_base_url, + ref->details.admin_add_incoming. + credit_account_no, + ref->details.admin_add_incoming. + exchange_base_url, &subject)) { GNUNET_break (0); @@ -841,7 +857,7 @@ interpreter_run (void *cls) GNUNET_free (subject); } next (is); - return; + return; case TBI_OC_EXPECT_TRANSFERS_EMPTY: if (GNUNET_OK != TALER_FAKEBANK_check_empty (is->fakebank)) { @@ -928,7 +944,7 @@ do_shutdown (void *cls) is->timeout_task = NULL; } - for (unsigned int i=0;TBI_OC_END != (cmd = &is->commands[i])->oc;i++) + for (unsigned int i = 0; TBI_OC_END != (cmd = &is->commands[i])->oc; i++) { switch (cmd->oc) { @@ -942,7 +958,8 @@ do_shutdown (void *cls) "Command %u (%s) did not complete\n", i, cmd->label); - TALER_BANK_admin_add_incoming_cancel (cmd->details.admin_add_incoming.aih); + TALER_BANK_admin_add_incoming_cancel ( + cmd->details.admin_add_incoming.aih); cmd->details.admin_add_incoming.aih = NULL; } break; @@ -1025,7 +1042,7 @@ TBI_run_interpreter (int *resultp, is); is->timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply - (GNUNET_TIME_UNIT_SECONDS, 150), + (GNUNET_TIME_UNIT_SECONDS, 150), &do_timeout, is); GNUNET_SCHEDULER_add_shutdown (&do_shutdown, is); } diff --git a/src/bank-lib/test_bank_interpreter.h b/src/bank-lib/test_bank_interpreter.h index ae323055..1f78ec0b 100644 --- a/src/bank-lib/test_bank_interpreter.h +++ b/src/bank-lib/test_bank_interpreter.h @@ -136,7 +136,8 @@ struct TBI_Command } admin_add_incoming; - struct { + struct + { /** * For which account do we query the history. @@ -186,7 +187,8 @@ struct TBI_Command * If @e opcode is #TBI_OC_EXPECT_TRANSFER, this * specifies which transfer we expected. */ - struct { + struct + { /** * Label of the command of an /admin/add/incoming @@ -199,7 +201,8 @@ struct TBI_Command /** * Execute /reject operation. */ - struct { + struct + { /** * Reference to the matching transfer that is now to be rejected. diff --git a/src/bank-lib/testing_api_cmd_history.c b/src/bank-lib/testing_api_cmd_history.c index 013bb647..e69cd7c1 100644 --- a/src/bank-lib/testing_api_cmd_history.c +++ b/src/bank-lib/testing_api_cmd_history.c @@ -80,7 +80,7 @@ struct HistoryState /** * Set to GNUNET_YES if the callback detects something - * unexpected. + * unexpected. */ int failed; @@ -184,7 +184,7 @@ test_cancelled (struct TALER_TESTING_Interpreter *is, current_cmd = &is->commands[off]; TALER_LOG_INFO ("Is `%s' rejected?\n", current_cmd->label); - for (unsigned int i=0;i<is->ip;i++) + for (unsigned int i = 0; i<is->ip; i++) { const struct TALER_TESTING_Command *c = &is->commands[i]; @@ -195,7 +195,7 @@ test_cancelled (struct TALER_TESTING_Interpreter *is, * reject command to mark them as rejected. So errors * about "reject traits" not found are NOT fatal here */ if (GNUNET_OK != TALER_TESTING_get_trait_rejected - (c, 0, &rejected_reference)) + (c, 0, &rejected_reference)) continue; TALER_LOG_INFO ("Command `%s' was rejected by `%s'.\n", @@ -220,7 +220,7 @@ static void free_history (struct History *h, uint64_t h_len) { - for (uint64_t off = 0;off<h_len;off++) + for (uint64_t off = 0; off<h_len; off++) { GNUNET_free (h[off].details.wire_transfer_subject); GNUNET_free (h[off].details.account_url); @@ -247,14 +247,14 @@ print_expected (struct History *h, (unsigned long long) h_len); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Expected history:\n"); - for (uint64_t i=0;i<h_len;i++) + for (uint64_t i = 0; i<h_len; i++) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "H(%llu): %s%s (serial: %llu, subject: %s," " counterpart: %s)\n", (unsigned long long) i, (TALER_BANK_DIRECTION_CREDIT == h[i].direction) ? - "+" : "-", + "+" : "-", TALER_amount2s (&h[i].details.amount), (unsigned long long) h[i].row_id, h[i].details.wire_transfer_subject, @@ -282,14 +282,14 @@ build_history_hit_limit (uint64_t total, { /* "/history-range" case. */ if (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != - hs->start_date.abs_value_us) + hs->start_date.abs_value_us) { const struct GNUNET_TIME_Absolute *timestamp; GNUNET_assert (GNUNET_OK == - TALER_TESTING_get_trait_absolute_time (pos, - 0, - ×tamp)); + TALER_TESTING_get_trait_absolute_time (pos, + 0, + ×tamp)); GNUNET_assert (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != hs->end_date.abs_value_us); @@ -345,18 +345,18 @@ build_history (struct TALER_TESTING_Interpreter *is, { TALER_LOG_INFO ("`%s': start row given via reference `%s'\n", - TALER_TESTING_interpreter_get_current_label (is), - hs->start_row_reference); + TALER_TESTING_interpreter_get_current_label (is), + hs->start_row_reference); add_incoming_cmd = TALER_TESTING_interpreter_lookup_command - (is, hs->start_row_reference); + (is, hs->start_row_reference); GNUNET_assert (NULL != add_incoming_cmd); GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_uint64 - (add_incoming_cmd, 0, &row_id_start)); + (add_incoming_cmd, 0, &row_id_start)); } GNUNET_assert ((0 != hs->num_results) || /* "/history" */ - (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != /* "/history-range" */ - hs->start_date.abs_value_us)); + (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != /* "/history-range" */ + hs->start_date.abs_value_us)); if (0 == is->ip) { @@ -388,7 +388,7 @@ build_history (struct TALER_TESTING_Interpreter *is, /* This loop counts how many commands _later than "start"_ belong * to the history of the caller. This is stored in the @var total * variable. */ - for (unsigned int off = start;off != end + inc; off += inc) + for (unsigned int off = start; off != end + inc; off += inc) { const struct TALER_TESTING_Command *pos = &is->commands[off]; int cancelled; @@ -418,7 +418,7 @@ build_history (struct TALER_TESTING_Interpreter *is, /* Seek "/history-range" starting row, _if_ that's the case */ if ((GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != - hs->start_date.abs_value_us) && (GNUNET_YES != ok)) + hs->start_date.abs_value_us) && (GNUNET_YES != ok)) { const struct GNUNET_TIME_Absolute *timestamp; @@ -427,8 +427,8 @@ build_history (struct TALER_TESTING_Interpreter *is, ×tamp); TALER_LOG_DEBUG ("Seeking first row, start vs timestamp: %llu vs %llu\n", - (long long unsigned int) hs->start_date.abs_value_us, - (long long unsigned int) timestamp->abs_value_us); + (long long unsigned int) hs->start_date.abs_value_us, + (long long unsigned int) timestamp->abs_value_us); if (hs->start_date.abs_value_us <= timestamp->abs_value_us) { @@ -510,7 +510,7 @@ build_history (struct TALER_TESTING_Interpreter *is, /** * This loop _only_ populates the array of history elements. */ - for (unsigned int off = start;off != end + inc; off += inc) + for (unsigned int off = start; off != end + inc; off += inc) { const struct TALER_TESTING_Command *pos = &is->commands[off]; int cancelled; @@ -520,7 +520,7 @@ build_history (struct TALER_TESTING_Interpreter *is, const uint64_t *debit_account_no; if (GNUNET_OK != TALER_TESTING_GET_TRAIT_ROW_ID - (pos, &row_id)) + (pos, &row_id)) continue; if (NULL != row_id_start) @@ -531,7 +531,7 @@ build_history (struct TALER_TESTING_Interpreter *is, /** * Warning: this zeroing is superfluous, as * total doesn't get incremented if 'start' - * was given and couldn't be found. + * was given and couldn't be found. */ total = 0; ok = GNUNET_YES; @@ -541,7 +541,7 @@ build_history (struct TALER_TESTING_Interpreter *is, /* Seek "/history-range" starting row, _if_ that's the case */ if ((GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != - hs->start_date.abs_value_us) && (GNUNET_YES != ok)) + hs->start_date.abs_value_us) && (GNUNET_YES != ok)) { const struct GNUNET_TIME_Absolute *timestamp; @@ -550,8 +550,8 @@ build_history (struct TALER_TESTING_Interpreter *is, ×tamp); TALER_LOG_DEBUG ("Seeking first row, start vs timestamp (2): %llu vs %llu\n", - (long long unsigned int) hs->start_date.abs_value_us, - (long long unsigned int) timestamp->abs_value_us); + (long long unsigned int) hs->start_date.abs_value_us, + (long long unsigned int) timestamp->abs_value_us); if (hs->start_date.abs_value_us <= timestamp->abs_value_us) { @@ -611,15 +611,15 @@ build_history (struct TALER_TESTING_Interpreter *is, if ( (GNUNET_YES == cancelled) && (0 == (hs->direction & TALER_BANK_DIRECTION_CANCEL)) ) { - TALER_LOG_WARNING ("`%s' was cancelled\n", - TALER_TESTING_interpreter_get_current_label - (is)); - continue; + TALER_LOG_WARNING ("`%s' was cancelled\n", + TALER_TESTING_interpreter_get_current_label + (is)); + continue; } - bank_hostname = strchr (hs->bank_url, ':'); - GNUNET_assert (NULL != bank_hostname); - bank_hostname += 3; + bank_hostname = strchr (hs->bank_url, ':'); + GNUNET_assert (NULL != bank_hostname); + bank_hostname += 3; /* Next two blocks only put the 'direction' and 'banking' * information. */ @@ -634,16 +634,16 @@ build_history (struct TALER_TESTING_Interpreter *is, GNUNET_asprintf (&h[total].details.account_url, - ('/' == bank_hostname[strlen(bank_hostname) -1]) - ? "payto://x-taler-bank/%s%llu" - : "payto://x-taler-bank/%s/%llu", - bank_hostname, - (unsigned long long) *debit_account_no); + ('/' == bank_hostname[strlen (bank_hostname) - 1]) + ? "payto://x-taler-bank/%s%llu" + : "payto://x-taler-bank/%s/%llu", + bank_hostname, + (unsigned long long) *debit_account_no); } /* Asked for debit, and account got the debit. */ if ( (0 != (hs->direction & TALER_BANK_DIRECTION_DEBIT)) && - (hs->account_no == *debit_account_no)) + (hs->account_no == *debit_account_no)) { h[total].direction = TALER_BANK_DIRECTION_DEBIT; if (GNUNET_YES == cancelled) @@ -651,11 +651,11 @@ build_history (struct TALER_TESTING_Interpreter *is, GNUNET_asprintf (&h[total].details.account_url, - ('/' == bank_hostname[strlen(bank_hostname) -1]) - ? "payto://x-taler-bank/%s%llu" - : "payto://x-taler-bank/%s/%llu", - bank_hostname, - (unsigned long long) *credit_account_no); + ('/' == bank_hostname[strlen (bank_hostname) - 1]) + ? "payto://x-taler-bank/%s%llu" + : "payto://x-taler-bank/%s/%llu", + bank_hostname, + (unsigned long long) *credit_account_no); } /* This block _completes_ the information of the current item, @@ -678,7 +678,7 @@ build_history (struct TALER_TESTING_Interpreter *is, (pos, 0, &subject)); GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_url - (pos, 0, &exchange_url)); + (pos, 0, &exchange_url)); h[total].details.amount = *amount; @@ -821,12 +821,12 @@ history_cb (void *cls, total = build_history (is, &h); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Expected history of length %llu, got %llu;" - " HTTP status code: %u, failed: %d\n", - (unsigned long long) total, - (unsigned long long) hs->results_obtained, - http_status, - hs->failed); + "Expected history of length %llu, got %llu;" + " HTTP status code: %u, failed: %d\n", + (unsigned long long) total, + (unsigned long long) hs->results_obtained, + http_status, + hs->failed); print_expected (h, total, UINT_MAX); free_history (h, total); TALER_TESTING_interpreter_fail (is); @@ -835,14 +835,14 @@ history_cb (void *cls, TALER_TESTING_interpreter_next (is); return; } - + if (MHD_HTTP_OK != http_status) { hs->hh = NULL; GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Unwanted response code from /history[-range]: %u\n", - http_status); + "Unwanted response code from /history[-range]: %u\n", + http_status); TALER_TESTING_interpreter_fail (is); return; } @@ -898,7 +898,7 @@ history_run (void *cls, const struct TALER_TESTING_Command *history_cmd; history_cmd = TALER_TESTING_interpreter_lookup_command - (is, hs->start_row_reference); + (is, hs->start_row_reference); if (NULL == history_cmd) TALER_TESTING_FAIL (is); @@ -940,7 +940,7 @@ history_range_run (void *cls, const struct TALER_TESTING_Command *cmd, struct TALER_TESTING_Interpreter *is) { - + struct HistoryState *hs = cls; const struct GNUNET_TIME_Absolute *start_date; const struct GNUNET_TIME_Absolute *end_date; @@ -948,17 +948,17 @@ history_range_run (void *cls, if (NULL != hs->start_row_reference) { - + const struct TALER_TESTING_Command *history_cmd; history_cmd = TALER_TESTING_interpreter_lookup_command - (is, hs->start_row_reference); + (is, hs->start_row_reference); if (NULL == history_cmd) TALER_TESTING_FAIL (is); if (GNUNET_OK != TALER_TESTING_get_trait_absolute_time - (history_cmd, 0, &start_date)) + (history_cmd, 0, &start_date)) TALER_TESTING_FAIL (is); hs->start_date = *start_date; } @@ -976,13 +976,13 @@ history_range_run (void *cls, const struct TALER_TESTING_Command *history_cmd; history_cmd = TALER_TESTING_interpreter_lookup_command - (is, hs->end_row_reference); + (is, hs->end_row_reference); if (NULL == history_cmd) TALER_TESTING_FAIL (is); if (GNUNET_OK != TALER_TESTING_get_trait_absolute_time - (history_cmd, 0, &end_date)) + (history_cmd, 0, &end_date)) TALER_TESTING_FAIL (is); hs->end_date = *end_date; } @@ -1019,7 +1019,7 @@ history_range_run (void *cls, static void history_cleanup (void *cls, - const struct TALER_TESTING_Command *cmd) + const struct TALER_TESTING_Command *cmd) { struct HistoryState *hs = cls; @@ -1046,19 +1046,19 @@ history_cleanup * @param start_row_reference reference to a command that can * offer a row identifier, to be used as the starting row * to accept in the result. - * @param num_result how many rows we want in the result. + * @param num_result how many rows we want in the result. * * @return the command. */ struct TALER_TESTING_Command TALER_TESTING_cmd_bank_history (const char *label, - const char *bank_url, - uint64_t account_no, - enum TALER_BANK_Direction direction, - unsigned int ascending, - const char *start_row_reference, - long long num_results) + const char *bank_url, + uint64_t account_no, + enum TALER_BANK_Direction direction, + unsigned int ascending, + const char *start_row_reference, + long long num_results) { struct HistoryState *hs; @@ -1105,12 +1105,12 @@ TALER_TESTING_cmd_bank_history struct TALER_TESTING_Command TALER_TESTING_cmd_bank_history_range (const char *label, - const char *bank_url, - uint64_t account_no, - enum TALER_BANK_Direction direction, - unsigned int ascending, - const char *start_row_reference, - const char *end_row_reference) + const char *bank_url, + uint64_t account_no, + enum TALER_BANK_Direction direction, + unsigned int ascending, + const char *start_row_reference, + const char *end_row_reference) { struct HistoryState *hs; @@ -1155,12 +1155,12 @@ TALER_TESTING_cmd_bank_history_range struct TALER_TESTING_Command TALER_TESTING_cmd_bank_history_range_with_dates (const char *label, - const char *bank_url, - uint64_t account_no, - enum TALER_BANK_Direction direction, - unsigned int ascending, - struct GNUNET_TIME_Absolute start_date, - struct GNUNET_TIME_Absolute end_date) + const char *bank_url, + uint64_t account_no, + enum TALER_BANK_Direction direction, + unsigned int ascending, + struct GNUNET_TIME_Absolute start_date, + struct GNUNET_TIME_Absolute end_date) { struct HistoryState *hs; diff --git a/src/bank-lib/testing_api_cmd_reject.c b/src/bank-lib/testing_api_cmd_reject.c index 46d67ff2..1f19a379 100644 --- a/src/bank-lib/testing_api_cmd_reject.c +++ b/src/bank-lib/testing_api_cmd_reject.c @@ -97,7 +97,7 @@ reject_cb (void *cls, static void reject_cleanup (void *cls, - const struct TALER_TESTING_Command *cmd) + const struct TALER_TESTING_Command *cmd) { struct RejectState *rs = cls; @@ -119,8 +119,8 @@ reject_cleanup */ static void reject_run (void *cls, - const struct TALER_TESTING_Command *cmd, - struct TALER_TESTING_Interpreter *is) + const struct TALER_TESTING_Command *cmd, + struct TALER_TESTING_Interpreter *is) { struct RejectState *rs = cls; const struct TALER_TESTING_Command *deposit_cmd; @@ -129,7 +129,7 @@ reject_run (void *cls, extern struct TALER_BANK_AuthenticationData AUTHS[]; deposit_cmd = TALER_TESTING_interpreter_lookup_command - (is, rs->deposit_reference); + (is, rs->deposit_reference); if (NULL == deposit_cmd) TALER_TESTING_FAIL (is); @@ -145,7 +145,7 @@ reject_run (void *cls, (unsigned long long) *credit_account); rs->rh = TALER_BANK_reject (is->ctx, rs->bank_url, - &AUTHS[*credit_account -1], + &AUTHS[*credit_account - 1], *credit_account, *row_id, &reject_cb, diff --git a/src/bank-lib/testing_api_helpers.c b/src/bank-lib/testing_api_helpers.c index f61f6664..db813df2 100644 --- a/src/bank-lib/testing_api_helpers.c +++ b/src/bank-lib/testing_api_helpers.c @@ -44,7 +44,7 @@ struct TALER_BANK_AuthenticationData AUTHS[] = { /* User credentials */ {.method = TALER_BANK_AUTH_BASIC, .details.basic.username = USER_USERNAME, - .details.basic.password = USER_PASSWORD } + .details.basic.password = USER_PASSWORD } }; /** @@ -115,14 +115,14 @@ TALER_TESTING_run_bank (const char *config_filename, serve_arg = "serve-uwsgi"; bank_proc = GNUNET_OS_start_process - (GNUNET_NO, - GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-bank-manage", - "taler-bank-manage", - "-c", config_filename, - "--with-db", database, - serve_arg, NULL); + (GNUNET_NO, + GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + "taler-bank-manage", + "taler-bank-manage", + "-c", config_filename, + "--with-db", database, + serve_arg, NULL); if (NULL == bank_proc) BANK_FAIL (); @@ -136,22 +136,22 @@ TALER_TESTING_run_bank (const char *config_filename, "Waiting for `taler-bank-manage' to be ready"); iter = 0; do + { + if (10 == iter) { - if (10 == iter) - { - fprintf ( - stderr, - "Failed to launch `taler-bank-manage' (or `wget')\n"); - GNUNET_OS_process_kill (bank_proc, - SIGTERM); - GNUNET_OS_process_wait (bank_proc); - GNUNET_OS_process_destroy (bank_proc); - BANK_FAIL (); - } - fprintf (stderr, "."); - sleep (1); - iter++; + fprintf ( + stderr, + "Failed to launch `taler-bank-manage' (or `wget')\n"); + GNUNET_OS_process_kill (bank_proc, + SIGTERM); + GNUNET_OS_process_wait (bank_proc); + GNUNET_OS_process_destroy (bank_proc); + BANK_FAIL (); } + fprintf (stderr, "."); + sleep (1); + iter++; + } while (0 != system (wget_cmd)); fprintf (stderr, "\n"); @@ -183,11 +183,11 @@ TALER_TESTING_prepare_bank (const char *config_filename) cfg = GNUNET_CONFIGURATION_create (); if (GNUNET_OK != GNUNET_CONFIGURATION_load - (cfg, config_filename)) + (cfg, config_filename)) BANK_FAIL (); if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string - (cfg, "bank", "DATABASE", &database)) + (cfg, "bank", "DATABASE", &database)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "bank", @@ -197,7 +197,7 @@ TALER_TESTING_prepare_bank (const char *config_filename) } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number - (cfg, "bank", "HTTP_PORT", &port)) + (cfg, "bank", "HTTP_PORT", &port)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "bank", @@ -208,27 +208,27 @@ TALER_TESTING_prepare_bank (const char *config_filename) GNUNET_CONFIGURATION_destroy (cfg); if (GNUNET_OK != GNUNET_NETWORK_test_port_free - (IPPROTO_TCP, (uint16_t) port)) + (IPPROTO_TCP, (uint16_t) port)) { fprintf (stderr, "Required port %llu not available, skipping.\n", - port); + port); BANK_FAIL (); } /* DB preparation */ if (NULL == - (dbreset_proc = GNUNET_OS_start_process ( - GNUNET_NO, - GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-bank-manage", - "taler-bank-manage", - "-c", "bank.conf", - "--with-db", database, - "django", - "flush", - "--no-input", NULL))) + (dbreset_proc = GNUNET_OS_start_process ( + GNUNET_NO, + GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + "taler-bank-manage", + "taler-bank-manage", + "-c", "bank.conf", + "--with-db", database, + "django", + "flush", + "--no-input", NULL))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to flush the bank db.\n"); diff --git a/src/benchmark/taler-exchange-benchmark.c b/src/benchmark/taler-exchange-benchmark.c index 094f23c7..d106eb55 100644 --- a/src/benchmark/taler-exchange-benchmark.c +++ b/src/benchmark/taler-exchange-benchmark.c @@ -41,7 +41,8 @@ #include "taler_error_codes.h" /* Error codes. */ -enum BenchmarkError { +enum BenchmarkError +{ MISSING_BANK_URL, FAILED_TO_LAUNCH_BANK, BAD_CLI_ARG, @@ -67,20 +68,23 @@ enum BenchmarkError { #define FIRST_INSTRUCTION -1 #define CMD_TRANSFER_TO_EXCHANGE(label, amount) \ - TALER_TESTING_cmd_fakebank_transfer_retry \ + TALER_TESTING_cmd_fakebank_transfer_retry \ (TALER_TESTING_cmd_fakebank_transfer (label, amount, \ - exchange_bank_account.details.x_taler_bank.bank_base_url, \ - USER_ACCOUNT_NUMBER, \ - exchange_bank_account.details.x_taler_bank.no, \ - "dummy_user", \ - "dummy_password", \ - "http://example.com/")) + exchange_bank_account.details. \ + x_taler_bank.bank_base_url, \ + USER_ACCOUNT_NUMBER, \ + exchange_bank_account.details. \ + x_taler_bank.no, \ + "dummy_user", \ + "dummy_password", \ + "http://example.com/")) /** * What mode should the benchmark run in? */ -enum BenchmarkMode { +enum BenchmarkMode +{ /** * Run as client (with fakebank), also starts a remote exchange. */ @@ -222,7 +226,7 @@ eval_probability (float probability) float random_01; random = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, - UINT64_MAX); + UINT64_MAX); random_01 = (double) random / UINT64_MAX; return (random_01 <= probability) ? GNUNET_OK : GNUNET_NO; } @@ -239,9 +243,9 @@ run (void *cls, struct TALER_Amount withdraw_fee; char *withdraw_fee_str; struct TALER_TESTING_Command all_commands - [howmany_reserves * (1 + /* Withdraw block */ - howmany_coins) + /* All units */ - 1 /* End CMD */]; + [howmany_reserves * (1 /* Withdraw block */ + + howmany_coins) /* All units */ + + 1 /* End CMD */]; char *AMOUNT_5; char *AMOUNT_4; char *AMOUNT_1; @@ -250,7 +254,8 @@ run (void *cls, GNUNET_asprintf (&AMOUNT_4, "%s:4", currency); GNUNET_asprintf (&AMOUNT_1, "%s:1", currency); - GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (currency, &total_reserve_amount)); + GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (currency, + &total_reserve_amount)); total_reserve_amount.value = 5 * howmany_coins; GNUNET_asprintf (&withdraw_fee_str, @@ -274,8 +279,8 @@ run (void *cls, { struct TALER_TESTING_Command make_reserve[] = { CMD_TRANSFER_TO_EXCHANGE - (create_reserve_label, - TALER_amount_to_string (&total_reserve_amount)), + (create_reserve_label, + TALER_amount_to_string (&total_reserve_amount)), TALER_TESTING_cmd_end () }; char *batch_label; @@ -303,24 +308,24 @@ run (void *cls, i + (howmany_coins * j)); unit[0] = TALER_TESTING_cmd_withdraw_with_retry - (TALER_TESTING_cmd_withdraw_amount - (withdraw_label, - create_reserve_label, - AMOUNT_5, - MHD_HTTP_OK)); + (TALER_TESTING_cmd_withdraw_amount + (withdraw_label, + create_reserve_label, + AMOUNT_5, + MHD_HTTP_OK)); unit[1] = TALER_TESTING_cmd_deposit_with_retry - (TALER_TESTING_cmd_deposit - ("deposit", - withdraw_label, - 0, /* Index of the one withdrawn coin in the traits. */ - TALER_TESTING_make_wire_details - (USER_ACCOUNT_NUMBER, - exchange_bank_account.details.x_taler_bank.hostname), - order_enc, - GNUNET_TIME_UNIT_ZERO, - AMOUNT_1, - MHD_HTTP_OK)); + (TALER_TESTING_cmd_deposit + ("deposit", + withdraw_label, + 0, /* Index of the one withdrawn coin in the traits. */ + TALER_TESTING_make_wire_details + (USER_ACCOUNT_NUMBER, + exchange_bank_account.details.x_taler_bank.hostname), + order_enc, + GNUNET_TIME_UNIT_ZERO, + AMOUNT_1, + MHD_HTTP_OK)); if (eval_probability (refresh_rate / 100.0)) { @@ -337,23 +342,23 @@ run (void *cls, j); unit[2] = TALER_TESTING_cmd_refresh_melt_with_retry - (TALER_TESTING_cmd_refresh_melt - (melt_label, - withdraw_label, - MHD_HTTP_OK, - NULL)); + (TALER_TESTING_cmd_refresh_melt + (melt_label, + withdraw_label, + MHD_HTTP_OK, + NULL)); unit[3] = TALER_TESTING_cmd_refresh_reveal_with_retry - (TALER_TESTING_cmd_refresh_reveal - (reveal_label, - melt_label, - MHD_HTTP_OK)); + (TALER_TESTING_cmd_refresh_reveal + (reveal_label, + melt_label, + MHD_HTTP_OK)); unit[4] = TALER_TESTING_cmd_refresh_link_with_retry - (TALER_TESTING_cmd_refresh_link - ("refresh-link", - reveal_label, - MHD_HTTP_OK)); + (TALER_TESTING_cmd_refresh_link + ("refresh-link", + reveal_label, + MHD_HTTP_OK)); unit[5] = TALER_TESTING_cmd_end (); } else @@ -402,7 +407,7 @@ launch_fakebank (void *cls) const char *bank_base_url = cls; const char *port; long pnum; - struct TALER_FAKEBANK_Handle * fakebank; + struct TALER_FAKEBANK_Handle *fakebank; port = strrchr (bank_base_url, (unsigned char) ':'); @@ -460,7 +465,8 @@ parallel_benchmark (TALER_TESTING_Main main_cb, NULL == loglev ? "INFO" : loglev, logfile); GNUNET_SCHEDULER_run (&launch_fakebank, - exchange_bank_account.details.x_taler_bank.bank_base_url); + exchange_bank_account.details.x_taler_bank. + bank_base_url); exit (0); } if (-1 == fakebank) @@ -534,9 +540,9 @@ parallel_benchmark (TALER_TESTING_Main main_cb, remote_cmd); GNUNET_assert (NULL != (exchange_slave_pipe = - GNUNET_DISK_pipe (GNUNET_YES, - GNUNET_YES, - 0, 0))); + GNUNET_DISK_pipe (GNUNET_YES, + GNUNET_YES, + 0, 0))); exchange_slave = GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, @@ -586,7 +592,7 @@ parallel_benchmark (TALER_TESTING_Main main_cb, start_time = GNUNET_TIME_absolute_get (); result = GNUNET_OK; - for (unsigned int i=0;i<howmany_clients;i++) + for (unsigned int i = 0; i<howmany_clients; i++) { if (0 == (cpids[i] = fork ())) { @@ -596,11 +602,11 @@ parallel_benchmark (TALER_TESTING_Main main_cb, logfile); result = TALER_TESTING_setup - (run, - NULL, - cfg_filename, - exchanged, - GNUNET_YES); + (run, + NULL, + cfg_filename, + exchanged, + GNUNET_YES); if (GNUNET_OK != result) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failure in child process test suite!\n"); @@ -620,7 +626,7 @@ parallel_benchmark (TALER_TESTING_Main main_cb, /* fork() success, continue starting more processes! */ } /* collect all children */ - for (unsigned int i=0;i<howmany_clients;i++) + for (unsigned int i = 0; i<howmany_clients; i++) { waitpid (cpids[i], &wstatus, @@ -638,9 +644,10 @@ parallel_benchmark (TALER_TESTING_Main main_cb, if (MODE_EXCHANGE == mode) (void) getchar (); - if ( (GNUNET_YES == linger) && ( (mode == MODE_BOTH || mode == MODE_CLIENT ) ) ) + if ( (GNUNET_YES == linger) && ( ((mode == MODE_BOTH)|| (mode == + MODE_CLIENT) ) ) ) { - printf("press ENTER to stop\n"); + printf ("press ENTER to stop\n"); (void) getchar (); } @@ -654,7 +661,7 @@ parallel_benchmark (TALER_TESTING_Main main_cb, * We can't send a signal here, as it would just kill SSH and * not necessarily the process on the other machine. */ GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle - (exchange_slave_pipe, GNUNET_DISK_PIPE_END_WRITE), + (exchange_slave_pipe, GNUNET_DISK_PIPE_END_WRITE), &c, sizeof (c)); GNUNET_break (GNUNET_OK == @@ -720,7 +727,7 @@ main (int argc, struct GNUNET_CONFIGURATION_Handle *cfg; struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_option_mandatory - (GNUNET_GETOPT_option_cfgfile (&cfg_filename)), + (GNUNET_GETOPT_option_cfgfile (&cfg_filename)), GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION), GNUNET_GETOPT_option_help ("Exchange benchmark"), GNUNET_GETOPT_option_loglevel (&loglev), @@ -788,7 +795,8 @@ main (int argc, return BAD_CONFIG_FILE; } if (NULL == cfg_filename) - cfg_filename = GNUNET_strdup (GNUNET_OS_project_data_get ()->user_config_file); + cfg_filename = GNUNET_strdup ( + GNUNET_OS_project_data_get ()->user_config_file); cfg = GNUNET_CONFIGURATION_create (); if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, @@ -822,21 +830,22 @@ main (int argc, GNUNET_CONFIGURATION_iterate_sections (cfg, - &pick_exchange_account_cb, - &bank_details_section); + &pick_exchange_account_cb, + &bank_details_section); if (NULL == bank_details_section) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Missing specification of bank account in configuration\n")); + _ ( + "Missing specification of bank account in configuration\n")); return BAD_CONFIG_FILE; } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string - (cfg, - bank_details_section, - "url", - &exchange_payto_url)) + (cfg, + bank_details_section, + "url", + &exchange_payto_url)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, bank_details_section, @@ -846,10 +855,10 @@ main (int argc, if (TALER_EC_NONE != TALER_WIRE_payto_to_account (exchange_payto_url, - &exchange_bank_account)) + &exchange_bank_account)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Malformed payto:// URL `%s' in configuration\n"), + _ ("Malformed payto:// URL `%s' in configuration\n"), exchange_payto_url); GNUNET_free (exchange_payto_url); return BAD_CONFIG_FILE; @@ -857,7 +866,8 @@ main (int argc, if (TALER_PAC_X_TALER_BANK != exchange_bank_account.type) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Malformed payto:// URL `%s' in configuration: x-taler-bank required\n"), + _ ( + "Malformed payto:// URL `%s' in configuration: x-taler-bank required\n"), exchange_payto_url); GNUNET_free (exchange_payto_url); return BAD_CONFIG_FILE; @@ -869,13 +879,13 @@ main (int argc, struct GNUNET_OS_Process *compute_wire_response; compute_wire_response = GNUNET_OS_start_process - (GNUNET_NO, - GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-exchange-wire", - "taler-exchange-wire", - "-c", cfg_filename, - NULL); + (GNUNET_NO, + GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + "taler-exchange-wire", + "taler-exchange-wire", + "-c", cfg_filename, + NULL); if (NULL == compute_wire_response) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -889,8 +899,8 @@ main (int argc, GNUNET_assert (GNUNET_OK == TALER_TESTING_prepare_exchange (cfg_filename, - &auditor_url, - &exchange_url)); + &auditor_url, + &exchange_url)); } else { @@ -952,7 +962,7 @@ main (int argc, if (GNUNET_OK == result) { struct rusage usage; - GNUNET_assert (0 == getrusage(RUSAGE_CHILDREN, &usage)); + GNUNET_assert (0 == getrusage (RUSAGE_CHILDREN, &usage)); fprintf (stdout, "Executed (Withdraw=%u, Deposit=%u, Refresh~=%5.2f) * Reserve=%u * Parallel=%u, operations in %s\n", howmany_coins, @@ -961,16 +971,16 @@ main (int argc, howmany_reserves, howmany_clients, GNUNET_STRINGS_relative_time_to_string - (duration, - GNUNET_NO)); + (duration, + GNUNET_NO)); fprintf (stdout, "(approximately %s/coin)\n", GNUNET_STRINGS_relative_time_to_string - (GNUNET_TIME_relative_divide (duration, - (unsigned long long) howmany_coins * - howmany_reserves * - howmany_clients), - GNUNET_YES)); + (GNUNET_TIME_relative_divide (duration, + (unsigned long long) howmany_coins + * howmany_reserves + * howmany_clients), + GNUNET_YES)); fprintf (stdout, "RAW: %04u %04u %04u %16llu\n", howmany_coins, @@ -978,8 +988,10 @@ main (int argc, howmany_clients, (unsigned long long) duration.rel_value_us); fprintf (stdout, "cpu time: sys %llu user %llu\n", \ - (unsigned long long) (usage.ru_stime.tv_sec * 1000 * 1000 + usage.ru_stime.tv_usec), - (unsigned long long) (usage.ru_utime.tv_sec * 1000 * 1000 + usage.ru_utime.tv_usec)); + (unsigned long long) (usage.ru_stime.tv_sec * 1000 * 1000 + + usage.ru_stime.tv_usec), + (unsigned long long) (usage.ru_utime.tv_sec * 1000 * 1000 + + usage.ru_utime.tv_usec)); } return (GNUNET_OK == result) ? 0 : result; } diff --git a/src/exchange-tools/taler-exchange-dbinit.c b/src/exchange-tools/taler-exchange-dbinit.c index 77aef1ee..afc1b837 100644 --- a/src/exchange-tools/taler-exchange-dbinit.c +++ b/src/exchange-tools/taler-exchange-dbinit.c @@ -74,11 +74,11 @@ run (void *cls, return; } if (gc_db) - { - if (GNUNET_SYSERR == plugin->gc (plugin->cls)) - fprintf (stderr, - "Garbage collection failed!\n"); - } + { + if (GNUNET_SYSERR == plugin->gc (plugin->cls)) + fprintf (stderr, + "Garbage collection failed!\n"); + } TALER_EXCHANGEDB_plugin_unload (plugin); } @@ -97,13 +97,13 @@ main (int argc, { const struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_option_flag ('r', - "reset", - "reset database (DANGEROUS: all existing data is lost!)", - &reset_db), + "reset", + "reset database (DANGEROUS: all existing data is lost!)", + &reset_db), GNUNET_GETOPT_option_flag ('g', - "gc", - "garbage collect database", - &gc_db), + "gc", + "garbage collect database", + &gc_db), GNUNET_GETOPT_OPTION_END }; @@ -118,9 +118,9 @@ main (int argc, if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "taler-exchange-dbinit", - "Initialize Taler exchange database", - options, - &run, NULL)) + "Initialize Taler exchange database", + options, + &run, NULL)) return 1; return global_ret; } diff --git a/src/exchange-tools/taler-exchange-keycheck.c b/src/exchange-tools/taler-exchange-keycheck.c index c657454a..ac452a05 100644 --- a/src/exchange-tools/taler-exchange-keycheck.c +++ b/src/exchange-tools/taler-exchange-keycheck.c @@ -61,7 +61,7 @@ signkeys_iter (void *cls, "Iterating over key `%s' for start time %s\n", filename, GNUNET_STRINGS_absolute_time_to_string - (GNUNET_TIME_absolute_ntoh (ski->issue.start))); + (GNUNET_TIME_absolute_ntoh (ski->issue.start))); if (ntohl (ski->issue.purpose.size) != (sizeof (struct TALER_ExchangeSigningKeyValidityPS))) @@ -71,9 +71,12 @@ signkeys_iter (void *cls, filename); return GNUNET_SYSERR; } - if ( (0 != GNUNET_TIME_absolute_ntoh (ski->issue.start).abs_value_us % 1000000) || - (0 != GNUNET_TIME_absolute_ntoh (ski->issue.expire).abs_value_us % 1000000) || - (0 != GNUNET_TIME_absolute_ntoh (ski->issue.end).abs_value_us % 1000000) ) + if ( (0 != GNUNET_TIME_absolute_ntoh (ski->issue.start).abs_value_us + % 1000000) || + (0 != GNUNET_TIME_absolute_ntoh (ski->issue.expire).abs_value_us + % 1000000) || + (0 != GNUNET_TIME_absolute_ntoh (ski->issue.end).abs_value_us + % 1000000) ) { fprintf (stderr, "Timestamps are not multiples of a round second\n"); @@ -127,7 +130,8 @@ exchange_signkeys_check () static int denomkeys_iter (void *cls, const char *alias, - const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) + const struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) { struct GNUNET_HashCode hc; @@ -140,10 +144,14 @@ denomkeys_iter (void *cls, return GNUNET_SYSERR; } - if ( (0 != GNUNET_TIME_absolute_ntoh (dki->issue.properties.start).abs_value_us % 1000000) || - (0 != GNUNET_TIME_absolute_ntoh (dki->issue.properties.expire_withdraw).abs_value_us % 1000000) || - (0 != GNUNET_TIME_absolute_ntoh (dki->issue.properties.expire_legal).abs_value_us % 1000000) || - (0 != GNUNET_TIME_absolute_ntoh (dki->issue.properties.expire_deposit).abs_value_us % 1000000) ) + if ( (0 != GNUNET_TIME_absolute_ntoh ( + dki->issue.properties.start).abs_value_us % 1000000) || + (0 != GNUNET_TIME_absolute_ntoh ( + dki->issue.properties.expire_withdraw).abs_value_us % 1000000) || + (0 != GNUNET_TIME_absolute_ntoh ( + dki->issue.properties.expire_legal).abs_value_us % 1000000) || + (0 != GNUNET_TIME_absolute_ntoh ( + dki->issue.properties.expire_deposit).abs_value_us % 1000000) ) { fprintf (stderr, "Timestamps are not multiples of a round second\n"); @@ -151,10 +159,11 @@ denomkeys_iter (void *cls, } if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY, - &dki->issue.properties.purpose, - &dki->issue.signature.eddsa_signature, - &dki->issue.properties.master.eddsa_pub)) + GNUNET_CRYPTO_eddsa_verify ( + TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY, + &dki->issue.properties.purpose, + &dki->issue.signature.eddsa_signature, + &dki->issue.properties.master.eddsa_pub)) { fprintf (stderr, "Denomination key for `%s' has invalid signature\n", @@ -194,7 +203,8 @@ exchange_denomkeys_check () "exchange", "master_public_key", &master_public_key_from_cfg, - sizeof (struct GNUNET_CRYPTO_EddsaPublicKey))) + sizeof (struct + GNUNET_CRYPTO_EddsaPublicKey))) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "exchange", @@ -268,9 +278,9 @@ main (int argc, char *const *argv) if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "taler-exchange-keycheck", - "Check keys of the exchange for validity", - options, - &run, NULL)) + "Check keys of the exchange for validity", + options, + &run, NULL)) return 1; return global_ret; diff --git a/src/exchange-tools/taler-exchange-keyup.c b/src/exchange-tools/taler-exchange-keyup.c index 4c8682e5..8486f02c 100644 --- a/src/exchange-tools/taler-exchange-keyup.c +++ b/src/exchange-tools/taler-exchange-keyup.c @@ -297,7 +297,8 @@ get_cointype_dir (const struct CoinTypeParams *p) hash_coin_type (p, &hash); hash_str = GNUNET_STRINGS_data_to_string_alloc (&hash, - sizeof (struct GNUNET_HashCode)); + sizeof (struct + GNUNET_HashCode)); GNUNET_assert (NULL != hash_str); GNUNET_assert (HASH_CUTOFF <= strlen (hash_str) + 1); hash_str[HASH_CUTOFF] = 0; @@ -311,7 +312,8 @@ get_cointype_dir (const struct CoinTypeParams *p) GNUNET_snprintf (dir, sizeof (dir), - "%s" DIR_SEPARATOR_STR TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS DIR_SEPARATOR_STR "%s-%s", + "%s" DIR_SEPARATOR_STR TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS + DIR_SEPARATOR_STR "%s-%s", exchange_directory, val_str, hash_str); @@ -462,7 +464,8 @@ static void create_signkey_issue_priv (struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration, struct GNUNET_TIME_Absolute end, - struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP *pi) + struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP + *pi) { struct GNUNET_CRYPTO_EddsaPrivateKey *priv; struct TALER_ExchangeSigningKeyValidityPS *issue = &pi->issue; @@ -478,7 +481,8 @@ create_signkey_issue_priv (struct GNUNET_TIME_Absolute start, GNUNET_CRYPTO_eddsa_key_get_public (&pi->signkey_priv.eddsa_priv, &issue->signkey_pub.eddsa_pub); issue->purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY); - issue->purpose.size = htonl (sizeof (struct TALER_ExchangeSigningKeyValidityPS)); + issue->purpose.size = htonl (sizeof (struct + TALER_ExchangeSigningKeyValidityPS)); GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_sign (&master_priv.eddsa_priv, &issue->purpose, @@ -753,20 +757,23 @@ get_cointype_params (const char *ct, */ static void create_denomkey_issue (const struct CoinTypeParams *params, - struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) + struct TALER_EXCHANGEDB_DenominationKeyIssueInformation * + dki) { dki->denom_priv.rsa_private_key = GNUNET_CRYPTO_rsa_private_key_create (params->rsa_keysize); GNUNET_assert (NULL != dki->denom_priv.rsa_private_key); dki->denom_pub.rsa_public_key - = GNUNET_CRYPTO_rsa_private_key_get_public (dki->denom_priv.rsa_private_key); + = GNUNET_CRYPTO_rsa_private_key_get_public ( + dki->denom_priv.rsa_private_key); GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key, &dki->issue.properties.denom_hash); dki->issue.properties.master = master_public_key; dki->issue.properties.start = GNUNET_TIME_absolute_hton (params->anchor); dki->issue.properties.expire_withdraw = - GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (params->anchor, - params->duration_withdraw)); + GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (params->anchor, + params-> + duration_withdraw)); dki->issue.properties.expire_deposit = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (params->anchor, params->duration_spend)); @@ -803,7 +810,7 @@ create_denomkey_issue (const struct CoinTypeParams *params, */ static void exchange_keys_update_cointype (void *cls, - const char *coin_alias) + const char *coin_alias) { int *ret = cls; struct CoinTypeParams p; @@ -837,7 +844,7 @@ exchange_keys_update_cointype (void *cls, GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_difference (p.anchor, lookahead_sign_stamp), - GNUNET_NO)); + GNUNET_NO)); dkf = get_cointype_file (&p, p.anchor); GNUNET_break (GNUNET_YES != @@ -853,14 +860,16 @@ exchange_keys_update_cointype (void *cls, &denomkey_issue); if (GNUNET_OK != TALER_EXCHANGEDB_denomination_key_write (dkf, - &denomkey_issue)) + &denomkey_issue)) { fprintf (stderr, "Failed to write denomination key information to file `%s'.\n", dkf); *ret = GNUNET_SYSERR; - GNUNET_CRYPTO_rsa_private_key_free (denomkey_issue.denom_priv.rsa_private_key); - GNUNET_CRYPTO_rsa_public_key_free (denomkey_issue.denom_pub.rsa_public_key); + GNUNET_CRYPTO_rsa_private_key_free ( + denomkey_issue.denom_priv.rsa_private_key); + GNUNET_CRYPTO_rsa_public_key_free ( + denomkey_issue.denom_pub.rsa_public_key); return; } if ( (NULL != auditor_output_file) && @@ -875,11 +884,14 @@ exchange_keys_update_cointype (void *cls, auditorrequestfile, STRERROR (errno)); *ret = GNUNET_SYSERR; - GNUNET_CRYPTO_rsa_private_key_free (denomkey_issue.denom_priv.rsa_private_key); - GNUNET_CRYPTO_rsa_public_key_free (denomkey_issue.denom_pub.rsa_public_key); + GNUNET_CRYPTO_rsa_private_key_free ( + denomkey_issue.denom_priv.rsa_private_key); + GNUNET_CRYPTO_rsa_public_key_free ( + denomkey_issue.denom_pub.rsa_public_key); return; } - GNUNET_CRYPTO_rsa_private_key_free (denomkey_issue.denom_priv.rsa_private_key); + GNUNET_CRYPTO_rsa_private_key_free ( + denomkey_issue.denom_priv.rsa_private_key); GNUNET_CRYPTO_rsa_public_key_free (denomkey_issue.denom_pub.rsa_public_key); p.anchor = GNUNET_TIME_absolute_add (p.anchor, p.duration_withdraw); @@ -1146,7 +1158,7 @@ static int revoke_denomination (const struct GNUNET_HashCode *hc) { char *basedir; - + if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (kcfg, "exchange", @@ -1193,7 +1205,7 @@ run (void *cls, if (now.abs_value_us != now_tmp.abs_value_us) { - /* The user gave "--now", use it */ + /* The user gave "--now", use it */ now = now_tmp; } /* The user _might_ have given "--now" but it matched @@ -1331,7 +1343,8 @@ run (void *cls, "exchange", "master_public_key", &master_public_key_from_cfg, - sizeof (struct GNUNET_CRYPTO_EddsaPublicKey))) + sizeof (struct + GNUNET_CRYPTO_EddsaPublicKey))) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "exchange", @@ -1346,7 +1359,7 @@ run (void *cls, GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, "exchange", "master_public_key", - _("does not match with private key")); + _ ("does not match with private key")); global_ret = 1; return; } @@ -1369,7 +1382,7 @@ run (void *cls, GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, "exchange", "lookahead_sign", - _("must not be zero")); + _ ("must not be zero")); global_ret = 1; return; } @@ -1457,10 +1470,10 @@ main (int argc, now = now_tmp = GNUNET_TIME_absolute_get (); if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, - "taler-exchange-keyup", - "Setup signing and denomination keys for a Taler exchange", - options, - &run, NULL)) + "taler-exchange-keyup", + "Setup signing and denomination keys for a Taler exchange", + options, + &run, NULL)) return 1; if (NULL != auditor_output_file) { diff --git a/src/exchange-tools/taler-exchange-wire.c b/src/exchange-tools/taler-exchange-wire.c index 366b69ec..1a057e4e 100644 --- a/src/exchange-tools/taler-exchange-wire.c +++ b/src/exchange-tools/taler-exchange-wire.c @@ -60,7 +60,7 @@ sign_account_data (void *cls, char *json_out; FILE *out; int ret; - + if (GNUNET_NO == ai->credit_enabled) return; if (NULL == ai->wire_response_filename) @@ -71,12 +71,12 @@ sign_account_data (void *cls, global_ret = 1; return; } - + wire = TALER_JSON_exchange_wire_signature_make (ai->payto_url, &master_priv); GNUNET_assert (NULL != wire); json_out = json_dumps (wire, - JSON_INDENT(2)); + JSON_INDENT (2)); json_decref (wire); GNUNET_assert (NULL != json_out); if (GNUNET_OK != @@ -242,10 +242,10 @@ main (int argc, NULL)); if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, - "taler-exchange-wire", - "Setup /wire response", - options, - &run, NULL)) + "taler-exchange-wire", + "Setup /wire response", + options, + &run, NULL)) return 1; return global_ret; } diff --git a/src/exchange-tools/taler-wire.c b/src/exchange-tools/taler-wire.c index f27caf74..213c1eff 100644 --- a/src/exchange-tools/taler-wire.c +++ b/src/exchange-tools/taler-wire.c @@ -151,7 +151,7 @@ confirmation_cb (void *cls, GNUNET_assert (NULL != emsg); fprintf (stderr, "%s", - emsg); + emsg); GNUNET_SCHEDULER_shutdown (); return; } @@ -179,22 +179,22 @@ prepare_cb (void *cls, struct TALER_WIRE_ExecuteHandle *eh; if (NULL == (eh = plugin_handle->execute_wire_transfer - (plugin_handle->cls, - buf, - buf_size, - confirmation_cb, - NULL))) + (plugin_handle->cls, + buf, + buf_size, + confirmation_cb, + NULL))) { fprintf (stderr, "Could not execute the wire transfer\n"); plugin_handle->prepare_wire_transfer_cancel (plugin_handle->cls, - ph); + ph); plugin_handle->execute_wire_transfer_cancel (plugin_handle->cls, - eh); + eh); GNUNET_SCHEDULER_shutdown (); } @@ -235,14 +235,14 @@ execute_wire_transfer () return; } if (NULL == (ph = plugin_handle->prepare_wire_transfer - (plugin_handle->cls, - account_section, - destination_account_url, - &a, - "http://exchange.example.com/", - &wtid, /* Any value will do. */ - prepare_cb, - NULL))) + (plugin_handle->cls, + account_section, + destination_account_url, + &a, + "http://exchange.example.com/", + &wtid, /* Any value will do. */ + prepare_cb, + NULL))) { fprintf (stderr, "Could not prepare the wire transfer\n"); @@ -269,20 +269,20 @@ execute_history () GNUNET_assert (GNUNET_OK == GNUNET_STRINGS_string_to_data (since_when, - strlen (since_when), - since_when_bin, - bin_len)); + strlen (since_when), + since_when_bin, + bin_len)); } if (NULL == plugin_handle->get_history - (plugin_handle->cls, - account_section, - TALER_BANK_DIRECTION_BOTH, - since_when_bin, - bin_len, - -10, - history_cb, - NULL)) + (plugin_handle->cls, + account_section, + TALER_BANK_DIRECTION_BOTH, + since_when_bin, + bin_len, + -10, + history_cb, + NULL)) { fprintf (stderr, "Could not request the transaction history.\n"); @@ -327,10 +327,10 @@ run (void *cls, } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string - (cfg, - account_section, - "plugin", - &plugin_name)) + (cfg, + account_section, + "plugin", + &plugin_name)) { fprintf (stderr, "Could not find the 'plugin' value under %s\n", @@ -353,7 +353,7 @@ run (void *cls, execute_wire_transfer (); else fprintf (stderr, - "Please give either --history/-H or --transfer/t\n"); + "Please give either --history/-H or --transfer/t\n"); GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); @@ -422,13 +422,13 @@ main (int argc, "WARNING", NULL)); /* filename */ ret = GNUNET_PROGRAM_run - (argc, - argv, - "taler-wire", - "CLI bank client.", - options, - &run, - NULL); + (argc, + argv, + "taler-wire", + "CLI bank client.", + options, + &run, + NULL); if (GNUNET_OK != ret) return ret; return global_ret; diff --git a/src/exchange/taler-exchange-aggregator.c b/src/exchange/taler-exchange-aggregator.c index 9b1c7e3e..b84c837e 100644 --- a/src/exchange/taler-exchange-aggregator.c +++ b/src/exchange/taler-exchange-aggregator.c @@ -287,7 +287,8 @@ static int reserves_idle; * Note: do not change here, Postgres requires us to hard-code the * LIMIT in the prepared statement. */ -static unsigned int aggregation_limit = TALER_EXCHANGEDB_MATCHING_DEPOSITS_LIMIT; +static unsigned int aggregation_limit = + TALER_EXCHANGEDB_MATCHING_DEPOSITS_LIMIT; @@ -347,13 +348,13 @@ update_fees (struct WireAccount *wa, p = p->next) { qs = db_plugin->insert_wire_fee (db_plugin->cls, - session, - wa->wire_plugin->method, - p->start_date, - p->end_date, - &p->wire_fee, - &p->closing_fee, - &p->master_sig); + session, + wa->wire_plugin->method, + p->start_date, + p->end_date, + &p->wire_fee, + &p->closing_fee, + &p->master_sig); if (qs < 0) { TALER_EXCHANGEDB_fees_free (wa->af); @@ -486,8 +487,9 @@ shutdown_task (void *cls) { if (NULL != wpd->eh) { - wpd->wa->wire_plugin->execute_wire_transfer_cancel (wpd->wa->wire_plugin->cls, - wpd->eh); + wpd->wa->wire_plugin->execute_wire_transfer_cancel ( + wpd->wa->wire_plugin->cls, + wpd->eh); wpd->eh = NULL; } db_plugin->rollback (db_plugin->cls, @@ -499,8 +501,9 @@ shutdown_task (void *cls) { if (NULL != au->ph) { - au->wa->wire_plugin->prepare_wire_transfer_cancel (au->wa->wire_plugin->cls, - au->ph); + au->wa->wire_plugin->prepare_wire_transfer_cancel ( + au->wa->wire_plugin->cls, + au->ph); au->ph = NULL; } db_plugin->rollback (db_plugin->cls, @@ -509,8 +512,9 @@ shutdown_task (void *cls) } if (NULL != ctc) { - ctc->wa->wire_plugin->prepare_wire_transfer_cancel (ctc->wa->wire_plugin->cls, - ctc->ph); + ctc->wa->wire_plugin->prepare_wire_transfer_cancel ( + ctc->wa->wire_plugin->cls, + ctc->ph); ctc->ph = NULL; db_plugin->rollback (db_plugin->cls, ctc->session); @@ -613,12 +617,12 @@ exchange_serve_process_config () */ static int refund_by_coin_cb (void *cls, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_MerchantSignatureP *merchant_sig, - const struct GNUNET_HashCode *h_contract, - uint64_t rtransaction_id, - const struct TALER_Amount *amount_with_fee, - const struct TALER_Amount *refund_fee) + const struct TALER_MerchantPublicKeyP *merchant_pub, + const struct TALER_MerchantSignatureP *merchant_sig, + const struct GNUNET_HashCode *h_contract, + uint64_t rtransaction_id, + const struct TALER_Amount *amount_with_fee, + const struct TALER_Amount *refund_fee) { struct AggregationUnit *aux = cls; @@ -632,8 +636,8 @@ refund_by_coin_cb (void *cls, return GNUNET_OK; /* different contract */ if (GNUNET_OK != TALER_amount_subtract (&aux->total_amount, - &aux->total_amount, - amount_with_fee)) + &aux->total_amount, + amount_with_fee)) { GNUNET_break (0); return GNUNET_SYSERR; @@ -680,17 +684,17 @@ deposit_cb (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fatally malformed record at row %llu over %s\n", (unsigned long long) row_id, - TALER_amount2s (amount_with_fee)); + TALER_amount2s (amount_with_fee)); return GNUNET_DB_STATUS_HARD_ERROR; } au->row_id = row_id; au->h_contract = h_contract_terms; qs = db_plugin->select_refunds_by_coin (db_plugin->cls, - au->session, - coin_pub, - &refund_by_coin_cb, - au); + au->session, + coin_pub, + &refund_by_coin_cb, + au); au->h_contract = NULL; if (0 > qs) { @@ -738,8 +742,8 @@ deposit_cb (void *cls, au->execution_time = GNUNET_TIME_absolute_get (); (void) GNUNET_TIME_round_abs (&au->execution_time); qs = update_fees (au->wa, - au->execution_time, - au->session); + au->execution_time, + au->session); if (qs <= 0) { if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) @@ -750,17 +754,17 @@ deposit_cb (void *cls, au->wire_fee = au->wa->af->wire_fee; qs = db_plugin->insert_aggregation_tracking (db_plugin->cls, - au->session, - &au->wtid, - row_id); + au->session, + &au->wtid, + row_id); if (qs <= 0) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } qs = db_plugin->mark_deposit_done (db_plugin->cls, - au->session, - row_id); + au->session, + row_id); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); @@ -811,13 +815,13 @@ aggregate_cb (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Fatally malformed record at %llu over amount %s\n", (unsigned long long) row_id, - TALER_amount2s (amount_with_fee)); + TALER_amount2s (amount_with_fee)); return GNUNET_DB_STATUS_HARD_ERROR; } /* add to total */ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Adding transaction amount %s to aggregation\n", - TALER_amount2s (&delta)); + "Adding transaction amount %s to aggregation\n", + TALER_amount2s (&delta)); if (GNUNET_OK != TALER_amount_add (&au->total_amount, &au->total_amount, @@ -832,10 +836,10 @@ aggregate_cb (void *cls, au->h_contract = h_contract_terms; qs = db_plugin->select_refunds_by_coin (db_plugin->cls, - au->session, - coin_pub, - &refund_by_coin_cb, - au); + au->session, + coin_pub, + &refund_by_coin_cb, + au); au->h_contract = NULL; if (0 > qs) { @@ -857,25 +861,25 @@ aggregate_cb (void *cls, au->additional_rows[au->rows_offset++] = row_id; /* insert into aggregation tracking table */ qs = db_plugin->insert_aggregation_tracking (db_plugin->cls, - au->session, - &au->wtid, - row_id); + au->session, + &au->wtid, + row_id); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } qs = db_plugin->mark_deposit_done (db_plugin->cls, - au->session, - row_id); + au->session, + row_id); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); return qs; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Added row %llu with %s to aggregation\n", - (unsigned long long) row_id, + "Added row %llu with %s to aggregation\n", + (unsigned long long) row_id, TALER_amount2s (&delta)); return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; } @@ -958,8 +962,8 @@ commit_or_warn (struct TALER_EXCHANGEDB_Session *session) */ static void prepare_close_cb (void *cls, - const char *buf, - size_t buf_size) + const char *buf, + size_t buf_size) { enum GNUNET_DB_QueryStatus qs; @@ -984,10 +988,10 @@ prepare_close_cb (void *cls, /* Commit our intention to execute the wire transfer! */ qs = db_plugin->wire_prepare_data_insert (db_plugin->cls, - ctc->session, - ctc->method, - buf, - buf_size); + ctc->session, + ctc->method, + buf, + buf_size); if (GNUNET_DB_STATUS_HARD_ERROR == qs) { GNUNET_break (0); @@ -1021,7 +1025,7 @@ prepare_close_cb (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Reserve closure committed, running transfer\n"); task = GNUNET_SCHEDULER_add_now (&run_transfers, - NULL); + NULL); } @@ -1059,10 +1063,10 @@ struct ExpiredReserveContext */ static enum GNUNET_DB_QueryStatus expired_reserve_cb (void *cls, - const struct TALER_ReservePublicKeyP *reserve_pub, - const struct TALER_Amount *left, - const char *account_details, - struct GNUNET_TIME_Absolute expiration_date) + const struct TALER_ReservePublicKeyP *reserve_pub, + const struct TALER_Amount *left, + const char *account_details, + struct GNUNET_TIME_Absolute expiration_date) { struct ExpiredReserveContext *erc = cls; struct TALER_EXCHANGEDB_Session *session = erc->session; @@ -1090,8 +1094,8 @@ expired_reserve_cb (void *cls, /* lookup `closing_fee` */ qs = update_fees (wa, - now, - session); + now, + session); if (qs <= 0) { if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) @@ -1106,8 +1110,8 @@ expired_reserve_cb (void *cls, /* calculate transfer amount */ ret = TALER_amount_subtract (&amount_without_fee, - left, - closing_fee); + left, + closing_fee); if ( (GNUNET_SYSERR == ret) || (GNUNET_NO == ret) ) { @@ -1122,21 +1126,21 @@ expired_reserve_cb (void *cls, /* NOTE: sizeof (*reserve_pub) == sizeof (wtid) right now, but to be future-compatible, we use the memset + min construction */ memset (&wtid, - 0, - sizeof (wtid)); + 0, + sizeof (wtid)); memcpy (&wtid, - reserve_pub, - GNUNET_MIN (sizeof (wtid), - sizeof (*reserve_pub))); + reserve_pub, + GNUNET_MIN (sizeof (wtid), + sizeof (*reserve_pub))); qs = db_plugin->insert_reserve_closed (db_plugin->cls, - session, - reserve_pub, - now, - account_details, - &wtid, - left, - closing_fee); + session, + reserve_pub, + now, + account_details, + &wtid, + left, + closing_fee); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Closing reserve %s over %s (%d, %d)\n", @@ -1149,8 +1153,8 @@ expired_reserve_cb (void *cls, { /* success, perform wire transfer */ if (GNUNET_SYSERR == - wa->wire_plugin->amount_round (wa->wire_plugin->cls, - &amount_without_fee)) + wa->wire_plugin->amount_round (wa->wire_plugin->cls, + &amount_without_fee)) { GNUNET_break (0); global_ret = GNUNET_SYSERR; @@ -1164,12 +1168,12 @@ expired_reserve_cb (void *cls, ctc->ph = wa->wire_plugin->prepare_wire_transfer (wa->wire_plugin->cls, wa->section_name, - account_details, - &amount_without_fee, - exchange_base_url, - &wtid, - &prepare_close_cb, - ctc); + account_details, + &amount_without_fee, + exchange_base_url, + &wtid, + &prepare_close_cb, + ctc); if (NULL == ctc->ph) { GNUNET_break (0); @@ -1233,7 +1237,7 @@ run_reserve_closures (void *cls) session); if (GNUNET_OK != db_plugin->start (db_plugin->cls, - session, + session, "aggregator reserve closures")) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -1247,10 +1251,10 @@ run_reserve_closures (void *cls) now = GNUNET_TIME_absolute_get (); (void) GNUNET_TIME_round_abs (&now); qs = db_plugin->get_expired_reserves (db_plugin->cls, - session, - now, - &expired_reserve_cb, - &erc); + session, + now, + &expired_reserve_cb, + &erc); switch (qs) { case GNUNET_DB_STATUS_HARD_ERROR: @@ -1264,7 +1268,7 @@ run_reserve_closures (void *cls) db_plugin->rollback (db_plugin->cls, session); task = GNUNET_SCHEDULER_add_now (&run_reserve_closures, - NULL); + NULL); return; case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -1273,14 +1277,14 @@ run_reserve_closures (void *cls) db_plugin->rollback (db_plugin->cls, session); task = GNUNET_SCHEDULER_add_now (&run_aggregation, - NULL); + NULL); return; case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: if (GNUNET_YES == erc.async_cont) break; (void) commit_or_warn (session); task = GNUNET_SCHEDULER_add_now (&run_reserve_closures, - NULL); + NULL); return; } } @@ -1307,7 +1311,7 @@ run_aggregation (void *cls) if (0 == (++swap % 2)) { task = GNUNET_SCHEDULER_add_now (&run_reserve_closures, - NULL); + NULL); return; } GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -1333,9 +1337,9 @@ run_aggregation (void *cls) au = GNUNET_new (struct AggregationUnit); au->session = session; qs = db_plugin->get_ready_deposit (db_plugin->cls, - session, - &deposit_cb, - au); + session, + &deposit_cb, + au); if (0 >= qs) { cleanup_au (); @@ -1354,7 +1358,7 @@ run_aggregation (void *cls) /* should re-try immediately */ swap--; /* do not count failed attempts */ task = GNUNET_SCHEDULER_add_now (&run_aggregation, - NULL); + NULL); return; } GNUNET_log (GNUNET_ERROR_TYPE_INFO, @@ -1368,15 +1372,15 @@ run_aggregation (void *cls) else { if ( (GNUNET_NO == reserves_idle) || - (GNUNET_YES == test_mode) ) - /* Possibly more to on reserves, go for it immediately */ - task = GNUNET_SCHEDULER_add_now (&run_reserve_closures, - NULL); + (GNUNET_YES == test_mode) ) + /* Possibly more to on reserves, go for it immediately */ + task = GNUNET_SCHEDULER_add_now (&run_reserve_closures, + NULL); else - /* nothing to do, sleep for a minute and try again */ - task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, - &run_aggregation, - NULL); + /* nothing to do, sleep for a minute and try again */ + task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, + &run_aggregation, + NULL); } return; } @@ -1386,12 +1390,12 @@ run_aggregation (void *cls) "Found ready deposit for %s, aggregating\n", TALER_B2S (&au->merchant_pub)); qs = db_plugin->iterate_matching_deposits (db_plugin->cls, - session, - &au->h_wire, - &au->merchant_pub, - &aggregate_cb, - au, - aggregation_limit); + session, + &au->h_wire, + &au->merchant_pub, + &aggregate_cb, + au, + aggregation_limit); if ( (GNUNET_DB_STATUS_HARD_ERROR == qs) || (GNUNET_YES == au->failed) ) { @@ -1412,7 +1416,7 @@ run_aggregation (void *cls) db_plugin->rollback (db_plugin->cls, session); task = GNUNET_SCHEDULER_add_now (&run_aggregation, - NULL); + NULL); return; } @@ -1431,8 +1435,8 @@ run_aggregation (void *cls) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Aggregate value too low for transfer (%d/%s)\n", - qs, - TALER_amount2s (&au->final_amount)); + qs, + TALER_amount2s (&au->final_amount)); /* Rollback ongoing transaction, as we will not use the respective WTID and thus need to remove the tracking data */ db_plugin->rollback (db_plugin->cls, @@ -1454,35 +1458,35 @@ run_aggregation (void *cls) } /* Mark transactions by row_id as minor */ qs = db_plugin->mark_deposit_tiny (db_plugin->cls, - session, - au->row_id); + session, + au->row_id); if (0 <= qs) { - for (unsigned int i=0;i<au->rows_offset;i++) + for (unsigned int i = 0; i<au->rows_offset; i++) { qs = db_plugin->mark_deposit_tiny (db_plugin->cls, - session, - au->additional_rows[i]); - if (0 > qs) - break; + session, + au->additional_rows[i]); + if (0 > qs) + break; } } if (GNUNET_DB_STATUS_SOFT_ERROR == qs) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Serialization issue, trying again later!\n"); + "Serialization issue, trying again later!\n"); db_plugin->rollback (db_plugin->cls, - session); + session); cleanup_au (); /* start again */ task = GNUNET_SCHEDULER_add_now (&run_aggregation, - NULL); + NULL); return; } if (GNUNET_DB_STATUS_HARD_ERROR == qs) { db_plugin->rollback (db_plugin->cls, - session); + session); cleanup_au (); GNUNET_SCHEDULER_shutdown (); return; @@ -1509,14 +1513,15 @@ run_aggregation (void *cls) char *url; url = TALER_JSON_wire_to_payto (au->wire); - au->ph = au->wa->wire_plugin->prepare_wire_transfer (au->wa->wire_plugin->cls, - au->wa->section_name, - url, - &au->final_amount, - exchange_base_url, - &au->wtid, - &prepare_cb, - au); + au->ph = au->wa->wire_plugin->prepare_wire_transfer ( + au->wa->wire_plugin->cls, + au->wa->section_name, + url, + &au->final_amount, + exchange_base_url, + &au->wtid, + &prepare_cb, + au); GNUNET_free (url); } if (NULL == au->ph) @@ -1563,24 +1568,24 @@ prepare_cb (void *cls, } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Storing %u bytes of wire prepare data\n", - (unsigned int) buf_size); + "Storing %u bytes of wire prepare data\n", + (unsigned int) buf_size); /* Commit our intention to execute the wire transfer! */ qs = db_plugin->wire_prepare_data_insert (db_plugin->cls, - session, - au->wa->wire_plugin->method, - buf, - buf_size); + session, + au->wa->wire_plugin->method, + buf, + buf_size); /* Commit the WTID data to 'wire_out' to finally satisfy aggregation table constraints */ if (qs >= 0) qs = db_plugin->store_wire_transfer_out (db_plugin->cls, - session, - au->execution_time, - &au->wtid, - au->wire, + session, + au->execution_time, + &au->wtid, + au->wire, au->wa->section_name, - &au->final_amount); + &au->final_amount); cleanup_au (); if (GNUNET_DB_STATUS_SOFT_ERROR == qs) { @@ -1672,8 +1677,8 @@ wire_confirm_cb (void *cls, return; } qs = db_plugin->wire_prepare_data_mark_finished (db_plugin->cls, - session, - wpd->row_id); + session, + wpd->row_id); if (0 >= qs) { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); @@ -1683,7 +1688,7 @@ wire_confirm_cb (void *cls, { /* try again */ task = GNUNET_SCHEDULER_add_now (&run_aggregation, - NULL); + NULL); } else { @@ -1759,11 +1764,12 @@ wire_prepare_cb (void *cls, wpd = NULL; return; } - wpd->eh = wpd->wa->wire_plugin->execute_wire_transfer (wpd->wa->wire_plugin->cls, - buf, - buf_size, - &wire_confirm_cb, - NULL); + wpd->eh = wpd->wa->wire_plugin->execute_wire_transfer ( + wpd->wa->wire_plugin->cls, + buf, + buf_size, + &wire_confirm_cb, + NULL); if (NULL == wpd->eh) { GNUNET_break (0); /* why? how to best recover? */ @@ -1821,13 +1827,13 @@ run_transfers (void *cls) wpd = GNUNET_new (struct WirePrepareData); wpd->session = session; qs = db_plugin->wire_prepare_data_get (db_plugin->cls, - session, - &wire_prepare_cb, - NULL); + session, + &wire_prepare_cb, + NULL); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs) return; /* continues in #wire_prepare_cb() */ db_plugin->rollback (db_plugin->cls, - session); + session); GNUNET_free (wpd); wpd = NULL; switch (qs) @@ -1840,7 +1846,7 @@ run_transfers (void *cls) case GNUNET_DB_STATUS_SOFT_ERROR: /* try again */ task = GNUNET_SCHEDULER_add_now (&run_transfers, - NULL); + NULL); return; case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: /* no more prepared wire transfers, go back to aggregation! */ @@ -1910,9 +1916,9 @@ main (int argc, { struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_option_flag ('t', - "test", - "run in test mode and exit when idle", - &test_mode), + "test", + "run in test mode and exit when idle", + &test_mode), GNUNET_GETOPT_option_version (VERSION "-" VCS_VERSION), GNUNET_GETOPT_OPTION_END }; @@ -1923,7 +1929,8 @@ main (int argc, if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "taler-exchange-aggregator", - gettext_noop ("background process that aggregates and executes wire transfers to merchants"), + gettext_noop ( + "background process that aggregates and executes wire transfers to merchants"), options, &run, NULL)) { diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index b30b19c3..cfeaf0ee 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -194,7 +194,7 @@ is_valid_correlation_id (const char *correlation_id) if (strlen (correlation_id) >= 64) return GNUNET_NO; for (int i = 0; i < strlen (correlation_id); i++) - if (!(isalnum (correlation_id[i]) || correlation_id[i] == '-')) + if (! (isalnum (correlation_id[i]) || (correlation_id[i] == '-'))) return GNUNET_NO; return GNUNET_YES; } @@ -223,193 +223,191 @@ handle_mhd_request (void *cls, size_t *upload_data_size, void **con_cls) { - static struct TEH_RequestHandler handlers[] = - { - /* Landing page, tell humans to go away. */ - { "/", MHD_HTTP_METHOD_GET, "text/plain", - "Hello, I'm the Taler exchange. This HTTP server is not for humans.\n", 0, - &TEH_MHD_handler_static_response, MHD_HTTP_OK }, - /* /robots.txt: disallow everything */ - { "/robots.txt", MHD_HTTP_METHOD_GET, "text/plain", - "User-agent: *\nDisallow: /\n", 0, - &TEH_MHD_handler_static_response, MHD_HTTP_OK }, - /* AGPL licensing page, redirect to source. As per the AGPL-license, - every deployment is required to offer the user a download of the - source. We make this easy by including a redirect to the source - here. */ - { "/agpl", MHD_HTTP_METHOD_GET, "text/plain", - NULL, 0, - &TEH_MHD_handler_agpl_redirect, MHD_HTTP_FOUND }, - - /* Return key material and fundamental properties for this exchange */ - { "/keys", MHD_HTTP_METHOD_GET, "application/json", - NULL, 0, - &TEH_KS_handler_keys, MHD_HTTP_OK }, - { "/keys", NULL, "text/plain", - "Only GET is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - /* Requests for wiring information */ - { "/wire", MHD_HTTP_METHOD_GET, "application/json", - NULL, 0, - &TEH_WIRE_handler_wire, MHD_HTTP_OK }, - { "/wire", NULL, "text/plain", - "Only GET is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - /* Withdrawing coins / interaction with reserves */ - { "/reserve/status", MHD_HTTP_METHOD_GET, "application/json", - NULL, 0, - &TEH_RESERVE_handler_reserve_status, MHD_HTTP_OK }, - { "/reserve/status", NULL, "text/plain", - "Only GET is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/reserve/withdraw", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_RESERVE_handler_reserve_withdraw, MHD_HTTP_OK }, - { "/reserve/withdraw", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - /* Depositing coins */ - { "/deposit", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_DEPOSIT_handler_deposit, MHD_HTTP_OK }, - { "/deposit", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - /* Refunding coins */ - { "/refund", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_REFUND_handler_refund, MHD_HTTP_OK }, - { "/refund", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - /* Dealing with change */ - { "/refresh/melt", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_REFRESH_handler_refresh_melt, MHD_HTTP_OK }, - { "/refresh/melt", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/refresh/reveal", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_REFRESH_handler_refresh_reveal, MHD_HTTP_OK }, - { "/refresh/reveal", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/refresh/reveal", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_REFRESH_handler_refresh_reveal, MHD_HTTP_OK }, - { "/refresh/reveal", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/refresh/link", MHD_HTTP_METHOD_GET, "application/json", - NULL, 0, - &TEH_REFRESH_handler_refresh_link, MHD_HTTP_OK }, - { "/refresh/link", NULL, "text/plain", - "Only GET is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/track/transfer", MHD_HTTP_METHOD_GET, "application/json", - NULL, 0, - &TEH_TRACKING_handler_track_transfer, MHD_HTTP_OK }, - { "/track/transfer", NULL, "text/plain", - "Only GET is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - { "/track/transaction", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_TRACKING_handler_track_transaction, MHD_HTTP_OK }, - { "/track/transaction", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/payback", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_PAYBACK_handler_payback, MHD_HTTP_OK }, - { "/refresh/link", NULL, "text/plain", - "Only GET is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + static struct TEH_RequestHandler handlers[] = { + /* Landing page, tell humans to go away. */ + { "/", MHD_HTTP_METHOD_GET, "text/plain", + "Hello, I'm the Taler exchange. This HTTP server is not for humans.\n", 0, + &TEH_MHD_handler_static_response, MHD_HTTP_OK }, + /* /robots.txt: disallow everything */ + { "/robots.txt", MHD_HTTP_METHOD_GET, "text/plain", + "User-agent: *\nDisallow: /\n", 0, + &TEH_MHD_handler_static_response, MHD_HTTP_OK }, + /* AGPL licensing page, redirect to source. As per the AGPL-license, + every deployment is required to offer the user a download of the + source. We make this easy by including a redirect to the source + here. */ + { "/agpl", MHD_HTTP_METHOD_GET, "text/plain", + NULL, 0, + &TEH_MHD_handler_agpl_redirect, MHD_HTTP_FOUND }, + + /* Return key material and fundamental properties for this exchange */ + { "/keys", MHD_HTTP_METHOD_GET, "application/json", + NULL, 0, + &TEH_KS_handler_keys, MHD_HTTP_OK }, + { "/keys", NULL, "text/plain", + "Only GET is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + /* Requests for wiring information */ + { "/wire", MHD_HTTP_METHOD_GET, "application/json", + NULL, 0, + &TEH_WIRE_handler_wire, MHD_HTTP_OK }, + { "/wire", NULL, "text/plain", + "Only GET is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + /* Withdrawing coins / interaction with reserves */ + { "/reserve/status", MHD_HTTP_METHOD_GET, "application/json", + NULL, 0, + &TEH_RESERVE_handler_reserve_status, MHD_HTTP_OK }, + { "/reserve/status", NULL, "text/plain", + "Only GET is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/reserve/withdraw", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_RESERVE_handler_reserve_withdraw, MHD_HTTP_OK }, + { "/reserve/withdraw", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + /* Depositing coins */ + { "/deposit", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_DEPOSIT_handler_deposit, MHD_HTTP_OK }, + { "/deposit", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + /* Refunding coins */ + { "/refund", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_REFUND_handler_refund, MHD_HTTP_OK }, + { "/refund", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + /* Dealing with change */ + { "/refresh/melt", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_REFRESH_handler_refresh_melt, MHD_HTTP_OK }, + { "/refresh/melt", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/refresh/reveal", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_REFRESH_handler_refresh_reveal, MHD_HTTP_OK }, + { "/refresh/reveal", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/refresh/reveal", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_REFRESH_handler_refresh_reveal, MHD_HTTP_OK }, + { "/refresh/reveal", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/refresh/link", MHD_HTTP_METHOD_GET, "application/json", + NULL, 0, + &TEH_REFRESH_handler_refresh_link, MHD_HTTP_OK }, + { "/refresh/link", NULL, "text/plain", + "Only GET is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/track/transfer", MHD_HTTP_METHOD_GET, "application/json", + NULL, 0, + &TEH_TRACKING_handler_track_transfer, MHD_HTTP_OK }, + { "/track/transfer", NULL, "text/plain", + "Only GET is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + { "/track/transaction", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_TRACKING_handler_track_transaction, MHD_HTTP_OK }, + { "/track/transaction", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/payback", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_PAYBACK_handler_payback, MHD_HTTP_OK }, + { "/refresh/link", NULL, "text/plain", + "Only GET is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, #if HAVE_DEVELOPER - /* Client crypto-interoperability test functions */ - { "/test", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_TEST_handler_test, MHD_HTTP_OK }, - { "/test", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/test/base32", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_TEST_handler_test_base32, MHD_HTTP_OK }, - { "/test/base32", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/test/encrypt", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_TEST_handler_test_encrypt, MHD_HTTP_OK }, - { "/test/encrypt", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/test/hkdf", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_TEST_handler_test_hkdf, MHD_HTTP_OK }, - { "/test/hkdf", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/test/ecdhe", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_TEST_handler_test_ecdhe, MHD_HTTP_OK }, - { "/test/ecdhe", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/test/eddsa", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_TEST_handler_test_eddsa, MHD_HTTP_OK }, - { "/test/eddsa", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/test/rsa/get", MHD_HTTP_METHOD_GET, "application/json", - NULL, 0, - &TEH_TEST_handler_test_rsa_get, MHD_HTTP_OK }, - { "/test/rsa/get", NULL, "text/plain", - "Only GET is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/test/rsa/sign", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_TEST_handler_test_rsa_sign, MHD_HTTP_OK }, - { "/test/rsa/sign", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, - - { "/test/transfer", MHD_HTTP_METHOD_POST, "application/json", - NULL, 0, - &TEH_TEST_handler_test_transfer, MHD_HTTP_OK }, - { "/test/transfer", NULL, "text/plain", - "Only POST is allowed", 0, - &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + /* Client crypto-interoperability test functions */ + { "/test", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_TEST_handler_test, MHD_HTTP_OK }, + { "/test", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/test/base32", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_TEST_handler_test_base32, MHD_HTTP_OK }, + { "/test/base32", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/test/encrypt", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_TEST_handler_test_encrypt, MHD_HTTP_OK }, + { "/test/encrypt", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/test/hkdf", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_TEST_handler_test_hkdf, MHD_HTTP_OK }, + { "/test/hkdf", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/test/ecdhe", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_TEST_handler_test_ecdhe, MHD_HTTP_OK }, + { "/test/ecdhe", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/test/eddsa", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_TEST_handler_test_eddsa, MHD_HTTP_OK }, + { "/test/eddsa", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/test/rsa/get", MHD_HTTP_METHOD_GET, "application/json", + NULL, 0, + &TEH_TEST_handler_test_rsa_get, MHD_HTTP_OK }, + { "/test/rsa/get", NULL, "text/plain", + "Only GET is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/test/rsa/sign", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_TEST_handler_test_rsa_sign, MHD_HTTP_OK }, + { "/test/rsa/sign", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + { "/test/transfer", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TEH_TEST_handler_test_transfer, MHD_HTTP_OK }, + { "/test/transfer", NULL, "text/plain", + "Only POST is allowed", 0, + &TEH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, #endif - { NULL, NULL, NULL, NULL, 0, 0 } - }; - static struct TEH_RequestHandler h404 = - { - "", NULL, "text/html", - "<html><title>404: not found</title></html>", 0, - &TEH_MHD_handler_static_response, MHD_HTTP_NOT_FOUND - }; + { NULL, NULL, NULL, NULL, 0, 0 } + }; + static struct TEH_RequestHandler h404 = { + "", NULL, "text/html", + "<html><title>404: not found</title></html>", 0, + &TEH_MHD_handler_static_response, MHD_HTTP_NOT_FOUND + }; struct TEH_RequestHandler *rh; struct ExchangeHttpRequestClosure *ecls = *con_cls; int ret; @@ -430,8 +428,9 @@ handle_mhd_request (void *cls, if ((NULL != correlation_id) && (GNUNET_YES != is_valid_correlation_id (correlation_id))) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "illegal incoming correlation ID\n"); - correlation_id = NULL; + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "illegal incoming correlation ID\n"); + correlation_id = NULL; } } @@ -452,7 +451,7 @@ handle_mhd_request (void *cls, if (0 == strcasecmp (method, MHD_HTTP_METHOD_HEAD)) method = MHD_HTTP_METHOD_GET; /* treat HEAD as GET here, MHD will do the rest */ - for (unsigned int i=0;NULL != handlers[i].url;i++) + for (unsigned int i = 0; NULL != handlers[i].url; i++) { rh = &handlers[i]; if ( (0 == strcasecmp (url, @@ -675,8 +674,10 @@ exchange_serve_process_config () } if (GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (TEH_master_public_key_str, - strlen (TEH_master_public_key_str), - &TEH_master_public_key.eddsa_pub)) + strlen ( + TEH_master_public_key_str), + &TEH_master_public_key. + eddsa_pub)) { fprintf (stderr, "Invalid master public key given in exchange configuration."); @@ -764,7 +765,7 @@ run_fake_client () sizeof (ports), "%u", serve_port); - if (0 == (cld = fork())) + if (0 == (cld = fork ())) { GNUNET_break (0 == close (0)); GNUNET_break (0 == dup2 (fd, 0)); @@ -824,7 +825,7 @@ connection_done (void *cls, if (NULL == input_filename) return; /* We signal ourselves to terminate. */ - if (0 != kill (getpid(), + if (0 != kill (getpid (), SIGTERM)) GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "kill"); @@ -992,21 +993,24 @@ write_stats () (unsigned long long) pid); fh = GNUNET_DISK_file_open (s, - (GNUNET_DISK_OPEN_WRITE | - GNUNET_DISK_OPEN_TRUNCATE | - GNUNET_DISK_OPEN_CREATE), - (GNUNET_DISK_PERM_USER_READ | - GNUNET_DISK_PERM_USER_WRITE)); + (GNUNET_DISK_OPEN_WRITE + | GNUNET_DISK_OPEN_TRUNCATE + | GNUNET_DISK_OPEN_CREATE), + (GNUNET_DISK_PERM_USER_READ + | GNUNET_DISK_PERM_USER_WRITE)); GNUNET_assert (NULL != fh); GNUNET_free (s); /* Collect stats, summed up for all threads */ - GNUNET_assert (0 == getrusage(RUSAGE_SELF, &usage)); + GNUNET_assert (0 == getrusage (RUSAGE_SELF, &usage)); GNUNET_asprintf (&s, "time_exchange sys %llu user %llu\n", \ - (unsigned long long) (usage.ru_stime.tv_sec * 1000 * 1000 + usage.ru_stime.tv_usec), - (unsigned long long) (usage.ru_utime.tv_sec * 1000 * 1000 + usage.ru_utime.tv_usec)); - GNUNET_assert (GNUNET_SYSERR != GNUNET_DISK_file_write_blocking (fh, s, strlen (s))); + (unsigned long long) (usage.ru_stime.tv_sec * 1000 * 1000 + + usage.ru_stime.tv_usec), + (unsigned long long) (usage.ru_utime.tv_sec * 1000 * 1000 + + usage.ru_utime.tv_usec)); + GNUNET_assert (GNUNET_SYSERR != GNUNET_DISK_file_write_blocking (fh, s, + strlen (s))); GNUNET_free (s); GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh)); @@ -1038,19 +1042,20 @@ main (int argc, "init-db", "create database tables and indicies if necessary", &init_db), - GNUNET_GETOPT_option_uint ('t', - "timeout", - "SECONDS", - "after how long do connections timeout by default (in seconds)", - &connection_timeout), + GNUNET_GETOPT_option_uint ('t', + "timeout", + "SECONDS", + "after how long do connections timeout by default (in seconds)", + &connection_timeout), #if HAVE_DEVELOPER - GNUNET_GETOPT_option_filename ('f', - "file-input", - "FILENAME", - "run in test-mode using FILENAME as the HTTP request to process", - &input_filename), + GNUNET_GETOPT_option_filename ('f', + "file-input", + "FILENAME", + "run in test-mode using FILENAME as the HTTP request to process", + &input_filename), #endif - GNUNET_GETOPT_option_help ("HTTP server providing a RESTful API to access a Taler exchange"), + GNUNET_GETOPT_option_help ( + "HTTP server providing a RESTful API to access a Taler exchange"), GNUNET_GETOPT_option_loglevel (&loglev), GNUNET_GETOPT_option_logfile (&logfile), GNUNET_GETOPT_option_version (VERSION "-" VCS_VERSION), @@ -1077,7 +1082,7 @@ main (int argc, GNUNET_CONFIGURATION_load (cfg, cfgfile)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Malformed configuration file `%s', exit ...\n"), + _ ("Malformed configuration file `%s', exit ...\n"), cfgfile); GNUNET_free_non_null (cfgfile); return 1; @@ -1092,9 +1097,9 @@ main (int argc, listen_fds = getenv ("LISTEN_FDS"); if ( (NULL != listen_pid) && (NULL != listen_fds) && - (getpid() == strtol (listen_pid, - NULL, - 10)) && + (getpid () == strtol (listen_pid, + NULL, + 10)) && (1 == strtoul (listen_fds, NULL, 10)) ) @@ -1131,7 +1136,10 @@ main (int argc, } mhd - = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_PIPE_FOR_SHUTDOWN | MHD_USE_DEBUG | MHD_USE_DUAL_STACK | MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_TCP_FASTOPEN, + = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_PIPE_FOR_SHUTDOWN + | MHD_USE_DEBUG | MHD_USE_DUAL_STACK + | MHD_USE_INTERNAL_POLLING_THREAD + | MHD_USE_TCP_FASTOPEN, (-1 == fh) ? serve_port : 0, NULL, NULL, &handle_mhd_request, NULL, @@ -1139,7 +1147,8 @@ main (int argc, MHD_OPTION_LISTEN_BACKLOG_SIZE, (unsigned int) 1024, MHD_OPTION_LISTEN_SOCKET, fh, MHD_OPTION_EXTERNAL_LOGGER, &handle_mhd_logs, NULL, - MHD_OPTION_NOTIFY_COMPLETED, &handle_mhd_completion_callback, NULL, + MHD_OPTION_NOTIFY_COMPLETED, + &handle_mhd_completion_callback, NULL, MHD_OPTION_CONNECTION_TIMEOUT, connection_timeout, #if HAVE_DEVELOPER MHD_OPTION_NOTIFY_CONNECTION, &connection_done, NULL, @@ -1225,7 +1234,8 @@ main (int argc, close it here */ GNUNET_break (0 == close (sock)); while (0 != MHD_get_daemon_info (mhd, - MHD_DAEMON_INFO_CURRENT_CONNECTIONS)->num_connections) + MHD_DAEMON_INFO_CURRENT_CONNECTIONS)-> + num_connections) sleep (1); /* Now we're really done, practice clean shutdown */ MHD_stop_daemon (mhd); diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c index 3b9dc36b..37bd2379 100644 --- a/src/exchange/taler-exchange-httpd_db.c +++ b/src/exchange/taler-exchange-httpd_db.c @@ -105,7 +105,8 @@ TEH_DB_run_transaction (struct MHD_Connection *connection, } TEH_plugin->preflight (TEH_plugin->cls, session); - for (unsigned int retries = 0;retries < MAX_TRANSACTION_COMMIT_RETRIES; retries++) + for (unsigned int retries = 0; retries < MAX_TRANSACTION_COMMIT_RETRIES; + retries++) { enum GNUNET_DB_QueryStatus qs; @@ -131,7 +132,7 @@ TEH_DB_run_transaction (struct MHD_Connection *connection, return GNUNET_SYSERR; if (0 <= qs) qs = TEH_plugin->commit (TEH_plugin->cls, - session); + session); if (GNUNET_DB_STATUS_HARD_ERROR == qs) { if (NULL != mhd_ret) @@ -150,7 +151,7 @@ TEH_DB_run_transaction (struct MHD_Connection *connection, MAX_TRANSACTION_COMMIT_RETRIES); if (NULL != mhd_ret) *mhd_ret = TEH_RESPONSE_reply_commit_error (connection, - TALER_EC_DB_COMMIT_FAILED_ON_RETRY); + TALER_EC_DB_COMMIT_FAILED_ON_RETRY); return GNUNET_SYSERR; } @@ -167,7 +168,8 @@ TEH_DB_run_transaction (struct MHD_Connection *connection, */ // FIXME: maybe move to another module, i.e. exchangedb??? int -TEH_DB_calculate_transaction_list_totals (struct TALER_EXCHANGEDB_TransactionList *tl, +TEH_DB_calculate_transaction_list_totals (struct + TALER_EXCHANGEDB_TransactionList *tl, const struct TALER_Amount *off, struct TALER_Amount *ret) { @@ -177,7 +179,8 @@ TEH_DB_calculate_transaction_list_totals (struct TALER_EXCHANGEDB_TransactionLis GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (spent.currency, &refunded)); - for (struct TALER_EXCHANGEDB_TransactionList *pos = tl; NULL != pos; pos = pos->next) + for (struct TALER_EXCHANGEDB_TransactionList *pos = tl; NULL != pos; pos = + pos->next) { switch (pos->type) { diff --git a/src/exchange/taler-exchange-httpd_db.h b/src/exchange/taler-exchange-httpd_db.h index 091421bb..c63b3668 100644 --- a/src/exchange/taler-exchange-httpd_db.h +++ b/src/exchange/taler-exchange-httpd_db.h @@ -80,9 +80,9 @@ TEH_DB_know_coin_transaction (void *cls, */ typedef enum GNUNET_DB_QueryStatus (*TEH_DB_TransactionCallback)(void *cls, - struct MHD_Connection *connection, - struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret); + struct MHD_Connection *connection, + struct TALER_EXCHANGEDB_Session *session, + int *mhd_ret); /** @@ -102,9 +102,9 @@ typedef enum GNUNET_DB_QueryStatus int TEH_DB_run_transaction (struct MHD_Connection *connection, const char *name, - int *mhd_ret, - TEH_DB_TransactionCallback cb, - void *cb_cls); + int *mhd_ret, + TEH_DB_TransactionCallback cb, + void *cb_cls); /** @@ -119,9 +119,10 @@ TEH_DB_run_transaction (struct MHD_Connection *connection, */ // FIXME: maybe move to another module, i.e. exchangedb??? int -TEH_DB_calculate_transaction_list_totals (struct TALER_EXCHANGEDB_TransactionList *tl, - const struct TALER_Amount *off, - struct TALER_Amount *ret); +TEH_DB_calculate_transaction_list_totals (struct + TALER_EXCHANGEDB_TransactionList *tl, + const struct TALER_Amount *off, + struct TALER_Amount *ret); #endif diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c index c19ad4b1..9e96dfd8 100644 --- a/src/exchange/taler-exchange-httpd_deposit.c +++ b/src/exchange/taler-exchange-httpd_deposit.c @@ -56,13 +56,13 @@ */ static int reply_deposit_success (struct MHD_Connection *connection, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct GNUNET_HashCode *h_wire, - const struct GNUNET_HashCode *h_contract_terms, - struct GNUNET_TIME_Absolute timestamp, - struct GNUNET_TIME_Absolute refund_deadline, - const struct TALER_MerchantPublicKeyP *merchant, - const struct TALER_Amount *amount_without_fee) + const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct GNUNET_HashCode *h_wire, + const struct GNUNET_HashCode *h_contract_terms, + struct GNUNET_TIME_Absolute timestamp, + struct GNUNET_TIME_Absolute refund_deadline, + const struct TALER_MerchantPublicKeyP *merchant, + const struct TALER_Amount *amount_without_fee) { struct TALER_DepositConfirmationPS dc; struct TALER_ExchangePublicKeyP pub; @@ -92,7 +92,8 @@ reply_deposit_success (struct MHD_Connection *connection, "{s:s, s:o, s:o}", "status", "DEPOSIT_OK", "sig", GNUNET_JSON_from_data_auto (&sig), - "pub", GNUNET_JSON_from_data_auto (&pub)); + "pub", GNUNET_JSON_from_data_auto ( + &pub)); } @@ -197,7 +198,7 @@ deposit_transaction (void *cls, TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_DEPOSIT_HISTORY_DB_ERROR); + TALER_EC_DEPOSIT_HISTORY_DB_ERROR); return GNUNET_DB_STATUS_HARD_ERROR; } /* Check that cost of all transactions is smaller than @@ -206,10 +207,10 @@ deposit_transaction (void *cls, &dc->value)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Deposited coin has insufficient funds left!\n"); + "Deposited coin has insufficient funds left!\n"); *mhd_ret = TEH_RESPONSE_reply_coin_insufficient_funds (connection, - TALER_EC_DEPOSIT_INSUFFICIENT_FUNDS, - tl); + TALER_EC_DEPOSIT_INSUFFICIENT_FUNDS, + tl); TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); return GNUNET_DB_STATUS_HARD_ERROR; @@ -223,7 +224,7 @@ deposit_transaction (void *cls, { TALER_LOG_WARNING ("Failed to store /deposit information in database\n"); *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_DEPOSIT_STORE_DB_ERROR); + TALER_EC_DEPOSIT_STORE_DB_ERROR); } return qs; } @@ -291,7 +292,7 @@ verify_and_execute_deposit (struct MHD_Connection *connection, { TEH_KS_release (mks); return TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_DEPOSIT_DB_DENOMINATION_KEY_UNKNOWN); + TALER_EC_DEPOSIT_DB_DENOMINATION_KEY_UNKNOWN); } TALER_amount_ntoh (&dc.value, &dki->issue.properties.value); @@ -341,20 +342,20 @@ check_timestamp_current (struct GNUNET_TIME_Absolute ts) if (r.rel_value_us > tolerance.rel_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Deposit timestamp too old: %llu vs %llu > %llu\n", - (unsigned long long) ts.abs_value_us, - (unsigned long long) GNUNET_TIME_absolute_get().abs_value_us, - (unsigned long long) tolerance.rel_value_us); + "Deposit timestamp too old: %llu vs %llu > %llu\n", + (unsigned long long) ts.abs_value_us, + (unsigned long long) GNUNET_TIME_absolute_get ().abs_value_us, + (unsigned long long) tolerance.rel_value_us); return GNUNET_SYSERR; } r = GNUNET_TIME_absolute_get_remaining (ts); if (r.rel_value_us > tolerance.rel_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Deposit timestamp too new: %llu vs %llu < - %llu\n", - (unsigned long long) ts.abs_value_us, - (unsigned long long) GNUNET_TIME_absolute_get().abs_value_us, - (unsigned long long) tolerance.rel_value_us); + "Deposit timestamp too new: %llu vs %llu < - %llu\n", + (unsigned long long) ts.abs_value_us, + (unsigned long long) GNUNET_TIME_absolute_get ().abs_value_us, + (unsigned long long) tolerance.rel_value_us); return GNUNET_SYSERR; } return GNUNET_OK; @@ -394,7 +395,8 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_json ("wire", &wire), TALER_JSON_spec_amount ("contribution", &deposit.amount_with_fee), - GNUNET_JSON_spec_fixed_auto ("denom_pub_hash", &deposit.coin.denom_pub_hash), + GNUNET_JSON_spec_fixed_auto ("denom_pub_hash", + &deposit.coin.denom_pub_hash), TALER_JSON_spec_denomination_signature ("ub_sig", &deposit.coin.denom_sig), GNUNET_JSON_spec_fixed_auto ("coin_pub", &deposit.coin.coin_pub), GNUNET_JSON_spec_fixed_auto ("merchant_pub", &deposit.merchant_pub), @@ -402,8 +404,10 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, GNUNET_JSON_spec_fixed_auto ("H_wire", &deposit.h_wire), GNUNET_JSON_spec_fixed_auto ("coin_sig", &deposit.csig), GNUNET_JSON_spec_absolute_time ("timestamp", &deposit.timestamp), - GNUNET_JSON_spec_absolute_time ("refund_deadline", &deposit.refund_deadline), - GNUNET_JSON_spec_absolute_time ("wire_transfer_deadline", &deposit.wire_deadline), + GNUNET_JSON_spec_absolute_time ("refund_deadline", + &deposit.refund_deadline), + GNUNET_JSON_spec_absolute_time ("wire_transfer_deadline", + &deposit.wire_deadline), GNUNET_JSON_spec_end () }; @@ -435,7 +439,7 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, GNUNET_break_op (0); GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_DEPOSIT_REFUND_DEADLINE_AFTER_WIRE_DEADLINE, + TALER_EC_DEPOSIT_REFUND_DEADLINE_AFTER_WIRE_DEADLINE, "refund_deadline"); } @@ -456,17 +460,18 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, GNUNET_break_op (0); GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_DEPOSIT_INVALID_TIMESTAMP, + TALER_EC_DEPOSIT_INVALID_TIMESTAMP, "timestamp"); } if (GNUNET_OK != TALER_JSON_merchant_wire_signature_hash (wire, &my_h_wire)) { - TALER_LOG_WARNING ("Failed to parse JSON wire format specification for /deposit request\n"); + TALER_LOG_WARNING ( + "Failed to parse JSON wire format specification for /deposit request\n"); GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_DEPOSIT_INVALID_WIRE_FORMAT_JSON, + TALER_EC_DEPOSIT_INVALID_WIRE_FORMAT_JSON, "wire"); } if (0 != GNUNET_memcmp (&deposit.h_wire, @@ -475,7 +480,7 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, /* Client hashed contract differently than we did, reject */ GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_DEPOSIT_INVALID_WIRE_FORMAT_CONTRACT_HASH_CONFLICT, + TALER_EC_DEPOSIT_INVALID_WIRE_FORMAT_CONTRACT_HASH_CONFLICT, "H_wire"); } @@ -499,7 +504,7 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, TALER_LOG_WARNING ("Unknown denomination key in /deposit request\n"); GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_arg_unknown (connection, - TALER_EC_DEPOSIT_DENOMINATION_KEY_UNKNOWN, + TALER_EC_DEPOSIT_DENOMINATION_KEY_UNKNOWN, "denom_pub"); } TALER_amount_ntoh (&deposit.deposit_fee, @@ -513,7 +518,7 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, TEH_KS_release (key_state); GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_signature_invalid (connection, - TALER_EC_DEPOSIT_DENOMINATION_SIGNATURE_INVALID, + TALER_EC_DEPOSIT_DENOMINATION_SIGNATURE_INVALID, "ub_sig"); } TALER_amount_ntoh (&deposit.deposit_fee, @@ -526,7 +531,7 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, GNUNET_break_op (0); GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_external_error (connection, - TALER_EC_DEPOSIT_NEGATIVE_VALUE_AFTER_FEE, + TALER_EC_DEPOSIT_NEGATIVE_VALUE_AFTER_FEE, "deposited amount smaller than depositing fee"); } diff --git a/src/exchange/taler-exchange-httpd_keystate.c b/src/exchange/taler-exchange-httpd_keystate.c index 2252622d..3c4e0e2a 100644 --- a/src/exchange/taler-exchange-httpd_keystate.c +++ b/src/exchange/taler-exchange-httpd_keystate.c @@ -364,7 +364,7 @@ destroy_response_factory (struct ResponseFactoryContext *rfc) json_decref (rfc->sign_keys_array); rfc->sign_keys_array = NULL; } - for (unsigned int i=0;i<rfc->denomkey_array_length;i++) + for (unsigned int i = 0; i<rfc->denomkey_array_length; i++) { struct DenominationKeyEntry *dke = &rfc->denomkey_array[i]; struct AuditorSignature *as; @@ -438,9 +438,9 @@ ks_release (struct TEH_KS_StateHandle *key_state) { GNUNET_assert (0 < key_state->refcnt); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "KS release called (%p/%d)\n", - key_state, - key_state->refcnt); + "KS release called (%p/%d)\n", + key_state, + key_state->refcnt); key_state->refcnt--; if (0 == key_state->refcnt) { @@ -460,7 +460,7 @@ ks_release (struct TEH_KS_StateHandle *key_state) GNUNET_CONTAINER_multihashmap_destroy (key_state->revoked_map); key_state->revoked_map = NULL; } - for (unsigned int i=0;i<key_state->krd_array_length;i++) + for (unsigned int i = 0; i<key_state->krd_array_length; i++) { struct KeysResponseData *krd = &key_state->krd_array[i]; @@ -527,7 +527,8 @@ handle_signal (int signal_number) */ static json_t * denom_key_issue_to_json (const struct TALER_DenominationPublicKey *pk, - const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki) + const struct + TALER_EXCHANGEDB_DenominationKeyInformationP *dki) { struct TALER_Amount value; struct TALER_Amount fee_withdraw; @@ -550,13 +551,17 @@ denom_key_issue_to_json (const struct TALER_DenominationPublicKey *pk, "master_sig", GNUNET_JSON_from_data_auto (&dki->signature), "stamp_start", - GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (dki->properties.start)), + GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh ( + dki->properties.start)), "stamp_expire_withdraw", - GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (dki->properties.expire_withdraw)), + GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh ( + dki->properties.expire_withdraw)), "stamp_expire_deposit", - GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (dki->properties.expire_deposit)), + GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh ( + dki->properties.expire_deposit)), "stamp_expire_legal", - GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (dki->properties.expire_legal)), + GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh ( + dki->properties.expire_legal)), "denom_pub", GNUNET_JSON_from_rsa_public_key (pk->rsa_public_key), "value", @@ -582,7 +587,8 @@ denom_key_issue_to_json (const struct TALER_DenominationPublicKey *pk, */ static int store_in_map (struct GNUNET_CONTAINER_MultiHashMap *map, - const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) + const struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) { struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *d2; int res; @@ -599,10 +605,11 @@ store_in_map (struct GNUNET_CONTAINER_MultiHashMap *map, = htonl (sizeof (struct TALER_DenominationKeyValidityPS)); denom_key_issue.master = TEH_master_public_key; if (GNUNET_SYSERR == - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY, - &denom_key_issue.purpose, - &dkip->signature.eddsa_signature, - &TEH_master_public_key.eddsa_pub)) + GNUNET_CRYPTO_eddsa_verify ( + TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY, + &denom_key_issue.purpose, + &dkip->signature.eddsa_signature, + &TEH_master_public_key.eddsa_pub)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid signature on denomination key `%s'\n", @@ -610,7 +617,7 @@ store_in_map (struct GNUNET_CONTAINER_MultiHashMap *map, return GNUNET_SYSERR; } } - + d2 = GNUNET_new (struct TALER_EXCHANGEDB_DenominationKeyIssueInformation); d2->issue = dki->issue; if (NULL != dki->denom_priv.rsa_private_key) @@ -692,9 +699,9 @@ TALER_EXCHANGE_conf_duration_provide () */ static enum GNUNET_DB_QueryStatus add_revocations_transaction (void *cls, - struct MHD_Connection *connection, - struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + struct MHD_Connection *connection, + struct TALER_EXCHANGEDB_Session *session, + int *mhd_ret) { struct AddRevocationContext *arc = cls; enum GNUNET_DB_QueryStatus qs; @@ -703,7 +710,8 @@ add_revocations_transaction (void *cls, qs = TEH_plugin->get_denomination_revocation (TEH_plugin->cls, session, - &arc->dki->issue.properties.denom_hash, + &arc->dki->issue.properties. + denom_hash, &master_sig, &rowid); if (0 > qs) @@ -712,7 +720,8 @@ add_revocations_transaction (void *cls, return qs; /* already exists == success */ return TEH_plugin->insert_denomination_revocation (TEH_plugin->cls, session, - &arc->dki->issue.properties.denom_hash, + &arc->dki->issue.properties + .denom_hash, arc->revocation_master_sig); } @@ -764,7 +773,8 @@ add_denomination_transaction (void *cls, static int reload_keys_denom_iter (void *cls, const char *alias, - const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) + const struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) { struct ResponseFactoryContext *rfc = cls; struct TEH_KS_StateHandle *key_state = rfc->key_state; @@ -776,7 +786,8 @@ reload_keys_denom_iter (void *cls, "Loading denomination key `%s' (%s)\n", alias, GNUNET_h2s (&dki->issue.properties.denom_hash)); - expire_deposit = GNUNET_TIME_absolute_ntoh (dki->issue.properties.expire_deposit); + expire_deposit = GNUNET_TIME_absolute_ntoh ( + dki->issue.properties.expire_deposit); if (expire_deposit.abs_value_us < rfc->now.abs_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -846,8 +857,8 @@ reload_keys_denom_iter (void *cls, */ static int revocations_iter (void *cls, - const struct GNUNET_HashCode *denom_hash, - const struct TALER_MasterSignatureP *revocation_master_sig) + const struct GNUNET_HashCode *denom_hash, + const struct TALER_MasterSignatureP *revocation_master_sig) { struct ResponseFactoryContext *rfc = cls; struct TEH_KS_StateHandle *key_state = rfc->key_state; @@ -855,7 +866,7 @@ revocations_iter (void *cls, struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki; dki = GNUNET_CONTAINER_multihashmap_get (key_state->denomkey_map, - denom_hash); + denom_hash); if (NULL == dki) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -865,15 +876,16 @@ revocations_iter (void *cls, } GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Adding denomination key `%s' to revocation set\n", - GNUNET_h2s (denom_hash)); + "Adding denomination key `%s' to revocation set\n", + GNUNET_h2s (denom_hash)); GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (key_state->denomkey_map, denom_hash, dki)); GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_put (key_state->revoked_map, - &dki->issue.properties.denom_hash, + &dki->issue.properties. + denom_hash, dki, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); /* Try to insert revocation into DB */ @@ -881,19 +893,20 @@ revocations_iter (void *cls, arc.revocation_master_sig = revocation_master_sig; if (GNUNET_OK != TEH_DB_run_transaction (NULL, - "add denomination key revocation", - NULL, - &add_revocations_transaction, - &arc)) + "add denomination key revocation", + NULL, + &add_revocations_transaction, + &arc)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to add revocation to database. This is fatal. Committing suicide via SIGTERM.\n"); + "Failed to add revocation to database. This is fatal. Committing suicide via SIGTERM.\n"); handle_signal (SIGTERM); return GNUNET_SYSERR; } GNUNET_assert (0 == - json_array_append_new (rfc->payback_array, - GNUNET_JSON_from_data_auto (denom_hash))); + json_array_append_new (rfc->payback_array, + GNUNET_JSON_from_data_auto ( + denom_hash))); return GNUNET_OK; } @@ -912,9 +925,11 @@ sign_key_issue_to_json (const struct TALER_ExchangeSigningKeyValidityPS *ski, return json_pack ("{s:o, s:o, s:o, s:o, s:o}", "stamp_start", - GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (ski->start)), + GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh ( + ski->start)), "stamp_expire", - GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (ski->expire)), + GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh ( + ski->expire)), "stamp_end", GNUNET_JSON_from_time_abs (GNUNET_TIME_absolute_ntoh (ski->end)), "master_sig", @@ -940,14 +955,16 @@ sign_key_issue_to_json (const struct TALER_ExchangeSigningKeyValidityPS *ski, static int reload_keys_sign_iter (void *cls, const char *filename, - const struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP *ski) + const struct + TALER_EXCHANGEDB_PrivateSigningKeyInformationP *ski) { struct ResponseFactoryContext *rfc = cls; struct TEH_KS_StateHandle *key_state = rfc->key_state; struct GNUNET_TIME_Absolute now; struct GNUNET_TIME_Absolute horizon; - horizon = GNUNET_TIME_relative_to_absolute (TALER_EXCHANGE_conf_duration_provide ()); + horizon = GNUNET_TIME_relative_to_absolute ( + TALER_EXCHANGE_conf_duration_provide ()); if (GNUNET_TIME_absolute_ntoh (ski->issue.start).abs_value_us > horizon.abs_value_us) { @@ -977,7 +994,8 @@ reload_keys_sign_iter (void *cls, /* The signkey is valid at this time, check if it's more recent than what we have so far! */ - if ( (GNUNET_TIME_absolute_ntoh (key_state->current_sign_key_issue.issue.start).abs_value_us < + if ( (GNUNET_TIME_absolute_ntoh ( + key_state->current_sign_key_issue.issue.start).abs_value_us < GNUNET_TIME_absolute_ntoh (ski->issue.start).abs_value_us) && (GNUNET_TIME_absolute_ntoh (ski->issue.start).abs_value_us < now.abs_value_us) ) @@ -1034,7 +1052,7 @@ reload_auditor_iter (void *cls, } /* Filter the auditor information for those for which the keys actually match the denomination keys that are active right now */ - for (unsigned int i=0;i<dki_len;i++) + for (unsigned int i = 0; i<dki_len; i++) { int matched; @@ -1043,26 +1061,26 @@ reload_auditor_iter (void *cls, &dki[i].denom_hash)) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Found auditor signature for DK `%s', but key is not in active map\n", - GNUNET_h2s (&dki[i].denom_hash)); + "Found auditor signature for DK `%s', but key is not in active map\n", + GNUNET_h2s (&dki[i].denom_hash)); continue; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Found auditor signature for DK `%s'\n", - GNUNET_h2s (&dki[i].denom_hash)); + "Found auditor signature for DK `%s'\n", + GNUNET_h2s (&dki[i].denom_hash)); /* Note: the array is sorted, we could theoretically speed this up using a binary search. */ matched = GNUNET_NO; - for (unsigned int j=0;j<rfc->denomkey_array_length;j++) + for (unsigned int j = 0; j<rfc->denomkey_array_length; j++) { struct DenominationKeyEntry *dke = &rfc->denomkey_array[j]; struct AuditorSignature *as; if (0 != - memcmp (&dki[i].denom_hash, - &dke->dki->issue.properties.denom_hash, - sizeof (struct GNUNET_HashCode))) - continue; + memcmp (&dki[i].denom_hash, + &dke->dki->issue.properties.denom_hash, + sizeof (struct GNUNET_HashCode))) + continue; if (0 != memcmp (&dki[i], &dke->dki->issue.properties, @@ -1072,8 +1090,8 @@ reload_auditor_iter (void *cls, GNUNET_break (0); continue; } - as = GNUNET_malloc (sizeof (struct AuditorSignature) + - strlen (auditor_url) + 1); + as = GNUNET_malloc (sizeof (struct AuditorSignature) + + strlen (auditor_url) + 1); as->asig = asigs[i]; as->apub = *apub; as->auditor_url = (const char *) &as[1]; @@ -1090,8 +1108,8 @@ reload_auditor_iter (void *cls, { GNUNET_break (0); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "DK `%s' is in active map, but not in array!?\n", - GNUNET_h2s (&dki[i].denom_hash)); + "DK `%s' is in active map, but not in array!?\n", + GNUNET_h2s (&dki[i].denom_hash)); } } return GNUNET_OK; @@ -1147,7 +1165,7 @@ denomkey_array_sort_comparator (const void *k1, if (d1.abs_value_us < d2.abs_value_us) return -1; if (d1.abs_value_us > d2.abs_value_us) - return 1; + return 1; return 0; } @@ -1164,15 +1182,15 @@ get_date_string (struct GNUNET_TIME_Absolute at, char *date) { static const char *const days[] = - { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; + { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; static const char *const mons[] = - { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", - "Nov", "Dec" - }; + { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", + "Nov", "Dec"}; struct tm now; time_t t; -#if !defined(HAVE_C11_GMTIME_S) && !defined(HAVE_W32_GMTIME_S) && !defined(HAVE_GMTIME_R) - struct tm* pNow; +#if ! defined(HAVE_C11_GMTIME_S) && ! defined(HAVE_W32_GMTIME_S) && \ + ! defined(HAVE_GMTIME_R) + struct tm*pNow; #endif date[0] = 0; @@ -1184,10 +1202,10 @@ get_date_string (struct GNUNET_TIME_Absolute at, if (0 != gmtime_s (&now, &t)) return; #elif defined(HAVE_GMTIME_R) - if (NULL == gmtime_r(&t, &now)) + if (NULL == gmtime_r (&t, &now)) return; #else - pNow = gmtime(&t); + pNow = gmtime (&t); if (NULL == pNow) return; now = *pNow; @@ -1364,7 +1382,7 @@ build_keys_response (const struct ResponseFactoryContext *rfc, auditors = GNUNET_CONTAINER_multihashmap_create (4, GNUNET_NO); - for (unsigned int i=denom_off;i<rfc->denomkey_array_length;i++) + for (unsigned int i = denom_off; i<rfc->denomkey_array_length; i++) { /* Add denomination key to the response */ const struct DenominationKeyEntry *dke @@ -1414,9 +1432,11 @@ build_keys_response (const struct ResponseFactoryContext *rfc, json_array_append_new (ae->ar, json_pack ("{s:o, s:o}", "denom_pub_h", - GNUNET_JSON_from_data_auto (denom_key_hash), + GNUNET_JSON_from_data_auto ( + denom_key_hash), "auditor_sig", - GNUNET_JSON_from_data_auto (&as->asig)))); + GNUNET_JSON_from_data_auto ( + &as->asig)))); } } @@ -1434,9 +1454,11 @@ build_keys_response (const struct ResponseFactoryContext *rfc, &ks.hc); rbc.hash_context = NULL; GNUNET_assert (GNUNET_OK == - GNUNET_CRYPTO_eddsa_sign (&rfc->key_state->current_sign_key_issue.signkey_priv.eddsa_priv, - &ks.purpose, - &sig.eddsa_signature)); + GNUNET_CRYPTO_eddsa_sign ( + &rfc->key_state->current_sign_key_issue.signkey_priv. + eddsa_priv, + &ks.purpose, + &sig.eddsa_signature)); if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, "exchangedb", @@ -1447,23 +1469,28 @@ build_keys_response (const struct ResponseFactoryContext *rfc, "exchangedb", "IDLE_RESERVE_EXPIRATION_TIME"); /* use default */ - reserve_closing_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_WEEKS, - 4); + reserve_closing_delay = GNUNET_TIME_relative_multiply ( + GNUNET_TIME_UNIT_WEEKS, + 4); } /* Build /keys response */ keys = json_pack ("{s:s, s:o, s:o, s:O, s:O," " s:o, s:o, s:o, s:o, s:o}", /* 1-5 */ "version", TALER_PROTOCOL_VERSION, - "master_public_key", GNUNET_JSON_from_data_auto (&TEH_master_public_key), - "reserve_closing_delay", GNUNET_JSON_from_time_rel (reserve_closing_delay), + "master_public_key", GNUNET_JSON_from_data_auto ( + &TEH_master_public_key), + "reserve_closing_delay", GNUNET_JSON_from_time_rel ( + reserve_closing_delay), "signkeys", rfc->sign_keys_array, "payback", rfc->payback_array, /* 6-10 */ "denoms", rbc.denom_keys_array, "auditors", rbc.auditors_array, - "list_issue_date", GNUNET_JSON_from_time_abs (rfc->key_state->reload_time), - "eddsa_pub", GNUNET_JSON_from_data_auto (&rfc->key_state->current_sign_key_issue.issue.signkey_pub), + "list_issue_date", GNUNET_JSON_from_time_abs ( + rfc->key_state->reload_time), + "eddsa_pub", GNUNET_JSON_from_data_auto ( + &rfc->key_state->current_sign_key_issue.issue.signkey_pub), "eddsa_sig", GNUNET_JSON_from_data_auto (&sig)); if (NULL == keys) { @@ -1560,13 +1587,14 @@ build_keys_response (const struct ResponseFactoryContext *rfc, static void reload_public_denoms_cb (void *cls, const struct TALER_DenominationPublicKey *denom_pub, - const struct TALER_EXCHANGEDB_DenominationKeyInformationP *issue) + const struct + TALER_EXCHANGEDB_DenominationKeyInformationP *issue) { struct ResponseFactoryContext *rfc = cls; struct TALER_EXCHANGEDB_DenominationKeyIssueInformation dki; if (rfc->now.abs_value_us > GNUNET_TIME_absolute_ntoh - (issue->properties.expire_legal).abs_value_us) + (issue->properties.expire_legal).abs_value_us) { /* Expired key, discard. */ return; @@ -1672,9 +1700,9 @@ make_fresh_key_state (struct GNUNET_TIME_Absolute now) /* process revocations */ if (-1 == TALER_EXCHANGEDB_revocations_iterate (TEH_revocation_directory, - &TEH_master_public_key, - &revocations_iter, - &rfc)) + &TEH_master_public_key, + &revocations_iter, + &rfc)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to load denomination keys from `%s'.\n", @@ -1716,7 +1744,8 @@ make_fresh_key_state (struct GNUNET_TIME_Absolute now) /* Initialize and sort the `denomkey_array` */ rfc.denomkey_array - = GNUNET_new_array (GNUNET_CONTAINER_multihashmap_size (key_state->denomkey_map), + = GNUNET_new_array (GNUNET_CONTAINER_multihashmap_size ( + key_state->denomkey_map), struct DenominationKeyEntry); GNUNET_CONTAINER_multihashmap_iterate (key_state->denomkey_map, &initialize_denomkey_array, @@ -1733,16 +1762,16 @@ make_fresh_key_state (struct GNUNET_TIME_Absolute now) &reload_auditor_iter, &rfc); /* Sanity check: do we have auditors for all denomination keys? */ - for (unsigned int i=0;i<rfc.denomkey_array_length;i++) + for (unsigned int i = 0; i<rfc.denomkey_array_length; i++) { const struct DenominationKeyEntry *dke = &rfc.denomkey_array[i]; if (NULL == dke->as_head) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Denomination key `%s' at %p not signed by any auditor!\n", - GNUNET_h2s (&dke->denom_key_hash), - dke); + "Denomination key `%s' at %p not signed by any auditor!\n", + GNUNET_h2s (&dke->denom_key_hash), + dke); } /* Determine size of `krd_array` by counting number of discrete @@ -1750,7 +1779,7 @@ make_fresh_key_state (struct GNUNET_TIME_Absolute now) last = GNUNET_TIME_UNIT_ZERO_ABS; key_state->krd_array_length = 0; off = 1; /* reserve one slot for the "no keys" response */ - for (unsigned int i=0;i<rfc.denomkey_array_length;i++) + for (unsigned int i = 0; i<rfc.denomkey_array_length; i++) { const struct DenominationKeyEntry *dke = &rfc.denomkey_array[i]; @@ -1765,7 +1794,8 @@ make_fresh_key_state (struct GNUNET_TIME_Absolute now) /* Compute next automatic reload time */ key_state->next_reload = - GNUNET_TIME_absolute_min (GNUNET_TIME_absolute_ntoh (key_state->current_sign_key_issue.issue.expire), + GNUNET_TIME_absolute_min (GNUNET_TIME_absolute_ntoh ( + key_state->current_sign_key_issue.issue.expire), key_state->min_dk_expire); GNUNET_assert (0 != key_state->next_reload.abs_value_us); @@ -1777,7 +1807,7 @@ make_fresh_key_state (struct GNUNET_TIME_Absolute now) struct KeysResponseData); off = 0; last = GNUNET_TIME_UNIT_ZERO_ABS; - for (unsigned int i=0;i<rfc.denomkey_array_length;i++) + for (unsigned int i = 0; i<rfc.denomkey_array_length; i++) { const struct DenominationKeyEntry *dke = &rfc.denomkey_array[i]; @@ -1839,8 +1869,8 @@ TEH_KS_release_ (const char *location, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "KS released at %s (%p/%d)\n", location, - key_state, - key_state->refcnt); + key_state, + key_state->refcnt); ks_release (key_state); GNUNET_assert (0 == pthread_mutex_unlock (&internal_key_state_mutex)); } @@ -1870,7 +1900,7 @@ TEH_KS_acquire_ (struct GNUNET_TIME_Absolute now, internal_key_state = NULL; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "KS released in acquire due to expiration\n"); + "KS released in acquire due to expiration\n"); ks_release (ks); rcd = 1; /* remember that we released 'internal_key_state' */ } @@ -1882,7 +1912,7 @@ TEH_KS_acquire_ (struct GNUNET_TIME_Absolute now, { GNUNET_assert (0 == pthread_mutex_unlock (&internal_key_state_mutex)); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to initialize key state\n"); + "Failed to initialize key state\n"); return NULL; } internal_key_state->refcnt += rcd; @@ -1892,16 +1922,16 @@ TEH_KS_acquire_ (struct GNUNET_TIME_Absolute now, { key_state->refcnt++; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "KS acquired at %s (%p/%d)\n", - location, - key_state, - key_state->refcnt); + "KS acquired at %s (%p/%d)\n", + location, + key_state, + key_state->refcnt); } else { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "KS acquire failed at %s\n", - location); + "KS acquire failed at %s\n", + location); } GNUNET_assert (0 == pthread_mutex_unlock (&internal_key_state_mutex)); @@ -1920,17 +1950,20 @@ TEH_KS_acquire_ (struct GNUNET_TIME_Absolute now, * or NULL if denom_pub could not be found (or is not valid at this time for the given @a use) */ struct TALER_EXCHANGEDB_DenominationKeyIssueInformation * -TEH_KS_denomination_key_lookup_by_hash (const struct TEH_KS_StateHandle *key_state, - const struct GNUNET_HashCode *denom_pub_hash, +TEH_KS_denomination_key_lookup_by_hash (const struct + TEH_KS_StateHandle *key_state, + const struct + GNUNET_HashCode *denom_pub_hash, enum TEH_KS_DenominationKeyUse use) { struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki; struct GNUNET_TIME_Absolute now; const struct GNUNET_CONTAINER_MultiHashMap *map; - map = (TEH_KS_DKU_PAYBACK == use) ? key_state->revoked_map : key_state->denomkey_map; + map = (TEH_KS_DKU_PAYBACK == use) ? key_state->revoked_map : + key_state->denomkey_map; dki = GNUNET_CONTAINER_multihashmap_get (map, - denom_pub_hash); + denom_pub_hash); if ( (NULL == dki) && (TEH_KS_DKU_ZOMBIE == use)) dki = GNUNET_CONTAINER_multihashmap_get (key_state->revoked_map, denom_pub_hash); @@ -1941,8 +1974,8 @@ TEH_KS_denomination_key_lookup_by_hash (const struct TEH_KS_StateHandle *key_sta GNUNET_TIME_absolute_ntoh (dki->issue.properties.start).abs_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Not returning DKI for %s, as start time is in the future\n", - GNUNET_h2s (denom_pub_hash)); + "Not returning DKI for %s, as start time is in the future\n", + GNUNET_h2s (denom_pub_hash)); return NULL; } now = GNUNET_TIME_absolute_get (); @@ -1950,48 +1983,52 @@ TEH_KS_denomination_key_lookup_by_hash (const struct TEH_KS_StateHandle *key_sta { case TEH_KS_DKU_WITHDRAW: if (now.abs_value_us > - GNUNET_TIME_absolute_ntoh (dki->issue.properties.expire_withdraw).abs_value_us) + GNUNET_TIME_absolute_ntoh ( + dki->issue.properties.expire_withdraw).abs_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Not returning DKI for %s, as time to create coins has passed\n", - GNUNET_h2s (denom_pub_hash)); + "Not returning DKI for %s, as time to create coins has passed\n", + GNUNET_h2s (denom_pub_hash)); return NULL; } if (NULL == dki->denom_priv.rsa_private_key) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Not returning DKI of %s for WITHDRAW operation as we lack the private key, even though the withdraw period did not yet expire!\n", - GNUNET_h2s (denom_pub_hash)); + "Not returning DKI of %s for WITHDRAW operation as we lack the private key, even though the withdraw period did not yet expire!\n", + GNUNET_h2s (denom_pub_hash)); return NULL; } break; case TEH_KS_DKU_DEPOSIT: if (now.abs_value_us > - GNUNET_TIME_absolute_ntoh (dki->issue.properties.expire_deposit).abs_value_us) + GNUNET_TIME_absolute_ntoh ( + dki->issue.properties.expire_deposit).abs_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Not returning DKI for %s, as time to spend coin has passed\n", - GNUNET_h2s (denom_pub_hash)); + "Not returning DKI for %s, as time to spend coin has passed\n", + GNUNET_h2s (denom_pub_hash)); return NULL; } break; case TEH_KS_DKU_PAYBACK: if (now.abs_value_us > - GNUNET_TIME_absolute_ntoh (dki->issue.properties.expire_deposit).abs_value_us) + GNUNET_TIME_absolute_ntoh ( + dki->issue.properties.expire_deposit).abs_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Not returning DKI for %s, as time to payback coin has passed\n", - GNUNET_h2s (denom_pub_hash)); + "Not returning DKI for %s, as time to payback coin has passed\n", + GNUNET_h2s (denom_pub_hash)); return NULL; } break; case TEH_KS_DKU_ZOMBIE: if (now.abs_value_us > - GNUNET_TIME_absolute_ntoh (dki->issue.properties.expire_legal).abs_value_us) + GNUNET_TIME_absolute_ntoh ( + dki->issue.properties.expire_legal).abs_value_us) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Not returning DKI for %s, as legal expiration of coin has passed\n", - GNUNET_h2s (denom_pub_hash)); + "Not returning DKI for %s, as legal expiration of coin has passed\n", + GNUNET_h2s (denom_pub_hash)); return NULL; } break; @@ -2113,7 +2150,7 @@ TEH_KS_loop (void) ret = GNUNET_SYSERR; break; } -read_again: + read_again: errno = 0; res = read (reload_pipe[0], &c, @@ -2206,14 +2243,15 @@ TEH_KS_sign (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, /* This *can* happen if the exchange's keys are not properly maintained. */ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Cannot sign request, no valid keys available\n")); + _ ("Cannot sign request, no valid keys available\n")); return GNUNET_SYSERR; } *pub = key_state->current_sign_key_issue.issue.signkey_pub; GNUNET_assert (GNUNET_OK == - GNUNET_CRYPTO_eddsa_sign (&key_state->current_sign_key_issue.signkey_priv.eddsa_priv, - purpose, - &sig->eddsa_signature)); + GNUNET_CRYPTO_eddsa_sign ( + &key_state->current_sign_key_issue.signkey_priv.eddsa_priv, + purpose, + &sig->eddsa_signature)); TEH_KS_release (key_state); return GNUNET_OK; } diff --git a/src/exchange/taler-exchange-httpd_keystate.h b/src/exchange/taler-exchange-httpd_keystate.h index 6f5d338c..7e2a659e 100644 --- a/src/exchange/taler-exchange-httpd_keystate.h +++ b/src/exchange/taler-exchange-httpd_keystate.h @@ -69,7 +69,7 @@ TEH_KS_release_ (const char *location, * client via the "now" URL parameter of "/keys". * @return the key state */ -#define TEH_KS_acquire(now) TEH_KS_acquire_(now, __FUNCTION__) +#define TEH_KS_acquire(now) TEH_KS_acquire_ (now, __FUNCTION__) /** @@ -93,7 +93,8 @@ TEH_KS_free (void); * periods for a key differ, the caller must specify which * use is relevant for the current operation. */ -enum TEH_KS_DenominationKeyUse { +enum TEH_KS_DenominationKeyUse +{ /** * The key is to be used for a /reserve/withdraw or /refresh (exchange) @@ -113,7 +114,7 @@ enum TEH_KS_DenominationKeyUse { /** * The key is to be used for a /refresh/payback operation, - * i.e. it is an old coin that regained value from a + * i.e. it is an old coin that regained value from a * payback on a new coin derived from the old coin. */ TEH_KS_DKU_ZOMBIE @@ -132,8 +133,10 @@ enum TEH_KS_DenominationKeyUse { * or NULL if denom_pub could not be found (or is not valid at this time for the given @a use) */ struct TALER_EXCHANGEDB_DenominationKeyIssueInformation * -TEH_KS_denomination_key_lookup_by_hash (const struct TEH_KS_StateHandle *key_state, - const struct GNUNET_HashCode *denom_pub_hash, +TEH_KS_denomination_key_lookup_by_hash (const struct + TEH_KS_StateHandle *key_state, + const struct + GNUNET_HashCode *denom_pub_hash, enum TEH_KS_DenominationKeyUse use); diff --git a/src/exchange/taler-exchange-httpd_mhd.c b/src/exchange/taler-exchange-httpd_mhd.c index e76ada2c..dfea44ad 100644 --- a/src/exchange/taler-exchange-httpd_mhd.c +++ b/src/exchange/taler-exchange-httpd_mhd.c @@ -45,10 +45,10 @@ */ int TEH_MHD_handler_static_response (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { struct MHD_Response *response; int ret; @@ -142,16 +142,16 @@ TEH_MHD_handler_agpl_redirect (struct TEH_RequestHandler *rh, */ int TEH_MHD_handler_send_json_pack_error (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { return TEH_RESPONSE_reply_json_pack (connection, - rh->response_code, - "{s:s}", - "error", - rh->data); + rh->response_code, + "{s:s}", + "error", + rh->data); } diff --git a/src/exchange/taler-exchange-httpd_parsing.c b/src/exchange/taler-exchange-httpd_parsing.c index d1a1e9df..dc77d182 100644 --- a/src/exchange/taler-exchange-httpd_parsing.c +++ b/src/exchange/taler-exchange-httpd_parsing.c @@ -33,7 +33,7 @@ /** * Maximum POST request size. */ -#define REQUEST_BUFFER_MAX (1024*1024) +#define REQUEST_BUFFER_MAX (1024 * 1024) @@ -80,21 +80,21 @@ TEH_PARSE_post_json (struct MHD_Connection *connection, case GNUNET_JSON_PR_OUT_OF_MEMORY: return (MHD_NO == TEH_RESPONSE_reply_internal_error - (connection, - TALER_EC_PARSER_OUT_OF_MEMORY, - "out of memory")) ? GNUNET_SYSERR : GNUNET_NO; + (connection, + TALER_EC_PARSER_OUT_OF_MEMORY, + "out of memory")) ? GNUNET_SYSERR : GNUNET_NO; case GNUNET_JSON_PR_CONTINUE: return GNUNET_YES; case GNUNET_JSON_PR_REQUEST_TOO_LARGE: return (MHD_NO == TEH_RESPONSE_reply_request_too_large - (connection)) ? GNUNET_SYSERR : GNUNET_NO; + (connection)) ? GNUNET_SYSERR : GNUNET_NO; case GNUNET_JSON_PR_JSON_INVALID: return (MHD_YES == TEH_RESPONSE_reply_invalid_json (connection)) - ? GNUNET_NO : GNUNET_SYSERR; + ? GNUNET_NO : GNUNET_SYSERR; case GNUNET_JSON_PR_SUCCESS: GNUNET_break (NULL != *json); return GNUNET_YES; @@ -149,9 +149,9 @@ TEH_PARSE_mhd_request_arg_data (struct MHD_Connection *connection, { return (MHD_NO == TEH_RESPONSE_reply_arg_missing (connection, - TALER_EC_PARAMETER_MISSING, - param_name)) - ? GNUNET_SYSERR : GNUNET_NO; + TALER_EC_PARAMETER_MISSING, + param_name)) + ? GNUNET_SYSERR : GNUNET_NO; } if (GNUNET_OK != GNUNET_STRINGS_string_to_data (str, @@ -160,9 +160,9 @@ TEH_PARSE_mhd_request_arg_data (struct MHD_Connection *connection, out_size)) return (MHD_NO == TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_PARAMETER_MALFORMED, - param_name)) - ? GNUNET_SYSERR : GNUNET_NO; + TALER_EC_PARAMETER_MALFORMED, + param_name)) + ? GNUNET_SYSERR : GNUNET_NO; return GNUNET_OK; } @@ -203,10 +203,12 @@ TEH_PARSE_json_data (struct MHD_Connection *connection, MHD_HTTP_BAD_REQUEST, "{s:s, s:I, s:s, s:I}", "error", "parse error", - "code", (json_int_t) TALER_EC_JSON_INVALID_WITH_DETAILS, + "code", + (json_int_t) + TALER_EC_JSON_INVALID_WITH_DETAILS, "field", error_json_name, "line", (json_int_t) error_line)) - ? GNUNET_NO : GNUNET_SYSERR; + ? GNUNET_NO : GNUNET_SYSERR; return ret; } return GNUNET_YES; @@ -257,7 +259,7 @@ TEH_PARSE_json_array (struct MHD_Connection *connection, "{s:s, s:I}", "error", "parse error", "dimension", dim)) - ? GNUNET_NO : GNUNET_SYSERR; + ? GNUNET_NO : GNUNET_SYSERR; return ret; } ret = GNUNET_JSON_parse (root, @@ -275,7 +277,7 @@ TEH_PARSE_json_array (struct MHD_Connection *connection, "error", "parse error", "field", error_json_name, "line", (json_int_t) error_line)) - ? GNUNET_NO : GNUNET_SYSERR; + ? GNUNET_NO : GNUNET_SYSERR; return ret; } return GNUNET_YES; diff --git a/src/exchange/taler-exchange-httpd_payback.c b/src/exchange/taler-exchange-httpd_payback.c index 50c0ffdb..468d69b3 100644 --- a/src/exchange/taler-exchange-httpd_payback.c +++ b/src/exchange/taler-exchange-httpd_payback.c @@ -67,7 +67,8 @@ reply_payback_unknown (struct MHD_Connection *connection, static int reply_payback_refresh_success (struct MHD_Connection *connection, const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_CoinSpendPublicKeyP *old_coin_pub, + const struct + TALER_CoinSpendPublicKeyP *old_coin_pub, const struct TALER_Amount *amount, struct GNUNET_TIME_Absolute timestamp) { @@ -94,11 +95,17 @@ reply_payback_refresh_success (struct MHD_Connection *connection, return TEH_RESPONSE_reply_json_pack (connection, MHD_HTTP_OK, "{s:o, s:o, s:o, s:o, s:o}", - "old_coin_pub", GNUNET_JSON_from_data_auto (old_coin_pub), - "timestamp", GNUNET_JSON_from_time_abs (timestamp), - "amount", TALER_JSON_from_amount (amount), - "exchange_sig", GNUNET_JSON_from_data_auto (&sig), - "exchange_pub", GNUNET_JSON_from_data_auto (&pub)); + "old_coin_pub", + GNUNET_JSON_from_data_auto ( + old_coin_pub), + "timestamp", GNUNET_JSON_from_time_abs ( + timestamp), + "amount", TALER_JSON_from_amount ( + amount), + "exchange_sig", + GNUNET_JSON_from_data_auto (&sig), + "exchange_pub", + GNUNET_JSON_from_data_auto (&pub)); } @@ -142,11 +149,16 @@ reply_payback_success (struct MHD_Connection *connection, return TEH_RESPONSE_reply_json_pack (connection, MHD_HTTP_OK, "{s:o, s:o, s:o, s:o, s:o}", - "reserve_pub", GNUNET_JSON_from_data_auto (reserve_pub), - "timestamp", GNUNET_JSON_from_time_abs (timestamp), - "amount", TALER_JSON_from_amount (amount), - "exchange_sig", GNUNET_JSON_from_data_auto (&sig), - "exchange_pub", GNUNET_JSON_from_data_auto (&pub)); + "reserve_pub", + GNUNET_JSON_from_data_auto (reserve_pub), + "timestamp", GNUNET_JSON_from_time_abs ( + timestamp), + "amount", TALER_JSON_from_amount ( + amount), + "exchange_sig", + GNUNET_JSON_from_data_auto (&sig), + "exchange_pub", + GNUNET_JSON_from_data_auto (&pub)); } @@ -405,7 +417,8 @@ payback_transaction (void *cls, static int verify_and_execute_payback (struct MHD_Connection *connection, const struct TALER_CoinPublicInfo *coin, - const struct TALER_DenominationBlindingKeyP *coin_bks, + const struct + TALER_DenominationBlindingKeyP *coin_bks, const struct TALER_CoinSpendSignatureP *coin_sig, int refreshed) { @@ -432,7 +445,8 @@ verify_and_execute_payback (struct MHD_Connection *connection, if (NULL == dki) { TEH_KS_release (key_state); - TALER_LOG_WARNING ("Denomination key in /payback request not in payback mode\n"); + TALER_LOG_WARNING ( + "Denomination key in /payback request not in payback mode\n"); return TEH_RESPONSE_reply_arg_unknown (connection, TALER_EC_PAYBACK_DENOMINATION_KEY_UNKNOWN, "denom_pub"); @@ -527,16 +541,16 @@ verify_and_execute_payback (struct MHD_Connection *connection, return mhd_ret; } return (refreshed) - ? reply_payback_refresh_success (connection, - &coin->coin_pub, - &pc.target.old_coin_pub, - &pc.amount, - pc.now) - : reply_payback_success (connection, - &coin->coin_pub, - &pc.target.reserve_pub, - &pc.amount, - pc.now); + ? reply_payback_refresh_success (connection, + &coin->coin_pub, + &pc.target.old_coin_pub, + &pc.amount, + pc.now) + : reply_payback_success (connection, + &coin->coin_pub, + &pc.target.reserve_pub, + &pc.amount, + pc.now); } @@ -579,8 +593,8 @@ TEH_PAYBACK_handler_payback (struct TEH_RequestHandler *rh, GNUNET_JSON_spec_fixed_auto ("coin_sig", &coin_sig), GNUNET_JSON_spec_mark_optional - (GNUNET_JSON_spec_boolean ("refreshed", - &refreshed)), + (GNUNET_JSON_spec_boolean ("refreshed", + &refreshed)), GNUNET_JSON_spec_end () }; diff --git a/src/exchange/taler-exchange-httpd_refresh_link.c b/src/exchange/taler-exchange-httpd_refresh_link.c index b6712f75..e5a33230 100644 --- a/src/exchange/taler-exchange-httpd_refresh_link.c +++ b/src/exchange/taler-exchange-httpd_refresh_link.c @@ -88,10 +88,12 @@ handle_link_data (void *cls, goto fail; json_object_set_new (obj, "denom_pub", - GNUNET_JSON_from_rsa_public_key (pos->denom_pub.rsa_public_key)); + GNUNET_JSON_from_rsa_public_key ( + pos->denom_pub.rsa_public_key)); json_object_set_new (obj, "ev_sig", - GNUNET_JSON_from_rsa_signature (pos->ev_sig.rsa_signature)); + GNUNET_JSON_from_rsa_signature ( + pos->ev_sig.rsa_signature)); json_object_set_new (obj, "link_sig", GNUNET_JSON_from_data_auto (&pos->orig_coin_link_sig)); @@ -113,7 +115,7 @@ handle_link_data (void *cls, root)) goto fail; return; - fail: + fail: ctx->ec = TALER_EC_JSON_ALLOCATION_FAILURE; json_decref (ctx->mlist); ctx->mlist = NULL; @@ -140,9 +142,9 @@ handle_link_data (void *cls, */ static enum GNUNET_DB_QueryStatus refresh_link_transaction (void *cls, - struct MHD_Connection *connection, - struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + struct MHD_Connection *connection, + struct TALER_EXCHANGEDB_Session *session, + int *mhd_ret) { struct HTD_Context *ctx = cls; enum GNUNET_DB_QueryStatus qs; @@ -162,8 +164,8 @@ refresh_link_transaction (void *cls, if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) { *mhd_ret = TEH_RESPONSE_reply_arg_unknown (connection, - TALER_EC_REFRESH_LINK_COIN_UNKNOWN, - "coin_pub"); + TALER_EC_REFRESH_LINK_COIN_UNKNOWN, + "coin_pub"); return GNUNET_DB_STATUS_HARD_ERROR; } return qs; @@ -193,12 +195,13 @@ TEH_REFRESH_handler_refresh_link (struct TEH_RequestHandler *rh, struct HTD_Context ctx; memset (&ctx, - 0, - sizeof (ctx)); + 0, + sizeof (ctx)); res = TEH_PARSE_mhd_request_arg_data (connection, "coin_pub", &ctx.coin_pub, - sizeof (struct TALER_CoinSpendPublicKeyP)); + sizeof (struct + TALER_CoinSpendPublicKeyP)); if (GNUNET_SYSERR == res) return MHD_NO; if (GNUNET_OK != res) diff --git a/src/exchange/taler-exchange-httpd_refresh_melt.c b/src/exchange/taler-exchange-httpd_refresh_melt.c index 8677d627..702857b8 100644 --- a/src/exchange/taler-exchange-httpd_refresh_melt.c +++ b/src/exchange/taler-exchange-httpd_refresh_melt.c @@ -48,9 +48,11 @@ */ static int reply_refresh_melt_insufficient_funds (struct MHD_Connection *connection, - const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct + TALER_CoinSpendPublicKeyP *coin_pub, struct TALER_Amount coin_value, - struct TALER_EXCHANGEDB_TransactionList *tl, + struct TALER_EXCHANGEDB_TransactionList * + tl, const struct TALER_Amount *requested, const struct TALER_Amount *residual) { @@ -59,14 +61,15 @@ reply_refresh_melt_insufficient_funds (struct MHD_Connection *connection, history = TEH_RESPONSE_compile_transaction_history (tl); if (NULL == history) return TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_REFRESH_MELT_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS); + TALER_EC_REFRESH_MELT_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS); return TEH_RESPONSE_reply_json_pack (connection, MHD_HTTP_FORBIDDEN, "{s:s, s:I, s:o, s:o, s:o, s:o, s:o}", "error", "insufficient funds", "code", - (json_int_t) TALER_EC_REFRESH_MELT_INSUFFICIENT_FUNDS, + (json_int_t) + TALER_EC_REFRESH_MELT_INSUFFICIENT_FUNDS, "coin_pub", GNUNET_JSON_from_data_auto (coin_pub), "original_value", @@ -104,8 +107,8 @@ reply_refresh_melt_success (struct MHD_Connection *connection, body.noreveal_index = htonl (noreveal_index); if (GNUNET_OK != TEH_KS_sign (&body.purpose, - &pub, - &sig)) + &pub, + &sig)) { return TEH_RESPONSE_reply_internal_error (connection, TALER_EC_EXCHANGE_BAD_CONFIGURATION, @@ -118,7 +121,8 @@ reply_refresh_melt_success (struct MHD_Connection *connection, "{s:i, s:o, s:o}", "noreveal_index", (int) noreveal_index, "exchange_sig", sig_json, - "exchange_pub", GNUNET_JSON_from_data_auto (&pub)); + "exchange_pub", + GNUNET_JSON_from_data_auto (&pub)); } @@ -238,10 +242,12 @@ refresh_check_melt (struct MHD_Connection *connection, &spent, &rmc->refresh_session.amount_with_fee)); *mhd_ret = reply_refresh_melt_insufficient_funds (connection, - &rmc->refresh_session.coin.coin_pub, + &rmc->refresh_session.coin + .coin_pub, coin_value, tl, - &rmc->refresh_session.amount_with_fee, + &rmc->refresh_session. + amount_with_fee, &coin_residual); TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); @@ -365,8 +371,8 @@ handle_refresh_melt (struct MHD_Connection *connection, { GNUNET_break_op (0); return TEH_RESPONSE_reply_external_error (connection, - TALER_EC_REFRESH_MELT_FEES_EXCEED_CONTRIBUTION, - "melt amount smaller than melting fee"); + TALER_EC_REFRESH_MELT_FEES_EXCEED_CONTRIBUTION, + "melt amount smaller than melting fee"); } } @@ -374,19 +380,22 @@ handle_refresh_melt (struct MHD_Connection *connection, { struct TALER_RefreshMeltCoinAffirmationPS body; - body.purpose.size = htonl (sizeof (struct TALER_RefreshMeltCoinAffirmationPS)); + body.purpose.size = htonl (sizeof (struct + TALER_RefreshMeltCoinAffirmationPS)); body.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT); body.rc = rmc->refresh_session.rc; TALER_amount_hton (&body.amount_with_fee, - &rmc->refresh_session.amount_with_fee); + &rmc->refresh_session.amount_with_fee); body.melt_fee = rmc->dki->issue.properties.fee_refresh; body.coin_pub = rmc->refresh_session.coin.coin_pub; if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_COIN_MELT, &body.purpose, - &rmc->refresh_session.coin_sig.eddsa_signature, - &rmc->refresh_session.coin.coin_pub.eddsa_pub)) + &rmc->refresh_session.coin_sig. + eddsa_signature, + &rmc->refresh_session.coin.coin_pub. + eddsa_pub)) { GNUNET_break_op (0); return TEH_RESPONSE_reply_signature_invalid (connection, @@ -489,7 +498,8 @@ TEH_REFRESH_handler_refresh_melt (struct TEH_RequestHandler *rh, /* Baseline: check if deposits/refreshs are generally simply still allowed for this denomination */ rmc.dki = TEH_KS_denomination_key_lookup_by_hash (key_state, - &rmc.refresh_session.coin.denom_pub_hash, + &rmc.refresh_session.coin. + denom_pub_hash, TEH_KS_DKU_DEPOSIT); /* Consider case that denomination was revoked but this coin was already seen and thus refresh is OK. */ @@ -498,7 +508,8 @@ TEH_REFRESH_handler_refresh_melt (struct TEH_RequestHandler *rh, struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki; dki = TEH_KS_denomination_key_lookup_by_hash (key_state, - &rmc.refresh_session.coin.denom_pub_hash, + &rmc.refresh_session.coin. + denom_pub_hash, TEH_KS_DKU_PAYBACK); if (NULL != dki) { @@ -533,7 +544,8 @@ TEH_REFRESH_handler_refresh_melt (struct TEH_RequestHandler *rh, struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki; dki = TEH_KS_denomination_key_lookup_by_hash (key_state, - &rmc.refresh_session.coin.denom_pub_hash, + &rmc.refresh_session.coin. + denom_pub_hash, TEH_KS_DKU_ZOMBIE); if (NULL != dki) { @@ -585,7 +597,7 @@ TEH_REFRESH_handler_refresh_melt (struct TEH_RequestHandler *rh, &rmc); - cleanup: + cleanup: if (NULL != key_state) { TEH_KS_release (key_state); @@ -593,7 +605,8 @@ TEH_REFRESH_handler_refresh_melt (struct TEH_RequestHandler *rh, } if (NULL != rmc.refresh_session.coin.denom_sig.rsa_signature) { - GNUNET_CRYPTO_rsa_signature_free (rmc.refresh_session.coin.denom_sig.rsa_signature); + GNUNET_CRYPTO_rsa_signature_free ( + rmc.refresh_session.coin.denom_sig.rsa_signature); rmc.refresh_session.coin.denom_sig.rsa_signature = NULL; } GNUNET_JSON_parse_free (spec); diff --git a/src/exchange/taler-exchange-httpd_refresh_reveal.c b/src/exchange/taler-exchange-httpd_refresh_reveal.c index 47287b15..a84e5dea 100644 --- a/src/exchange/taler-exchange-httpd_refresh_reveal.c +++ b/src/exchange/taler-exchange-httpd_refresh_reveal.c @@ -54,8 +54,8 @@ */ static int reply_refresh_reveal_success (struct MHD_Connection *connection, - unsigned int num_newcoins, - const struct TALER_DenominationSignature *sigs) + unsigned int num_newcoins, + const struct TALER_DenominationSignature *sigs) { json_t *list; int ret; @@ -69,8 +69,9 @@ reply_refresh_reveal_success (struct MHD_Connection *connection, obj = json_object (); json_object_set_new (obj, - "ev_sig", - GNUNET_JSON_from_rsa_signature (sigs[newcoin_index].rsa_signature)); + "ev_sig", + GNUNET_JSON_from_rsa_signature ( + sigs[newcoin_index].rsa_signature)); GNUNET_assert (0 == json_array_append_new (list, obj)); @@ -102,14 +103,17 @@ reply_refresh_reveal_success (struct MHD_Connection *connection, */ static int reply_refresh_reveal_missmatch (struct MHD_Connection *connection, - const struct TALER_RefreshCommitmentP *rc) + const struct TALER_RefreshCommitmentP *rc) { return TEH_RESPONSE_reply_json_pack (connection, MHD_HTTP_CONFLICT, "{s:s, s:I, s:o}", "error", "commitment violation", - "code", (json_int_t) TALER_EC_REFRESH_REVEAL_COMMITMENT_VIOLATION, - "rc_expected", GNUNET_JSON_from_data_auto (rc)); + "code", + (json_int_t) + TALER_EC_REFRESH_REVEAL_COMMITMENT_VIOLATION, + "rc_expected", + GNUNET_JSON_from_data_auto (rc)); } @@ -205,14 +209,15 @@ check_exists_cb (void *cls, sizeof (struct TALER_TransferPublicKeyP))); GNUNET_break_op (0 == memcmp (tprivs, &rctx->transfer_privs, - sizeof (struct TALER_TransferPrivateKeyP) * num_tprivs)); + sizeof (struct TALER_TransferPrivateKeyP) + * num_tprivs)); /* We usually sign early (optimistic!), but in case we change that *and* we do find the operation in the database, we could use this: */ if (NULL == rctx->ev_sigs) { rctx->ev_sigs = GNUNET_new_array (num_newcoins, struct TALER_DenominationSignature); - for (unsigned int i=0;i<num_newcoins;i++) + for (unsigned int i = 0; i<num_newcoins; i++) rctx->ev_sigs[i].rsa_signature = GNUNET_CRYPTO_rsa_signature_dup (rrcs[i].coin_sig.rsa_signature); } @@ -245,7 +250,8 @@ refresh_reveal_preflight (void *cls, &rctx->rc, &check_exists_cb, rctx); - switch (qs) { + switch (qs) + { case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: return qs; /* continue normal execution */ case GNUNET_DB_STATUS_SOFT_ERROR: @@ -253,7 +259,7 @@ refresh_reveal_preflight (void *cls, case GNUNET_DB_STATUS_HARD_ERROR: GNUNET_break (qs); *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_REFRESH_REVEAL_DB_FETCH_REVEAL_ERROR); + TALER_EC_REFRESH_REVEAL_DB_FETCH_REVEAL_ERROR); rctx->preflight_ok = GNUNET_SYSERR; return GNUNET_DB_STATUS_HARD_ERROR; case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: @@ -275,7 +281,8 @@ refresh_reveal_preflight (void *cls, static void free_refresh_melt (struct TALER_EXCHANGEDB_RefreshMelt *refresh_melt) { - GNUNET_CRYPTO_rsa_signature_free (refresh_melt->session.coin.denom_sig.rsa_signature); + GNUNET_CRYPTO_rsa_signature_free ( + refresh_melt->session.coin.denom_sig.rsa_signature); } @@ -299,9 +306,9 @@ free_refresh_melt (struct TALER_EXCHANGEDB_RefreshMelt *refresh_melt) */ static enum GNUNET_DB_QueryStatus refresh_reveal_transaction (void *cls, - struct MHD_Connection *connection, - struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + struct MHD_Connection *connection, + struct TALER_EXCHANGEDB_Session *session, + int *mhd_ret) { struct RevealContext *rctx = cls; struct TALER_EXCHANGEDB_RefreshMelt refresh_melt; @@ -316,8 +323,8 @@ refresh_reveal_transaction (void *cls, if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) { *mhd_ret = TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_REFRESH_REVEAL_SESSION_UNKNOWN, - "rc"); + TALER_EC_REFRESH_REVEAL_SESSION_UNKNOWN, + "rc"); return GNUNET_DB_STATUS_HARD_ERROR; } if (GNUNET_DB_STATUS_SOFT_ERROR == qs) @@ -327,7 +334,7 @@ refresh_reveal_transaction (void *cls, { GNUNET_break (0); *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_REFRESH_REVEAL_DB_FETCH_SESSION_ERROR); + TALER_EC_REFRESH_REVEAL_DB_FETCH_SESSION_ERROR); if (refresh_melt.session.noreveal_index >= TALER_CNC_KAPPA) free_refresh_melt (&refresh_melt); return GNUNET_DB_STATUS_HARD_ERROR; @@ -343,7 +350,7 @@ refresh_reveal_transaction (void *cls, unsigned int off; off = 0; /* did we pass session.noreveal_index yet? */ - for (unsigned int i=0;i<TALER_CNC_KAPPA;i++) + for (unsigned int i = 0; i<TALER_CNC_KAPPA; i++) { struct TALER_RefreshCommitmentEntry *rce = &rcs[i]; @@ -357,7 +364,8 @@ refresh_reveal_transaction (void *cls, else { /* Reconstruct coin envelopes from transfer private key */ - struct TALER_TransferPrivateKeyP *tpriv = &rctx->transfer_privs[i - off]; + struct TALER_TransferPrivateKeyP *tpriv = &rctx->transfer_privs[i + - off]; struct TALER_TransferSecretP ts; GNUNET_CRYPTO_ecdhe_key_get_public (&tpriv->ecdhe_priv, @@ -367,7 +375,7 @@ refresh_reveal_transaction (void *cls, &ts); rce->new_coins = GNUNET_new_array (rctx->num_fresh_coins, struct TALER_RefreshCoinData); - for (unsigned int j=0;j<rctx->num_fresh_coins;j++) + for (unsigned int j = 0; j<rctx->num_fresh_coins; j++) { struct TALER_RefreshCoinData *rcd = &rce->new_coins[j]; struct TALER_PlanchetSecretsP ps; @@ -394,13 +402,13 @@ refresh_reveal_transaction (void *cls, &refresh_melt.session.amount_with_fee); /* Free resources allocated above */ - for (unsigned int i=0;i<TALER_CNC_KAPPA;i++) + for (unsigned int i = 0; i<TALER_CNC_KAPPA; i++) { struct TALER_RefreshCommitmentEntry *rce = &rcs[i]; if (i == refresh_melt.session.noreveal_index) continue; /* This offset is special... */ - for (unsigned int j=0;j<rctx->num_fresh_coins;j++) + for (unsigned int j = 0; j<rctx->num_fresh_coins; j++) { struct TALER_RefreshCoinData *rcd = &rce->new_coins[j]; @@ -426,7 +434,7 @@ refresh_reveal_transaction (void *cls, struct TALER_Amount refresh_cost; refresh_cost = refresh_melt.melt_fee; - for (unsigned int i=0;i<rctx->num_fresh_coins;i++) + for (unsigned int i = 0; i<rctx->num_fresh_coins; i++) { struct TALER_Amount fee_withdraw; struct TALER_Amount value; @@ -492,7 +500,7 @@ refresh_reveal_persist (void *cls, { struct TALER_EXCHANGEDB_RefreshRevealedCoin rrcs[rctx->num_fresh_coins]; - for (unsigned int i=0;i<rctx->num_fresh_coins;i++) + for (unsigned int i = 0; i<rctx->num_fresh_coins; i++) { struct TALER_EXCHANGEDB_RefreshRevealedCoin *rrc = &rrcs[i]; @@ -564,7 +572,7 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, { GNUNET_break_op (0); return TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_REFRESH_REVEAL_NEW_DENOMS_ARRAY_SIZE_MISSMATCH, + TALER_EC_REFRESH_REVEAL_NEW_DENOMS_ARRAY_SIZE_MISSMATCH, "new_denoms/coin_evs"); } if (json_array_size (new_denoms_h_json) != @@ -577,7 +585,7 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, } /* Parse transfer private keys array */ - for (unsigned int i=0;i<num_tprivs;i++) + for (unsigned int i = 0; i<num_tprivs; i++) { struct GNUNET_JSON_Specification trans_spec[] = { GNUNET_JSON_spec_fixed_auto (NULL, &rctx->transfer_privs[i]), @@ -596,7 +604,8 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, /* Resolve denomination hashes */ { - const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dkis[num_fresh_coins]; + const struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation *dkis[num_fresh_coins]; struct GNUNET_HashCode dki_h[num_fresh_coins]; struct TALER_RefreshCoinData rcds[num_fresh_coins]; struct TALER_CoinSpendSignatureP link_sigs[num_fresh_coins]; @@ -614,7 +623,7 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, } /* Parse denomination key hashes */ - for (unsigned int i=0;i<num_fresh_coins;i++) + for (unsigned int i = 0; i<num_fresh_coins; i++) { struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto (NULL, @@ -646,7 +655,7 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, } /* Parse coin envelopes */ - for (unsigned int i=0;i<num_fresh_coins;i++) + for (unsigned int i = 0; i<num_fresh_coins; i++) { struct TALER_RefreshCoinData *rcd = &rcds[i]; struct GNUNET_JSON_Specification spec[] = { @@ -663,7 +672,7 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, -1); if (GNUNET_OK != res) { - for (unsigned int j=0;j<i;j++) + for (unsigned int j = 0; j<i; j++) GNUNET_free_non_null (rcds[j].coin_ev); TEH_KS_release (key_state); return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -703,11 +712,11 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, } } /* Parse link signatures array */ - for (unsigned int i=0;i<num_fresh_coins;i++) + for (unsigned int i = 0; i<num_fresh_coins; i++) { struct GNUNET_JSON_Specification link_spec[] = { - GNUNET_JSON_spec_fixed_auto (NULL, &link_sigs[i]), - GNUNET_JSON_spec_end () + GNUNET_JSON_spec_fixed_auto (NULL, &link_sigs[i]), + GNUNET_JSON_spec_end () }; int res; @@ -734,7 +743,8 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_COIN_LINK, &ldp.purpose, &link_sigs[i].eddsa_signature, - &refresh_melt.session.coin.coin_pub.eddsa_pub)) + &refresh_melt.session.coin.coin_pub. + eddsa_pub)) { GNUNET_break_op (0); res = TEH_RESPONSE_reply_signature_invalid (connection, @@ -753,12 +763,13 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, /* sign _early_ (optimistic!) to keep out of transaction scope! */ rctx->ev_sigs = GNUNET_new_array (rctx->num_fresh_coins, struct TALER_DenominationSignature); - for (unsigned int i=0;i<rctx->num_fresh_coins;i++) + for (unsigned int i = 0; i<rctx->num_fresh_coins; i++) { rctx->ev_sigs[i].rsa_signature - = GNUNET_CRYPTO_rsa_sign_blinded (rctx->dkis[i]->denom_priv.rsa_private_key, - rctx->rcds[i].coin_ev, - rctx->rcds[i].coin_ev_size); + = GNUNET_CRYPTO_rsa_sign_blinded ( + rctx->dkis[i]->denom_priv.rsa_private_key, + rctx->rcds[i].coin_ev, + rctx->rcds[i].coin_ev_size); if (NULL == rctx->ev_sigs[i].rsa_signature) { GNUNET_break (0); @@ -772,7 +783,7 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, the pre-check might be satisfied by a concurrent transaction voiding our final commit due to uniqueness violation; naturally, on hard errors we exit immediately */ - for (unsigned int retries=0;retries < MAX_REVEAL_RETRIES;retries++) + for (unsigned int retries = 0; retries < MAX_REVEAL_RETRIES; retries++) { /* do transactional work */ rctx->preflight_ok = GNUNET_NO; @@ -825,17 +836,17 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, } /* end for (retries...) */ GNUNET_break (MHD_NO != res); - cleanup: + cleanup: GNUNET_break (MHD_NO != res); /* free resources */ if (NULL != rctx->ev_sigs) { - for (unsigned int i=0;i<num_fresh_coins;i++) + for (unsigned int i = 0; i<num_fresh_coins; i++) if (NULL != rctx->ev_sigs[i].rsa_signature) GNUNET_CRYPTO_rsa_signature_free (rctx->ev_sigs[i].rsa_signature); GNUNET_free (rctx->ev_sigs); } - for (unsigned int i=0;i<num_fresh_coins;i++) + for (unsigned int i = 0; i<num_fresh_coins; i++) GNUNET_free_non_null (rcds[i].coin_ev); TEH_KS_release (key_state); return res; diff --git a/src/exchange/taler-exchange-httpd_refund.c b/src/exchange/taler-exchange-httpd_refund.c index 5fea37da..ce66d657 100644 --- a/src/exchange/taler-exchange-httpd_refund.c +++ b/src/exchange/taler-exchange-httpd_refund.c @@ -45,7 +45,7 @@ */ static int reply_refund_success (struct MHD_Connection *connection, - const struct TALER_EXCHANGEDB_Refund *refund) + const struct TALER_EXCHANGEDB_Refund *refund) { struct TALER_RefundConfirmationPS rc; struct TALER_ExchangePublicKeyP pub; @@ -63,8 +63,8 @@ reply_refund_success (struct MHD_Connection *connection, &refund->refund_fee); if (GNUNET_OK != TEH_KS_sign (&rc.purpose, - &pub, - &sig)) + &pub, + &sig)) { return TEH_RESPONSE_reply_internal_error (connection, TALER_EC_EXCHANGE_BAD_CONFIGURATION, @@ -75,7 +75,8 @@ reply_refund_success (struct MHD_Connection *connection, "{s:s, s:o, s:o}", "status", "REFUND_OK", "sig", GNUNET_JSON_from_data_auto (&sig), - "pub", GNUNET_JSON_from_data_auto (&pub)); + "pub", GNUNET_JSON_from_data_auto ( + &pub)); } @@ -90,14 +91,14 @@ reply_refund_success (struct MHD_Connection *connection, */ static int reply_refund_failure (struct MHD_Connection *connection, - unsigned int response_code, - enum TALER_ErrorCode ec) + unsigned int response_code, + enum TALER_ErrorCode ec) { return TEH_RESPONSE_reply_json_pack (connection, response_code, "{s:s, s:I}", "status", "refund failure", - "code", (json_int_t) ec); + "code", (json_int_t) ec); } @@ -111,14 +112,17 @@ reply_refund_failure (struct MHD_Connection *connection, */ static int reply_refund_conflict (struct MHD_Connection *connection, - const struct TALER_EXCHANGEDB_TransactionList *tl) + const struct TALER_EXCHANGEDB_TransactionList *tl) { return TEH_RESPONSE_reply_json_pack (connection, MHD_HTTP_CONFLICT, "{s:s, s:I, s:o}", "status", "conflicting refund", - "code", (json_int_t) TALER_EC_REFUND_CONFLICT, - "history", TEH_RESPONSE_compile_transaction_history (tl)); + "code", + (json_int_t) TALER_EC_REFUND_CONFLICT, + "history", + TEH_RESPONSE_compile_transaction_history ( + tl)); } @@ -142,9 +146,9 @@ reply_refund_conflict (struct MHD_Connection *connection, */ static enum GNUNET_DB_QueryStatus refund_transaction (void *cls, - struct MHD_Connection *connection, - struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + struct MHD_Connection *connection, + struct TALER_EXCHANGEDB_Session *session, + int *mhd_ret) { const struct TALER_EXCHANGEDB_Refund *refund = cls; struct TALER_EXCHANGEDB_TransactionList *tl; @@ -170,8 +174,8 @@ refund_transaction (void *cls, { if (GNUNET_DB_STATUS_HARD_ERROR == qs) *mhd_ret = reply_refund_failure (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_REFUND_COIN_NOT_FOUND); + MHD_HTTP_NOT_FOUND, + TALER_EC_REFUND_COIN_NOT_FOUND); return qs; } deposit_found = GNUNET_NO; @@ -254,14 +258,14 @@ refund_transaction (void *cls, TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); *mhd_ret = TEH_RESPONSE_reply_transaction_unknown (connection, - TALER_EC_REFUND_DEPOSIT_NOT_FOUND); + TALER_EC_REFUND_DEPOSIT_NOT_FOUND); return GNUNET_DB_STATUS_HARD_ERROR; } /* handle if conflicting refund found */ if (GNUNET_SYSERR == refund_found) { *mhd_ret = reply_refund_conflict (connection, - tl); + tl); TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); return GNUNET_DB_STATUS_HARD_ERROR; @@ -271,7 +275,7 @@ refund_transaction (void *cls, { /* /refund already done, simply re-transmit confirmation */ *mhd_ret = reply_refund_success (connection, - ref); + ref); TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); return GNUNET_DB_STATUS_HARD_ERROR; @@ -287,15 +291,15 @@ refund_transaction (void *cls, { GNUNET_break_op (0); /* currency missmatch */ *mhd_ret = reply_refund_failure (connection, - MHD_HTTP_PRECONDITION_FAILED, - TALER_EC_REFUND_CURRENCY_MISSMATCH); + MHD_HTTP_PRECONDITION_FAILED, + TALER_EC_REFUND_CURRENCY_MISSMATCH); return GNUNET_DB_STATUS_HARD_ERROR; } /* check if we already send the money for the /deposit */ qs = TEH_plugin->test_deposit_done (TEH_plugin->cls, - session, - dep); + session, + dep); if (GNUNET_DB_STATUS_HARD_ERROR == qs) { /* Internal error, we first had the deposit in the history, @@ -304,8 +308,8 @@ refund_transaction (void *cls, TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); *mhd_ret = TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_REFUND_DB_INCONSISTENT, - "database inconsistent"); + TALER_EC_REFUND_DB_INCONSISTENT, + "database inconsistent"); return qs; } if (GNUNET_DB_STATUS_SOFT_ERROR == qs) @@ -317,8 +321,8 @@ refund_transaction (void *cls, TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); *mhd_ret = reply_refund_failure (connection, - MHD_HTTP_GONE, - TALER_EC_REFUND_MERCHANT_ALREADY_PAID); + MHD_HTTP_GONE, + TALER_EC_REFUND_MERCHANT_ALREADY_PAID); return GNUNET_DB_STATUS_HARD_ERROR; } @@ -330,8 +334,8 @@ refund_transaction (void *cls, TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); *mhd_ret = reply_refund_failure (connection, - MHD_HTTP_PRECONDITION_FAILED, - TALER_EC_REFUND_INSUFFICIENT_FUNDS); + MHD_HTTP_PRECONDITION_FAILED, + TALER_EC_REFUND_INSUFFICIENT_FUNDS); return GNUNET_DB_STATUS_HARD_ERROR; } @@ -360,8 +364,8 @@ refund_transaction (void *cls, TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); *mhd_ret = TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_REFUND_DENOMINATION_KEY_NOT_FOUND, - "denomination key not found"); + TALER_EC_REFUND_DENOMINATION_KEY_NOT_FOUND, + "denomination key not found"); return GNUNET_DB_STATUS_HARD_ERROR; } TALER_amount_ntoh (&expect_fee, @@ -375,8 +379,8 @@ refund_transaction (void *cls, TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); *mhd_ret = TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_REFUND_FEE_TOO_LOW, - "refund_fee"); + TALER_EC_REFUND_FEE_TOO_LOW, + "refund_fee"); return GNUNET_DB_STATUS_HARD_ERROR; } if (1 == fee_cmp) @@ -389,13 +393,13 @@ refund_transaction (void *cls, /* Finally, store new refund data */ qs = TEH_plugin->insert_refund (TEH_plugin->cls, - session, - refund); + session, + refund); if (GNUNET_DB_STATUS_HARD_ERROR == qs) { TALER_LOG_WARNING ("Failed to store /refund information in database\n"); *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_REFUND_STORE_DB_ERROR); + TALER_EC_REFUND_STORE_DB_ERROR); return qs; } /* Success or soft failure */ @@ -415,7 +419,7 @@ refund_transaction (void *cls, */ static int verify_and_execute_refund (struct MHD_Connection *connection, - const struct TALER_EXCHANGEDB_Refund *refund) + const struct TALER_EXCHANGEDB_Refund *refund) { struct TALER_RefundRequestPS rr; int mhd_ret; @@ -436,7 +440,7 @@ verify_and_execute_refund (struct MHD_Connection *connection, { GNUNET_break_op (0); return TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_REFUND_FEE_CURRENCY_MISSMATCH, + TALER_EC_REFUND_FEE_CURRENCY_MISSMATCH, "refund_fee"); } if (-1 == TALER_amount_cmp (&refund->refund_amount, @@ -444,8 +448,8 @@ verify_and_execute_refund (struct MHD_Connection *connection, { GNUNET_break_op (0); return TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_REFUND_FEE_ABOVE_AMOUNT, - "refund_amount"); + TALER_EC_REFUND_FEE_ABOVE_AMOUNT, + "refund_amount"); } if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_REFUND, @@ -455,18 +459,18 @@ verify_and_execute_refund (struct MHD_Connection *connection, { TALER_LOG_WARNING ("Invalid signature on /refund request\n"); return TEH_RESPONSE_reply_signature_invalid (connection, - TALER_EC_REFUND_MERCHANT_SIGNATURE_INVALID, + TALER_EC_REFUND_MERCHANT_SIGNATURE_INVALID, "merchant_sig"); } if (GNUNET_OK != TEH_DB_run_transaction (connection, "run refund", - &mhd_ret, - &refund_transaction, - (void *) refund)) + &mhd_ret, + &refund_transaction, + (void *) refund)) return mhd_ret; return reply_refund_success (connection, - refund); + refund); } @@ -486,10 +490,10 @@ verify_and_execute_refund (struct MHD_Connection *connection, */ int TEH_REFUND_handler_refund (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { json_t *json; int res; @@ -523,7 +527,7 @@ TEH_REFUND_handler_refund (struct TEH_RequestHandler *rh, if (GNUNET_NO == res) return MHD_YES; /* failure */ res = verify_and_execute_refund (connection, - &refund); + &refund); GNUNET_JSON_parse_free (spec); return res; } diff --git a/src/exchange/taler-exchange-httpd_refund.h b/src/exchange/taler-exchange-httpd_refund.h index 1fa52b14..ce5aa351 100644 --- a/src/exchange/taler-exchange-httpd_refund.h +++ b/src/exchange/taler-exchange-httpd_refund.h @@ -44,9 +44,9 @@ */ int TEH_REFUND_handler_refund (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); #endif diff --git a/src/exchange/taler-exchange-httpd_reserve_status.c b/src/exchange/taler-exchange-httpd_reserve_status.c index 6ff73de7..a3f4dac9 100644 --- a/src/exchange/taler-exchange-httpd_reserve_status.c +++ b/src/exchange/taler-exchange-httpd_reserve_status.c @@ -38,17 +38,17 @@ */ static int reply_reserve_status_success (struct MHD_Connection *connection, - const struct TALER_EXCHANGEDB_ReserveHistory *rh) + const struct TALER_EXCHANGEDB_ReserveHistory *rh) { json_t *json_balance; json_t *json_history; struct TALER_Amount balance; json_history = TEH_RESPONSE_compile_reserve_history (rh, - &balance); + &balance); if (NULL == json_history) return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_RESERVE_STATUS_DB_ERROR, + TALER_EC_RESERVE_STATUS_DB_ERROR, "balance calculation failure"); json_balance = TALER_JSON_from_amount (&balance); return TEH_RESPONSE_reply_json_pack (connection, @@ -96,16 +96,16 @@ struct ReserveStatusContext */ static enum GNUNET_DB_QueryStatus reserve_status_transaction (void *cls, - struct MHD_Connection *connection, - struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + struct MHD_Connection *connection, + struct TALER_EXCHANGEDB_Session *session, + int *mhd_ret) { struct ReserveStatusContext *rsc = cls; return TEH_plugin->get_reserve_history (TEH_plugin->cls, - session, - &rsc->reserve_pub, - &rsc->rh); + session, + &rsc->reserve_pub, + &rsc->rh); } @@ -136,7 +136,8 @@ TEH_RESERVE_handler_reserve_status (struct TEH_RequestHandler *rh, res = TEH_PARSE_mhd_request_arg_data (connection, "reserve_pub", &rsc.reserve_pub, - sizeof (struct TALER_ReservePublicKeyP)); + sizeof (struct + TALER_ReservePublicKeyP)); if (GNUNET_SYSERR == res) return MHD_NO; /* internal error */ if (GNUNET_NO == res) @@ -145,9 +146,9 @@ TEH_RESERVE_handler_reserve_status (struct TEH_RequestHandler *rh, if (GNUNET_OK != TEH_DB_run_transaction (connection, "get reserve status", - &mhd_ret, - &reserve_status_transaction, - &rsc)) + &mhd_ret, + &reserve_status_transaction, + &rsc)) return mhd_ret; /* generate proper response */ @@ -157,9 +158,11 @@ TEH_RESERVE_handler_reserve_status (struct TEH_RequestHandler *rh, "{s:s, s:s, s:I}", "error", "Reserve not found", "parameter", "withdraw_pub", - "code", (json_int_t) TALER_EC_RESERVE_STATUS_UNKNOWN); + "code", + (json_int_t) + TALER_EC_RESERVE_STATUS_UNKNOWN); mhd_ret = reply_reserve_status_success (connection, - rsc.rh); + rsc.rh); TEH_plugin->free_reserve_history (TEH_plugin->cls, rsc.rh); return mhd_ret; diff --git a/src/exchange/taler-exchange-httpd_reserve_withdraw.c b/src/exchange/taler-exchange-httpd_reserve_withdraw.c index 65bca25e..e5829d9d 100644 --- a/src/exchange/taler-exchange-httpd_reserve_withdraw.c +++ b/src/exchange/taler-exchange-httpd_reserve_withdraw.c @@ -52,7 +52,8 @@ */ static int reply_reserve_withdraw_insufficient_funds (struct MHD_Connection *connection, - const struct TALER_EXCHANGEDB_ReserveHistory *rh) + const struct + TALER_EXCHANGEDB_ReserveHistory *rh) { json_t *json_balance; json_t *json_history; @@ -65,7 +66,7 @@ reply_reserve_withdraw_insufficient_funds (struct MHD_Connection *connection, * it fails "internally" to dump as string (= corrupted). */ || (0 == json_dumpb (json_history, NULL, 0, 0))) return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_WITHDRAW_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS, + TALER_EC_WITHDRAW_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS, "balance calculation failure"); json_balance = TALER_JSON_from_amount (&balance); @@ -73,7 +74,9 @@ reply_reserve_withdraw_insufficient_funds (struct MHD_Connection *connection, MHD_HTTP_FORBIDDEN, "{s:s, s:I, s:o, s:o}", "error", "Insufficient funds", - "code", (json_int_t) TALER_EC_WITHDRAW_INSUFFICIENT_FUNDS, + "code", + (json_int_t) + TALER_EC_WITHDRAW_INSUFFICIENT_FUNDS, "balance", json_balance, "history", json_history); } @@ -88,7 +91,9 @@ reply_reserve_withdraw_insufficient_funds (struct MHD_Connection *connection, */ static int reply_reserve_withdraw_success (struct MHD_Connection *connection, - const struct TALER_EXCHANGEDB_CollectableBlindcoin *collectable) + const struct + TALER_EXCHANGEDB_CollectableBlindcoin * + collectable) { json_t *sig_json; @@ -205,7 +210,7 @@ withdraw_transaction (void *cls, GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); if (GNUNET_DB_STATUS_HARD_ERROR == qs) *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_WITHDRAW_DB_FETCH_ERROR); + TALER_EC_WITHDRAW_DB_FETCH_ERROR); wc->collectable.sig = denom_sig; return qs; } @@ -248,14 +253,14 @@ withdraw_transaction (void *cls, { if (GNUNET_DB_STATUS_HARD_ERROR == qs) *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_WITHDRAW_DB_FETCH_ERROR); + TALER_EC_WITHDRAW_DB_FETCH_ERROR); return qs; } if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) { *mhd_ret = TEH_RESPONSE_reply_arg_unknown (connection, - TALER_EC_WITHDRAW_RESERVE_UNKNOWN, - "reserve_pub"); + TALER_EC_WITHDRAW_RESERVE_UNKNOWN, + "reserve_pub"); return GNUNET_DB_STATUS_HARD_ERROR; } if (0 < TALER_amount_cmp (&wc->amount_required, @@ -293,7 +298,7 @@ withdraw_transaction (void *cls, } /* Balance is good, sign the coin! */ -#if !OPTIMISTIC_SIGN +#if ! OPTIMISTIC_SIGN if (NULL == wc->collectable.sig.rsa_signature) { wc->collectable.sig.rsa_signature @@ -326,7 +331,7 @@ withdraw_transaction (void *cls, GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); if (GNUNET_DB_STATUS_HARD_ERROR == qs) *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_WITHDRAW_DB_STORE_ERROR); + TALER_EC_WITHDRAW_DB_STORE_ERROR); return qs; } return qs; @@ -407,7 +412,7 @@ TEH_RESERVE_handler_reserve_withdraw (struct TEH_RequestHandler *rh, GNUNET_JSON_parse_free (spec); TEH_KS_release (wc.key_state); return TEH_RESPONSE_reply_arg_unknown (connection, - TALER_EC_WITHDRAW_DENOMINATION_KEY_NOT_FOUND, + TALER_EC_WITHDRAW_DENOMINATION_KEY_NOT_FOUND, "denom_pub"); } GNUNET_assert (NULL != wc.dki->denom_priv.rsa_private_key); @@ -417,14 +422,14 @@ TEH_RESERVE_handler_reserve_withdraw (struct TEH_RequestHandler *rh, &wc.dki->issue.properties.fee_withdraw); if (GNUNET_OK != TALER_amount_add (&wc.amount_required, - &amount, - &fee_withdraw)) + &amount, + &fee_withdraw)) { GNUNET_JSON_parse_free (spec); TEH_KS_release (wc.key_state); return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_WITHDRAW_AMOUNT_FEE_OVERFLOW, - "amount overflow for value plus withdraw fee"); + TALER_EC_WITHDRAW_AMOUNT_FEE_OVERFLOW, + "amount overflow for value plus withdraw fee"); } TALER_amount_hton (&wc.wsrd.amount_with_fee, &wc.amount_required); @@ -446,11 +451,12 @@ TEH_RESERVE_handler_reserve_withdraw (struct TEH_RequestHandler *rh, &wc.signature.eddsa_signature, &wc.wsrd.reserve_pub.eddsa_pub)) { - TALER_LOG_WARNING ("Client supplied invalid signature for /reserve/withdraw request\n"); + TALER_LOG_WARNING ( + "Client supplied invalid signature for /reserve/withdraw request\n"); GNUNET_JSON_parse_free (spec); TEH_KS_release (wc.key_state); return TEH_RESPONSE_reply_signature_invalid (connection, - TALER_EC_WITHDRAW_RESERVE_SIGNATURE_INVALID, + TALER_EC_WITHDRAW_RESERVE_SIGNATURE_INVALID, "reserve_sig"); } @@ -474,9 +480,9 @@ TEH_RESERVE_handler_reserve_withdraw (struct TEH_RequestHandler *rh, if (GNUNET_OK != TEH_DB_run_transaction (connection, "run reserve withdraw", - &mhd_ret, - &withdraw_transaction, - &wc)) + &mhd_ret, + &withdraw_transaction, + &wc)) { TEH_KS_release (wc.key_state); /* Even if #withdraw_transaction() failed, it may have created a signature @@ -490,7 +496,7 @@ TEH_RESERVE_handler_reserve_withdraw (struct TEH_RequestHandler *rh, GNUNET_JSON_parse_free (spec); mhd_ret = reply_reserve_withdraw_success (connection, - &wc.collectable); + &wc.collectable); GNUNET_CRYPTO_rsa_signature_free (wc.collectable.sig.rsa_signature); return mhd_ret; } diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c index f05e4260..1c2f92f0 100644 --- a/src/exchange/taler-exchange-httpd_responses.c +++ b/src/exchange/taler-exchange-httpd_responses.c @@ -74,22 +74,22 @@ TEH_RESPONSE_can_compress (struct MHD_Connection *connection) const char *de; ae = MHD_lookup_connection_value (connection, - MHD_HEADER_KIND, - MHD_HTTP_HEADER_ACCEPT_ENCODING); + MHD_HEADER_KIND, + MHD_HTTP_HEADER_ACCEPT_ENCODING); if (NULL == ae) return MHD_NO; if (0 == strcmp (ae, "*")) return MHD_YES; de = strstr (ae, - "deflate"); + "deflate"); if (NULL == de) return MHD_NO; if ( ( (de == ae) || - (de[-1] == ',') || - (de[-1] == ' ') ) && + (de[-1] == ',') || + (de[-1] == ' ') ) && ( (de[strlen ("deflate")] == '\0') || - (de[strlen ("deflate")] == ',') || + (de[strlen ("deflate")] == ',') || (de[strlen ("deflate")] == ';') ) ) return MHD_YES; return MHD_NO; @@ -116,9 +116,9 @@ TEH_RESPONSE_body_compress (void **buf, if (NULL == cbuf) return MHD_NO; ret = compress (cbuf, - &cbuf_size, - (const Bytef *) *buf, - *buf_size); + &cbuf_size, + (const Bytef *) *buf, + *buf_size); if ( (Z_OK != ret) || (cbuf_size >= *buf_size) ) { @@ -153,7 +153,7 @@ TEH_RESPONSE_reply_json (struct MHD_Connection *connection, int comp; json_str = json_dumps (json, - JSON_INDENT(2)); + JSON_INDENT (2)); if (NULL == json_str) { /** @@ -172,7 +172,7 @@ TEH_RESPONSE_reply_json (struct MHD_Connection *connection, if (MHD_YES == TEH_RESPONSE_can_compress (connection)) comp = TEH_RESPONSE_body_compress (&json_str, - &json_len); + &json_len); resp = MHD_create_response_from_buffer (json_len, json_str, MHD_RESPMEM_MUST_FREE); @@ -460,7 +460,8 @@ TEH_RESPONSE_reply_invalid_json (struct MHD_Connection *connection) MHD_HTTP_BAD_REQUEST, "{s:s, s:I}", "error", "invalid json", - "code", (json_int_t) TALER_EC_JSON_INVALID); + "code", + (json_int_t) TALER_EC_JSON_INVALID); } @@ -471,7 +472,8 @@ TEH_RESPONSE_reply_invalid_json (struct MHD_Connection *connection) * @return json representation of the @a rh, NULL on error */ json_t * -TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_TransactionList *tl) +TEH_RESPONSE_compile_transaction_history (const struct + TALER_EXCHANGEDB_TransactionList *tl) { json_t *history; @@ -497,7 +499,8 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact dr.h_contract_terms = deposit->h_contract_terms; dr.h_wire = deposit->h_wire; dr.timestamp = GNUNET_TIME_absolute_hton (deposit->timestamp); - dr.refund_deadline = GNUNET_TIME_absolute_hton (deposit->refund_deadline); + dr.refund_deadline = GNUNET_TIME_absolute_hton ( + deposit->refund_deadline); TALER_amount_hton (&dr.amount_with_fee, &deposit->amount_with_fee); TALER_amount_hton (&dr.deposit_fee, @@ -519,16 +522,32 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact #endif if (0 != json_array_append_new (history, - json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}", - "type", "DEPOSIT", - "amount", TALER_JSON_from_amount (&deposit->amount_with_fee), - "deposit_fee", TALER_JSON_from_amount (&deposit->deposit_fee), - "timestamp", GNUNET_JSON_from_time_abs (deposit->timestamp), - "refund_deadline", GNUNET_JSON_from_time_abs (deposit->refund_deadline), - "merchant_pub", GNUNET_JSON_from_data_auto (&deposit->merchant_pub), - "h_contract_terms", GNUNET_JSON_from_data_auto (&deposit->h_contract_terms), - "h_wire", GNUNET_JSON_from_data_auto (&deposit->h_wire), - "coin_sig", GNUNET_JSON_from_data_auto (&deposit->csig)))) + json_pack ( + "{s:s, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}", + "type", "DEPOSIT", + "amount", TALER_JSON_from_amount ( + &deposit->amount_with_fee), + "deposit_fee", + TALER_JSON_from_amount ( + &deposit->deposit_fee), + "timestamp", + GNUNET_JSON_from_time_abs ( + deposit->timestamp), + "refund_deadline", + GNUNET_JSON_from_time_abs ( + deposit->refund_deadline), + "merchant_pub", + GNUNET_JSON_from_data_auto ( + &deposit->merchant_pub), + "h_contract_terms", + GNUNET_JSON_from_data_auto ( + &deposit->h_contract_terms), + "h_wire", + GNUNET_JSON_from_data_auto ( + &deposit->h_wire), + "coin_sig", + GNUNET_JSON_from_data_auto ( + &deposit->csig)))) { GNUNET_break (0); json_decref (history); @@ -542,7 +561,8 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact const struct TALER_EXCHANGEDB_RefreshMelt *melt = pos->details.melt; ms.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT); - ms.purpose.size = htonl (sizeof (struct TALER_RefreshMeltCoinAffirmationPS)); + ms.purpose.size = htonl (sizeof (struct + TALER_RefreshMeltCoinAffirmationPS)); ms.rc = melt->session.rc; TALER_amount_hton (&ms.amount_with_fee, &melt->session.amount_with_fee); @@ -566,10 +586,16 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact json_array_append_new (history, json_pack ("{s:s, s:o, s:o, s:o, s:o}", "type", "MELT", - "amount", TALER_JSON_from_amount (&melt->session.amount_with_fee), - "melt_fee", TALER_JSON_from_amount (&melt->melt_fee), - "rc", GNUNET_JSON_from_data_auto (&melt->session.rc), - "coin_sig", GNUNET_JSON_from_data_auto (&melt->session.coin_sig)))) + "amount", TALER_JSON_from_amount ( + &melt->session.amount_with_fee), + "melt_fee", + TALER_JSON_from_amount ( + &melt->melt_fee), + "rc", GNUNET_JSON_from_data_auto ( + &melt->session.rc), + "coin_sig", + GNUNET_JSON_from_data_auto ( + &melt->session.coin_sig)))) { GNUNET_break (0); json_decref (history); @@ -617,14 +643,25 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact #endif if (0 != json_array_append_new (history, - json_pack ("{s:s, s:o, s:o, s:o, s:o, s:I, s:o}", - "type", "REFUND", - "amount", TALER_JSON_from_amount (&value), - "refund_fee", TALER_JSON_from_amount (&refund->refund_fee), - "h_contract_terms", GNUNET_JSON_from_data_auto (&refund->h_contract_terms), - "merchant_pub", GNUNET_JSON_from_data_auto (&refund->merchant_pub), - "rtransaction_id", (json_int_t) refund->rtransaction_id, - "merchant_sig", GNUNET_JSON_from_data_auto (&refund->merchant_sig)))) + json_pack ( + "{s:s, s:o, s:o, s:o, s:o, s:I, s:o}", + "type", "REFUND", + "amount", TALER_JSON_from_amount ( + &value), + "refund_fee", + TALER_JSON_from_amount ( + &refund->refund_fee), + "h_contract_terms", + GNUNET_JSON_from_data_auto ( + &refund->h_contract_terms), + "merchant_pub", + GNUNET_JSON_from_data_auto ( + &refund->merchant_pub), + "rtransaction_id", + (json_int_t) refund->rtransaction_id, + "merchant_sig", + GNUNET_JSON_from_data_auto ( + &refund->merchant_sig)))) { GNUNET_break (0); json_decref (history); @@ -634,12 +671,14 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact break; case TALER_EXCHANGEDB_TT_OLD_COIN_PAYBACK: { - struct TALER_EXCHANGEDB_PaybackRefresh *pr = pos->details.old_coin_payback; + struct TALER_EXCHANGEDB_PaybackRefresh *pr = + pos->details.old_coin_payback; struct TALER_PaybackRefreshConfirmationPS pc; struct TALER_ExchangePublicKeyP epub; struct TALER_ExchangeSignatureP esig; - pc.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_PAYBACK_REFRESH); + pc.purpose.purpose = htonl ( + TALER_SIGNATURE_EXCHANGE_CONFIRM_PAYBACK_REFRESH); pc.purpose.size = htonl (sizeof (pc)); pc.timestamp = GNUNET_TIME_absolute_hton (pr->timestamp); TALER_amount_hton (&pc.payback_amount, @@ -664,11 +703,20 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact json_array_append_new (history, json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}", "type", "OLD-COIN-PAYBACK", - "amount", TALER_JSON_from_amount (&pr->value), - "exchange_sig", GNUNET_JSON_from_data_auto (&esig), - "exchange_pub", GNUNET_JSON_from_data_auto (&epub), - "coin_pub", GNUNET_JSON_from_data_auto (&pr->coin.coin_pub), - "timestamp", GNUNET_JSON_from_time_abs (pr->timestamp)))) + "amount", TALER_JSON_from_amount ( + &pr->value), + "exchange_sig", + GNUNET_JSON_from_data_auto ( + &esig), + "exchange_pub", + GNUNET_JSON_from_data_auto ( + &epub), + "coin_pub", + GNUNET_JSON_from_data_auto ( + &pr->coin.coin_pub), + "timestamp", + GNUNET_JSON_from_time_abs ( + pr->timestamp)))) { GNUNET_break (0); json_decref (history); @@ -703,11 +751,20 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact json_array_append_new (history, json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}", "type", "PAYBACK", - "amount", TALER_JSON_from_amount (&payback->value), - "exchange_sig", GNUNET_JSON_from_data_auto (&esig), - "exchange_pub", GNUNET_JSON_from_data_auto (&epub), - "reserve_pub", GNUNET_JSON_from_data_auto (&payback->reserve_pub), - "timestamp", GNUNET_JSON_from_time_abs (payback->timestamp)))) + "amount", TALER_JSON_from_amount ( + &payback->value), + "exchange_sig", + GNUNET_JSON_from_data_auto ( + &esig), + "exchange_pub", + GNUNET_JSON_from_data_auto ( + &epub), + "reserve_pub", + GNUNET_JSON_from_data_auto ( + &payback->reserve_pub), + "timestamp", + GNUNET_JSON_from_time_abs ( + payback->timestamp)))) { GNUNET_break (0); json_decref (history); @@ -717,12 +774,14 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact break; case TALER_EXCHANGEDB_TT_PAYBACK_REFRESH: { - struct TALER_EXCHANGEDB_PaybackRefresh *pr = pos->details.payback_refresh; + struct TALER_EXCHANGEDB_PaybackRefresh *pr = + pos->details.payback_refresh; struct TALER_PaybackRefreshConfirmationPS pc; struct TALER_ExchangePublicKeyP epub; struct TALER_ExchangeSignatureP esig; - pc.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_PAYBACK_REFRESH); + pc.purpose.purpose = htonl ( + TALER_SIGNATURE_EXCHANGE_CONFIRM_PAYBACK_REFRESH); pc.purpose.size = htonl (sizeof (pc)); pc.timestamp = GNUNET_TIME_absolute_hton (pr->timestamp); TALER_amount_hton (&pc.payback_amount, @@ -747,11 +806,20 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact json_array_append_new (history, json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}", "type", "PAYBACK-REFRESH", - "amount", TALER_JSON_from_amount (&pr->value), - "exchange_sig", GNUNET_JSON_from_data_auto (&esig), - "exchange_pub", GNUNET_JSON_from_data_auto (&epub), - "old_coin_pub", GNUNET_JSON_from_data_auto (&pr->old_coin_pub), - "timestamp", GNUNET_JSON_from_time_abs (pr->timestamp)))) + "amount", TALER_JSON_from_amount ( + &pr->value), + "exchange_sig", + GNUNET_JSON_from_data_auto ( + &esig), + "exchange_pub", + GNUNET_JSON_from_data_auto ( + &epub), + "old_coin_pub", + GNUNET_JSON_from_data_auto ( + &pr->old_coin_pub), + "timestamp", + GNUNET_JSON_from_time_abs ( + pr->timestamp)))) { GNUNET_break (0); json_decref (history); @@ -781,7 +849,8 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact int TEH_RESPONSE_reply_coin_insufficient_funds (struct MHD_Connection *connection, enum TALER_ErrorCode ec, - const struct TALER_EXCHANGEDB_TransactionList *tl) + const struct + TALER_EXCHANGEDB_TransactionList *tl) { json_t *history; @@ -808,7 +877,8 @@ TEH_RESPONSE_reply_coin_insufficient_funds (struct MHD_Connection *connection, * @return json representation of the @a rh, NULL on error */ json_t * -TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHistory *rh, +TEH_RESPONSE_compile_reserve_history (const struct + TALER_EXCHANGEDB_ReserveHistory *rh, struct TALER_Amount *balance) { struct TALER_Amount deposit_total; @@ -827,30 +897,38 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto case TALER_EXCHANGEDB_RO_BANK_TO_EXCHANGE: if (0 == (1 & ret)) deposit_total = pos->details.bank->amount; - else - if (GNUNET_OK != - TALER_amount_add (&deposit_total, - &deposit_total, - &pos->details.bank->amount)) - { - GNUNET_break (0); - json_decref (json_history); - return NULL; - } + else if (GNUNET_OK != + TALER_amount_add (&deposit_total, + &deposit_total, + &pos->details.bank->amount)) + { + GNUNET_break (0); + json_decref (json_history); + return NULL; + } ret |= 1; if (0 != json_array_append_new (json_history, json_pack ("{s:s, s:o, s:s, s:o, s:o}", "type", "DEPOSIT", - "timestamp", GNUNET_JSON_from_time_abs (pos->details.bank->execution_date), - "sender_account_url", pos->details.bank->sender_account_details, - "wire_reference", GNUNET_JSON_from_data (pos->details.bank->wire_reference, - pos->details.bank->wire_reference_size), - "amount", TALER_JSON_from_amount (&pos->details.bank->amount)))) + "timestamp", + GNUNET_JSON_from_time_abs ( + pos->details.bank->execution_date), + "sender_account_url", + pos->details.bank-> + sender_account_details, + "wire_reference", + GNUNET_JSON_from_data ( + pos->details.bank->wire_reference, + pos + ->details. + bank->wire_reference_size), + "amount", TALER_JSON_from_amount ( + &pos->details.bank->amount)))) { GNUNET_break (0); - json_decref (json_history); - return NULL; + json_decref (json_history); + return NULL; } break; case TALER_EXCHANGEDB_RO_WITHDRAW_COIN: @@ -879,11 +957,24 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto json_array_append_new (json_history, json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}", "type", "WITHDRAW", - "reserve_sig", GNUNET_JSON_from_data_auto (&pos->details.withdraw->reserve_sig), - "h_coin_envelope", GNUNET_JSON_from_data_auto (&pos->details.withdraw->h_coin_envelope), - "h_denom_pub", GNUNET_JSON_from_data_auto (&pos->details.withdraw->denom_pub_hash), - "withdraw_fee", TALER_JSON_from_amount (&pos->details.withdraw->withdraw_fee), - "amount", TALER_JSON_from_amount (&value)))) + "reserve_sig", + GNUNET_JSON_from_data_auto ( + &pos->details.withdraw-> + reserve_sig), + "h_coin_envelope", + GNUNET_JSON_from_data_auto ( + &pos->details.withdraw-> + h_coin_envelope), + "h_denom_pub", + GNUNET_JSON_from_data_auto ( + &pos->details.withdraw-> + denom_pub_hash), + "withdraw_fee", + TALER_JSON_from_amount ( + &pos->details.withdraw-> + withdraw_fee), + "amount", TALER_JSON_from_amount ( + &value)))) { GNUNET_break (0); json_decref (json_history); @@ -901,16 +992,15 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto payback = pos->details.payback; if (0 == (1 & ret)) deposit_total = payback->value; - else - if (GNUNET_OK != - TALER_amount_add (&deposit_total, - &deposit_total, - &payback->value)) - { - GNUNET_break (0); - json_decref (json_history); - return NULL; - } + else if (GNUNET_OK != + TALER_amount_add (&deposit_total, + &deposit_total, + &payback->value)) + { + GNUNET_break (0); + json_decref (json_history); + return NULL; + } ret |= 1; pc.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_PAYBACK); pc.purpose.size = htonl (sizeof (struct TALER_PaybackConfirmationPS)); @@ -933,11 +1023,18 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto json_array_append_new (json_history, json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}", "type", "PAYBACK", - "exchange_pub", GNUNET_JSON_from_data_auto (&pub), - "exchange_sig", GNUNET_JSON_from_data_auto (&sig), - "timestamp", GNUNET_JSON_from_time_abs (payback->timestamp), - "amount", TALER_JSON_from_amount (&payback->value), - "coin_pub", GNUNET_JSON_from_data_auto (&payback->coin.coin_pub)))) + "exchange_pub", + GNUNET_JSON_from_data_auto (&pub), + "exchange_sig", + GNUNET_JSON_from_data_auto (&sig), + "timestamp", + GNUNET_JSON_from_time_abs ( + payback->timestamp), + "amount", TALER_JSON_from_amount ( + &payback->value), + "coin_pub", + GNUNET_JSON_from_data_auto ( + &payback->coin.coin_pub)))) { GNUNET_break (0); json_decref (json_history); @@ -971,15 +1068,19 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto } ret |= 2; rcc.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_RESERVE_CLOSED); - rcc.purpose.size = htonl (sizeof (struct TALER_ReserveCloseConfirmationPS)); - rcc.timestamp = GNUNET_TIME_absolute_hton (pos->details.closing->execution_date); + rcc.purpose.size = htonl (sizeof (struct + TALER_ReserveCloseConfirmationPS)); + rcc.timestamp = GNUNET_TIME_absolute_hton ( + pos->details.closing->execution_date); TALER_amount_hton (&rcc.closing_amount, &value); TALER_amount_hton (&rcc.closing_fee, &pos->details.closing->closing_fee); rcc.reserve_pub = pos->details.closing->reserve_pub; GNUNET_CRYPTO_hash (pos->details.closing->receiver_account_details, - strlen (pos->details.closing->receiver_account_details) + 1, + strlen ( + pos->details.closing->receiver_account_details) + + 1, &rcc.h_wire); rcc.wtid = pos->details.closing->wtid; if (GNUNET_OK != @@ -993,15 +1094,27 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto } if (0 != json_array_append_new (json_history, - json_pack ("{s:s, s:s, s:o, s:o, s:o, s:o, s:o, s:o}", - "type", "CLOSING", - "receiver_account_details", pos->details.closing->receiver_account_details, - "wtid", GNUNET_JSON_from_data_auto (&pos->details.closing->wtid), - "exchange_pub", GNUNET_JSON_from_data_auto (&pub), - "exchange_sig", GNUNET_JSON_from_data_auto (&sig), - "timestamp", GNUNET_JSON_from_time_abs (pos->details.closing->execution_date), - "amount", TALER_JSON_from_amount (&value), - "closing_fee", TALER_JSON_from_amount (&pos->details.closing->closing_fee)))) + json_pack ( + "{s:s, s:s, s:o, s:o, s:o, s:o, s:o, s:o}", + "type", "CLOSING", + "receiver_account_details", + pos->details.closing-> + receiver_account_details, + "wtid", + GNUNET_JSON_from_data_auto ( + &pos->details.closing->wtid), + "exchange_pub", + GNUNET_JSON_from_data_auto (&pub), + "exchange_sig", + GNUNET_JSON_from_data_auto (&sig), + "timestamp", + GNUNET_JSON_from_time_abs ( + pos->details.closing->execution_date), + "amount", TALER_JSON_from_amount ( + &value), + "closing_fee", + TALER_JSON_from_amount ( + &pos->details.closing->closing_fee)))) { GNUNET_break (0); json_decref (json_history); diff --git a/src/exchange/taler-exchange-httpd_responses.h b/src/exchange/taler-exchange-httpd_responses.h index 9b127156..177eaa43 100644 --- a/src/exchange/taler-exchange-httpd_responses.h +++ b/src/exchange/taler-exchange-httpd_responses.h @@ -54,7 +54,7 @@ TEH_RESPONSE_add_global_headers (struct MHD_Response *response); */ int TEH_RESPONSE_body_compress (void **buf, - size_t *buf_size); + size_t *buf_size); /** @@ -108,7 +108,7 @@ TEH_RESPONSE_reply_json_pack (struct MHD_Connection *connection, */ int TEH_RESPONSE_reply_signature_invalid (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name); @@ -122,7 +122,7 @@ TEH_RESPONSE_reply_signature_invalid (struct MHD_Connection *connection, */ int TEH_RESPONSE_reply_arg_invalid (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name); @@ -138,7 +138,7 @@ TEH_RESPONSE_reply_arg_invalid (struct MHD_Connection *connection, */ int TEH_RESPONSE_reply_arg_unknown (struct MHD_Connection *connection, - enum TALER_ErrorCode ec, + enum TALER_ErrorCode ec, const char *param_name); @@ -239,8 +239,9 @@ TEH_RESPONSE_reply_invalid_json (struct MHD_Connection *connectionx); * @return json representation of the @a rh, NULL on error */ json_t * -TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHistory *rh, - struct TALER_Amount *balance); +TEH_RESPONSE_compile_reserve_history (const struct + TALER_EXCHANGEDB_ReserveHistory *rh, + struct TALER_Amount *balance); /** @@ -257,7 +258,8 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto int TEH_RESPONSE_reply_coin_insufficient_funds (struct MHD_Connection *connection, enum TALER_ErrorCode ec, - const struct TALER_EXCHANGEDB_TransactionList *tl); + const struct + TALER_EXCHANGEDB_TransactionList *tl); /** @@ -271,7 +273,7 @@ TEH_RESPONSE_reply_coin_insufficient_funds (struct MHD_Connection *connection, */ int TEH_RESPONSE_reply_transaction_unknown (struct MHD_Connection *connection, - enum TALER_ErrorCode ec); + enum TALER_ErrorCode ec); /** @@ -281,7 +283,8 @@ TEH_RESPONSE_reply_transaction_unknown (struct MHD_Connection *connection, * @return json representation of the @a rh */ json_t * -TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_TransactionList *tl); +TEH_RESPONSE_compile_transaction_history (const struct + TALER_EXCHANGEDB_TransactionList *tl); #endif diff --git a/src/exchange/taler-exchange-httpd_test.c b/src/exchange/taler-exchange-httpd_test.c index 73ce0e55..b55a9888 100644 --- a/src/exchange/taler-exchange-httpd_test.c +++ b/src/exchange/taler-exchange-httpd_test.c @@ -53,10 +53,10 @@ static struct GNUNET_CRYPTO_RsaPrivateKey *rsa_pk; */ int TEH_TEST_handler_test_base32 (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { json_t *json; int res; @@ -78,20 +78,20 @@ TEH_TEST_handler_test_base32 (struct TEH_RequestHandler *rh, if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; res = TEH_PARSE_json_data (connection, - json, - spec); + json, + spec); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; GNUNET_CRYPTO_hash (in_ptr, - in_ptr_size, - &hc); + in_ptr_size, + &hc); GNUNET_JSON_parse_free (spec); json_decref (json); return TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o}", - "output", - GNUNET_JSON_from_data_auto (&hc)); + MHD_HTTP_OK, + "{s:o}", + "output", + GNUNET_JSON_from_data_auto (&hc)); } @@ -114,10 +114,10 @@ TEH_TEST_handler_test_base32 (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test_encrypt (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { json_t *json; int res; @@ -143,37 +143,39 @@ TEH_TEST_handler_test_encrypt (struct TEH_RequestHandler *rh, if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; res = TEH_PARSE_json_data (connection, - json, - spec); + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; GNUNET_assert (GNUNET_YES == - GNUNET_CRYPTO_kdf (&skey, sizeof (struct GNUNET_CRYPTO_SymmetricSessionKey), - "skey", strlen ("skey"), - &key, sizeof (key), - NULL, 0)); + GNUNET_CRYPTO_kdf (&skey, sizeof (struct + GNUNET_CRYPTO_SymmetricSessionKey), + "skey", strlen ("skey"), + &key, sizeof (key), + NULL, 0)); GNUNET_assert (GNUNET_YES == - GNUNET_CRYPTO_kdf (&iv, sizeof (struct GNUNET_CRYPTO_SymmetricInitializationVector), - "iv", strlen ("iv"), - &key, sizeof (key), - NULL, 0)); + GNUNET_CRYPTO_kdf (&iv, sizeof (struct + GNUNET_CRYPTO_SymmetricInitializationVector), + "iv", strlen ("iv"), + &key, sizeof (key), + NULL, 0)); out = GNUNET_malloc (in_ptr_size); GNUNET_break (in_ptr_size == - GNUNET_CRYPTO_symmetric_encrypt (in_ptr, - in_ptr_size, - &skey, - &iv, - out)); + GNUNET_CRYPTO_symmetric_encrypt (in_ptr, + in_ptr_size, + &skey, + &iv, + out)); json = GNUNET_JSON_from_data (out, in_ptr_size); GNUNET_free (out); GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o}", - "output", - json); + MHD_HTTP_OK, + "{s:o}", + "output", + json); } @@ -196,10 +198,10 @@ TEH_TEST_handler_test_encrypt (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test_hkdf (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { json_t *json; int res; @@ -221,8 +223,8 @@ TEH_TEST_handler_test_hkdf (struct TEH_RequestHandler *rh, if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; res = TEH_PARSE_json_data (connection, - json, - spec); + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -235,10 +237,10 @@ TEH_TEST_handler_test_hkdf (struct TEH_RequestHandler *rh, GNUNET_JSON_parse_free (spec); json = GNUNET_JSON_from_data_auto (&hc); return TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o}", - "output", - json); + MHD_HTTP_OK, + "{s:o}", + "output", + json); } @@ -258,10 +260,10 @@ TEH_TEST_handler_test_hkdf (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test_ecdhe (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { json_t *json; int res; @@ -284,27 +286,27 @@ TEH_TEST_handler_test_ecdhe (struct TEH_RequestHandler *rh, if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; res = TEH_PARSE_json_data (connection, - json, - spec); + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; if (GNUNET_OK != GNUNET_CRYPTO_ecc_ecdh (&priv, - &pub, - &hc)) + &pub, + &hc)) { GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_TEST_ECDH_ERROR, - "Failed to perform ECDH"); + TALER_EC_TEST_ECDH_ERROR, + "Failed to perform ECDH"); } GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o}", - "ecdh_hash", - GNUNET_JSON_from_data_auto (&hc)); + MHD_HTTP_OK, + "{s:o}", + "ecdh_hash", + GNUNET_JSON_from_data_auto (&hc)); } @@ -325,10 +327,10 @@ TEH_TEST_handler_test_ecdhe (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test_eddsa (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { json_t *json; int res; @@ -352,8 +354,8 @@ TEH_TEST_handler_test_eddsa (struct TEH_RequestHandler *rh, if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; res = TEH_PARSE_json_data (connection, - json, - spec); + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -361,38 +363,38 @@ TEH_TEST_handler_test_eddsa (struct TEH_RequestHandler *rh, purpose.purpose = htonl (TALER_SIGNATURE_CLIENT_TEST_EDDSA); if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_CLIENT_TEST_EDDSA, - &purpose, - &sig, - &pub)) + &purpose, + &sig, + &pub)) { GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_signature_invalid (connection, - TALER_EC_TEST_EDDSA_INVALID, - "eddsa_sig"); + TALER_EC_TEST_EDDSA_INVALID, + "eddsa_sig"); } GNUNET_JSON_parse_free (spec); pk = GNUNET_CRYPTO_eddsa_key_create (); purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_TEST_EDDSA); if (GNUNET_OK != GNUNET_CRYPTO_eddsa_sign (pk, - &purpose, - &sig)) + &purpose, + &sig)) { GNUNET_free (pk); return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_TEST_EDDSA_ERROR, - "Failed to EdDSA-sign"); + TALER_EC_TEST_EDDSA_ERROR, + "Failed to EdDSA-sign"); } GNUNET_CRYPTO_eddsa_key_get_public (pk, - &pub); + &pub); GNUNET_free (pk); return TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o, s:o}", - "eddsa_pub", - GNUNET_JSON_from_data_auto (&pub), - "eddsa_sig", - GNUNET_JSON_from_data_auto (&sig)); + MHD_HTTP_OK, + "{s:o, s:o}", + "eddsa_pub", + GNUNET_JSON_from_data_auto (&pub), + "eddsa_sig", + GNUNET_JSON_from_data_auto (&sig)); } @@ -423,22 +425,22 @@ TEH_TEST_handler_test_rsa_get (struct TEH_RequestHandler *rh, { GNUNET_break (0); return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_TEST_RSA_GEN_ERROR, - "Failed to create RSA key"); + TALER_EC_TEST_RSA_GEN_ERROR, + "Failed to create RSA key"); } pub = GNUNET_CRYPTO_rsa_private_key_get_public (rsa_pk); if (NULL == pub) { GNUNET_break (0); return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_TEST_RSA_PUB_ERROR, - "Failed to get public RSA key"); + TALER_EC_TEST_RSA_PUB_ERROR, + "Failed to get public RSA key"); } res = TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o}", - "rsa_pub", - GNUNET_JSON_from_rsa_public_key (pub)); + MHD_HTTP_OK, + "{s:o}", + "rsa_pub", + GNUNET_JSON_from_rsa_public_key (pub)); GNUNET_CRYPTO_rsa_public_key_free (pub); return res; } @@ -483,8 +485,8 @@ TEH_TEST_handler_test_rsa_sign (struct TEH_RequestHandler *rh, if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; res = TEH_PARSE_json_data (connection, - json, - spec); + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -495,26 +497,26 @@ TEH_TEST_handler_test_rsa_sign (struct TEH_RequestHandler *rh, GNUNET_break (0); GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_TEST_RSA_GEN_ERROR, - "Failed to create RSA key"); + TALER_EC_TEST_RSA_GEN_ERROR, + "Failed to create RSA key"); } sig = GNUNET_CRYPTO_rsa_sign_blinded (rsa_pk, - in_ptr, - in_ptr_size); + in_ptr, + in_ptr_size); if (NULL == sig) { GNUNET_break (0); GNUNET_JSON_parse_free (spec); return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_TEST_RSA_SIGN_ERROR, - "Failed to RSA-sign"); + TALER_EC_TEST_RSA_SIGN_ERROR, + "Failed to RSA-sign"); } GNUNET_JSON_parse_free (spec); res = TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o}", - "rsa_blind_sig", - GNUNET_JSON_from_rsa_signature (sig)); + MHD_HTTP_OK, + "{s:o}", + "rsa_blind_sig", + GNUNET_JSON_from_rsa_signature (sig)); GNUNET_CRYPTO_rsa_signature_free (sig); return res; } @@ -536,10 +538,10 @@ TEH_TEST_handler_test_rsa_sign (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test_transfer (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { json_t *json; int res; @@ -562,8 +564,8 @@ TEH_TEST_handler_test_transfer (struct TEH_RequestHandler *rh, if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; res = TEH_PARSE_json_data (connection, - json, - spec); + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -571,10 +573,10 @@ TEH_TEST_handler_test_transfer (struct TEH_RequestHandler *rh, &coin_pub, &secret); return TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o}", - "secret", - GNUNET_JSON_from_data_auto (&secret)); + MHD_HTTP_OK, + "{s:o}", + "secret", + GNUNET_JSON_from_data_auto (&secret)); } @@ -590,10 +592,10 @@ TEH_TEST_handler_test_transfer (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size) + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size) { json_t *json; int res; diff --git a/src/exchange/taler-exchange-httpd_test.h b/src/exchange/taler-exchange-httpd_test.h index e68ae2f7..d1f8f000 100644 --- a/src/exchange/taler-exchange-httpd_test.h +++ b/src/exchange/taler-exchange-httpd_test.h @@ -43,10 +43,10 @@ */ int TEH_TEST_handler_test_base32 (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); /** @@ -68,10 +68,10 @@ TEH_TEST_handler_test_base32 (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test_encrypt (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); /** @@ -93,10 +93,10 @@ TEH_TEST_handler_test_encrypt (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test_hkdf (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); /** @@ -115,10 +115,10 @@ TEH_TEST_handler_test_hkdf (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test_ecdhe (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); /** @@ -138,10 +138,10 @@ TEH_TEST_handler_test_ecdhe (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test_eddsa (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); /** @@ -199,10 +199,10 @@ TEH_TEST_handler_test_rsa_sign (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test_transfer (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); /** @@ -217,9 +217,9 @@ TEH_TEST_handler_test_transfer (struct TEH_RequestHandler *rh, */ int TEH_TEST_handler_test (struct TEH_RequestHandler *rh, - struct MHD_Connection *connection, - void **connection_cls, - const char *upload_data, - size_t *upload_data_size); + struct MHD_Connection *connection, + void **connection_cls, + const char *upload_data, + size_t *upload_data_size); #endif diff --git a/src/exchange/taler-exchange-httpd_track_transaction.c b/src/exchange/taler-exchange-httpd_track_transaction.c index fdda22b8..c8919268 100644 --- a/src/exchange/taler-exchange-httpd_track_transaction.c +++ b/src/exchange/taler-exchange-httpd_track_transaction.c @@ -40,12 +40,14 @@ */ static int reply_transfer_pending (struct MHD_Connection *connection, - struct GNUNET_TIME_Absolute planned_exec_time) + struct GNUNET_TIME_Absolute planned_exec_time) { return TEH_RESPONSE_reply_json_pack (connection, MHD_HTTP_ACCEPTED, "{s:o}", - "execution_time", GNUNET_JSON_from_time_abs (planned_exec_time)); + "execution_time", + GNUNET_JSON_from_time_abs ( + planned_exec_time)); } @@ -65,12 +67,12 @@ reply_transfer_pending (struct MHD_Connection *connection, */ static int reply_track_transaction (struct MHD_Connection *connection, - const struct GNUNET_HashCode *h_contract_terms, - const struct GNUNET_HashCode *h_wire, - const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_Amount *coin_contribution, - const struct TALER_WireTransferIdentifierRawP *wtid, - struct GNUNET_TIME_Absolute exec_time) + const struct GNUNET_HashCode *h_contract_terms, + const struct GNUNET_HashCode *h_wire, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct TALER_Amount *coin_contribution, + const struct TALER_WireTransferIdentifierRawP *wtid, + struct GNUNET_TIME_Absolute exec_time) { struct TALER_ConfirmWirePS cw; struct TALER_ExchangePublicKeyP pub; @@ -87,8 +89,8 @@ reply_track_transaction (struct MHD_Connection *connection, coin_contribution); if (GNUNET_OK != TEH_KS_sign (&cw.purpose, - &pub, - &sig)) + &pub, + &sig)) { return TEH_RESPONSE_reply_internal_error (connection, TALER_EC_EXCHANGE_BAD_CONFIGURATION, @@ -97,11 +99,17 @@ reply_track_transaction (struct MHD_Connection *connection, return TEH_RESPONSE_reply_json_pack (connection, MHD_HTTP_OK, "{s:o, s:o, s:o, s:o, s:o}", - "wtid", GNUNET_JSON_from_data_auto (wtid), - "execution_time", GNUNET_JSON_from_time_abs (exec_time), - "coin_contribution", TALER_JSON_from_amount (coin_contribution), - "exchange_sig", GNUNET_JSON_from_data_auto (&sig), - "exchange_pub", GNUNET_JSON_from_data_auto (&pub)); + "wtid", GNUNET_JSON_from_data_auto ( + wtid), + "execution_time", + GNUNET_JSON_from_time_abs (exec_time), + "coin_contribution", + TALER_JSON_from_amount ( + coin_contribution), + "exchange_sig", + GNUNET_JSON_from_data_auto (&sig), + "exchange_pub", + GNUNET_JSON_from_data_auto (&pub)); } @@ -173,10 +181,10 @@ struct DepositWtidContext */ static void handle_wtid_data (void *cls, - const struct TALER_WireTransferIdentifierRawP *wtid, + const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_Amount *coin_contribution, const struct TALER_Amount *coin_fee, - struct GNUNET_TIME_Absolute execution_time) + struct GNUNET_TIME_Absolute execution_time) { struct DepositWtidContext *ctx = cls; @@ -188,8 +196,8 @@ handle_wtid_data (void *cls, } if (GNUNET_SYSERR == TALER_amount_subtract (&ctx->coin_delta, - coin_contribution, - coin_fee)) + coin_contribution, + coin_fee)) { GNUNET_break (0); ctx->pending = GNUNET_SYSERR; @@ -221,35 +229,35 @@ handle_wtid_data (void *cls, */ static enum GNUNET_DB_QueryStatus track_transaction_transaction (void *cls, - struct MHD_Connection *connection, - struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + struct MHD_Connection *connection, + struct TALER_EXCHANGEDB_Session *session, + int *mhd_ret) { struct DepositWtidContext *ctx = cls; enum GNUNET_DB_QueryStatus qs; qs = TEH_plugin->wire_lookup_deposit_wtid (TEH_plugin->cls, - session, - &ctx->tps->h_contract_terms, - &ctx->tps->h_wire, - &ctx->tps->coin_pub, - ctx->merchant_pub, - &handle_wtid_data, - ctx); + session, + &ctx->tps->h_contract_terms, + &ctx->tps->h_wire, + &ctx->tps->coin_pub, + ctx->merchant_pub, + &handle_wtid_data, + ctx); if (0 > qs) { if (GNUNET_DB_STATUS_HARD_ERROR == qs) { GNUNET_break (0); *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_TRACK_TRANSACTION_DB_FETCH_FAILED); + TALER_EC_TRACK_TRANSACTION_DB_FETCH_FAILED); } return qs; } if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) { *mhd_ret = TEH_RESPONSE_reply_transaction_unknown (connection, - TALER_EC_TRACK_TRANSACTION_NOT_FOUND); + TALER_EC_TRACK_TRANSACTION_NOT_FOUND); return GNUNET_DB_STATUS_HARD_ERROR; } return qs; @@ -268,23 +276,28 @@ track_transaction_transaction (void *cls, */ static int check_and_handle_track_transaction_request (struct MHD_Connection *connection, - const struct TALER_DepositTrackPS *tps, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct TALER_MerchantSignatureP *merchant_sig) + const struct + TALER_DepositTrackPS *tps, + const struct + TALER_MerchantPublicKeyP * + merchant_pub, + const struct + TALER_MerchantSignatureP * + merchant_sig) { struct DepositWtidContext ctx; int mhd_ret; if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_TRACK_TRANSACTION, - &tps->purpose, - &merchant_sig->eddsa_sig, - &merchant_pub->eddsa_pub)) + &tps->purpose, + &merchant_sig->eddsa_sig, + &merchant_pub->eddsa_pub)) { GNUNET_break_op (0); return TEH_RESPONSE_reply_signature_invalid (connection, - TALER_EC_TRACK_TRANSACTION_MERCHANT_SIGNATURE_INVALID, - "merchant_sig"); + TALER_EC_TRACK_TRANSACTION_MERCHANT_SIGNATURE_INVALID, + "merchant_sig"); } ctx.pending = GNUNET_NO; ctx.tps = tps; @@ -293,23 +306,23 @@ check_and_handle_track_transaction_request (struct MHD_Connection *connection, if (GNUNET_OK != TEH_DB_run_transaction (connection, "handle track transaction", - &mhd_ret, - &track_transaction_transaction, - &ctx)) + &mhd_ret, + &track_transaction_transaction, + &ctx)) return mhd_ret; if (GNUNET_YES == ctx.pending) return reply_transfer_pending (connection, - ctx.execution_time); + ctx.execution_time); if (GNUNET_SYSERR == ctx.pending) return TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_TRACK_TRANSACTION_DB_FEE_INCONSISTENT); + TALER_EC_TRACK_TRANSACTION_DB_FEE_INCONSISTENT); return reply_track_transaction (connection, - &tps->h_contract_terms, - &tps->h_wire, - &tps->coin_pub, - &ctx.coin_delta, - &ctx.wtid, - ctx.execution_time); + &tps->h_contract_terms, + &tps->h_wire, + &tps->coin_pub, + &ctx.coin_delta, + &ctx.wtid, + ctx.execution_time); } diff --git a/src/exchange/taler-exchange-httpd_track_transfer.c b/src/exchange/taler-exchange-httpd_track_transfer.c index 80a29ee0..2aaeacd7 100644 --- a/src/exchange/taler-exchange-httpd_track_transfer.c +++ b/src/exchange/taler-exchange-httpd_track_transfer.c @@ -84,12 +84,13 @@ struct TEH_TrackTransferDetail */ static int reply_track_transfer_details (struct MHD_Connection *connection, - const struct TALER_Amount *total, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const struct GNUNET_HashCode *h_wire, - const struct TALER_Amount *wire_fee, - struct GNUNET_TIME_Absolute exec_time, - const struct TEH_TrackTransferDetail *wdd_head) + const struct TALER_Amount *total, + const struct + TALER_MerchantPublicKeyP *merchant_pub, + const struct GNUNET_HashCode *h_wire, + const struct TALER_Amount *wire_fee, + struct GNUNET_TIME_Absolute exec_time, + const struct TEH_TrackTransferDetail *wdd_head) { const struct TEH_TrackTransferDetail *wdd_pos; json_t *deposits; @@ -117,10 +118,19 @@ reply_track_transfer_details (struct MHD_Connection *connection, GNUNET_assert (0 == json_array_append_new (deposits, json_pack ("{s:o, s:o, s:o, s:o}", - "h_contract_terms", GNUNET_JSON_from_data_auto (&wdd_pos->h_contract_terms), - "coin_pub", GNUNET_JSON_from_data_auto (&wdd_pos->coin_pub), - "deposit_value", TALER_JSON_from_amount (&wdd_pos->deposit_value), - "deposit_fee", TALER_JSON_from_amount (&wdd_pos->deposit_fee)))); + "h_contract_terms", + GNUNET_JSON_from_data_auto ( + &wdd_pos-> + h_contract_terms), + "coin_pub", + GNUNET_JSON_from_data_auto ( + &wdd_pos->coin_pub), + "deposit_value", + TALER_JSON_from_amount ( + &wdd_pos->deposit_value), + "deposit_fee", + TALER_JSON_from_amount ( + &wdd_pos->deposit_fee)))); } wdp.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT); wdp.purpose.size = htonl (sizeof (struct TALER_WireDepositDataPS)); @@ -134,8 +144,8 @@ reply_track_transfer_details (struct MHD_Connection *connection, &wdp.h_details); if (GNUNET_OK != TEH_KS_sign (&wdp.purpose, - &pub, - &sig)) + &pub, + &sig)) { json_decref (deposits); return TEH_RESPONSE_reply_internal_error (connection, @@ -147,13 +157,20 @@ reply_track_transfer_details (struct MHD_Connection *connection, MHD_HTTP_OK, "{s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}", "total", TALER_JSON_from_amount (total), - "wire_fee", TALER_JSON_from_amount (wire_fee), - "merchant_pub", GNUNET_JSON_from_data_auto (merchant_pub), - "H_wire", GNUNET_JSON_from_data_auto (h_wire), - "execution_time", GNUNET_JSON_from_time_abs (exec_time), + "wire_fee", TALER_JSON_from_amount ( + wire_fee), + "merchant_pub", + GNUNET_JSON_from_data_auto ( + merchant_pub), + "H_wire", GNUNET_JSON_from_data_auto ( + h_wire), + "execution_time", + GNUNET_JSON_from_time_abs (exec_time), "deposits", deposits, - "exchange_sig", GNUNET_JSON_from_data_auto (&sig), - "exchange_pub", GNUNET_JSON_from_data_auto (&pub)); + "exchange_sig", + GNUNET_JSON_from_data_auto (&sig), + "exchange_pub", + GNUNET_JSON_from_data_auto (&pub)); } @@ -353,9 +370,9 @@ handle_transaction_data (void *cls, */ static enum GNUNET_DB_QueryStatus track_transfer_transaction (void *cls, - struct MHD_Connection *connection, - struct TALER_EXCHANGEDB_Session *session, - int *mhd_ret) + struct MHD_Connection *connection, + struct TALER_EXCHANGEDB_Session *session, + int *mhd_ret) { struct WtidTransactionContext *ctx = cls; enum GNUNET_DB_QueryStatus qs; @@ -369,17 +386,17 @@ track_transfer_transaction (void *cls, ctx->wdd_tail = NULL; ctx->wire_method = NULL; qs = TEH_plugin->lookup_wire_transfer (TEH_plugin->cls, - session, - &ctx->wtid, - &handle_transaction_data, - ctx); + session, + &ctx->wtid, + &handle_transaction_data, + ctx); if (0 > qs) { if (GNUNET_DB_STATUS_HARD_ERROR == qs) { GNUNET_break (0); *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_TRACK_TRANSFER_DB_FETCH_FAILED); + TALER_EC_TRACK_TRANSFER_DB_FETCH_FAILED); } return qs; } @@ -387,33 +404,33 @@ track_transfer_transaction (void *cls, { GNUNET_break (0); *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_TRACK_TRANSFER_DB_INCONSISTENT); + TALER_EC_TRACK_TRANSFER_DB_INCONSISTENT); return GNUNET_DB_STATUS_HARD_ERROR; } if (GNUNET_NO == ctx->is_valid) { *mhd_ret = TEH_RESPONSE_reply_arg_unknown (connection, - TALER_EC_TRACK_TRANSFER_WTID_NOT_FOUND, - "wtid"); + TALER_EC_TRACK_TRANSFER_WTID_NOT_FOUND, + "wtid"); return GNUNET_DB_STATUS_HARD_ERROR; } qs = TEH_plugin->get_wire_fee (TEH_plugin->cls, - session, - ctx->wire_method, - ctx->exec_time, - &wire_fee_start_date, - &wire_fee_end_date, - &ctx->wire_fee, - &closing_fee, - &wire_fee_master_sig); + session, + ctx->wire_method, + ctx->exec_time, + &wire_fee_start_date, + &wire_fee_end_date, + &ctx->wire_fee, + &closing_fee, + &wire_fee_master_sig); if (0 >= qs) { if ( (GNUNET_DB_STATUS_HARD_ERROR == qs) || - (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS) ) + (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS) ) { GNUNET_break (0); *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_TRACK_TRANSFER_WIRE_FEE_NOT_FOUND); + TALER_EC_TRACK_TRANSFER_WIRE_FEE_NOT_FOUND); } return qs; } @@ -424,7 +441,7 @@ track_transfer_transaction (void *cls, { GNUNET_break (0); *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_TRACK_TRANSFER_WIRE_FEE_INCONSISTENT); + TALER_EC_TRACK_TRANSFER_WIRE_FEE_INCONSISTENT); return GNUNET_DB_STATUS_HARD_ERROR; } return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; @@ -477,7 +494,8 @@ TEH_TRACKING_handler_track_transfer (struct TEH_RequestHandler *rh, res = TEH_PARSE_mhd_request_arg_data (connection, "wtid", &ctx.wtid, - sizeof (struct TALER_WireTransferIdentifierRawP)); + sizeof (struct + TALER_WireTransferIdentifierRawP)); if (GNUNET_SYSERR == res) return MHD_NO; /* internal error */ if (GNUNET_NO == res) @@ -485,20 +503,20 @@ TEH_TRACKING_handler_track_transfer (struct TEH_RequestHandler *rh, if (GNUNET_OK != TEH_DB_run_transaction (connection, "run track transfer", - &mhd_ret, - &track_transfer_transaction, - &ctx)) + &mhd_ret, + &track_transfer_transaction, + &ctx)) { free_ctx (&ctx); return mhd_ret; } mhd_ret = reply_track_transfer_details (connection, - &ctx.total, - &ctx.merchant_pub, - &ctx.h_wire, - &ctx.wire_fee, - ctx.exec_time, - ctx.wdd_head); + &ctx.total, + &ctx.merchant_pub, + &ctx.h_wire, + &ctx.wire_fee, + ctx.exec_time, + ctx.wdd_head); free_ctx (&ctx); return mhd_ret; } diff --git a/src/exchange/taler-exchange-httpd_validation.c b/src/exchange/taler-exchange-httpd_validation.c index acb12117..0be21528 100644 --- a/src/exchange/taler-exchange-httpd_validation.c +++ b/src/exchange/taler-exchange-httpd_validation.c @@ -320,7 +320,7 @@ TEH_json_validate_wireformat (const json_t *wire, payto_url); return TALER_EC_PAYTO_MALFORMED; } - for (struct Plugin *p=wire_head; NULL != p; p = p->next) + for (struct Plugin *p = wire_head; NULL != p; p = p->next) { if (0 == strcasecmp (p->plugin->method, method)) diff --git a/src/exchange/taler-exchange-httpd_wire.c b/src/exchange/taler-exchange-httpd_wire.c index bbbf3fb4..797ed8be 100644 --- a/src/exchange/taler-exchange-httpd_wire.c +++ b/src/exchange/taler-exchange-httpd_wire.c @@ -57,11 +57,19 @@ fees_to_json (struct TALER_EXCHANGEDB_AggregateFees *af) if (0 != json_array_append_new (a, json_pack ("{s:o, s:o, s:o, s:o, s:o}", - "wire_fee", TALER_JSON_from_amount (&af->wire_fee), - "closing_fee", TALER_JSON_from_amount (&af->closing_fee), - "start_date", GNUNET_JSON_from_time_abs (af->start_date), - "end_date", GNUNET_JSON_from_time_abs (af->end_date), - "sig", GNUNET_JSON_from_data_auto (&af->master_sig)))) + "wire_fee", TALER_JSON_from_amount ( + &af->wire_fee), + "closing_fee", + TALER_JSON_from_amount ( + &af->closing_fee), + "start_date", + GNUNET_JSON_from_time_abs ( + af->start_date), + "end_date", + GNUNET_JSON_from_time_abs ( + af->end_date), + "sig", GNUNET_JSON_from_data_auto ( + &af->master_sig)))) { GNUNET_break (0); json_decref (a); @@ -157,7 +165,7 @@ TEH_WIRE_init () /** * Clean up wire subsystem. */ -void __attribute__ ((destructor)) +void __attribute__ ((destructor)) TEH_wire_cleanup () { if (NULL != wire_methods) diff --git a/src/exchange/taler-exchange-wirewatch.c b/src/exchange/taler-exchange-wirewatch.c index ac2d96a0..ea737b7b 100644 --- a/src/exchange/taler-exchange-wirewatch.c +++ b/src/exchange/taler-exchange-wirewatch.c @@ -216,8 +216,9 @@ shutdown_task (void *cls) { char *wtid_s; - wtid_s = wa_pos->wire_plugin->reject_transfer_cancel (wa_pos->wire_plugin->cls, - rt); + wtid_s = wa_pos->wire_plugin->reject_transfer_cancel ( + wa_pos->wire_plugin->cls, + rt); rt = NULL; GNUNET_free (wtid_s); } @@ -262,8 +263,8 @@ add_account_cb (void *cls, if (NULL == wa->wire_plugin) { GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, - "Failed to load wire plugin for `%s'\n", - ai->plugin_name); + "Failed to load wire plugin for `%s'\n", + ai->plugin_name); GNUNET_free (wa); return; } @@ -355,7 +356,7 @@ reject_cb (void *cls, ec); GNUNET_free (rtc->wtid_s); db_plugin->rollback (db_plugin->cls, - rtc->session); + rtc->session); GNUNET_free (rtc); GNUNET_SCHEDULER_shutdown (); return; @@ -385,10 +386,10 @@ reject_cb (void *cls, static int history_cb (void *cls, enum TALER_ErrorCode ec, - enum TALER_BANK_Direction dir, - const void *row_off, - size_t row_off_size, - const struct TALER_WIRE_TransferDetails *details) + enum TALER_BANK_Direction dir, + const void *row_off, + size_t row_off_size, + const struct TALER_WIRE_TransferDetails *details) { struct TALER_EXCHANGEDB_Session *session = cls; enum GNUNET_DB_QueryStatus qs; @@ -409,7 +410,7 @@ history_cb (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "End of list. Committing progress!\n"); qs = db_plugin->commit (db_plugin->cls, - session); + session); if (GNUNET_DB_STATUS_SOFT_ERROR == qs) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -529,14 +530,14 @@ history_cb (void *cls, &details->wtid, sizeof (reserve_pub)); qs = db_plugin->reserves_in_insert (db_plugin->cls, - session, - &reserve_pub, - &details->amount, - details->execution_date, - details->account_url, + session, + &reserve_pub, + &details->amount, + details->execution_date, + details->account_url, wa_pos->section_name, - row_off, - row_off_size); + row_off, + row_off_size); if (GNUNET_DB_STATUS_HARD_ERROR == qs) { GNUNET_break (0); @@ -554,7 +555,7 @@ history_cb (void *cls, /* try again */ GNUNET_assert (NULL == task); task = GNUNET_SCHEDULER_add_now (&find_transfers, - NULL); + NULL); return GNUNET_SYSERR; } @@ -565,8 +566,8 @@ history_cb (void *cls, latest_row_off_size = row_off_size; } memcpy (latest_row_off, - row_off, - row_off_size); + row_off, + row_off_size); return GNUNET_OK; } @@ -705,24 +706,25 @@ main (int argc, { struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_option_flag ('T', - "test", - "run in test mode and exit when idle", - &test_mode), + "test", + "run in test mode and exit when idle", + &test_mode), GNUNET_GETOPT_option_flag ('r', - "reset", - "start fresh with all transactions in the history", - &reset_mode), + "reset", + "start fresh with all transactions in the history", + &reset_mode), GNUNET_GETOPT_OPTION_END }; if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, - &argc, &argv)) + &argc, &argv)) return 2; if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "taler-exchange-wirewatch", - gettext_noop ("background process that watches for incomming wire transfers from customers"), + gettext_noop ( + "background process that watches for incomming wire transfers from customers"), options, &run, NULL)) { diff --git a/src/exchange/test_taler_exchange_aggregator.c b/src/exchange/test_taler_exchange_aggregator.c index b02c976a..274a28ac 100644 --- a/src/exchange/test_taler_exchange_aggregator.c +++ b/src/exchange/test_taler_exchange_aggregator.c @@ -32,7 +32,8 @@ /** * Commands for the interpreter. */ -enum OpCode { +enum OpCode +{ /** * Terminate testcase with 'skipped' result. @@ -86,14 +87,16 @@ struct Command */ const char *label; - union { + union + { /** * If @e opcode is #OPCODE_EXPECT_TRANSACTION, this * specifies which transaction we expected. Note that * the WTID will be set, not checked! */ - struct { + struct + { /** * Amount to be transferred. @@ -126,7 +129,8 @@ struct Command * If @e opcode is #OPCODE_DATABASE_DEPOST, this * specifies which deposit operation we should fake. */ - struct { + struct + { /** * Each merchant name is automatically mapped to a unique @@ -174,7 +178,7 @@ struct State /** * Array of commands to run. */ - struct Command* commands; + struct Command*commands; /** * Offset of the next command to be run. @@ -339,9 +343,10 @@ maint_child_death (void *cls) aggregator_state->ioff++; state = aggregator_state; aggregator_state = NULL; - child_death_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, - pr, - &maint_child_death, NULL); + child_death_task = GNUNET_SCHEDULER_add_read_file ( + GNUNET_TIME_UNIT_FOREVER_REL, + pr, + &maint_child_death, NULL); interpreter (state); } @@ -354,7 +359,8 @@ maint_child_death (void *cls) static void fake_issue (struct TALER_EXCHANGEDB_DenominationKeyInformationP *issue) { - memset (issue, 0, sizeof (struct TALER_EXCHANGEDB_DenominationKeyInformationP)); + memset (issue, 0, sizeof (struct + TALER_EXCHANGEDB_DenominationKeyInformationP)); GNUNET_assert (GNUNET_OK == TALER_string_to_amount_nbo ("EUR:1", &issue->properties.value)); @@ -440,7 +446,8 @@ do_deposit (struct Command *cmd) GNUNET_asprintf (&str, "payto://x-taler-bank/localhost:8082/%llu", - (unsigned long long) cmd->details.deposit.merchant_account); + (unsigned long + long) cmd->details.deposit.merchant_account); deposit.receiver_wire_account = json_pack ("{s:s, s:s}", "salt", "this-is-a-salt-value", @@ -448,11 +455,13 @@ do_deposit (struct Command *cmd) GNUNET_free (str); } GNUNET_assert (GNUNET_OK == - TALER_JSON_merchant_wire_signature_hash (deposit.receiver_wire_account, - &deposit.h_wire)); + TALER_JSON_merchant_wire_signature_hash ( + deposit.receiver_wire_account, + &deposit.h_wire)); deposit.timestamp = GNUNET_TIME_absolute_get (); GNUNET_TIME_round_abs (&deposit.timestamp); - deposit.wire_deadline = GNUNET_TIME_relative_to_absolute (cmd->details.deposit.wire_deadline); + deposit.wire_deadline = GNUNET_TIME_relative_to_absolute ( + cmd->details.deposit.wire_deadline); GNUNET_TIME_round_abs (&deposit.wire_deadline); /* finally, actually perform the DB operation */ @@ -550,7 +559,7 @@ interpreter (void *cls) fail (cmd); return; } - return; + return; case OPCODE_EXPECT_TRANSACTIONS_EMPTY: if (GNUNET_OK != TALER_FAKEBANK_check_empty (fb)) { @@ -585,7 +594,8 @@ interpreter (void *cls) &want_amount, cmd->details.expect_transaction.debit_account, cmd->details.expect_transaction.credit_account, - cmd->details.expect_transaction.exchange_base_url, + cmd->details.expect_transaction. + exchange_base_url, &cmd->details.expect_transaction.subject)) { fail (cmd); @@ -641,7 +651,8 @@ run_test () .label = "expect-deposit-1", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 4, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:0.89" }, @@ -688,7 +699,8 @@ run_test () .label = "expect-deposit-2", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 4, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:1.79" }, @@ -734,7 +746,8 @@ run_test () .label = "expect-deposit-3a", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 4, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:0.89" }, { @@ -742,7 +755,8 @@ run_test () .label = "expect-deposit-3b", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 4, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:0.89" }, { @@ -750,7 +764,8 @@ run_test () .label = "expect-deposit-3c", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 5, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:0.89" }, { @@ -799,7 +814,8 @@ run_test () .label = "expect-deposit-4", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 4, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:0.19" }, @@ -844,7 +860,8 @@ run_test () .label = "expect-deposit-5", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 4, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:0.19" }, @@ -927,7 +944,8 @@ run_test () .label = "expect-deposit-6", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 4, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:0.01" }, @@ -967,7 +985,8 @@ run_test () .label = "expect-deposit-7", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 4, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:0.01" }, /* Now check profit was actually taken */ @@ -989,7 +1008,8 @@ run_test () .label = "expect-deposit-7", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 4, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:0.01" }, @@ -1047,7 +1067,8 @@ run_test () .label = "expect-deposit-8", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 4, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:0.03" }, @@ -1107,7 +1128,8 @@ run_test () .label = "expect-deposit-9", .details.expect_transaction.debit_account = 3, .details.expect_transaction.credit_account = 4, - .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transaction.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transaction.amount = "EUR:0.01" }, @@ -1166,7 +1188,7 @@ run (void *cls) fake_issue (&issue); dpk.rsa_public_key = coin_pub; GNUNET_CRYPTO_rsa_public_key_hash (dpk.rsa_public_key, - &issue.properties.denom_hash); + &issue.properties.denom_hash); if ( (GNUNET_OK != plugin->start (plugin->cls, session, @@ -1179,18 +1201,18 @@ run (void *cls) (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != plugin->commit (plugin->cls, session)) ) - { - GNUNET_break (0); - TALER_EXCHANGEDB_plugin_unload (plugin); - plugin = NULL; - result = 77; - return; - } + { + GNUNET_break (0); + TALER_EXCHANGEDB_plugin_unload (plugin); + plugin = NULL; + result = 77; + return; + } child_death_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_DISK_pipe_handle (sigpipe, - GNUNET_DISK_PIPE_END_READ), - &maint_child_death, + GNUNET_DISK_pipe_handle (sigpipe, + GNUNET_DISK_PIPE_END_READ), + &maint_child_death, NULL); GNUNET_SCHEDULER_add_shutdown (&shutdown_action, NULL); @@ -1217,13 +1239,13 @@ static void sighandler_child_death () { static char c; - int old_errno = errno; /* back-up errno */ + int old_errno = errno; /* back-up errno */ GNUNET_break (1 == - GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle - (sigpipe, GNUNET_DISK_PIPE_END_WRITE), - &c, sizeof (c))); - errno = old_errno; /* restore errno */ + GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle + (sigpipe, GNUNET_DISK_PIPE_END_WRITE), + &c, sizeof (c))); + errno = old_errno; /* restore errno */ } @@ -1266,14 +1288,14 @@ main (int argc, if (NULL == proc) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to run `taler-exchange-keyup`, is your PATH correct?\n"); + "Failed to run `taler-exchange-keyup`, is your PATH correct?\n"); return 77; } GNUNET_OS_process_wait (proc); GNUNET_OS_process_destroy (proc); if (GNUNET_OK != GNUNET_NETWORK_test_port_free (IPPROTO_TCP, - 8082)) + 8082)) { fprintf (stderr, "Required port %u not available, skipping.\n", diff --git a/src/exchange/test_taler_exchange_wirewatch.c b/src/exchange/test_taler_exchange_wirewatch.c index 4a23bdb5..27b98bb0 100644 --- a/src/exchange/test_taler_exchange_wirewatch.c +++ b/src/exchange/test_taler_exchange_wirewatch.c @@ -34,7 +34,8 @@ /** * Commands for the interpreter. */ -enum OpCode { +enum OpCode +{ /** * Terminate testcase with 'skipped' result. @@ -94,14 +95,16 @@ struct Command */ const char *label; - union { + union + { /** * If @e opcode is #OPCODE_EXPECT_TRANSFER, this * specifies which transaction we expected. Note that * the WTID will be set, not checked! */ - struct { + struct + { /** * Amount to be transferred. @@ -135,7 +138,8 @@ struct Command * If @e opcode is #OPCODE_RUN_TRANSFER, this * specifies which transaction the bank should do. */ - struct { + struct + { /** * Amount to be transferred. @@ -164,7 +168,8 @@ struct Command } run_transfer; - struct { + struct + { /** * The handle for the aggregator process that we are testing. @@ -178,7 +183,8 @@ struct Command } aggregator; - struct { + struct + { /** * The handle for the wirewatch process that we are testing. @@ -210,7 +216,7 @@ struct State /** * Array of commands to run. */ - struct Command* commands; + struct Command*commands; /** * Offset of the next command to be run. @@ -335,7 +341,7 @@ shutdown_action (void *cls) TALER_FAKEBANK_stop (fb); fb = NULL; } - for (unsigned int i=0;i<=state->ioff;i++) + for (unsigned int i = 0; i<=state->ioff; i++) { struct Command *cmd = &state->commands[i]; @@ -351,8 +357,9 @@ shutdown_action (void *cls) } if (NULL != cmd->details.aggregator.aggregator_proc) { - GNUNET_break (0 == GNUNET_OS_process_kill (cmd->details.aggregator.aggregator_proc, - SIGKILL)); + GNUNET_break (0 == GNUNET_OS_process_kill ( + cmd->details.aggregator.aggregator_proc, + SIGKILL)); GNUNET_OS_process_wait (cmd->details.aggregator.aggregator_proc); GNUNET_OS_process_destroy (cmd->details.aggregator.aggregator_proc); cmd->details.aggregator.aggregator_proc = NULL; @@ -366,8 +373,9 @@ shutdown_action (void *cls) } if (NULL != cmd->details.wirewatch.wirewatch_proc) { - GNUNET_break (0 == GNUNET_OS_process_kill (cmd->details.wirewatch.wirewatch_proc, - SIGKILL)); + GNUNET_break (0 == GNUNET_OS_process_kill ( + cmd->details.wirewatch.wirewatch_proc, + SIGKILL)); GNUNET_OS_process_wait (cmd->details.wirewatch.wirewatch_proc); GNUNET_OS_process_destroy (cmd->details.wirewatch.wirewatch_proc); cmd->details.wirewatch.wirewatch_proc = NULL; @@ -614,7 +622,8 @@ run (void *cls) .label = "run-transfer-good-to-exchange", .details.run_transfer.debit_account = 4, .details.run_transfer.credit_account = 3, - .details.run_transfer.subject = "SRB8VQHNTNJWSSG7BXT24Z063ZSXN7T0MHCQCBAFC1V17BZH10D0", + .details.run_transfer.subject = + "SRB8VQHNTNJWSSG7BXT24Z063ZSXN7T0MHCQCBAFC1V17BZH10D0", .details.run_transfer.amount = "EUR:5.00" }, /* creates reserve */ @@ -628,7 +637,8 @@ run (void *cls) .label = "clear-good-transfer-to-exchange", .details.expect_transfer.debit_account = 4, .details.expect_transfer.credit_account = 3, - .details.expect_transfer.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transfer.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transfer.amount = "EUR:5.00" }, /* should do NOTHING, it is too early... */ @@ -658,7 +668,8 @@ run (void *cls) .label = "check-reserve-expiration-transfer", .details.expect_transfer.debit_account = 3, .details.expect_transfer.credit_account = 4, - .details.expect_transfer.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transfer.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transfer.amount = "EUR:4.99" }, /* check nothing else happened */ @@ -685,7 +696,8 @@ run (void *cls) .label = "expect-bad-transfer-to-exchange", .details.expect_transfer.debit_account = 4, .details.expect_transfer.credit_account = 3, - .details.expect_transfer.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transfer.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transfer.amount = "EUR:5.00" }, { @@ -693,7 +705,8 @@ run (void *cls) .label = "expect-rewire-transfer-from-exchange", .details.expect_transfer.debit_account = 3, .details.expect_transfer.credit_account = 4, - .details.expect_transfer.exchange_base_url = "https://exchange.taler.net/", + .details.expect_transfer.exchange_base_url = + "https://exchange.taler.net/", .details.expect_transfer.amount = "EUR:5.00" }, { @@ -739,13 +752,13 @@ static void sighandler_child_death () { static char c; - int old_errno = errno; /* back-up errno */ + int old_errno = errno; /* back-up errno */ GNUNET_break (1 == - GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle - (sigpipe, GNUNET_DISK_PIPE_END_WRITE), - &c, sizeof (c))); - errno = old_errno; /* restore errno */ + GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle + (sigpipe, GNUNET_DISK_PIPE_END_WRITE), + &c, sizeof (c))); + errno = old_errno; /* restore errno */ } @@ -788,7 +801,7 @@ main (int argc, if (NULL == proc) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to run `taler-exchange-keyup`, is your PATH correct?\n"); + "Failed to run `taler-exchange-keyup`, is your PATH correct?\n"); return 77; } GNUNET_OS_process_wait (proc); @@ -804,14 +817,14 @@ main (int argc, if (NULL == proc) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to run `taler-exchange-keyup`, is your PATH correct?\n"); + "Failed to run `taler-exchange-keyup`, is your PATH correct?\n"); return 77; } GNUNET_OS_process_wait (proc); GNUNET_OS_process_destroy (proc); if (GNUNET_OK != GNUNET_NETWORK_test_port_free (IPPROTO_TCP, - 8082)) + 8082)) { fprintf (stderr, "Required port %u not available, skipping.\n", diff --git a/src/exchangedb/exchangedb_accounts.c b/src/exchangedb/exchangedb_accounts.c index 10328fbe..f336b53a 100644 --- a/src/exchangedb/exchangedb_accounts.c +++ b/src/exchangedb/exchangedb_accounts.c @@ -100,7 +100,7 @@ check_for_account (void *cls, ai.plugin_name = plugin_name; ai.payto_url = payto_url; ai.wire_response_filename = wire_response_filename; - + ai.debit_enabled = (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (ctx->cfg, section, diff --git a/src/exchangedb/exchangedb_auditorkeys.c b/src/exchangedb/exchangedb_auditorkeys.c index 38498d9b..6546c1a3 100644 --- a/src/exchangedb/exchangedb_auditorkeys.c +++ b/src/exchangedb/exchangedb_auditorkeys.c @@ -141,8 +141,8 @@ auditor_iter (void *cls, return GNUNET_OK; } if ( (size - sizeof (struct AuditorFileHeaderP)) / dki_len < - (sizeof (struct TALER_DenominationKeyValidityPS) + - sizeof (struct TALER_AuditorSignatureP)) ) + (sizeof (struct TALER_DenominationKeyValidityPS) + + sizeof (struct TALER_AuditorSignatureP)) ) { GNUNET_break_op (0); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -152,9 +152,9 @@ auditor_iter (void *cls, return GNUNET_OK; } url_len = size - - sizeof (struct AuditorFileHeaderP) - - dki_len * (sizeof (struct TALER_DenominationKeyValidityPS) + - sizeof (struct TALER_AuditorSignatureP)); + - sizeof (struct AuditorFileHeaderP) + - dki_len * (sizeof (struct TALER_DenominationKeyValidityPS) + + sizeof (struct TALER_AuditorSignatureP)); sigs = (const struct TALER_AuditorSignatureP *) &af[1]; dki = (const struct TALER_DenominationKeyValidityPS *) &sigs[dki_len]; auditor_url = (const char *) &dki[dki_len]; @@ -171,12 +171,12 @@ auditor_iter (void *cls, /* Ignoring return value to not interrupt the iteration */ if (GNUNET_OK != (iret = aic->it (aic->it_cls, - &af->apub, - auditor_url, - &af->mpub, - dki_len, - sigs, - dki))) + &af->apub, + auditor_url, + &af->mpub, + dki_len, + sigs, + dki))) { GNUNET_free (af); if (GNUNET_SYSERR == iret) @@ -248,7 +248,8 @@ TALER_EXCHANGEDB_auditor_write (const char *filename, const struct TALER_AuditorSignatureP *asigs, const struct TALER_MasterPublicKeyP *mpub, unsigned int dki_len, - const struct TALER_DenominationKeyValidityPS *dki) + const struct + TALER_DenominationKeyValidityPS *dki) { struct AuditorFileHeaderP af; struct GNUNET_DISK_FileHandle *fh; @@ -262,9 +263,11 @@ TALER_EXCHANGEDB_auditor_write (const char *filename, af.dki_len = htonl ((uint32_t) dki_len); ret = GNUNET_SYSERR; if (NULL == (fh = GNUNET_DISK_file_open - (filename, - GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_TRUNCATE, - GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE))) + (filename, + GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE + | GNUNET_DISK_OPEN_TRUNCATE, + GNUNET_DISK_PERM_USER_READ + | GNUNET_DISK_PERM_USER_WRITE))) goto cleanup; wsize = sizeof (struct AuditorFileHeaderP); if (GNUNET_SYSERR == (wrote = GNUNET_DISK_file_write (fh, @@ -291,7 +294,7 @@ TALER_EXCHANGEDB_auditor_write (const char *filename, auditor_url, wsize)) ret = GNUNET_OK; - cleanup: + cleanup: eno = errno; if (NULL != fh) (void) GNUNET_DISK_file_close (fh); diff --git a/src/exchangedb/exchangedb_denomkeys.c b/src/exchangedb/exchangedb_denomkeys.c index d9e604eb..be2ee66b 100644 --- a/src/exchangedb/exchangedb_denomkeys.c +++ b/src/exchangedb/exchangedb_denomkeys.c @@ -59,8 +59,10 @@ GNUNET_NETWORK_STRUCT_END */ int TALER_EXCHANGEDB_denomination_key_revoke (const char *revocation_dir, - const struct GNUNET_HashCode *denom_hash, - const struct TALER_MasterPrivateKeyP *mpriv) + const struct + GNUNET_HashCode *denom_hash, + const struct + TALER_MasterPrivateKeyP *mpriv) { struct TALER_MasterDenominationKeyRevocationPS rm; char *fn; @@ -69,7 +71,7 @@ TALER_EXCHANGEDB_denomination_key_revoke (const char *revocation_dir, ret = GNUNET_SYSERR; GNUNET_asprintf (&fn, - "%s" DIR_SEPARATOR_STR + "%s" DIR_SEPARATOR_STR "%s.rev", revocation_dir, GNUNET_h2s_full (denom_hash)); @@ -83,9 +85,10 @@ TALER_EXCHANGEDB_denomination_key_revoke (const char *revocation_dir, rd.denom_hash = *denom_hash; if (sizeof (rd) != GNUNET_DISK_fn_write (fn, - &rd, - sizeof (rd), - GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE)) + &rd, + sizeof (rd), + GNUNET_DISK_PERM_USER_READ + | GNUNET_DISK_PERM_USER_WRITE)) ret = GNUNET_SYSERR; else ret = GNUNET_OK; @@ -104,7 +107,9 @@ TALER_EXCHANGEDB_denomination_key_revoke (const char *revocation_dir, */ int TALER_EXCHANGEDB_denomination_key_read (const char *filename, - struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) + struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation + *dki) { uint64_t size; size_t offset; @@ -156,7 +161,8 @@ TALER_EXCHANGEDB_denomination_key_read (const char *filename, offset); GNUNET_free (data); if (0 == GNUNET_TIME_absolute_get_remaining - (GNUNET_TIME_absolute_ntoh (dki->issue.properties.expire_withdraw)).rel_value_us) + (GNUNET_TIME_absolute_ntoh ( + dki->issue.properties.expire_withdraw)).rel_value_us) { if (0 != UNLINK (filename)) { @@ -180,7 +186,9 @@ TALER_EXCHANGEDB_denomination_key_read (const char *filename, */ int TALER_EXCHANGEDB_denomination_key_write (const char *filename, - const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) + const struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation + *dki) { char *priv_enc; size_t priv_enc_size; @@ -198,9 +206,11 @@ TALER_EXCHANGEDB_denomination_key_write (const char *filename, GNUNET_DISK_directory_create_for_file (filename)) return GNUNET_SYSERR; if (NULL == (fh = GNUNET_DISK_file_open - (filename, - GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_TRUNCATE, - GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE | GNUNET_DISK_OPEN_FAILIFEXISTS))) + (filename, + GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE + | GNUNET_DISK_OPEN_TRUNCATE, + GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE + | GNUNET_DISK_OPEN_FAILIFEXISTS))) goto cleanup; wsize = sizeof (struct TALER_EXCHANGEDB_DenominationKeyInformationP); if (GNUNET_SYSERR == (wrote = GNUNET_DISK_file_write (fh, @@ -217,7 +227,7 @@ TALER_EXCHANGEDB_denomination_key_write (const char *filename, if (wrote != priv_enc_size) goto cleanup; ret = GNUNET_OK; - cleanup: + cleanup: GNUNET_free_non_null (priv_enc); if (NULL != fh) (void) GNUNET_DISK_file_close (fh); @@ -328,7 +338,8 @@ denomkeys_iterate_topdir_iter (void *cls, */ int TALER_EXCHANGEDB_denomination_keys_iterate (const char *exchange_base_dir, - TALER_EXCHANGEDB_DenominationKeyIterator it, + TALER_EXCHANGEDB_DenominationKeyIterator + it, void *it_cls) { char *dir; @@ -336,7 +347,8 @@ TALER_EXCHANGEDB_denomination_keys_iterate (const char *exchange_base_dir, int ret; GNUNET_asprintf (&dir, - "%s" DIR_SEPARATOR_STR TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS, + "%s" DIR_SEPARATOR_STR + TALER_EXCHANGEDB_DIR_DENOMINATION_KEYS, exchange_base_dir); dic.it = it; dic.it_cls = it_cls; @@ -363,7 +375,7 @@ struct RevocationsIterateContext * Closure for @e it. */ void *it_cls; - + /** * Master public key to use to validate revocations. */ @@ -385,7 +397,7 @@ struct RevocationsIterateContext */ static int revocations_iterate_cb (void *cls, - const char *filename) + const char *filename) { struct RevocationsIterateContext *ric = cls; struct RevocationFileP rf; @@ -394,34 +406,37 @@ revocations_iterate_cb (void *cls, /* Check if revocation is valid... */ if (sizeof (rf) != GNUNET_DISK_fn_read (filename, - &rf, - sizeof (rf))) + &rf, + sizeof (rf))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Invalid revocation file `%s' found and ignored (bad size)\n"), - filename); + _ ( + "Invalid revocation file `%s' found and ignored (bad size)\n"), + filename); return GNUNET_OK; } rm.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED); rm.purpose.size = htonl (sizeof (rm)); rm.h_denom_pub = rf.denom_hash; if (GNUNET_OK != - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED, - &rm.purpose, - &rf.msig.eddsa_signature, - &ric->master_pub->eddsa_pub)) + GNUNET_CRYPTO_eddsa_verify ( + TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED, + &rm.purpose, + &rf.msig.eddsa_signature, + &ric->master_pub->eddsa_pub)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Invalid revocation file `%s' found and ignored (bad signature)\n"), - filename); + _ ( + "Invalid revocation file `%s' found and ignored (bad signature)\n"), + filename); return GNUNET_OK; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Denomination key `%s' was revoked!\n", - GNUNET_h2s (&rm.h_denom_pub)); + "Denomination key `%s' was revoked!\n", + GNUNET_h2s (&rm.h_denom_pub)); return ric->it (ric->it_cls, - &rm.h_denom_pub, - &rf.msig); + &rm.h_denom_pub, + &rf.msig); } @@ -439,9 +454,10 @@ revocations_iterate_cb (void *cls, */ int TALER_EXCHANGEDB_revocations_iterate (const char *revocation_dir, - const struct TALER_MasterPublicKeyP *master_pub, - TALER_EXCHANGEDB_RevocationIterator it, - void *it_cls) + const struct + TALER_MasterPublicKeyP *master_pub, + TALER_EXCHANGEDB_RevocationIterator it, + void *it_cls) { struct RevocationsIterateContext ric = { .it = it, @@ -452,10 +468,10 @@ TALER_EXCHANGEDB_revocations_iterate (const char *revocation_dir, if (GNUNET_OK != GNUNET_DISK_directory_create (revocation_dir)) return 0; /* directory doesn't exist and we couldn't even create it, - clearly means there are no revocations there */ + clearly means there are no revocations there */ return GNUNET_DISK_directory_scan (revocation_dir, - &revocations_iterate_cb, - &ric); + &revocations_iterate_cb, + &ric); } diff --git a/src/exchangedb/exchangedb_fees.c b/src/exchangedb/exchangedb_fees.c index d6fdac4d..f06be73a 100644 --- a/src/exchangedb/exchangedb_fees.c +++ b/src/exchangedb/exchangedb_fees.c @@ -191,11 +191,11 @@ TALER_EXCHANGEDB_fees_write (const char *filename, return GNUNET_SYSERR; fh = GNUNET_DISK_file_open (filename, - GNUNET_DISK_OPEN_WRITE | - GNUNET_DISK_OPEN_TRUNCATE | - GNUNET_DISK_OPEN_CREATE, - GNUNET_DISK_PERM_USER_READ | - GNUNET_DISK_PERM_USER_WRITE); + GNUNET_DISK_OPEN_WRITE + | GNUNET_DISK_OPEN_TRUNCATE + | GNUNET_DISK_OPEN_CREATE, + GNUNET_DISK_PERM_USER_READ + | GNUNET_DISK_PERM_USER_WRITE); if (NULL == fh) return GNUNET_SYSERR; diff --git a/src/exchangedb/exchangedb_signkeys.c b/src/exchangedb/exchangedb_signkeys.c index cb16ee49..10e4f7a6 100644 --- a/src/exchangedb/exchangedb_signkeys.c +++ b/src/exchangedb/exchangedb_signkeys.c @@ -63,18 +63,20 @@ signkeys_iterate_dir_iter (void *cls, nread = GNUNET_DISK_fn_read (filename, &issue, - sizeof (struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP)); + sizeof (struct + TALER_EXCHANGEDB_PrivateSigningKeyInformationP)); if (nread != sizeof (struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid signkey file `%s': wrong size (%d, expected %u)\n", filename, (int) nread, - (unsigned int) sizeof (struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP)); + (unsigned int) sizeof (struct + TALER_EXCHANGEDB_PrivateSigningKeyInformationP)); return GNUNET_OK; } if (0 == GNUNET_TIME_absolute_get_remaining - (GNUNET_TIME_absolute_ntoh (issue.issue.expire)).rel_value_us) + (GNUNET_TIME_absolute_ntoh (issue.issue.expire)).rel_value_us) { if (0 != UNLINK (filename)) { @@ -143,7 +145,8 @@ get_signkey_file (const char *exchange_directory, char *fn; GNUNET_asprintf (&fn, - "%s" DIR_SEPARATOR_STR TALER_EXCHANGEDB_DIR_SIGNING_KEYS DIR_SEPARATOR_STR "%llu", + "%s" DIR_SEPARATOR_STR TALER_EXCHANGEDB_DIR_SIGNING_KEYS + DIR_SEPARATOR_STR "%llu", exchange_directory, (unsigned long long) start.abs_value_us); return fn; @@ -161,7 +164,9 @@ get_signkey_file (const char *exchange_directory, int TALER_EXCHANGEDB_signing_key_write (const char *exchange_base_dir, struct GNUNET_TIME_Absolute start, - const struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP *ski) + const struct + TALER_EXCHANGEDB_PrivateSigningKeyInformationP + *ski) { char *skf; ssize_t nwrite; @@ -173,8 +178,10 @@ TALER_EXCHANGEDB_signing_key_write (const char *exchange_base_dir, return GNUNET_SYSERR; nwrite = GNUNET_DISK_fn_write (skf, ski, - sizeof (struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP), - GNUNET_DISK_PERM_USER_WRITE | GNUNET_DISK_PERM_USER_READ); + sizeof (struct + TALER_EXCHANGEDB_PrivateSigningKeyInformationP), + GNUNET_DISK_PERM_USER_WRITE + | GNUNET_DISK_PERM_USER_READ); if (sizeof (struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP) != nwrite) { GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, diff --git a/src/exchangedb/perf_taler_exchangedb.c b/src/exchangedb/perf_taler_exchangedb.c index 5cde719c..64fde0c1 100644 --- a/src/exchangedb/perf_taler_exchangedb.c +++ b/src/exchangedb/perf_taler_exchangedb.c @@ -50,86 +50,85 @@ * and logs the results using Gauger */ int -main (int argc, char ** argv) +main (int argc, char **argv) { int ret; - struct PERF_TALER_EXCHANGEDB_Cmd benchmark[] = - { + struct PERF_TALER_EXCHANGEDB_Cmd benchmark[] = { /* Denomination used to create coins */ PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("Initializing database"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("01 - denomination loop", - NB_DENOMINATION_INIT), + NB_DENOMINATION_INIT), PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""), PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DENOMINATION ("01 - denomination"), PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DENOMINATION ("01 - insert", - "01 - denomination"), + "01 - denomination"), PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""), PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("01 - save denomination", - "01 - denomination loop", - "01 - denomination", - NB_DENOMINATION_SAVE), + "01 - denomination loop", + "01 - denomination", + NB_DENOMINATION_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("01 - end", - "01 - denomination loop"), + "01 - denomination loop"), /* End of initialization */ /* Reserve initialization */ PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("02 - init reserve loop", NB_RESERVE_INIT), PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_RESERVE ("02 - reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_RESERVE ("02 - insert", - "02 - reserve"), + "02 - reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("02 - save reserve", - "02 - init reserve loop", - "02 - reserve", - NB_RESERVE_SAVE), + "02 - init reserve loop", + "02 - reserve", + NB_RESERVE_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("02 - end", - "02 - init reserve loop"), + "02 - init reserve loop"), /* End reserve init */ /* Withdrawal initialization */ PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("03 - init withdraw loop", - NB_WITHDRAW_INIT), + NB_WITHDRAW_INIT), PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - denomination load", - "03 - init withdraw loop", - "01 - save denomination"), + "03 - init withdraw loop", + "01 - save denomination"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("03 - reserve load", - "03 - init withdraw loop", - "02 - save reserve"), + "03 - init withdraw loop", + "02 - save reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("03 - withdraw", - "03 - denomination load", - "03 - reserve load"), + "03 - denomination load", + "03 - reserve load"), PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW ("03 - insert", - "03 - withdraw"), + "03 - withdraw"), PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""), PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("03 - save coin", - "03 - init withdraw loop", - "03 - withdraw", - NB_WITHDRAW_SAVE), + "03 - init withdraw loop", + "03 - withdraw", + NB_WITHDRAW_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("03 - end", - "03 - init withdraw loop"), + "03 - init withdraw loop"), /*End of withdrawal initialization */ /*Deposit initialization */ PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("04 - deposit init loop", - NB_DEPOSIT_INIT), + NB_DEPOSIT_INIT), PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("04 - coin load", - "04 - deposit init loop", - "03 - save coin"), + "04 - deposit init loop", + "03 - save coin"), PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_DEPOSIT ("04 - deposit", - "04 - coin load"), + "04 - coin load"), PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_DEPOSIT ("04 - insert", - "04 - deposit"), + "04 - deposit"), PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""), PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("04 - deposit array", - "04 - deposit init loop", - "04 - deposit", - NB_DEPOSIT_SAVE), + "04 - deposit init loop", + "04 - deposit", + NB_DEPOSIT_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", - "04 - deposit init loop"), + "04 - deposit init loop"), /* End of deposit initialization */ /* Session initialization */ PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("05 - refresh session init loop", - NB_REFRESH_INIT), + NB_REFRESH_INIT), PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("05 - denomination load", "05 - refresh session init loop", @@ -140,8 +139,9 @@ main (int argc, char ** argv) PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("05 - withdraw", "05 - denomination load", "05 - reserve load"), - PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_REFRESH_SESSION ("05 - refresh session", - "05 - withdraw"), + PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_REFRESH_SESSION ( + "05 - refresh session", + "05 - withdraw"), PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("05 - session array", "05 - refresh session init loop", "05 - refresh session", @@ -152,190 +152,190 @@ main (int argc, char ** argv) /* End of refresh session initialization */ /* Refresh melt initialization */ PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("06 - refresh melt init loop", - NB_MELT_INIT), + NB_MELT_INIT), PERF_TALER_EXCHANGEDB_INIT_CMD_START_TRANSACTION (""), /* TODO: initialize using coins & sessions created localy * in order to make sure the same coin are not melted twice*/ PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("06 - session hash", - "06 - refresh melt init loop", - "05 - session array"), + "06 - refresh melt init loop", + "05 - session array"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("06 - coin", - "06 - refresh melt init loop", - "03 - save coin"), + "06 - refresh melt init loop", + "03 - save coin"), PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("06 - end", - "06 - refresh melt init loop"), + "06 - refresh melt init loop"), /* End of refresh melt initialization */ PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of initialization"), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("Start of performances measuring"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("21 - start"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("21 - reserve insert measure", - NB_RESERVE_SAVE), + NB_RESERVE_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_RESERVE ("21 - reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_RESERVE ("21 - insert", - "21 - reserve"), + "21 - reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", - "21 - reserve insert measure"), + "21 - reserve insert measure"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("21 - stop"), PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("21 - gauger", - "21 - start", - "21 - stop", - "POSTGRES", - "Number of reserve inserted per second", - "item/sec", - NB_RESERVE_SAVE), + "21 - start", + "21 - stop", + "POSTGRES", + "Number of reserve inserted per second", + "item/sec", + NB_RESERVE_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of reserve insertion"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("22 - start"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("22 - reserve load measure", - NB_RESERVE_SAVE), + NB_RESERVE_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("22 - reserve", - "22 - reserve load measure", - "02 - save reserve"), + "22 - reserve load measure", + "02 - save reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE ("22 - get", - "22 - reserve"), + "22 - reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", - "22 - reserve load measure"), + "22 - reserve load measure"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("22 - stop"), PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", - "22 - start", - "22 - stop", - "POSTGRES", - "Number of reserve loaded per second", - "item/sec", - NB_RESERVE_SAVE), + "22 - start", + "22 - stop", + "POSTGRES", + "Number of reserve loaded per second", + "item/sec", + NB_RESERVE_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of reserve retreival"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("23 - start"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("23 - reserve history measure", - NB_RESERVE_SAVE), + NB_RESERVE_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("23 - reserve", - "23 - reserve history measure", - "02 - save reserve"), + "23 - reserve history measure", + "02 - save reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_RESERVE_HISTORY ("", - "23 - reserve"), + "23 - reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", - "23 - reserve history measure"), + "23 - reserve history measure"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("23 - stop"), PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", - "23 - start", - "23 - stop", - "POSTGRES", - "Number of reserve history loaded per second", - "item/sec", - NB_RESERVE_SAVE), + "23 - start", + "23 - stop", + "POSTGRES", + "Number of reserve history loaded per second", + "item/sec", + NB_RESERVE_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of reserve history access"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("24 - start"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("24 - withdraw insert measure", - NB_WITHDRAW_SAVE), + NB_WITHDRAW_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("24 - reserve", - "24 - withdraw insert measure", - "02 - save reserve"), + "24 - withdraw insert measure", + "02 - save reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("24 - denomination", - "24 - withdraw insert measure", - "01 - save denomination"), + "24 - withdraw insert measure", + "01 - save denomination"), PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("24 - withdraw", - "24 - denomination", - "24 - reserve"), + "24 - denomination", + "24 - reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_INSERT_WITHDRAW ("24 - insert", - "24 - withdraw"), + "24 - withdraw"), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", - "24 - withdraw insert measure"), + "24 - withdraw insert measure"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("24 - stop"), PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", - "24 - start", - "24 - stop", - "POSTGRES", - "Number of withdraw insert per second", - "item/sec", - NB_WITHDRAW_SAVE), + "24 - start", + "24 - stop", + "POSTGRES", + "Number of withdraw insert per second", + "item/sec", + NB_WITHDRAW_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of withdraw insertion"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("25 - start"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("25 - withdraw insert measure", - NB_RESERVE_SAVE), + NB_RESERVE_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("25 - coin", - "25 - withdraw insert measure", - "03 - save coin"), + "25 - withdraw insert measure", + "03 - save coin"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_WITHDRAW ("", - "25 - coin"), + "25 - coin"), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", - "25 - withdraw insert measure"), + "25 - withdraw insert measure"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("25 - stop"), PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", - "25 - start", - "25 - stop", - "POSTGRES", - "Number of withdraw loaded per second", - "item/sec", - NB_RESERVE_SAVE), + "25 - start", + "25 - stop", + "POSTGRES", + "Number of withdraw loaded per second", + "item/sec", + NB_RESERVE_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of withdraw loading"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("26 - start"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("26 - get coin transaction", - NB_WITHDRAW_SAVE), + NB_WITHDRAW_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("26 - coin", - "26 - get coin transaction", - "03 - save coin"), - PERF_TALER_EXCHANGEDB_INIT_CMD_GET_COIN_TRANSACTION("", - "26 - coin"), + "26 - get coin transaction", + "03 - save coin"), + PERF_TALER_EXCHANGEDB_INIT_CMD_GET_COIN_TRANSACTION ("", + "26 - coin"), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", - "26 - get coin transaction"), + "26 - get coin transaction"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("26 - end"), PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", - "26 - start", - "26 - end", - "POSTGRES", - "Number of coin transaction history loaded per second", - "item/sec", - NB_WITHDRAW_SAVE), + "26 - start", + "26 - end", + "POSTGRES", + "Number of coin transaction history loaded per second", + "item/sec", + NB_WITHDRAW_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of transaction loading"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("27 - start"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("27 - /reserve/withdraw", - NB_WITHDRAW_SAVE), + NB_WITHDRAW_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("27 - reserve", - "27 - /reserve/withdraw", - "02 - save reserve"), + "27 - /reserve/withdraw", + "02 - save reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("27 - dki", - "27 - /reserve/withdraw", - "01 - save denomination"), + "27 - /reserve/withdraw", + "01 - save denomination"), PERF_TALER_EXCHANGEDB_INIT_CMD_WITHDRAW_SIGN ("", - "27 - dki", - "27 - reserve"), + "27 - dki", + "27 - reserve"), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", - "27 - /reserve/withdraw"), + "27 - /reserve/withdraw"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("27 - end"), PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", - "27 - start", - "27 - end", - "POSTGRES", - "Number of /reserve/withdraw per second", - "item/sec", - NB_WITHDRAW_SAVE), + "27 - start", + "27 - end", + "POSTGRES", + "Number of /reserve/withdraw per second", + "item/sec", + NB_WITHDRAW_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_DEBUG ("End of /reserve/withdraw"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("28 - start"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("28 - /deposit", - NB_DEPOSIT_SAVE), + NB_DEPOSIT_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_LOAD_ARRAY ("28 - coin", - "28 - /deposit", - "03 - save coin"), + "28 - /deposit", + "03 - save coin"), PERF_TALER_EXCHANGEDB_INIT_CMD_DEPOSIT ("28 - deposit", - "28 - coin"), + "28 - coin"), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", - "28 - /deposit"), + "28 - /deposit"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("28 - stop"), PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", - "28 - start", - "28 - stop", - "POSTGRES", - "Number of /deposit per second", - "item/sec", - NB_DEPOSIT_SAVE), + "28 - start", + "28 - stop", + "POSTGRES", + "Number of /deposit per second", + "item/sec", + NB_DEPOSIT_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("29 - start"), PERF_TALER_EXCHANGEDB_INIT_CMD_LOOP ("29 - insert refresh session", NB_REFRESH_SAVE), @@ -349,30 +349,32 @@ main (int argc, char ** argv) PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_WITHDRAW ("29 - withdraw", "29 - denomination load", "29 - reserve load"), - PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_REFRESH_SESSION ("29 - refresh session", - "29 - withdraw"), + PERF_TALER_EXCHANGEDB_INIT_CMD_CREATE_REFRESH_SESSION ( + "29 - refresh session", + "29 - withdraw"), PERF_TALER_EXCHANGEDB_INIT_CMD_SAVE_ARRAY ("29 - session array", "29 - insert refresh session", "29 - refresh session", NB_RESERVE_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_COMMIT_TRANSACTION (""), PERF_TALER_EXCHANGEDB_INIT_CMD_END_LOOP ("", - "29 - insert refresh session"), + "29 - insert refresh session"), PERF_TALER_EXCHANGEDB_INIT_CMD_GET_TIME ("29 - stop"), PERF_TALER_EXCHANGEDB_INIT_CMD_GAUGER ("", - "29 - start", - "29 - stop", - "POSTGRES", - "Number of refresh session inserted per second", - "item/sec", - NB_REFRESH_SAVE), + "29 - start", + "29 - stop", + "POSTGRES", + "Number of refresh session inserted per second", + "item/sec", + NB_REFRESH_SAVE), PERF_TALER_EXCHANGEDB_INIT_CMD_END (""), }; ret = PERF_TALER_EXCHANGEDB_run_benchmark ( "perf-taler-exchangedb", "./test-exchange-db-postgres.conf", - (struct PERF_TALER_EXCHANGEDB_Cmd []) {PERF_TALER_EXCHANGEDB_INIT_CMD_END("")}, + (struct PERF_TALER_EXCHANGEDB_Cmd []) {PERF_TALER_EXCHANGEDB_INIT_CMD_END ( + "")}, benchmark); if (GNUNET_SYSERR == ret) return 1; diff --git a/src/exchangedb/perf_taler_exchangedb_init.c b/src/exchangedb/perf_taler_exchangedb_init.c index 7053bca4..d27634bd 100644 --- a/src/exchangedb/perf_taler_exchangedb_init.c +++ b/src/exchangedb/perf_taler_exchangedb_init.c @@ -43,7 +43,7 @@ PERF_TALER_EXCHANGEDB_denomination_init () struct TALER_DenominationPublicKey denom_pub; struct TALER_EXCHANGEDB_DenominationKeyInformationP issue; - master_prvt = GNUNET_CRYPTO_eddsa_key_create(); + master_prvt = GNUNET_CRYPTO_eddsa_key_create (); dki = GNUNET_new (struct TALER_EXCHANGEDB_DenominationKeyIssueInformation); GNUNET_assert (NULL != dki); @@ -61,16 +61,21 @@ PERF_TALER_EXCHANGEDB_denomination_init () struct TALER_Amount amount; struct GNUNET_TIME_Absolute now; - properties.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY); - properties.purpose.size = htonl (sizeof (struct TALER_DenominationKeyValidityPS)); + properties.purpose.purpose = htonl ( + TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY); + properties.purpose.size = htonl (sizeof (struct + TALER_DenominationKeyValidityPS)); GNUNET_CRYPTO_eddsa_key_get_public (master_prvt, &properties.master.eddsa_pub); - now = GNUNET_TIME_absolute_get(); + now = GNUNET_TIME_absolute_get (); (void) GNUNET_TIME_round_abs (&now); properties.start = GNUNET_TIME_absolute_hton (now); - properties.expire_withdraw = GNUNET_TIME_absolute_hton (GNUNET_TIME_UNIT_FOREVER_ABS); - properties.expire_deposit = GNUNET_TIME_absolute_hton (GNUNET_TIME_UNIT_FOREVER_ABS); - properties.expire_legal = GNUNET_TIME_absolute_hton (GNUNET_TIME_UNIT_FOREVER_ABS); + properties.expire_withdraw = GNUNET_TIME_absolute_hton ( + GNUNET_TIME_UNIT_FOREVER_ABS); + properties.expire_deposit = GNUNET_TIME_absolute_hton ( + GNUNET_TIME_UNIT_FOREVER_ABS); + properties.expire_legal = GNUNET_TIME_absolute_hton ( + GNUNET_TIME_UNIT_FOREVER_ABS); GNUNET_assert (GNUNET_OK == TALER_string_to_amount (CURRENCY ":1.1", &amount)); TALER_amount_hton (&properties.value, &amount); @@ -105,15 +110,18 @@ PERF_TALER_EXCHANGEDB_denomination_init () * @return a copy of @a deposit; NULL if error */ struct TALER_EXCHANGEDB_DenominationKeyIssueInformation * -PERF_TALER_EXCHANGEDB_denomination_copy (const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) +PERF_TALER_EXCHANGEDB_denomination_copy (const struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation + *dki) { struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *copy; GNUNET_assert (NULL != - (copy = GNUNET_new (struct TALER_EXCHANGEDB_DenominationKeyIssueInformation))); + (copy = GNUNET_new (struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation))); {/* denom_priv */ copy->denom_priv.rsa_private_key = - GNUNET_CRYPTO_rsa_private_key_dup ( dki->denom_priv.rsa_private_key); + GNUNET_CRYPTO_rsa_private_key_dup (dki->denom_priv.rsa_private_key); } {/* denom_pub */ copy->denom_pub.rsa_public_key = @@ -132,7 +140,9 @@ PERF_TALER_EXCHANGEDB_denomination_copy (const struct TALER_EXCHANGEDB_Denominat * @param dki pointer to the struct to free */ int -PERF_TALER_EXCHANGEDB_denomination_free (struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki) +PERF_TALER_EXCHANGEDB_denomination_free (struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation + *dki) { if (NULL == dki) return GNUNET_OK; @@ -166,7 +176,8 @@ PERF_TALER_EXCHANGEDB_reserve_init () GNUNET_CRYPTO_eddsa_key_get_public (&reserve->private, &reserve->reserve.pub.eddsa_pub); GNUNET_assert (GNUNET_OK == - TALER_string_to_amount (CURRENCY ":1000", &reserve->reserve.balance)); + TALER_string_to_amount (CURRENCY ":1000", + &reserve->reserve.balance)); reserve->reserve.expiry = GNUNET_TIME_UNIT_FOREVER_ABS; return reserve; } @@ -178,7 +189,8 @@ PERF_TALER_EXCHANGEDB_reserve_init () * @return a copy of @a reserve; NULL if error */ struct PERF_TALER_EXCHANGEDB_Reserve * -PERF_TALER_EXCHANGEDB_reserve_copy (const struct PERF_TALER_EXCHANGEDB_Reserve *reserve) +PERF_TALER_EXCHANGEDB_reserve_copy (const struct + PERF_TALER_EXCHANGEDB_Reserve *reserve) { struct PERF_TALER_EXCHANGEDB_Reserve *copy; GNUNET_assert (NULL != @@ -193,7 +205,8 @@ PERF_TALER_EXCHANGEDB_reserve_copy (const struct PERF_TALER_EXCHANGEDB_Reserve * * @param reserve pointer to the structure to be freed */ int -PERF_TALER_EXCHANGEDB_reserve_free (struct PERF_TALER_EXCHANGEDB_Reserve *reserve) +PERF_TALER_EXCHANGEDB_reserve_free (struct + PERF_TALER_EXCHANGEDB_Reserve *reserve) { if (NULL == reserve) return GNUNET_OK; @@ -208,7 +221,8 @@ PERF_TALER_EXCHANGEDB_reserve_free (struct PERF_TALER_EXCHANGEDB_Reserve *reserv * @param dki the denomination key used to sign the key */ struct TALER_EXCHANGEDB_Deposit * -PERF_TALER_EXCHANGEDB_deposit_init (const struct PERF_TALER_EXCHANGEDB_Coin *coin) +PERF_TALER_EXCHANGEDB_deposit_init (const struct + PERF_TALER_EXCHANGEDB_Coin *coin) { struct TALER_EXCHANGEDB_Deposit *deposit; struct TALER_CoinSpendSignatureP csig; @@ -225,7 +239,7 @@ PERF_TALER_EXCHANGEDB_deposit_init (const struct PERF_TALER_EXCHANGEDB_Coin *coi &h_contract_terms); GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &h_wire); - { //csig + { // csig struct u32_presign { struct GNUNET_CRYPTO_EccSignaturePurpose purpose; @@ -242,11 +256,11 @@ PERF_TALER_EXCHANGEDB_deposit_init (const struct PERF_TALER_EXCHANGEDB_Coin *coi &unsigned_data.purpose, &csig.eddsa_signature)); } - { //merchant_pub + { // merchant_pub struct GNUNET_CRYPTO_EddsaPrivateKey *eddsa_prv; eddsa_prv = GNUNET_CRYPTO_eddsa_key_create (); - GNUNET_assert(NULL != eddsa_prv); + GNUNET_assert (NULL != eddsa_prv); GNUNET_CRYPTO_eddsa_key_get_public (eddsa_prv, &merchant_pub.eddsa_pub); GNUNET_free (eddsa_prv); @@ -289,7 +303,8 @@ PERF_TALER_EXCHANGEDB_deposit_init (const struct PERF_TALER_EXCHANGEDB_Coin *coi * @return a copy of @a deposit; NULL if error */ struct TALER_EXCHANGEDB_Deposit * -PERF_TALER_EXCHANGEDB_deposit_copy (const struct TALER_EXCHANGEDB_Deposit *deposit) +PERF_TALER_EXCHANGEDB_deposit_copy (const struct + TALER_EXCHANGEDB_Deposit *deposit) { struct TALER_EXCHANGEDB_Deposit *copy; @@ -337,7 +352,7 @@ PERF_TALER_EXCHANGEDB_coin_init ( GNUNET_assert (NULL != coin); /* priv */ - priv = GNUNET_CRYPTO_eddsa_key_create(); + priv = GNUNET_CRYPTO_eddsa_key_create (); GNUNET_assert (NULL != priv); coin->priv = *priv; GNUNET_free (priv); @@ -480,14 +495,16 @@ PERF_TALER_EXCHANGEDB_refresh_melt_init (struct TALER_RefreshCommitmentP *rc, * @return an copy of @ melt */ struct TALER_EXCHANGEDB_RefreshMelt * -PERF_TALER_EXCHANGEDB_refresh_melt_copy (const struct TALER_EXCHANGEDB_RefreshMelt *melt) +PERF_TALER_EXCHANGEDB_refresh_melt_copy (const struct + TALER_EXCHANGEDB_RefreshMelt *melt) { struct TALER_EXCHANGEDB_RefreshMelt *copy; copy = GNUNET_new (struct TALER_EXCHANGEDB_RefreshMelt); *copy = *melt; copy->session.coin.denom_sig.rsa_signature = - GNUNET_CRYPTO_rsa_signature_dup (melt->session.coin.denom_sig.rsa_signature); + GNUNET_CRYPTO_rsa_signature_dup ( + melt->session.coin.denom_sig.rsa_signature); GNUNET_assert (NULL != copy->session.coin.denom_sig.rsa_signature); return copy; @@ -501,7 +518,8 @@ PERF_TALER_EXCHANGEDB_refresh_melt_copy (const struct TALER_EXCHANGEDB_RefreshMe * @return #GNUNET_OK if the operation was successful, #GNUNET_SYSERROR */ int -PERF_TALER_EXCHANGEDB_refresh_melt_free (struct TALER_EXCHANGEDB_RefreshMelt *melt) +PERF_TALER_EXCHANGEDB_refresh_melt_free (struct + TALER_EXCHANGEDB_RefreshMelt *melt) { GNUNET_CRYPTO_rsa_signature_free (melt->session.coin.denom_sig.rsa_signature); GNUNET_free (melt); diff --git a/src/exchangedb/perf_taler_exchangedb_init.h b/src/exchangedb/perf_taler_exchangedb_init.h index a1f2559e..f20b35c5 100644 --- a/src/exchangedb/perf_taler_exchangedb_init.h +++ b/src/exchangedb/perf_taler_exchangedb_init.h @@ -79,7 +79,9 @@ PERF_TALER_EXCHANGEDB_denomination_init (void); * @return a copy of @a deposit; NULL if error */ struct TALER_EXCHANGEDB_DenominationKeyIssueInformation * -PERF_TALER_EXCHANGEDB_denomination_copy (const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki); +PERF_TALER_EXCHANGEDB_denomination_copy (const struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation + *dki); /** @@ -87,7 +89,9 @@ PERF_TALER_EXCHANGEDB_denomination_copy (const struct TALER_EXCHANGEDB_Denominat * @param dki pointer to the struct to free */ int -PERF_TALER_EXCHANGEDB_denomination_free (struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki); +PERF_TALER_EXCHANGEDB_denomination_free (struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation + *dki); /** @@ -104,7 +108,8 @@ PERF_TALER_EXCHANGEDB_reserve_init (void); * @return a copy of @a reserve; NULL if error */ struct PERF_TALER_EXCHANGEDB_Reserve * -PERF_TALER_EXCHANGEDB_reserve_copy (const struct PERF_TALER_EXCHANGEDB_Reserve *reserve); +PERF_TALER_EXCHANGEDB_reserve_copy (const struct + PERF_TALER_EXCHANGEDB_Reserve *reserve); /** @@ -112,7 +117,8 @@ PERF_TALER_EXCHANGEDB_reserve_copy (const struct PERF_TALER_EXCHANGEDB_Reserve * * @param reserve pointer to the structure to be freed */ int -PERF_TALER_EXCHANGEDB_reserve_free (struct PERF_TALER_EXCHANGEDB_Reserve *reserve); +PERF_TALER_EXCHANGEDB_reserve_free (struct + PERF_TALER_EXCHANGEDB_Reserve *reserve); /** @@ -120,7 +126,8 @@ PERF_TALER_EXCHANGEDB_reserve_free (struct PERF_TALER_EXCHANGEDB_Reserve *reserv * @param dki the denomination key used to sign the key */ struct TALER_EXCHANGEDB_Deposit * -PERF_TALER_EXCHANGEDB_deposit_init (const struct PERF_TALER_EXCHANGEDB_Coin *coin); +PERF_TALER_EXCHANGEDB_deposit_init (const struct + PERF_TALER_EXCHANGEDB_Coin *coin); /** @@ -129,7 +136,8 @@ PERF_TALER_EXCHANGEDB_deposit_init (const struct PERF_TALER_EXCHANGEDB_Coin *coi * @return a copy of @a deposit; NULL if error */ struct TALER_EXCHANGEDB_Deposit * -PERF_TALER_EXCHANGEDB_deposit_copy (const struct TALER_EXCHANGEDB_Deposit *deposit); +PERF_TALER_EXCHANGEDB_deposit_copy (const struct + TALER_EXCHANGEDB_Deposit *deposit); /** @@ -147,8 +155,11 @@ PERF_TALER_EXCHANGEDB_deposit_free (struct TALER_EXCHANGEDB_Deposit *deposit); * @return a randomly generated CollectableBlindcoin */ struct PERF_TALER_EXCHANGEDB_Coin * -PERF_TALER_EXCHANGEDB_coin_init (const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki, - const struct PERF_TALER_EXCHANGEDB_Reserve *reserve); +PERF_TALER_EXCHANGEDB_coin_init (const struct + TALER_EXCHANGEDB_DenominationKeyIssueInformation + *dki, + const struct + PERF_TALER_EXCHANGEDB_Reserve *reserve); /** @@ -187,7 +198,8 @@ PERF_TALER_EXCHANGEDB_refresh_melt_init (struct TALER_RefreshCommitmentP *rc, * @return an copy of @ melt */ struct TALER_EXCHANGEDB_RefreshMelt * -PERF_TALER_EXCHANGEDB_refresh_melt_copy (const struct TALER_EXCHANGEDB_RefreshMelt *melt); +PERF_TALER_EXCHANGEDB_refresh_melt_copy (const struct + TALER_EXCHANGEDB_RefreshMelt *melt); /** @@ -197,6 +209,7 @@ PERF_TALER_EXCHANGEDB_refresh_melt_copy (const struct TALER_EXCHANGEDB_RefreshMe * @return #GNUNET_OK if the operation was successful, #GNUNET_SYSERROR */ int -PERF_TALER_EXCHANGEDB_refresh_melt_free (struct TALER_EXCHANGEDB_RefreshMelt *melt); +PERF_TALER_EXCHANGEDB_refresh_melt_free (struct + TALER_EXCHANGEDB_RefreshMelt *melt); #endif diff --git a/src/exchangedb/perf_taler_exchangedb_interpreter.c b/src/exchangedb/perf_taler_exchangedb_interpreter.c index 6c968410..8286966c 100644 --- a/src/exchangedb/perf_taler_exchangedb_interpreter.c +++ b/src/exchangedb/perf_taler_exchangedb_interpreter.c @@ -110,31 +110,31 @@ data_copy (const struct PERF_TALER_EXCHANGEDB_Data *data, copy->type = data->type; switch (data->type) { - case PERF_TALER_EXCHANGEDB_TIME: - copy->data.time = GNUNET_new (struct GNUNET_TIME_Absolute); - *copy->data.time = *data->data.time; - return; - case PERF_TALER_EXCHANGEDB_DEPOSIT: - copy->data.deposit - = PERF_TALER_EXCHANGEDB_deposit_copy (data->data.deposit); - return; - case PERF_TALER_EXCHANGEDB_COIN: - copy->data.coin - = PERF_TALER_EXCHANGEDB_coin_copy (data->data.coin); - return; - case PERF_TALER_EXCHANGEDB_RESERVE: - copy->data.reserve - = PERF_TALER_EXCHANGEDB_reserve_copy (data->data.reserve); - return; - case PERF_TALER_EXCHANGEDB_DENOMINATION_INFO: - copy->data.dki - = PERF_TALER_EXCHANGEDB_denomination_copy (data->data.dki); - return; - case PERF_TALER_EXCHANGEDB_REFRESH_HASH: - copy->data.rc = data->data.rc; - break; - case PERF_TALER_EXCHANGEDB_NONE: - break; + case PERF_TALER_EXCHANGEDB_TIME: + copy->data.time = GNUNET_new (struct GNUNET_TIME_Absolute); + *copy->data.time = *data->data.time; + return; + case PERF_TALER_EXCHANGEDB_DEPOSIT: + copy->data.deposit + = PERF_TALER_EXCHANGEDB_deposit_copy (data->data.deposit); + return; + case PERF_TALER_EXCHANGEDB_COIN: + copy->data.coin + = PERF_TALER_EXCHANGEDB_coin_copy (data->data.coin); + return; + case PERF_TALER_EXCHANGEDB_RESERVE: + copy->data.reserve + = PERF_TALER_EXCHANGEDB_reserve_copy (data->data.reserve); + return; + case PERF_TALER_EXCHANGEDB_DENOMINATION_INFO: + copy->data.dki + = PERF_TALER_EXCHANGEDB_denomination_copy (data->data.dki); + return; + case PERF_TALER_EXCHANGEDB_REFRESH_HASH: + copy->data.rc = data->data.rc; + break; + case PERF_TALER_EXCHANGEDB_NONE: + break; } } @@ -151,7 +151,7 @@ cmd_find (const struct PERF_TALER_EXCHANGEDB_Cmd *cmd, { unsigned int i; - for (i=0; PERF_TALER_EXCHANGEDB_CMD_END != cmd[i].command; i++) + for (i = 0; PERF_TALER_EXCHANGEDB_CMD_END != cmd[i].command; i++) if (0 == strcmp (cmd[i].label, search)) return i; return GNUNET_SYSERR; @@ -171,718 +171,721 @@ cmd_init (struct PERF_TALER_EXCHANGEDB_Cmd cmd[]) { unsigned int i; - for (i=0; PERF_TALER_EXCHANGEDB_CMD_END != cmd[i].command; i++) + for (i = 0; PERF_TALER_EXCHANGEDB_CMD_END != cmd[i].command; i++) { switch (cmd[i].command) { - case PERF_TALER_EXCHANGEDB_CMD_END_LOOP: - { - int ret; + case PERF_TALER_EXCHANGEDB_CMD_END_LOOP: + { + int ret; - ret = cmd_find (cmd, - cmd[i].details.end_loop.label_loop); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, + ret = cmd_find (cmd, cmd[i].details.end_loop.label_loop); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_CMD_LOOP != cmd[ret].command) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s at %s\n", - i, - cmd[i].details.end_loop.label_loop, - cmd[i].label); - return GNUNET_SYSERR; - } - cmd[i].details.end_loop.index_loop = ret; + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.end_loop.label_loop); + return GNUNET_SYSERR; } - break; - - case PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY: + if (PERF_TALER_EXCHANGEDB_CMD_LOOP != cmd[ret].command) { - int ret; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s at %s\n", + i, + cmd[i].details.end_loop.label_loop, + cmd[i].label); + return GNUNET_SYSERR; + } + cmd[i].details.end_loop.index_loop = ret; + } + break; - ret = cmd_find (cmd, - cmd[i].details.save_array.label_save); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s at %s\n", - i, - cmd[i].details.save_array.label_save, - cmd[i].label); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_NONE == cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s at %s\n", - i, - cmd[i].details.save_array.label_save, - cmd[i].label); - return GNUNET_SYSERR; - } - cmd[i].details.save_array.index_save = ret; + case PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY: + { + int ret; - ret = cmd_find (cmd, - cmd[i].details.save_array.label_loop); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s at %s\n", - i, - cmd[i].details.save_array.label_loop, - cmd[i].label); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_CMD_LOOP != cmd[ret].command) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s at %s\n", - i, - cmd[i].details.save_array.label_loop, - cmd[i].label); - return GNUNET_SYSERR; - } - cmd[i].details.save_array.index_loop = ret; - - GNUNET_assert (NULL == cmd[i].details.save_array.data_saved); - cmd[i].details.save_array.data_saved = - GNUNET_new_array (cmd[i].details.save_array.nb_saved, - struct PERF_TALER_EXCHANGEDB_Data); - cmd[i].details.save_array.type_saved = - cmd[cmd[i].details.save_array.index_save].exposed.type; + ret = cmd_find (cmd, + cmd[i].details.save_array.label_save); + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s at %s\n", + i, + cmd[i].details.save_array.label_save, + cmd[i].label); + return GNUNET_SYSERR; } - break; - - case PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY: + if (PERF_TALER_EXCHANGEDB_NONE == cmd[ret].exposed.type) { - int ret; - - ret = cmd_find (cmd, - cmd[i].details.load_array.label_save); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s at %s\n", - i, - cmd[i].details.load_array.label_save, - cmd[i].label); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY != cmd[ret].command) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s at %s\n", - i, - cmd[i].details.load_array.label_save, - cmd[i].label); - return GNUNET_SYSERR; - } - cmd[i].details.load_array.index_save = ret; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s at %s\n", + i, + cmd[i].details.save_array.label_save, + cmd[i].label); + return GNUNET_SYSERR; + } + cmd[i].details.save_array.index_save = ret; - ret = cmd_find (cmd, - cmd[i].details.load_array.label_loop); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, - cmd[i].details.load_array.label_loop); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_CMD_LOOP != cmd[ret].command) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, - cmd[i].details.load_array.label_loop); - return GNUNET_SYSERR; - } - cmd[i].details.load_array.index_loop = ret; + ret = cmd_find (cmd, + cmd[i].details.save_array.label_loop); + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s at %s\n", + i, + cmd[i].details.save_array.label_loop, + cmd[i].label); + return GNUNET_SYSERR; + } + if (PERF_TALER_EXCHANGEDB_CMD_LOOP != cmd[ret].command) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s at %s\n", + i, + cmd[i].details.save_array.label_loop, + cmd[i].label); + return GNUNET_SYSERR; + } + cmd[i].details.save_array.index_loop = ret; + + GNUNET_assert (NULL == cmd[i].details.save_array.data_saved); + cmd[i].details.save_array.data_saved = + GNUNET_new_array (cmd[i].details.save_array.nb_saved, + struct PERF_TALER_EXCHANGEDB_Data); + cmd[i].details.save_array.type_saved = + cmd[cmd[i].details.save_array.index_save].exposed.type; + } + break; - cmd[i].details.load_array.permutation = - GNUNET_CRYPTO_random_permute ( - GNUNET_CRYPTO_QUALITY_WEAK, - cmd[cmd[i].details.load_array.index_save].details.save_array.nb_saved); - GNUNET_assert (NULL != cmd[i].details.load_array.permutation); + case PERF_TALER_EXCHANGEDB_CMD_LOAD_ARRAY: + { + int ret; - cmd[i].exposed.type = cmd[cmd[i].details.load_array.index_save].details.save_array.type_saved; + ret = cmd_find (cmd, + cmd[i].details.load_array.label_save); + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s at %s\n", + i, + cmd[i].details.load_array.label_save, + cmd[i].label); + return GNUNET_SYSERR; + } + if (PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY != cmd[ret].command) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s at %s\n", + i, + cmd[i].details.load_array.label_save, + cmd[i].label); + return GNUNET_SYSERR; } - break; + cmd[i].details.load_array.index_save = ret; - case PERF_TALER_EXCHANGEDB_CMD_LOAD_RANDOM: + ret = cmd_find (cmd, + cmd[i].details.load_array.label_loop); + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.load_array.label_loop); + return GNUNET_SYSERR; + } + if (PERF_TALER_EXCHANGEDB_CMD_LOOP != cmd[ret].command) { - int ret; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s\n", + i, + cmd[i].details.load_array.label_loop); + return GNUNET_SYSERR; + } + cmd[i].details.load_array.index_loop = ret; + + cmd[i].details.load_array.permutation = + GNUNET_CRYPTO_random_permute ( + GNUNET_CRYPTO_QUALITY_WEAK, + cmd[cmd[i].details.load_array.index_save].details.save_array. + nb_saved); + GNUNET_assert (NULL != cmd[i].details.load_array.permutation); + + cmd[i].exposed.type = + cmd[cmd[i].details.load_array.index_save].details.save_array. + type_saved; + } + break; - ret = cmd_find (cmd, - cmd[i].details.load_random.label_save); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, - cmd[i].details.load_random.label_save); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY != cmd[ret].command) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, + case PERF_TALER_EXCHANGEDB_CMD_LOAD_RANDOM: + { + int ret; + + ret = cmd_find (cmd, cmd[i].details.load_random.label_save); - return GNUNET_SYSERR; - } - cmd[i].details.load_random.index_save = ret; + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.load_random.label_save); + return GNUNET_SYSERR; } - break; - - case PERF_TALER_EXCHANGEDB_CMD_GAUGER: + if (PERF_TALER_EXCHANGEDB_CMD_SAVE_ARRAY != cmd[ret].command) { - int ret; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s\n", + i, + cmd[i].details.load_random.label_save); + return GNUNET_SYSERR; + } + cmd[i].details.load_random.index_save = ret; + } + break; - ret = cmd_find (cmd, - cmd[i].details.gauger.label_start); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, - cmd[i].details.gauger.label_start); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_TIME != cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, + case PERF_TALER_EXCHANGEDB_CMD_GAUGER: + { + int ret; + + ret = cmd_find (cmd, cmd[i].details.gauger.label_start); - return GNUNET_SYSERR; - } - cmd[i].details.gauger.index_start = ret; + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.gauger.label_start); + return GNUNET_SYSERR; + } + if (PERF_TALER_EXCHANGEDB_TIME != cmd[ret].exposed.type) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s\n", + i, + cmd[i].details.gauger.label_start); + return GNUNET_SYSERR; + } + cmd[i].details.gauger.index_start = ret; - ret = cmd_find (cmd, - cmd[i].details.gauger.label_stop); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, + ret = cmd_find (cmd, cmd[i].details.gauger.label_stop); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_TIME != cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, - cmd[i].details.gauger.label_stop); - return GNUNET_SYSERR; - } - cmd[i].details.gauger.index_stop = ret; + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.gauger.label_stop); + return GNUNET_SYSERR; } - break; - - case PERF_TALER_EXCHANGEDB_CMD_INSERT_DENOMINATION: + if (PERF_TALER_EXCHANGEDB_TIME != cmd[ret].exposed.type) { - int ret; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Wrong type reference to %s\n", + i, + cmd[i].details.gauger.label_stop); + return GNUNET_SYSERR; + } + cmd[i].details.gauger.index_stop = ret; + } + break; - ret = cmd_find (cmd, - cmd[i].details.insert_denomination.label_denom); - if (GNUNET_SYSERR == ret) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Undefined reference to %s\n", - i, - cmd[i].details.insert_denomination.label_denom); - return GNUNET_SYSERR; - } - if (PERF_TALER_EXCHANGEDB_DENOMINATION_INFO != cmd[ret].exposed.type) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "%d:Wrong type reference to %s\n", - i, + case PERF_TALER_EXCHANGEDB_CMD_INSERT_DENOMINATION: + { + int ret; + + ret = cmd_find (cmd, cmd[i].details.insert_denomination.label_denom); - return GNUNET_SYSERR; - } - cmd[i].details.insert_denomination.index_denom = ret; + if (GNUNET_SYSERR == ret) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "%d:Undefined reference to %s\n", + i, + cmd[i].details.insert_denomination.label_denom); + return GNUNET_SYSERR; } - break; - - case PERF_TAL |