diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-08-23 12:50:34 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-08-23 12:51:07 +0200 |
commit | e7e10a2931cc19969b2c060a0996506e5b7ce43e (patch) | |
tree | 377da45437911a06a8014aead814f2719b06bcd6 /src/authorization/anastasis_authorization_plugin_iban.c | |
parent | c533c5441456cb81e64be24f52eb1ee35ee3243e (diff) | |
download | anastasis-e7e10a2931cc19969b2c060a0996506e5b7ce43e.tar.gz anastasis-e7e10a2931cc19969b2c060a0996506e5b7ce43e.tar.bz2 anastasis-e7e10a2931cc19969b2c060a0996506e5b7ce43e.zip |
-misc bugfixes for IBAN plugin
Diffstat (limited to 'src/authorization/anastasis_authorization_plugin_iban.c')
-rw-r--r-- | src/authorization/anastasis_authorization_plugin_iban.c | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/src/authorization/anastasis_authorization_plugin_iban.c b/src/authorization/anastasis_authorization_plugin_iban.c index f8a4868..3c72e16 100644 --- a/src/authorization/anastasis_authorization_plugin_iban.c +++ b/src/authorization/anastasis_authorization_plugin_iban.c @@ -198,9 +198,13 @@ iban_validate (void *cls, iban_number = GNUNET_strndup (data, data_length); emsg = TALER_iban_validate (iban_number); - GNUNET_free (iban_number); if (NULL != emsg) { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Invalid IBAN `%s' provided: %s\n", + iban_number, + emsg); + GNUNET_free (iban_number); if (MHD_NO == TALER_MHD_reply_with_error (connection, MHD_HTTP_EXPECTATION_FAILED, @@ -213,6 +217,7 @@ iban_validate (void *cls, GNUNET_free (emsg); return GNUNET_NO; } + GNUNET_free (iban_number); return GNUNET_OK; } @@ -447,6 +452,7 @@ test_wire_transfers (struct ANASTASIS_AUTHORIZATION_State *as) now = GNUNET_TIME_absolute_get (); limit = GNUNET_TIME_absolute_subtract (now, CODE_VALIDITY_PERIOD); + (void) GNUNET_TIME_round_abs (&limit); GNUNET_asprintf (&debit_account_uri, "payto://iban/%s", as->iban_number); @@ -497,9 +503,12 @@ iban_process (struct ANASTASIS_AUTHORIZATION_State *as, struct MHD_Connection *connection) { struct IBAN_Context *ctx = as->ctx; + struct ANASTASIS_DatabasePlugin *db = ctx->ac->db; MHD_RESULT mres; enum GNUNET_DB_QueryStatus qs; struct MHD_Response *resp; + struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); + struct GNUNET_TIME_Absolute after; if (NULL == as->eh) { @@ -512,16 +521,20 @@ iban_process (struct ANASTASIS_AUTHORIZATION_State *as, GNUNET_CRYPTO_hash (as->iban_number, strlen (as->iban_number), &espec.debit_iban_hash); - as->eh = ctx->ac->db->event_listen (ctx->ac->db->cls, - &espec.header, - GNUNET_TIME_absolute_get_remaining ( - timeout), - &bank_event_cb, - as); + as->eh = db->event_listen (db->cls, + &espec.header, + GNUNET_TIME_absolute_get_remaining ( + timeout), + &bank_event_cb, + as); } - qs = ctx->ac->db->test_challenge_code_satisfied (ctx->ac->db->cls, - &as->truth_uuid, - as->code); + after = GNUNET_TIME_absolute_subtract (now, + CODE_VALIDITY_PERIOD); + (void) GNUNET_TIME_round_abs (&after); + qs = db->test_challenge_code_satisfied (db->cls, + &as->truth_uuid, + as->code, + after); switch (qs) { case GNUNET_DB_STATUS_HARD_ERROR: @@ -612,6 +625,18 @@ libanastasis_plugin_authorization_iban_init (void *cls) return NULL; } if (GNUNET_OK != + TALER_config_get_amount (cfg, + "authorization-iban", + "COST", + &ctx->expected_amount)) + { + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "authorization-iban", + "COST"); + GNUNET_free (ctx); + return NULL; + } + if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "authorization-iban", "BUSINESS_NAME", @@ -655,7 +680,7 @@ libanastasis_plugin_authorization_iban_init (void *cls) plugin->payment_plugin_managed = true; plugin->code_validity_period = CODE_VALIDITY_PERIOD; plugin->code_rotation_period = GNUNET_TIME_UNIT_WEEKS; - plugin->code_retransmission_frequency = GNUNET_TIME_UNIT_FOREVER_REL; /* not applicable */ + plugin->code_retransmission_frequency = GNUNET_TIME_UNIT_ZERO; /* not applicable */ plugin->cls = ctx; plugin->validate = &iban_validate; plugin->start = &iban_start; |