diff options
Diffstat (limited to 'src/authorization/anastasis-helper-authorization-iban.c')
-rw-r--r-- | src/authorization/anastasis-helper-authorization-iban.c | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/src/authorization/anastasis-helper-authorization-iban.c b/src/authorization/anastasis-helper-authorization-iban.c index 0d3200a..d509c0e 100644 --- a/src/authorization/anastasis-helper-authorization-iban.c +++ b/src/authorization/anastasis-helper-authorization-iban.c | |||
@@ -17,10 +17,6 @@ | |||
17 | * @file anastasis-helper-authorization-iban.c | 17 | * @file anastasis-helper-authorization-iban.c |
18 | * @brief Process that watches for wire transfers to Anastasis bank account | 18 | * @brief Process that watches for wire transfers to Anastasis bank account |
19 | * @author Christian Grothoff | 19 | * @author Christian Grothoff |
20 | * | ||
21 | * TODO: | ||
22 | * - needs to add DB triggers to notify main service of inbound activity | ||
23 | * - needs man page | ||
24 | */ | 20 | */ |
25 | #include "platform.h" | 21 | #include "platform.h" |
26 | #include "anastasis_eufin_lib.h" | 22 | #include "anastasis_eufin_lib.h" |
@@ -31,6 +27,7 @@ | |||
31 | #include <jansson.h> | 27 | #include <jansson.h> |
32 | #include <pthread.h> | 28 | #include <pthread.h> |
33 | #include <microhttpd.h> | 29 | #include <microhttpd.h> |
30 | #include "iban.h" | ||
34 | 31 | ||
35 | /** | 32 | /** |
36 | * How long to wait for an HTTP reply if there | 33 | * How long to wait for an HTTP reply if there |
@@ -108,6 +105,37 @@ static struct GNUNET_SCHEDULER_Task *task; | |||
108 | 105 | ||
109 | 106 | ||
110 | /** | 107 | /** |
108 | * Notify anastasis-http that we received @a amount | ||
109 | * from @a sender_account_uri with @a code. | ||
110 | * | ||
111 | * @param sender_account_uri payto:// URI of the sending account | ||
112 | * @param code numeric code used in the wire transfer subject | ||
113 | * @param amount the amount that was wired | ||
114 | */ | ||
115 | static void | ||
116 | notify (const char *sender_account_uri, | ||
117 | uint64_t code, | ||
118 | const struct TALER_Amount *amount) | ||
119 | { | ||
120 | struct IbanEventP ev = { | ||
121 | .header.type = htons (TALER_DBEVENT_ANASTASIS_AUTH_IBAN_TRANSFER), | ||
122 | .header.size = htons (sizeof (ev)), | ||
123 | .code = GNUNET_htonll (code) | ||
124 | }; | ||
125 | const char *as; | ||
126 | |||
127 | GNUNET_CRYPTO_hash (sender_account_uri, | ||
128 | strlen (sender_account_uri), | ||
129 | &ev.debit_iban_hash); | ||
130 | as = TALER_amount2s (amount); | ||
131 | db_plugin->event_notify (db_plugin->cls, | ||
132 | &ev.header, | ||
133 | as, | ||
134 | strlen (as)); | ||
135 | } | ||
136 | |||
137 | |||
138 | /** | ||
111 | * We're being aborted with CTRL-C (or SIGTERM). Shut down. | 139 | * We're being aborted with CTRL-C (or SIGTERM). Shut down. |
112 | * | 140 | * |
113 | * @param cls closure | 141 | * @param cls closure |
@@ -152,6 +180,9 @@ static void | |||
152 | find_transfers (void *cls); | 180 | find_transfers (void *cls); |
153 | 181 | ||
154 | 182 | ||
183 | #include "iban.c" | ||
184 | |||
185 | |||
155 | /** | 186 | /** |
156 | * Callbacks of this type are used to serve the result of asking | 187 | * Callbacks of this type are used to serve the result of asking |
157 | * the bank for the transaction history. | 188 | * the bank for the transaction history. |
@@ -232,6 +263,17 @@ history_cb (void *cls, | |||
232 | break; | 263 | break; |
233 | } | 264 | } |
234 | latest_row_off = serial_id; | 265 | latest_row_off = serial_id; |
266 | { | ||
267 | uint64_t code; | ||
268 | |||
269 | if (GNUNET_OK != | ||
270 | extract_code (details->wire_subject, | ||
271 | &code)) | ||
272 | return GNUNET_OK; | ||
273 | notify (details->debit_account_uri, | ||
274 | code, | ||
275 | &details->amount); | ||
276 | } | ||
235 | return GNUNET_OK; | 277 | return GNUNET_OK; |
236 | } | 278 | } |
237 | 279 | ||