diff options
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; | |||
104 | static struct GNUNET_SCHEDULER_Task *task; | 104 | static 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 | */ | ||
114 | static char * | ||
115 | payto_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 | |||
180 | find_transfers (void *cls); | 225 | find_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 | */ | ||
190 | static char * | ||
191 | payto_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. |