aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-08-27 18:18:32 +0200
committerChristian Grothoff <christian@grothoff.org>2021-08-27 18:18:32 +0200
commitc80eee722ed94e9c40f042f6e6404af059347f97 (patch)
treef9fe67600cd4fecd78fb0749a6f99eddc40d5a70
parentcd44840c4258a60bd8aa8c6b3d0fa2b6b8920193 (diff)
downloadanastasis-c80eee722ed94e9c40f042f6e6404af059347f97.tar.gz
anastasis-c80eee722ed94e9c40f042f6e6404af059347f97.zip
-fix IBAN notification logic
-rw-r--r--src/authorization/anastasis-helper-authorization-iban.c89
-rw-r--r--src/authorization/anastasis_authorization_plugin_iban.c4
-rw-r--r--src/backend/anastasis-httpd_truth.c11
3 files changed, 59 insertions, 45 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;
104static struct GNUNET_SCHEDULER_Task *task; 104static struct GNUNET_SCHEDULER_Task *task;
105 105
106 106
107#include "iban.c"
108
109/**
110 * Extract IBAN from a payto URI.
111 *
112 * @return NULL on error
113 */
114static char *
115payto_get_iban (const char *payto_uri)
116{
117 const char *start;
118 const char *q;
119 const char *bic_end;
120
121 if (0 !=
122 strncasecmp (payto_uri,
123 "payto://iban/",
124 strlen ("payto://iban/")))
125 return NULL;
126 start = &payto_uri[strlen ("payto://iban/")];
127 q = strchr (start,
128 '?');
129 bic_end = strchr (start,
130 '/');
131 if ( (NULL != q) &&
132 (NULL != bic_end) &&
133 (bic_end < q) )
134 start = bic_end + 1;
135 if ( (NULL == q) &&
136 (NULL != bic_end) )
137 start = bic_end + 1;
138 if (NULL == q)
139 return GNUNET_strdup (start);
140 return GNUNET_strndup (start,
141 q - start);
142}
143
144
107/** 145/**
108 * Notify anastasis-http that we received @a amount 146 * Notify anastasis-http that we received @a amount
109 * from @a sender_account_uri with @a code. 147 * from @a sender_account_uri with @a code.
@@ -123,10 +161,17 @@ notify (const char *sender_account_uri,
123 .code = GNUNET_htonll (code) 161 .code = GNUNET_htonll (code)
124 }; 162 };
125 const char *as; 163 const char *as;
126 164 char *iban;
127 GNUNET_CRYPTO_hash (sender_account_uri, 165
128 strlen (sender_account_uri), 166 iban = payto_get_iban (sender_account_uri);
167 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
168 "Generating events for code %llu from %s\n",
169 (unsigned long long) code,
170 iban);
171 GNUNET_CRYPTO_hash (iban,
172 strlen (iban),
129 &ev.debit_iban_hash); 173 &ev.debit_iban_hash);
174 GNUNET_free (iban);
130 as = TALER_amount2s (amount); 175 as = TALER_amount2s (amount);
131 db_plugin->event_notify (db_plugin->cls, 176 db_plugin->event_notify (db_plugin->cls,
132 &ev.header, 177 &ev.header,
@@ -180,44 +225,6 @@ static void
180find_transfers (void *cls); 225find_transfers (void *cls);
181 226
182 227
183#include "iban.c"
184
185/**
186 * Extract IBAN from a payto URI.
187 *
188 * @return NULL on error
189 */
190static char *
191payto_get_iban (const char *payto_uri)
192{
193 const char *start;
194 const char *q;
195 const char *bic_end;
196
197 if (0 !=
198 strncasecmp (payto_uri,
199 "payto://iban/",
200 strlen ("payto://iban/")))
201 return NULL;
202 start = &payto_uri[strlen ("payto://iban/")];
203 q = strchr (start,
204 '?');
205 bic_end = strchr (start,
206 '/');
207 if ( (NULL != q) &&
208 (NULL != bic_end) &&
209 (bic_end < q) )
210 start = bic_end + 1;
211 if ( (NULL == q) &&
212 (NULL != bic_end) )
213 start = bic_end + 1;
214 if (NULL == q)
215 return GNUNET_strdup (start);
216 return GNUNET_strndup (start,
217 q - start);
218}
219
220
221/** 228/**
222 * Callbacks of this type are used to serve the result of asking 229 * Callbacks of this type are used to serve the result of asking
223 * the bank for the transaction history. 230 * the bank for the transaction history.
diff --git a/src/authorization/anastasis_authorization_plugin_iban.c b/src/authorization/anastasis_authorization_plugin_iban.c
index cdd51a7..7717770 100644
--- a/src/authorization/anastasis_authorization_plugin_iban.c
+++ b/src/authorization/anastasis_authorization_plugin_iban.c
@@ -530,6 +530,10 @@ iban_process (struct ANASTASIS_AUTHORIZATION_State *as,
530 .code = GNUNET_htonll (as->code) 530 .code = GNUNET_htonll (as->code)
531 }; 531 };
532 532
533 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
534 "Subscribing to events for code %llu from %s\n",
535 (unsigned long long) as->code,
536 as->iban_number);
533 GNUNET_CRYPTO_hash (as->iban_number, 537 GNUNET_CRYPTO_hash (as->iban_number,
534 strlen (as->iban_number), 538 strlen (as->iban_number),
535 &espec.debit_iban_hash); 539 &espec.debit_iban_hash);
diff --git a/src/backend/anastasis-httpd_truth.c b/src/backend/anastasis-httpd_truth.c
index 613e27f..4853e15 100644
--- a/src/backend/anastasis-httpd_truth.c
+++ b/src/backend/anastasis-httpd_truth.c
@@ -316,8 +316,8 @@ AH_truth_shutdown (void)
316 } 316 }
317 if (gc->suspended) 317 if (gc->suspended)
318 { 318 {
319 MHD_resume_connection (gc->connection);
320 gc->suspended = false; 319 gc->suspended = false;
320 MHD_resume_connection (gc->connection);
321 } 321 }
322 if (NULL != gc->as) 322 if (NULL != gc->as)
323 { 323 {
@@ -576,8 +576,8 @@ proposal_cb (void *cls,
576 gc); 576 gc);
577 gc->in_list = false; 577 gc->in_list = false;
578 GNUNET_assert (gc->suspended); 578 GNUNET_assert (gc->suspended);
579 MHD_resume_connection (gc->connection);
580 gc->suspended = false; 579 gc->suspended = false;
580 MHD_resume_connection (gc->connection);
581 AH_trigger_daemon (NULL); 581 AH_trigger_daemon (NULL);
582 if (MHD_HTTP_OK != por->hr.http_status) 582 if (MHD_HTTP_OK != por->hr.http_status)
583 { 583 {
@@ -641,8 +641,8 @@ check_payment_cb (void *cls,
641 gc); 641 gc);
642 gc->in_list = false; 642 gc->in_list = false;
643 GNUNET_assert (gc->suspended); 643 GNUNET_assert (gc->suspended);
644 MHD_resume_connection (gc->connection);
645 gc->suspended = false; 644 gc->suspended = false;
645 MHD_resume_connection (gc->connection);
646 AH_trigger_daemon (NULL); 646 AH_trigger_daemon (NULL);
647 647
648 switch (hr->http_status) 648 switch (hr->http_status)
@@ -895,6 +895,7 @@ run_authorization_process (struct MHD_Connection *connection,
895 enum ANASTASIS_AUTHORIZATION_Result ret; 895 enum ANASTASIS_AUTHORIZATION_Result ret;
896 enum GNUNET_DB_QueryStatus qs; 896 enum GNUNET_DB_QueryStatus qs;
897 897
898 GNUNET_assert (! gc->suspended);
898 ret = gc->authorization->process (gc->as, 899 ret = gc->authorization->process (gc->as,
899 gc->timeout, 900 gc->timeout,
900 connection); 901 connection);
@@ -922,13 +923,13 @@ run_authorization_process (struct MHD_Connection *connection,
922 return MHD_YES; 923 return MHD_YES;
923 case ANASTASIS_AUTHORIZATION_RES_SUSPENDED: 924 case ANASTASIS_AUTHORIZATION_RES_SUSPENDED:
924 /* connection was suspended */ 925 /* connection was suspended */
926 gc->suspended = true;
925 if (NULL == AH_to_heap) 927 if (NULL == AH_to_heap)
926 AH_to_heap = GNUNET_CONTAINER_heap_create ( 928 AH_to_heap = GNUNET_CONTAINER_heap_create (
927 GNUNET_CONTAINER_HEAP_ORDER_MIN); 929 GNUNET_CONTAINER_HEAP_ORDER_MIN);
928 gc->hn = GNUNET_CONTAINER_heap_insert (AH_to_heap, 930 gc->hn = GNUNET_CONTAINER_heap_insert (AH_to_heap,
929 gc, 931 gc,
930 gc->timeout.abs_value_us); 932 gc->timeout.abs_value_us);
931 gc->suspended = true;
932 if (NULL != to_task) 933 if (NULL != to_task)
933 { 934 {
934 GNUNET_SCHEDULER_cancel (to_task); 935 GNUNET_SCHEDULER_cancel (to_task);
@@ -1135,6 +1136,7 @@ AH_handler_truth_get (
1135 GNUNET_assert (NULL != gc->authorization); 1136 GNUNET_assert (NULL != gc->authorization);
1136 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1137 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1137 "Continuing with running the authorization process\n"); 1138 "Continuing with running the authorization process\n");
1139 GNUNET_assert (! gc->suspended);
1138 return run_authorization_process (connection, 1140 return run_authorization_process (connection,
1139 gc); 1141 gc);
1140 1142
@@ -1547,6 +1549,7 @@ AH_handler_truth_get (
1547 GNUNET_CONTAINER_DLL_insert (gc_head, 1549 GNUNET_CONTAINER_DLL_insert (gc_head,
1548 gc_tail, 1550 gc_tail,
1549 gc); 1551 gc);
1552 GNUNET_assert (! gc->suspended);
1550 return run_authorization_process (connection, 1553 return run_authorization_process (connection,
1551 gc); 1554 gc);
1552} 1555}