diff options
| author | Christian Grothoff <christian@grothoff.org> | 2022-12-29 10:10:25 +0100 |
|---|---|---|
| committer | Christian Grothoff <christian@grothoff.org> | 2022-12-29 10:10:25 +0100 |
| commit | fa840f7071da56c4794c887b813ca2a6f491f836 (patch) | |
| tree | 7b126d737aa1fdc3df2ea60f76540af6011ea049 /src/exchange/taler-exchange-httpd_purses_delete.c | |
| parent | 5828eead705965b5ac87cfad78636b1363b16396 (diff) | |
| parent | 915d6ddfaa638a9759766eaf69dfef7e8e17474b (diff) | |
Merge branch 'master' of git+ssh://git.taler.net/exchange
Diffstat (limited to 'src/exchange/taler-exchange-httpd_purses_delete.c')
| -rw-r--r-- | src/exchange/taler-exchange-httpd_purses_delete.c | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/src/exchange/taler-exchange-httpd_purses_delete.c b/src/exchange/taler-exchange-httpd_purses_delete.c index 34ab11b5..58cc7825 100644 --- a/src/exchange/taler-exchange-httpd_purses_delete.c +++ b/src/exchange/taler-exchange-httpd_purses_delete.c @@ -24,6 +24,7 @@ #include <gnunet/gnunet_json_lib.h> #include <jansson.h> #include <microhttpd.h> +#include "taler_dbevents.h" #include "taler_json_lib.h" #include "taler_mhd_lib.h" #include "taler-exchange-httpd_common_deposit.h" @@ -35,13 +36,27 @@ MHD_RESULT TEH_handler_purses_delete ( - struct MHD_Connection *connection, - const struct TALER_PurseContractPublicKeyP *purse_pub) + struct TEH_RequestContext *rc, + const char *const args[1]) { + struct MHD_Connection *connection = rc->connection; + struct TALER_PurseContractPublicKeyP purse_pub; struct TALER_PurseContractSignatureP purse_sig; bool found; bool decided; + if (GNUNET_OK != + GNUNET_STRINGS_string_to_data (args[0], + strlen (args[0]), + &purse_pub, + sizeof (purse_pub))) + { + GNUNET_break_op (0); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_EXCHANGE_GENERIC_PURSE_PUB_MALFORMED, + args[0]); + } { const char *sig; @@ -66,7 +81,7 @@ TEH_handler_purses_delete ( } if (GNUNET_OK != - TALER_wallet_purse_delete_verify (purse_pub, + TALER_wallet_purse_delete_verify (&purse_pub, &purse_sig)) { TALER_LOG_WARNING ("Invalid signature on /purses/$PID/delete request\n"); @@ -89,7 +104,7 @@ TEH_handler_purses_delete ( enum GNUNET_DB_QueryStatus qs; qs = TEH_plugin->do_purse_delete (TEH_plugin->cls, - purse_pub, + &purse_pub, &purse_sig, &decided, &found); @@ -117,6 +132,23 @@ TEH_handler_purses_delete ( TALER_EC_EXCHANGE_PURSE_DELETE_ALREADY_DECIDED, NULL); } + { + /* Possible minor optimization: integrate notification with + transaction above... */ + struct TALER_PurseEventP rep = { + .header.size = htons (sizeof (rep)), + .header.type = htons (TALER_DBEVENT_EXCHANGE_PURSE_DEPOSITED), + .purse_pub = purse_pub + }; + + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Notifying about purse deletion %s\n", + TALER_B2S (&purse_pub)); + TEH_plugin->event_notify (TEH_plugin->cls, + &rep.header, + NULL, + 0); + } /* success */ return TALER_MHD_reply_static (connection, MHD_HTTP_NO_CONTENT, |
