diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-08-27 18:18:32 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-08-27 18:18:32 +0200 |
commit | c80eee722ed94e9c40f042f6e6404af059347f97 (patch) | |
tree | f9fe67600cd4fecd78fb0749a6f99eddc40d5a70 /src/authorization/anastasis-helper-authorization-iban.c | |
parent | cd44840c4258a60bd8aa8c6b3d0fa2b6b8920193 (diff) | |
download | anastasis-c80eee722ed94e9c40f042f6e6404af059347f97.tar.gz anastasis-c80eee722ed94e9c40f042f6e6404af059347f97.tar.bz2 anastasis-c80eee722ed94e9c40f042f6e6404af059347f97.zip |
-fix IBAN notification logic
Diffstat (limited to 'src/authorization/anastasis-helper-authorization-iban.c')
-rw-r--r-- | src/authorization/anastasis-helper-authorization-iban.c | 89 |
1 files changed, 48 insertions, 41 deletions
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. |