diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-08-18 17:37:58 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-08-18 17:37:58 +0200 |
commit | 5f288737d51441694b2c25a6e6591cf2735b0730 (patch) | |
tree | ee55f9bd533158bda4ea369c0ce81222bfba57f7 | |
parent | d67df6dfa492454945414759577ea169ec0f6824 (diff) | |
download | anastasis-5f288737d51441694b2c25a6e6591cf2735b0730.tar.gz anastasis-5f288737d51441694b2c25a6e6591cf2735b0730.zip |
-get anastasis-helper-authorization-iban to build
-rw-r--r-- | src/authorization/.gitignore | 1 | ||||
-rw-r--r-- | src/authorization/Makefile.am | 20 | ||||
-rw-r--r-- | src/authorization/anastasis-helper-authorization-iban.c | 60 | ||||
-rw-r--r-- | src/authorization/libanastasiseufin/lae_credit.c | 12 | ||||
-rw-r--r-- | src/include/anastasis_eufin_lib.h | 7 | ||||
-rw-r--r-- | src/include/anastasis_util_lib.h | 7 | ||||
-rw-r--r-- | src/include/platform.h | 27 |
7 files changed, 97 insertions, 37 deletions
diff --git a/src/authorization/.gitignore b/src/authorization/.gitignore new file mode 100644 index 0000000..0aebea9 --- /dev/null +++ b/src/authorization/.gitignore | |||
@@ -0,0 +1 @@ | |||
anastasis-helper-authorization-iban | |||
diff --git a/src/authorization/Makefile.am b/src/authorization/Makefile.am index 5cf6db1..15b16d1 100644 --- a/src/authorization/Makefile.am +++ b/src/authorization/Makefile.am | |||
@@ -23,6 +23,22 @@ if USE_COVERAGE | |||
23 | XLIB = -lgcov | 23 | XLIB = -lgcov |
24 | endif | 24 | endif |
25 | 25 | ||
26 | bin_PROGRAMS = \ | ||
27 | anastasis-helper-authorization-iban | ||
28 | |||
29 | anastasis_helper_authorization_iban_SOURCES = \ | ||
30 | anastasis-helper-authorization-iban.c | ||
31 | anastasis_helper_authorization_iban_LDADD = \ | ||
32 | $(top_builddir)/src/stasis/libanastasisdb.la \ | ||
33 | $(top_builddir)/src/authorization/libanastasiseufin/libanastasiseufin.la \ | ||
34 | $(top_builddir)/src/util/libanastasisutil.la \ | ||
35 | -lgnunetcurl \ | ||
36 | -lgnunetutil \ | ||
37 | -ljansson \ | ||
38 | -lmicrohttpd \ | ||
39 | -lpthread | ||
40 | |||
41 | |||
26 | lib_LTLIBRARIES = \ | 42 | lib_LTLIBRARIES = \ |
27 | libanastasisauthorization.la | 43 | libanastasisauthorization.la |
28 | 44 | ||
@@ -51,6 +67,7 @@ libanastasis_plugin_authorization_file_la_LIBADD = \ | |||
51 | $(LTLIBINTL) | 67 | $(LTLIBINTL) |
52 | libanastasis_plugin_authorization_file_la_LDFLAGS = \ | 68 | libanastasis_plugin_authorization_file_la_LDFLAGS = \ |
53 | $(ANASTASIS_PLUGIN_LDFLAGS) \ | 69 | $(ANASTASIS_PLUGIN_LDFLAGS) \ |
70 | $(top_builddir)/src/stasis/libanastasisdb.la \ | ||
54 | -ltalerjson \ | 71 | -ltalerjson \ |
55 | -ltalermhd \ | 72 | -ltalermhd \ |
56 | -ltalerutil \ | 73 | -ltalerutil \ |
@@ -66,6 +83,7 @@ libanastasis_plugin_authorization_email_la_LIBADD = \ | |||
66 | $(LTLIBINTL) | 83 | $(LTLIBINTL) |
67 | libanastasis_plugin_authorization_email_la_LDFLAGS = \ | 84 | libanastasis_plugin_authorization_email_la_LDFLAGS = \ |
68 | $(ANASTASIS_PLUGIN_LDFLAGS) \ | 85 | $(ANASTASIS_PLUGIN_LDFLAGS) \ |
86 | $(top_builddir)/src/stasis/libanastasisdb.la \ | ||
69 | -ltalerjson \ | 87 | -ltalerjson \ |
70 | -ltalermhd \ | 88 | -ltalermhd \ |
71 | -ltalerutil \ | 89 | -ltalerutil \ |
@@ -97,6 +115,7 @@ libanastasis_plugin_authorization_post_la_LIBADD = \ | |||
97 | $(LTLIBINTL) | 115 | $(LTLIBINTL) |
98 | libanastasis_plugin_authorization_post_la_LDFLAGS = \ | 116 | libanastasis_plugin_authorization_post_la_LDFLAGS = \ |
99 | $(ANASTASIS_PLUGIN_LDFLAGS) \ | 117 | $(ANASTASIS_PLUGIN_LDFLAGS) \ |
118 | $(top_builddir)/src/stasis/libanastasisdb.la \ | ||
100 | -ltalerjson \ | 119 | -ltalerjson \ |
101 | -ltalermhd \ | 120 | -ltalermhd \ |
102 | -ltalerutil \ | 121 | -ltalerutil \ |
@@ -112,6 +131,7 @@ libanastasis_plugin_authorization_sms_la_LIBADD = \ | |||
112 | $(LTLIBINTL) | 131 | $(LTLIBINTL) |
113 | libanastasis_plugin_authorization_sms_la_LDFLAGS = \ | 132 | libanastasis_plugin_authorization_sms_la_LDFLAGS = \ |
114 | $(ANASTASIS_PLUGIN_LDFLAGS) \ | 133 | $(ANASTASIS_PLUGIN_LDFLAGS) \ |
134 | $(top_builddir)/src/stasis/libanastasisdb.la \ | ||
115 | -ltalerjson \ | 135 | -ltalerjson \ |
116 | -ltalermhd \ | 136 | -ltalermhd \ |
117 | -ltalerutil \ | 137 | -ltalerutil \ |
diff --git a/src/authorization/anastasis-helper-authorization-iban.c b/src/authorization/anastasis-helper-authorization-iban.c index 946b008..066b4cb 100644 --- a/src/authorization/anastasis-helper-authorization-iban.c +++ b/src/authorization/anastasis-helper-authorization-iban.c | |||
@@ -25,13 +25,14 @@ | |||
25 | * - needs to add DB triggers to notify main service of inbound activity | 25 | * - needs to add DB triggers to notify main service of inbound activity |
26 | */ | 26 | */ |
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "anastasis_eufin_lib.h" | ||
29 | #include "anastasis_database_lib.h" | ||
30 | #include "anastasis_util_lib.h" | ||
31 | #include <taler/taler_json_lib.h> | ||
28 | #include <gnunet/gnunet_util_lib.h> | 32 | #include <gnunet/gnunet_util_lib.h> |
29 | #include <jansson.h> | 33 | #include <jansson.h> |
30 | #include <pthread.h> | 34 | #include <pthread.h> |
31 | #include <microhttpd.h> | 35 | #include <microhttpd.h> |
32 | #include <taler/taler_json_lib.h> | ||
33 | #include <XXX_bank_service.h> | ||
34 | #include "anastasis_db_lib.h" | ||
35 | 36 | ||
36 | /** | 37 | /** |
37 | * How long to wait for an HTTP reply if there | 38 | * How long to wait for an HTTP reply if there |
@@ -40,19 +41,24 @@ | |||
40 | #define LONGPOLL_TIMEOUT GNUNET_TIME_UNIT_HOURS | 41 | #define LONGPOLL_TIMEOUT GNUNET_TIME_UNIT_HOURS |
41 | 42 | ||
42 | /** | 43 | /** |
44 | * How long to wait between HTTP requests? | ||
45 | */ | ||
46 | #define RETRY_TIMEOUT GNUNET_TIME_UNIT_MINUTES | ||
47 | |||
48 | /** | ||
43 | * Authentication data needed to access the account. | 49 | * Authentication data needed to access the account. |
44 | */ | 50 | */ |
45 | static struct BANK_AccountInfo *auth; | 51 | static struct ANASTASIS_EUFIN_AuthenticationData auth; |
46 | 52 | ||
47 | /** | 53 | /** |
48 | * Bank account payto://-URI this process is monitoring. | 54 | * Bank account payto://-URI this process is monitoring. |
49 | */ | 55 | */ |
50 | static struct credit_account_uri; | 56 | static char *credit_account_uri; |
51 | 57 | ||
52 | /** | 58 | /** |
53 | * Active request for history. | 59 | * Active request for history. |
54 | */ | 60 | */ |
55 | static struct BANK_CreditHistoryHandle *hh; | 61 | static struct ANASTASIS_EUFIN_CreditHistoryHandle *hh; |
56 | 62 | ||
57 | /** | 63 | /** |
58 | * Handle to the context for interacting with the bank. | 64 | * Handle to the context for interacting with the bank. |
@@ -92,6 +98,12 @@ static struct GNUNET_TIME_Relative idle_sleep_interval; | |||
92 | static int global_ret; | 98 | static int global_ret; |
93 | 99 | ||
94 | /** | 100 | /** |
101 | * Run in test-mode, do not background, only import currently | ||
102 | * pending transactions. | ||
103 | */ | ||
104 | static int test_mode; | ||
105 | |||
106 | /** | ||
95 | * Current task waiting for execution, if any. | 107 | * Current task waiting for execution, if any. |
96 | */ | 108 | */ |
97 | static struct GNUNET_SCHEDULER_Task *task; | 109 | static struct GNUNET_SCHEDULER_Task *task; |
@@ -108,7 +120,7 @@ shutdown_task (void *cls) | |||
108 | (void) cls; | 120 | (void) cls; |
109 | if (NULL != hh) | 121 | if (NULL != hh) |
110 | { | 122 | { |
111 | BANK_credit_history_cancel (hh); | 123 | ANASTASIS_EUFIN_credit_history_cancel (hh); |
112 | hh = NULL; | 124 | hh = NULL; |
113 | } | 125 | } |
114 | if (NULL != ctx) | 126 | if (NULL != ctx) |
@@ -157,11 +169,10 @@ history_cb (void *cls, | |||
157 | unsigned int http_status, | 169 | unsigned int http_status, |
158 | enum TALER_ErrorCode ec, | 170 | enum TALER_ErrorCode ec, |
159 | uint64_t serial_id, | 171 | uint64_t serial_id, |
160 | const struct BANK_CreditDetails *details) | 172 | const struct ANASTASIS_EUFIN_CreditDetails *details) |
161 | { | 173 | { |
162 | enum GNUNET_DB_QueryStatus qs; | 174 | enum GNUNET_DB_QueryStatus qs; |
163 | 175 | ||
164 | (void) json; | ||
165 | if (NULL == details) | 176 | if (NULL == details) |
166 | { | 177 | { |
167 | hh = NULL; | 178 | hh = NULL; |
@@ -175,9 +186,9 @@ history_cb (void *cls, | |||
175 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 186 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
176 | "End of list.\n"); | 187 | "End of list.\n"); |
177 | GNUNET_assert (NULL == task); | 188 | GNUNET_assert (NULL == task); |
178 | task = GNUNET_SCHEDULER_add_at (delayed_until, | 189 | task = GNUNET_SCHEDULER_add_delayed (idle_sleep_interval, |
179 | &find_transfers, | 190 | &find_transfers, |
180 | NULL); | 191 | NULL); |
181 | return GNUNET_OK; /* will be ignored anyway */ | 192 | return GNUNET_OK; /* will be ignored anyway */ |
182 | } | 193 | } |
183 | if (serial_id <= latest_row_off) | 194 | if (serial_id <= latest_row_off) |
@@ -200,7 +211,7 @@ history_cb (void *cls, | |||
200 | &details->amount, | 211 | &details->amount, |
201 | details->debit_account_uri, | 212 | details->debit_account_uri, |
202 | details->credit_account_uri, | 213 | details->credit_account_uri, |
203 | details->execution_time); | 214 | details->execution_date); |
204 | switch (qs) | 215 | switch (qs) |
205 | { | 216 | { |
206 | case GNUNET_DB_STATUS_HARD_ERROR: | 217 | case GNUNET_DB_STATUS_HARD_ERROR: |
@@ -234,20 +245,18 @@ history_cb (void *cls, | |||
234 | static void | 245 | static void |
235 | find_transfers (void *cls) | 246 | find_transfers (void *cls) |
236 | { | 247 | { |
237 | enum GNUNET_DB_QueryStatus qs; | ||
238 | |||
239 | (void) cls; | 248 | (void) cls; |
240 | task = NULL; | 249 | task = NULL; |
241 | GNUNET_assert (NULL == hh); | 250 | GNUNET_assert (NULL == hh); |
242 | hh = BANK_credit_history (ctx, | 251 | hh = ANASTASIS_EUFIN_credit_history (ctx, |
243 | &auth, | 252 | &auth, |
244 | latest_row_off, | 253 | latest_row_off, |
245 | 1024, | 254 | 1024, |
246 | test_mode | 255 | test_mode |
247 | ? GNUNET_TIME_UNIT_ZERO | 256 | ? GNUNET_TIME_UNIT_ZERO |
248 | : LONGPOLL_TIMEOUT, | 257 | : LONGPOLL_TIMEOUT, |
249 | &history_cb, | 258 | &history_cb, |
250 | NULL); | 259 | NULL); |
251 | if (NULL == hh) | 260 | if (NULL == hh) |
252 | { | 261 | { |
253 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 262 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -310,8 +319,7 @@ run (void *cls, | |||
310 | GNUNET_break (0); | 319 | GNUNET_break (0); |
311 | return; | 320 | return; |
312 | } | 321 | } |
313 | latest_row_off = FIXME; // need new DB function! | 322 | idle_sleep_interval = RETRY_TIMEOUT; |
314 | |||
315 | task = GNUNET_SCHEDULER_add_now (&find_transfers, | 323 | task = GNUNET_SCHEDULER_add_now (&find_transfers, |
316 | NULL); | 324 | NULL); |
317 | } | 325 | } |
diff --git a/src/authorization/libanastasiseufin/lae_credit.c b/src/authorization/libanastasiseufin/lae_credit.c index b97536b..e8cabb5 100644 --- a/src/authorization/libanastasiseufin/lae_credit.c +++ b/src/authorization/libanastasiseufin/lae_credit.c | |||
@@ -117,8 +117,7 @@ parse_account_history (struct ANASTASIS_EUFIN_CreditHistoryHandle *hh, | |||
117 | MHD_HTTP_OK, | 117 | MHD_HTTP_OK, |
118 | TALER_EC_NONE, | 118 | TALER_EC_NONE, |
119 | row_id, | 119 | row_id, |
120 | &td, | 120 | &td)) |
121 | transaction)) | ||
122 | { | 121 | { |
123 | hh->hcb = NULL; | 122 | hh->hcb = NULL; |
124 | GNUNET_JSON_parse_free (hist_spec); | 123 | GNUNET_JSON_parse_free (hist_spec); |
@@ -205,8 +204,7 @@ handle_credit_history_finished (void *cls, | |||
205 | response_code, | 204 | response_code, |
206 | ec, | 205 | ec, |
207 | 0LLU, | 206 | 0LLU, |
208 | NULL, | 207 | NULL); |
209 | j); | ||
210 | ANASTASIS_EUFIN_credit_history_cancel (hh); | 208 | ANASTASIS_EUFIN_credit_history_cancel (hh); |
211 | } | 209 | } |
212 | 210 | ||
@@ -272,9 +270,9 @@ ANASTASIS_EUFIN_credit_history ( | |||
272 | hh = GNUNET_new (struct ANASTASIS_EUFIN_CreditHistoryHandle); | 270 | hh = GNUNET_new (struct ANASTASIS_EUFIN_CreditHistoryHandle); |
273 | hh->hcb = hres_cb; | 271 | hh->hcb = hres_cb; |
274 | hh->hcb_cls = hres_cb_cls; | 272 | hh->hcb_cls = hres_cb_cls; |
275 | hh->request_url = Anastasis_url_join (auth->wire_gateway_url, | 273 | hh->request_url = TALER_url_join (auth->wire_gateway_url, |
276 | url, | 274 | url, |
277 | NULL); | 275 | NULL); |
278 | if (NULL == hh->request_url) | 276 | if (NULL == hh->request_url) |
279 | { | 277 | { |
280 | GNUNET_free (hh); | 278 | GNUNET_free (hh); |
diff --git a/src/include/anastasis_eufin_lib.h b/src/include/anastasis_eufin_lib.h index 38eb61d..daff98a 100644 --- a/src/include/anastasis_eufin_lib.h +++ b/src/include/anastasis_eufin_lib.h | |||
@@ -22,10 +22,11 @@ | |||
22 | #ifndef ANASTASIS_EUFIN_LIB_H | 22 | #ifndef ANASTASIS_EUFIN_LIB_H |
23 | #define ANASTASIS_EUFIN_LIB_H | 23 | #define ANASTASIS_EUFIN_LIB_H |
24 | 24 | ||
25 | #define GNU_TALER_ERROR_CODES_H 1 | ||
26 | #include "anastasis_error_codes.h" | ||
25 | #include <jansson.h> | 27 | #include <jansson.h> |
26 | #include <gnunet/gnunet_curl_lib.h> | 28 | #include <gnunet/gnunet_curl_lib.h> |
27 | #include <taler/taler_util.h> | 29 | #include <taler/taler_util.h> |
28 | #include <taler/taler_error_codes.h> | ||
29 | 30 | ||
30 | 31 | ||
31 | /** | 32 | /** |
@@ -145,7 +146,6 @@ struct ANASTASIS_EUFIN_CreditDetails | |||
145 | * @param ec detailed error code | 146 | * @param ec detailed error code |
146 | * @param serial_id monotonically increasing counter corresponding to the transaction | 147 | * @param serial_id monotonically increasing counter corresponding to the transaction |
147 | * @param details details about the wire transfer | 148 | * @param details details about the wire transfer |
148 | * @param json detailed response from the HTTPD, or NULL if reply was not in JSON | ||
149 | * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration | 149 | * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration |
150 | */ | 150 | */ |
151 | typedef enum GNUNET_GenericReturnValue | 151 | typedef enum GNUNET_GenericReturnValue |
@@ -154,8 +154,7 @@ typedef enum GNUNET_GenericReturnValue | |||
154 | unsigned int http_status, | 154 | unsigned int http_status, |
155 | enum TALER_ErrorCode ec, | 155 | enum TALER_ErrorCode ec, |
156 | uint64_t serial_id, | 156 | uint64_t serial_id, |
157 | const struct ANASTASIS_EUFIN_CreditDetails *details, | 157 | const struct ANASTASIS_EUFIN_CreditDetails *details); |
158 | const json_t *json); | ||
159 | 158 | ||
160 | 159 | ||
161 | /** | 160 | /** |
diff --git a/src/include/anastasis_util_lib.h b/src/include/anastasis_util_lib.h index 3d380a3..e780d82 100644 --- a/src/include/anastasis_util_lib.h +++ b/src/include/anastasis_util_lib.h | |||
@@ -37,6 +37,13 @@ ANASTASIS_project_data_default (void); | |||
37 | 37 | ||
38 | 38 | ||
39 | /** | 39 | /** |
40 | * Initialize libanastasisutil. | ||
41 | */ | ||
42 | void | ||
43 | ANASTASIS_OS_init (void); | ||
44 | |||
45 | |||
46 | /** | ||
40 | * Handle for the child management | 47 | * Handle for the child management |
41 | */ | 48 | */ |
42 | struct ANASTASIS_ChildWaitHandle; | 49 | struct ANASTASIS_ChildWaitHandle; |
diff --git a/src/include/platform.h b/src/include/platform.h index 31aa7b9..7667460 100644 --- a/src/include/platform.h +++ b/src/include/platform.h | |||
@@ -39,6 +39,33 @@ | |||
39 | #define VERBOSE(cmd) do { break; } while (0) | 39 | #define VERBOSE(cmd) do { break; } while (0) |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | |||
43 | /* LSB-style exit status codes */ | ||
44 | #ifndef EXIT_INVALIDARGUMENT | ||
45 | #define EXIT_INVALIDARGUMENT 2 | ||
46 | #endif | ||
47 | |||
48 | #ifndef EXIT_NOTIMPLEMENTED | ||
49 | #define EXIT_NOTIMPLEMENTED 3 | ||
50 | #endif | ||
51 | |||
52 | #ifndef EXIT_NOPERMISSION | ||
53 | #define EXIT_NOPERMISSION 4 | ||
54 | #endif | ||
55 | |||
56 | #ifndef EXIT_NOTINSTALLED | ||
57 | #define EXIT_NOTINSTALLED 5 | ||
58 | #endif | ||
59 | |||
60 | #ifndef EXIT_NOTCONFIGURED | ||
61 | #define EXIT_NOTCONFIGURED 6 | ||
62 | #endif | ||
63 | |||
64 | #ifndef EXIT_NOTRUNNING | ||
65 | #define EXIT_NOTRUNNING 7 | ||
66 | #endif | ||
67 | |||
68 | |||
42 | /* Include the features available for GNU source */ | 69 | /* Include the features available for GNU source */ |
43 | #define _GNU_SOURCE | 70 | #define _GNU_SOURCE |
44 | 71 | ||