From c80eee722ed94e9c40f042f6e6404af059347f97 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 27 Aug 2021 18:18:32 +0200 Subject: -fix IBAN notification logic --- .../anastasis-helper-authorization-iban.c | 89 ++++++++++++---------- 1 file changed, 48 insertions(+), 41 deletions(-) (limited to 'src/authorization/anastasis-helper-authorization-iban.c') diff --git a/src/authorization/anastasis-helper-authorization-iban.c b/src/authorization/anastasis-helper-authorization-iban.c index 012780d..04dfa03 100644 --- a/src/authorization/anastasis-helper-authorization-iban.c +++ b/src/authorization/anastasis-helper-authorization-iban.c @@ -104,6 +104,44 @@ static int test_mode; static struct GNUNET_SCHEDULER_Task *task; +#include "iban.c" + +/** + * Extract IBAN from a payto URI. + * + * @return NULL on error + */ +static char * +payto_get_iban (const char *payto_uri) +{ + const char *start; + const char *q; + const char *bic_end; + + if (0 != + strncasecmp (payto_uri, + "payto://iban/", + strlen ("payto://iban/"))) + return NULL; + start = &payto_uri[strlen ("payto://iban/")]; + q = strchr (start, + '?'); + bic_end = strchr (start, + '/'); + if ( (NULL != q) && + (NULL != bic_end) && + (bic_end < q) ) + start = bic_end + 1; + if ( (NULL == q) && + (NULL != bic_end) ) + start = bic_end + 1; + if (NULL == q) + return GNUNET_strdup (start); + return GNUNET_strndup (start, + q - start); +} + + /** * Notify anastasis-http that we received @a amount * from @a sender_account_uri with @a code. @@ -123,10 +161,17 @@ notify (const char *sender_account_uri, .code = GNUNET_htonll (code) }; const char *as; - - GNUNET_CRYPTO_hash (sender_account_uri, - strlen (sender_account_uri), + char *iban; + + iban = payto_get_iban (sender_account_uri); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Generating events for code %llu from %s\n", + (unsigned long long) code, + iban); + GNUNET_CRYPTO_hash (iban, + strlen (iban), &ev.debit_iban_hash); + GNUNET_free (iban); as = TALER_amount2s (amount); db_plugin->event_notify (db_plugin->cls, &ev.header, @@ -180,44 +225,6 @@ static void find_transfers (void *cls); -#include "iban.c" - -/** - * Extract IBAN from a payto URI. - * - * @return NULL on error - */ -static char * -payto_get_iban (const char *payto_uri) -{ - const char *start; - const char *q; - const char *bic_end; - - if (0 != - strncasecmp (payto_uri, - "payto://iban/", - strlen ("payto://iban/"))) - return NULL; - start = &payto_uri[strlen ("payto://iban/")]; - q = strchr (start, - '?'); - bic_end = strchr (start, - '/'); - if ( (NULL != q) && - (NULL != bic_end) && - (bic_end < q) ) - start = bic_end + 1; - if ( (NULL == q) && - (NULL != bic_end) ) - start = bic_end + 1; - if (NULL == q) - return GNUNET_strdup (start); - return GNUNET_strndup (start, - q - start); -} - - /** * Callbacks of this type are used to serve the result of asking * the bank for the transaction history. -- cgit v1.2.3