diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/taler_bank_service.h | 77 | ||||
-rw-r--r-- | src/include/taler_error_codes.h | 28 | ||||
-rw-r--r-- | src/include/taler_fakebank_lib.h | 17 | ||||
-rw-r--r-- | src/include/taler_wire_plugin.h | 2 |
4 files changed, 120 insertions, 4 deletions
diff --git a/src/include/taler_bank_service.h b/src/include/taler_bank_service.h index 246174df9..6349326a1 100644 --- a/src/include/taler_bank_service.h +++ b/src/include/taler_bank_service.h @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2015, 2016, 2017 GNUnet e.V. & Inria + Copyright (C) 2015, 2016, 2017 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software @@ -25,6 +25,7 @@ #include <jansson.h> #include <gnunet/gnunet_curl_lib.h> #include "taler_util.h" +#include "taler_error_codes.h" /** @@ -98,12 +99,14 @@ struct TALER_BANK_AdminAddIncomingHandle; * @param cls closure * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request * 0 if the bank's reply is bogus (fails to follow the protocol) + * @param ec detailed error code * @param serial_id unique ID of the wire transfer in the bank's records; UINT64_MAX on error * @param json detailed response from the HTTPD, or NULL if reply was not in JSON */ typedef void (*TALER_BANK_AdminAddIncomingResultCallback) (void *cls, unsigned int http_status, + enum TALER_ErrorCode ec, uint64_t serial_id, const json_t *json); @@ -118,7 +121,7 @@ typedef void * @param bank_base_url URL of the bank (used to execute this request) * @param auth authentication data to use * @param exchange_base_url base URL of the exchange (for tracking) - * @param wtid wire transfer identifier for the transfer + * @param subject wire transfer subject for the transfer * @param amount amount that was deposited * @param debit_account_no account number to withdraw from (53 bits at most) * @param credit_account_no account number to deposit into (53 bits at most) @@ -133,7 +136,7 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx, const char *bank_base_url, const struct TALER_BANK_AuthenticationData *auth, const char *exchange_base_url, - const struct TALER_WireTransferIdentifierRawP *wtid, + const char *subject, const struct TALER_Amount *amount, uint64_t debit_account_no, uint64_t credit_account_no, @@ -174,7 +177,15 @@ enum TALER_BANK_Direction { /** * Return both types of transactions. */ - TALER_BANK_DIRECTION_BOTH = (TALER_BANK_DIRECTION_CREDIT | TALER_BANK_DIRECTION_DEBIT) + TALER_BANK_DIRECTION_BOTH = (TALER_BANK_DIRECTION_CREDIT | TALER_BANK_DIRECTION_DEBIT), + + /** + * Bit mask that is applied to view transactions that have been + * cancelled. The bit is set for cancelled transactions that are + * returned from /history, and must also be set in order for + * cancelled transactions to show up in the /history. + */ + TALER_BANK_DIRECTION_CANCEL = 4 }; @@ -222,6 +233,7 @@ struct TALER_BANK_TransferDetails * #MHD_HTTP_NO_CONTENT if there are no more results; on success the * last callback is always of this status (even if `abs(num_results)` were * already returned). + * @param ec detailed error code * @param dir direction of the transfer * @param serial_id monotonically increasing counter corresponding to the transaction * @param details details about the wire transfer @@ -230,6 +242,7 @@ struct TALER_BANK_TransferDetails typedef void (*TALER_BANK_HistoryResultCallback) (void *cls, unsigned int http_status, + enum TALER_ErrorCode ec, enum TALER_BANK_Direction dir, uint64_t serial_id, const struct TALER_BANK_TransferDetails *details, @@ -277,5 +290,61 @@ void TALER_BANK_history_cancel (struct TALER_BANK_HistoryHandle *hh); +/** + * Handle for #TALER_BANK_reject() operation. + */ +struct TALER_BANK_RejectHandle; + + +/** + * Callbacks of this type are used to serve the result of asking + * the bank to reject an incoming wire transfer. + * + * @param cls closure + * @param http_status HTTP response code, #MHD_HTTP_NO_CONTENT (204) for successful status request; + * #MHD_HTTP_NOT_FOUND if the rowid is unknown; + * 0 if the bank's reply is bogus (fails to follow the protocol), + * @param ec detailed error code + */ +typedef void +(*TALER_BANK_RejectResultCallback) (void *cls, + unsigned int http_status, + enum TALER_ErrorCode ec); + + +/** + * Request rejection of a wire transfer, marking it as cancelled and voiding + * its effects. + * + * @param ctx curl context for the event loop + * @param bank_base_url URL of the bank (used to execute this request) + * @param auth authentication data to use + * @param account_number which account number should we query + * @param rowid transfer to reject + * @param rcb the callback to call with the operation result + * @param rcb_cls closure for @a rcb + * @return NULL + * if the inputs are invalid. + * In this case, the callback is not called. + */ +struct TALER_BANK_RejectHandle * +TALER_BANK_reject (struct GNUNET_CURL_Context *ctx, + const char *bank_base_url, + const struct TALER_BANK_AuthenticationData *auth, + uint64_t account_number, + uint64_t rowid, + TALER_BANK_RejectResultCallback rcb, + void *rcb_cls); + + +/** + * Cancel an reject request. This function cannot be used on a request + * handle if the response was is already served for it. + * + * @param rh the reject request handle + */ +void +TALER_BANK_reject_cancel (struct TALER_BANK_RejectHandle *rh); + #endif /* _TALER_BANK_SERVICE_H */ diff --git a/src/include/taler_error_codes.h b/src/include/taler_error_codes.h index 6047e1643..e8a3aaee8 100644 --- a/src/include/taler_error_codes.h +++ b/src/include/taler_error_codes.h @@ -1488,6 +1488,34 @@ enum TALER_ErrorCode */ TALER_EC_TEST_RSA_SIGN_ERROR = 4005, + /* *************** Taler BANK/FAKEBANK error codes *************** */ + + + /** + * Authentication failed for the /admin/add/incoming request. + * Returned with a status code of MHD_HTTP_FORBIDDEN. + */ + TALER_EC_BANK_TRANSFER_NOT_AUHTORIZED = 4101, + + /** + * Authentication failed for the /history request. + * Returned with a status code of MHD_HTTP_FORBIDDEN. + */ + TALER_EC_BANK_HISTORY_NOT_AUHTORIZED = 4151, + + /** + * The bank could not find the wire transfer that was supposed to + * be rejected. + * Returned with a status code of MHD_HTTP_NOT_FOUND. + */ + TALER_EC_BANK_REJECT_NOT_FOUND = 4250, + + /** + * Authentication failed for the /reject request. + * Returned with a status code of MHD_HTTP_FORBIDDEN. + */ + TALER_EC_BANK_REJECT_NOT_AUHTORIZED = 4251, + /** * End of error code range. diff --git a/src/include/taler_fakebank_lib.h b/src/include/taler_fakebank_lib.h index 3df1e6095..5e0d7d1d1 100644 --- a/src/include/taler_fakebank_lib.h +++ b/src/include/taler_fakebank_lib.h @@ -88,6 +88,8 @@ TALER_FAKEBANK_make_transfer (struct TALER_FAKEBANK_Handle *h, * to the transfer identifier and remove the transaction from the * list. If the transaction was not recorded, return #GNUNET_SYSERR. * + * Rejected transfers do NOT show with "check". + * * @param h bank instance * @param want_amount transfer amount desired * @param want_debit account that should have been debited @@ -107,6 +109,21 @@ TALER_FAKEBANK_check (struct TALER_FAKEBANK_Handle *h, /** + * Reject incoming wire transfer to account @a credit_account + * as identified by @a rowid. + * + * @param h fake bank handle + * @param rowid identifies transfer to reject + * @param credit_account account number of owner of credited account + * @return #GNUNET_YES on success, #GNUNET_NO if the wire transfer was not found + */ +int +TALER_FAKEBANK_reject_transfer (struct TALER_FAKEBANK_Handle *h, + uint64_t rowid, + uint64_t credit_account); + + +/** * Stop running the fake bank. * * @param h bank to stop diff --git a/src/include/taler_wire_plugin.h b/src/include/taler_wire_plugin.h index 6e355baf6..c0e29609f 100644 --- a/src/include/taler_wire_plugin.h +++ b/src/include/taler_wire_plugin.h @@ -83,6 +83,7 @@ struct TALER_WIRE_TransferDetails * the bank for the transaction history. * * @param cls closure + * @param ec taler error code * @param dir direction of the transfer * @param row_off identification of the position at which we are querying * @param row_off_size number of bytes in @a row_off @@ -91,6 +92,7 @@ struct TALER_WIRE_TransferDetails */ typedef int (*TALER_WIRE_HistoryResultCallback) (void *cls, + enum TALER_ErrorCode ec, enum TALER_BANK_Direction dir, const void *row_off, size_t row_off_size, |