From 346c351e5ff2fc184f1c044f4ffbf82bc80fe655 Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Fri, 22 Dec 2017 21:22:57 +0100 Subject: redefining/adding bank error codes --- src/include/taler_error_codes.h | 83 +++++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 33 deletions(-) (limited to 'src/include/taler_error_codes.h') diff --git a/src/include/taler_error_codes.h b/src/include/taler_error_codes.h index 2d0c8325..759e6fc7 100644 --- a/src/include/taler_error_codes.h +++ b/src/include/taler_error_codes.h @@ -1503,67 +1503,84 @@ enum TALER_ErrorCode /* *************** Taler BANK/FAKEBANK error codes *************** */ /** - * Authentication failed for an unspecified request. - * To return when the view name is not available, or - * no specific error code is defined yet. + * The request cannot be served because the client failed to + * login. To be returned along HTTP 401 Unauthorized. */ - TALER_EC_BANK_NOT_AUTHORIZED = 5000, + TALER_EC_BANK_REJECT_LOGIN_FAILED = 5312, /** - * The bank could not find the bank account specified - * in the request. Returned with a status code of MHD_HTTP_NOT_FOUND. + * The transaction cannot be rejected becasue it does not exist + * at the bank. To be returned along HTTP 404 Not Found. */ - TALER_EC_BANK_UNKNOWN_ACCOUNT = 5001, + TALER_EC_BANK_REJECT_TRANSACTION_NOT_FOUND = 5301, /** - * Authentication failed for the /admin/add/incoming request. - * Returned with a status code of MHD_HTTP_FORBIDDEN. + * The client does not own the account credited by the transaction + * which is to be rejected, so it has no rights do reject it. To be + * returned along HTTP 403 Forbidden. */ - TALER_EC_BANK_TRANSFER_NOT_AUHTORIZED = 5100, + TALER_EC_BANK_REJECT_NO_RIGHTS = 5313, /** - * The wire transfer cannot be done because the debitor would - * reach a unallowed debit. + * The POSTed JSON at /reject was invalid. To be returned along + * HTTP 400 Bad Request. */ - TALER_EC_BANK_TRANSFER_DEBIT = 5101, + TALER_EC_BANK_REJECT_JSON_INVALID = 5306, /** - * The wire transfer cannot be done because the credit and - * debit account are the same. + * A URL parameter for /history was missing. To be returned along + * HTTP 400 Bad Request. */ - TALER_EC_BANK_TRANSFER_SAME_ACCOUNT = 5102, + TALER_EC_BANK_HISTORY_PARAMETER_MISSING = 5208, /** - * Authentication failed for the /history request. - * Returned with a status code of MHD_HTTP_FORBIDDEN. + * A URL parameter for /history was malformed. To be returned along + * HTTP 400 Bad Request. */ - TALER_EC_BANK_HISTORY_NOT_AUHTORIZED = 5200, + TALER_EC_BANK_HISTORY_PARAMETER_MALFORMED = 5209, /** - * The bank library had trouble obtaining a valid - * HTTP response. - * Returned with a status code of 0. + * The client failed to login for /history. To be returned along + * HTTP 401 Unauthorized. */ - TALER_EC_BANK_HISTORY_HTTP_FAILURE = 5201, + TALER_EC_BANK_HISTORY_LOGIN_FAILED = 5212, /** - * The bank could not find the wire transfer that was supposed to - * be rejected. - * Returned with a status code of MHD_HTTP_NOT_FOUND. + * The bank had trouble obtaining a valid HTTP response. To be returned + * along status code 0. */ - TALER_EC_BANK_REJECT_NOT_FOUND = 5300, + TALER_EC_BANK_HISTORY_HTTP_FAILURE = 5213, /** - * Authentication failed for the /reject request. - * Returned with a status code of MHD_HTTP_FORBIDDEN. + * The debit account for /admin/add/incoming is not known to the + * bank. To be returned along HTTP 404 Not Found. */ - TALER_EC_BANK_REJECT_NOT_AUTHORIZED = 5301, + TALER_EC_BANK_ADD_INCOMING_UNKNOWN_ACCOUNT = 5100, /** - * The client wants to reject a transaction where they are - * not the _credit_ party, impossible! + * The client specified the same bank account for both the credit + * and the debit account. The bank will not accomplish this operation. + * To be returned along HTTP 403 Forbidden. */ - TALER_EC_BANK_REJECT_NO_RIGHTS = 5302, + TALER_EC_BANK_ADD_INCOMING_SAME_ACCOUNT = 5102, + + /** + * The operation would put the client in a debit situation which is + * forbidden to them. To return along HTTP 403 Forbidden. + */ + TALER_EC_BANK_ADD_INCOMING_UNALLOWED_DEBIT = 5103, + + /** + * The client POSTed an invalid JSON. To be returned along HTTP + * 400 Bad Request. + */ + TALER_EC_BANK_ADD_INCOMING_JSON_INVALID = 5106, + + /** + * The client failed to login for /admin/add/incoming. To be returned + * along HTTP 401 Unauthorized. + */ + TALER_EC_BANK_ADD_INCOMING_LOGIN_FAILED = 5112, /** * End of error code range. -- cgit v1.2.3 From 4f2ad1051b1433974e5d598b1546202797729e31 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 1 Jan 2018 22:10:26 +0100 Subject: change 'f' to 'contribution' in /deposit --- src/exchange-lib/exchange_api_deposit.c | 2 +- src/exchange/taler-exchange-httpd_deposit.c | 6 +++++- src/include/taler_error_codes.h | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src/include/taler_error_codes.h') diff --git a/src/exchange-lib/exchange_api_deposit.c b/src/exchange-lib/exchange_api_deposit.c index d90b1aa7..76e3e4da 100644 --- a/src/exchange-lib/exchange_api_deposit.c +++ b/src/exchange-lib/exchange_api_deposit.c @@ -454,7 +454,7 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange, " s:o," /* merchant_pub */ " s:o, s:o," /* refund_deadline, wire_deadline */ " s:o}", /* coin_sig */ - "f", TALER_JSON_from_amount (amount), + "contribution", TALER_JSON_from_amount (amount), "wire", wire_details, "H_wire", GNUNET_JSON_from_data_auto (&h_wire), "h_contract_terms", GNUNET_JSON_from_data_auto (h_contract_terms), diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c index b7fb3452..542c56c9 100644 --- a/src/exchange/taler-exchange-httpd_deposit.c +++ b/src/exchange/taler-exchange-httpd_deposit.c @@ -149,6 +149,8 @@ deposit_transaction (void *cls, { struct TALER_Amount amount_without_fee; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "/deposit replay, accepting again!\n"); GNUNET_assert (GNUNET_OK == TALER_amount_subtract (&amount_without_fee, &deposit->amount_with_fee, @@ -191,6 +193,8 @@ deposit_transaction (void *cls, if (0 < TALER_amount_cmp (&spent, &dc->value)) { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Deposited coin has insufficient funds left!\n"); *mhd_ret = TEH_RESPONSE_reply_coin_insufficient_funds (connection, TALER_EC_DEPOSIT_INSUFFICIENT_FUNDS, tl); @@ -376,7 +380,7 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, struct GNUNET_HashCode my_h_wire; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_json ("wire", &wire), - TALER_JSON_spec_amount ("f", &deposit.amount_with_fee), + TALER_JSON_spec_amount ("contribution", &deposit.amount_with_fee), TALER_JSON_spec_denomination_public_key ("denom_pub", &deposit.coin.denom_pub), TALER_JSON_spec_denomination_signature ("ub_sig", &deposit.coin.denom_sig), GNUNET_JSON_spec_fixed_auto ("coin_pub", &deposit.coin.coin_pub), diff --git a/src/include/taler_error_codes.h b/src/include/taler_error_codes.h index 759e6fc7..d90bd4f3 100644 --- a/src/include/taler_error_codes.h +++ b/src/include/taler_error_codes.h @@ -1001,6 +1001,7 @@ enum TALER_ErrorCode TALER_EC_PAY_REFUND_DEADLINE_PAST_WIRE_TRANSFER_DEADLINE = 2114, /** + * The request fails to provide coins for the payment. * This response is provided with HTTP status code * MHD_HTTP_BAD_REQUEST. -- cgit v1.2.3