diff options
Diffstat (limited to 'src/bank-lib/bank_api_admin.c')
-rw-r--r-- | src/bank-lib/bank_api_admin.c | 77 |
1 files changed, 25 insertions, 52 deletions
diff --git a/src/bank-lib/bank_api_admin.c b/src/bank-lib/bank_api_admin.c index d1a05297d..f12ab6ee2 100644 --- a/src/bank-lib/bank_api_admin.c +++ b/src/bank-lib/bank_api_admin.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2015--2020 Taler Systems SA + Copyright (C) 2015--2023 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -16,7 +16,7 @@ */ /** * @file bank-lib/bank_api_admin.c - * @brief Implementation of the /admin/ requests of the bank's HTTP API + * @brief Implementation of the /admin/add-incoming requests of the bank's HTTP API * @author Christian Grothoff */ #include "platform.h" @@ -27,7 +27,7 @@ /** - * @brief An admin/add-incoming Handle + * @brief An /admin/add-incoming Handle */ struct TALER_BANK_AdminAddIncomingHandle { @@ -74,25 +74,25 @@ handle_admin_add_incoming_finished (void *cls, const void *response) { struct TALER_BANK_AdminAddIncomingHandle *aai = cls; - uint64_t row_id = UINT64_MAX; - struct GNUNET_TIME_Absolute timestamp; - enum TALER_ErrorCode ec; const json_t *j = response; + struct TALER_BANK_AdminAddIncomingResponse ir = { + .http_status = response_code, + .response = response + }; aai->job = NULL; - timestamp = GNUNET_TIME_UNIT_FOREVER_ABS; switch (response_code) { case 0: - ec = TALER_EC_GENERIC_INVALID_RESPONSE; + ir.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; case MHD_HTTP_OK: { struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_uint64 ("row_id", - &row_id), - TALER_JSON_spec_absolute_time ("timestamp", - ×tamp), + &ir.details.ok.serial_id), + GNUNET_JSON_spec_timestamp ("timestamp", + &ir.details.ok.timestamp), GNUNET_JSON_spec_end () }; @@ -102,42 +102,41 @@ handle_admin_add_incoming_finished (void *cls, NULL, NULL)) { GNUNET_break_op (0); - response_code = 0; - ec = TALER_EC_GENERIC_INVALID_RESPONSE; + ir.http_status = 0; + ir.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; } - ec = TALER_EC_NONE; } break; case MHD_HTTP_BAD_REQUEST: /* This should never happen, either us or the bank is buggy (or API version conflict); just pass JSON reply to the application */ GNUNET_break_op (0); - ec = TALER_JSON_get_error_code (j); + ir.ec = TALER_JSON_get_error_code (j); break; case MHD_HTTP_FORBIDDEN: /* Access denied */ - ec = TALER_JSON_get_error_code (j); + ir.ec = TALER_JSON_get_error_code (j); break; case MHD_HTTP_UNAUTHORIZED: /* Nothing really to verify, bank says the password is invalid; we should pass the JSON reply to the application */ - ec = TALER_JSON_get_error_code (j); + ir.ec = TALER_JSON_get_error_code (j); break; case MHD_HTTP_NOT_FOUND: /* Nothing really to verify, maybe account really does not exist. We should pass the JSON reply to the application */ - ec = TALER_JSON_get_error_code (j); + ir.ec = TALER_JSON_get_error_code (j); break; case MHD_HTTP_CONFLICT: /* Nothing to verify, we used the same wire subject twice? */ - ec = TALER_JSON_get_error_code (j); + ir.ec = TALER_JSON_get_error_code (j); break; case MHD_HTTP_INTERNAL_SERVER_ERROR: /* Server had an internal issue; we should retry, but this API leaves this to the application */ - ec = TALER_JSON_get_error_code (j); + ir.ec = TALER_JSON_get_error_code (j); break; default: /* unexpected response code */ @@ -145,36 +144,15 @@ handle_admin_add_incoming_finished (void *cls, "Unexpected response code %u\n", (unsigned int) response_code); GNUNET_break (0); - ec = TALER_JSON_get_error_code (j); + ir.ec = TALER_JSON_get_error_code (j); break; } aai->cb (aai->cb_cls, - response_code, - ec, - row_id, - timestamp, - j); + &ir); TALER_BANK_admin_add_incoming_cancel (aai); } -/** - * Perform a wire transfer from some account to the exchange to fill a - * reserve. Note that this API is usually only used for testing (with - * fakebank and our Python bank) and thus may not be accessible in a - * production setting. - * - * @param ctx curl context for the event loop - * @param auth authentication data to send to the bank - * @param reserve_pub wire transfer subject for the transfer - * @param amount amount that was is to be deposited - * @param debit_account account to deposit from (payto URI, but used as 'payfrom') - * @param res_cb the callback to call when the final result for this request is available - * @param res_cb_cls closure for the above callback - * @return NULL - * if the inputs are invalid (i.e. invalid amount) or internal errors. - * In this case, the callback is not called. - */ struct TALER_BANK_AdminAddIncomingHandle * TALER_BANK_admin_add_incoming ( struct GNUNET_CURL_Context *ctx, @@ -232,9 +210,10 @@ TALER_BANK_admin_add_incoming ( "Requesting administrative transaction at `%s' for reserve %s\n", aai->request_url, TALER_B2S (reserve_pub)); - aai->post_ctx.headers = curl_slist_append - (aai->post_ctx.headers, - "Content-Type: application/json"); + aai->post_ctx.headers + = curl_slist_append ( + aai->post_ctx.headers, + "Content-Type: application/json"); eh = curl_easy_init (); if ( (NULL == eh) || @@ -268,12 +247,6 @@ TALER_BANK_admin_add_incoming ( } -/** - * Cancel an add incoming. This function cannot be used on a request - * handle if a response is already served for it. - * - * @param aai the admin add incoming request handle - */ void TALER_BANK_admin_add_incoming_cancel ( struct TALER_BANK_AdminAddIncomingHandle *aai) |