diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-06-30 22:09:15 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-06-30 22:09:15 +0200 |
commit | 253d220ea54d45557f33dd3a7affef0e79593218 (patch) | |
tree | c50e34b2070f1bd1d3d340e7bec62db6ea6f4125 | |
parent | 68bf92de2c1d754a04663236a4106e2c5635ebc4 (diff) |
towards implementing #3851: /admin/add/incoming
-rw-r--r-- | src/mint/Makefile.am | 1 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd.c | 10 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_db.c | 24 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_db.h | 19 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_parsing.h | 2 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_responses.c | 19 | ||||
-rw-r--r-- | src/mint/taler-mint-httpd_responses.h | 12 |
7 files changed, 87 insertions, 0 deletions
diff --git a/src/mint/Makefile.am b/src/mint/Makefile.am index 2cda4fac1..112dbbf18 100644 --- a/src/mint/Makefile.am +++ b/src/mint/Makefile.am @@ -11,6 +11,7 @@ taler_mint_httpd_SOURCES = \ taler-mint-httpd_parsing.c taler-mint-httpd_parsing.h \ taler-mint-httpd_responses.c taler-mint-httpd_responses.h \ taler-mint-httpd_mhd.c taler-mint-httpd_mhd.h \ + taler-mint-httpd_admin.c taler-mint-httpd_admin.h \ taler-mint-httpd_deposit.c taler-mint-httpd_deposit.h \ taler-mint-httpd_withdraw.c taler-mint-httpd_withdraw.h \ taler-mint-httpd_refresh.c taler-mint-httpd_refresh.h diff --git a/src/mint/taler-mint-httpd.c b/src/mint/taler-mint-httpd.c index 66d7e01e2..a0f1eca4b 100644 --- a/src/mint/taler-mint-httpd.c +++ b/src/mint/taler-mint-httpd.c @@ -28,6 +28,7 @@ #include <pthread.h> #include "taler-mint-httpd_parsing.h" #include "taler-mint-httpd_mhd.h" +#include "taler-mint-httpd_admin.h" #include "taler-mint-httpd_deposit.h" #include "taler-mint-httpd_withdraw.h" #include "taler-mint-httpd_refresh.h" @@ -199,6 +200,15 @@ handle_mhd_request (void *cls, "Only GET is allowed", 0, &TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + /* FIXME: maybe conditionally compile these? */ + { "/admin/add/incoming", MHD_HTTP_METHOD_POST, "application/json", + NULL, 0, + &TMH_ADMIN_handler_admin_add_incoming, MHD_HTTP_OK }, + { "/admin/add/incoming", NULL, "text/plain", + "Only POST is allowed", 0, + &TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED }, + + #if HAVE_DEVELOPER { "/test", MHD_HTTP_METHOD_POST, "application/json", NULL, 0, diff --git a/src/mint/taler-mint-httpd_db.c b/src/mint/taler-mint-httpd_db.c index 78a8d6f40..512ed9a48 100644 --- a/src/mint/taler-mint-httpd_db.c +++ b/src/mint/taler-mint-httpd_db.c @@ -1374,4 +1374,28 @@ TMH_DB_execute_refresh_link (struct MHD_Connection *connection, } +/** + * Add an incoming transaction to the database. Checks if the + * transaction is fresh (not a duplicate) and if so adds it to + * the database. + * + * @param connection the MHD connection to handle + * @param reserve_pub public key of the reserve + * @param amount amount to add to the reserve + * @param execution_time when did we receive the wire transfer + * @param wire details about the wire transfer + * @return MHD result code + */ +int +TMH_DB_execute_admin_add_incoming (struct MHD_Connection *connection, + const struct TALER_ReservePublicKeyP *reserve_pub, + const struct TALER_Amount *amount, + struct GNUNET_TIME_Absolute execution_time, + json_t *wire) +{ + GNUNET_break (0); // FIXME: #3851! + return MHD_NO; +} + + /* end of taler-mint-httpd_db.c */ diff --git a/src/mint/taler-mint-httpd_db.h b/src/mint/taler-mint-httpd_db.h index 56a4dd9cb..8a171153a 100644 --- a/src/mint/taler-mint-httpd_db.h +++ b/src/mint/taler-mint-httpd_db.h @@ -167,5 +167,24 @@ TMH_DB_execute_refresh_link (struct MHD_Connection *connection, const struct TALER_CoinSpendPublicKeyP *coin_pub); + +/** + * Add an incoming transaction to the database. + * + * @param connection the MHD connection to handle + * @param reserve_pub public key of the reserve + * @param amount amount to add to the reserve + * @param execution_time when did we receive the wire transfer + * @param wire details about the wire transfer + * @return MHD result code + */ +int +TMH_DB_execute_admin_add_incoming (struct MHD_Connection *connection, + const struct TALER_ReservePublicKeyP *reserve_pub, + const struct TALER_Amount *amount, + struct GNUNET_TIME_Absolute execution_time, + json_t *wire); + + #endif /* TALER_MINT_HTTPD_DB_H */ diff --git a/src/mint/taler-mint-httpd_parsing.h b/src/mint/taler-mint-httpd_parsing.h index 4714ab6a0..2439f39f9 100644 --- a/src/mint/taler-mint-httpd_parsing.h +++ b/src/mint/taler-mint-httpd_parsing.h @@ -134,6 +134,7 @@ enum TMH_PARSE_JsonNavigationCommand * Param: struct GNUNET_TIME_Absolute * */ TMH_PARSE_JNC_RET_TIME_ABSOLUTE + }; @@ -299,6 +300,7 @@ TMH_PARSE_release_data (struct TMH_PARSE_FieldSpecification *spec); */ #define TMH_PARSE_MEMBER_TIME_ABS(field,atime) { field, atime, sizeof(*atime), 0, TMH_PARSE_JNC_RET_TIME_ABSOLUTE, 0 } + /** * Generate line in parser specification indicating the end of the spec. */ diff --git a/src/mint/taler-mint-httpd_responses.c b/src/mint/taler-mint-httpd_responses.c index ccc144e29..013cc19b8 100644 --- a/src/mint/taler-mint-httpd_responses.c +++ b/src/mint/taler-mint-httpd_responses.c @@ -172,6 +172,25 @@ TMH_RESPONSE_reply_arg_missing (struct MHD_Connection *connection, /** + * Send a response indicating permission denied. + * + * @param connection the MHD connection to use + * @param hint hint about why access was denied + * @return a MHD result code + */ +int +TMH_RESPONSE_reply_permission_denied (struct MHD_Connection *connection, + const char *hint) +{ + return TMH_RESPONSE_reply_json_pack (connection, + MHD_HTTP_FORBIDDEN, + "{s:s, s:s}", + "error", "permission denied", + "hint", hint); +} + + +/** * Send a response indicating an internal error. * * @param connection the MHD connection to use diff --git a/src/mint/taler-mint-httpd_responses.h b/src/mint/taler-mint-httpd_responses.h index 2ae06209d..1f8e1e44c 100644 --- a/src/mint/taler-mint-httpd_responses.h +++ b/src/mint/taler-mint-httpd_responses.h @@ -115,6 +115,18 @@ TMH_RESPONSE_reply_arg_missing (struct MHD_Connection *connection, /** + * Send a response indicating permission denied. + * + * @param connection the MHD connection to use + * @param hint hint about why access was denied + * @return a MHD result code + */ +int +TMH_RESPONSE_reply_permission_denied (struct MHD_Connection *connection, + const char *hint); + + +/** * Send a response indicating an internal error. * * @param connection the MHD connection to use |