diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-06-04 14:29:15 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-06-04 14:29:15 +0200 |
commit | 9e7d3f90657dc2ac9905c8800bff79cd1c97ebd9 (patch) | |
tree | 0a300d457949440336ecc4230e5e8ee73e2d1b3f /src/bank-lib/bank_api_transfer.c | |
parent | 0ad3de938e37cd4f34dd791283350ccfc09df2db (diff) | |
download | exchange-9e7d3f90657dc2ac9905c8800bff79cd1c97ebd9.tar.xz |
address FIXMEs in bank service API
Diffstat (limited to 'src/bank-lib/bank_api_transfer.c')
-rw-r--r-- | src/bank-lib/bank_api_transfer.c | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/src/bank-lib/bank_api_transfer.c b/src/bank-lib/bank_api_transfer.c index 94d8c6b61..0748a0d7e 100644 --- a/src/bank-lib/bank_api_transfer.c +++ b/src/bank-lib/bank_api_transfer.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 @@ -158,23 +158,24 @@ handle_transfer_finished (void *cls, { struct TALER_BANK_TransferHandle *th = cls; const json_t *j = response; - uint64_t row_id = UINT64_MAX; - struct GNUNET_TIME_Timestamp timestamp = GNUNET_TIME_UNIT_FOREVER_TS; - enum TALER_ErrorCode ec; + struct TALER_BANK_TransferResponse tr = { + .http_status = response_code, + .response = j + }; th->job = NULL; switch (response_code) { case 0: - ec = TALER_EC_GENERIC_INVALID_RESPONSE; + tr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; case MHD_HTTP_OK: { struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_uint64 ("row_id", - &row_id), + &tr.details.ok.row_id), GNUNET_JSON_spec_timestamp ("timestamp", - ×tamp), + &tr.details.ok.timestamp), GNUNET_JSON_spec_end () }; @@ -184,39 +185,38 @@ handle_transfer_finished (void *cls, NULL, NULL)) { GNUNET_break_op (0); - response_code = 0; - ec = TALER_EC_GENERIC_INVALID_RESPONSE; + tr.http_status = 0; + tr.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); + tr.ec = TALER_JSON_get_error_code (j); break; case MHD_HTTP_UNAUTHORIZED: /* Nothing really to verify, bank says our credentials are invalid. We should pass the JSON reply to the application. */ - ec = TALER_JSON_get_error_code (j); + tr.ec = TALER_JSON_get_error_code (j); break; case MHD_HTTP_NOT_FOUND: /* Nothing really to verify, endpoint wrong -- could be user unknown */ - ec = TALER_JSON_get_error_code (j); + tr.ec = TALER_JSON_get_error_code (j); break; case MHD_HTTP_CONFLICT: /* Nothing really to verify. Server says we used the same transfer request UID before, but with different details. Should not happen if the user properly used #TALER_BANK_prepare_transfer() and our PRNG is not broken... */ - ec = TALER_JSON_get_error_code (j); + tr.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); + tr.ec = TALER_JSON_get_error_code (j); break; default: /* unexpected response code */ @@ -224,14 +224,11 @@ handle_transfer_finished (void *cls, "Unexpected response code %u\n", (unsigned int) response_code); GNUNET_break (0); - ec = TALER_JSON_get_error_code (j); + tr.ec = TALER_JSON_get_error_code (j); break; } th->cb (th->cb_cls, - response_code, - ec, - row_id, - timestamp); + &tr); TALER_BANK_transfer_cancel (th); } |