exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit fb8349a7e3088f1ca0215ecebcfef553098d7ab9
parent 8e4969eb663dbb2242b0137b1138a8e29610de18
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 30 Apr 2022 13:46:35 +0200

-add notifications for purse events

Diffstat:
Msrc/exchange/taler-exchange-httpd_purses_deposit.c | 15+++++++++++++++
Msrc/exchange/taler-exchange-httpd_purses_get.c | 8+++++---
Msrc/exchange/taler-exchange-httpd_purses_merge.c | 17+++++++++++++++++
3 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/src/exchange/taler-exchange-httpd_purses_deposit.c b/src/exchange/taler-exchange-httpd_purses_deposit.c @@ -26,6 +26,7 @@ #include <jansson.h> #include <microhttpd.h> #include <pthread.h> +#include "taler_dbevents.h" #include "taler_json_lib.h" #include "taler_mhd_lib.h" #include "taler-exchange-httpd_purses_deposit.h" @@ -276,6 +277,20 @@ deposit_transaction (void *cls, return GNUNET_DB_STATUS_HARD_ERROR; } } + { + struct TALER_PurseEventP rep = { + .header.size = htons (sizeof (rep)), + .header.type = htons (TALER_DBEVENT_EXCHANGE_PURSE_DEPOSITED), + .purse_pub = *pcc->purse_pub + }; + + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Notifying about purse deposit\n"); + TEH_plugin->event_notify (TEH_plugin->cls, + &rep.header, + NULL, + 0); + } return qs; } diff --git a/src/exchange/taler-exchange-httpd_purses_get.c b/src/exchange/taler-exchange-httpd_purses_get.c @@ -332,9 +332,6 @@ TEH_handler_purses_get (struct TEH_RequestContext *rc, gc->purse_expiration)); } - // FIXME: compare amount to deposited amount; - // if below, set 'deposit_timestamp' to zero! - if (GNUNET_TIME_absolute_is_future (gc->timeout) && ( ((gc->wait_for_merge) && GNUNET_TIME_absolute_is_never (gc->merge_timestamp.abs_time)) || @@ -358,6 +355,11 @@ TEH_handler_purses_get (struct TEH_RequestContext *rc, >, gc->purse_expiration)) dt = gc->purse_expiration; + if (0 < + TALER_amount_cmp (&gc->amount, + &gc->deposited)) + dt = GNUNET_TIME_UNIT_ZERO_TS; + // FIXME: add exchange signature!? // FIXME: return amount? res = TALER_MHD_REPLY_JSON_PACK ( diff --git a/src/exchange/taler-exchange-httpd_purses_merge.c b/src/exchange/taler-exchange-httpd_purses_merge.c @@ -26,6 +26,7 @@ #include <jansson.h> #include <microhttpd.h> #include <pthread.h> +#include "taler_dbevents.h" #include "taler_json_lib.h" #include "taler_mhd_lib.h" #include "taler-exchange-httpd_purses_merge.h" @@ -307,6 +308,22 @@ merge_transaction (void *cls, GNUNET_free (partner_url); return GNUNET_DB_STATUS_HARD_ERROR; } + + { + struct TALER_PurseEventP rep = { + .header.size = htons (sizeof (rep)), + .header.type = htons (TALER_DBEVENT_EXCHANGE_PURSE_MERGED), + .purse_pub = *pcc->purse_pub + }; + + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Notifying about purse merge\n"); + TEH_plugin->event_notify (TEH_plugin->cls, + &rep.header, + NULL, + 0); + } + return qs; }