diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-10-07 15:59:00 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-10-07 15:59:00 +0200 |
commit | 9e4fffeb2fdb0a6ec84b29ff386353f10441ff13 (patch) | |
tree | 5a33030fb4afb5cfe814907c27ecfa5dff8d29ff | |
parent | bce6e642b11674967229287aa3b9abe4df0e5ad9 (diff) |
respect zero-limits
-rw-r--r-- | src/backend/taler-merchant-httpd_exchanges.c | 30 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-post-orders.c | 24 |
2 files changed, 47 insertions, 7 deletions
diff --git a/src/backend/taler-merchant-httpd_exchanges.c b/src/backend/taler-merchant-httpd_exchanges.c index f5cefc48..f18b7c84 100644 --- a/src/backend/taler-merchant-httpd_exchanges.c +++ b/src/backend/taler-merchant-httpd_exchanges.c @@ -35,7 +35,7 @@ * Threshold after which exponential backoff should not increase. */ #define RETRY_BACKOFF_THRESHOLD GNUNET_TIME_relative_multiply ( \ - GNUNET_TIME_UNIT_SECONDS, 60) + GNUNET_TIME_UNIT_SECONDS, 60) /** * This is how long /keys long-polls for, so we should @@ -43,7 +43,7 @@ * answer. See exchange_api_handle.c. */ #define LONG_POLL_THRESHOLD GNUNET_TIME_relative_multiply ( \ - GNUNET_TIME_UNIT_SECONDS, 120) + GNUNET_TIME_UNIT_SECONDS, 120) /** @@ -720,6 +720,12 @@ TMH_exchange_check_debit ( &kyc_ok, &jlimits); GNUNET_break (qs >= 0); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "get_kyc_limits for %s at %s returned %s/%s\n", + wm->payto_uri, + exchange->url, + kyc_ok ? "KYC OK" : "KYC missing", + NULL == jlimits ? "default limits" : "custom limits"); if ( (qs > 0) && (NULL != jlimits) ) { @@ -756,6 +762,10 @@ TMH_exchange_check_debit ( if ( (TALER_KYCLOGIC_KYC_TRIGGER_DEPOSIT != ot) && (TALER_KYCLOGIC_KYC_TRIGGER_TRANSACTION != ot) ) continue; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "KYC rule %u with limit %s applies\n", + (unsigned int) idx, + TALER_amount2s (&threshold)); if (unlimited) { unlimited = false; @@ -794,6 +804,9 @@ TMH_exchange_check_debit ( } else { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Evaluating default limits of %s\n", + exchange->url); TALER_EXCHANGE_keys_evaluate_hard_limits ( keys, TALER_KYCLOGIC_KYC_TRIGGER_DEPOSIT, @@ -802,6 +815,19 @@ TMH_exchange_check_debit ( keys, TALER_KYCLOGIC_KYC_TRIGGER_TRANSACTION, max_amount); + if (TALER_EXCHANGE_keys_evaluate_zero_limits ( + keys, + TALER_KYCLOGIC_KYC_TRIGGER_DEPOSIT) || + TALER_EXCHANGE_keys_evaluate_zero_limits ( + keys, + TALER_KYCLOGIC_KYC_TRIGGER_TRANSACTION)) + { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Operation is zero-limited by default\n"); + GNUNET_assert (GNUNET_OK == + TALER_amount_set_zero (max_amount->currency, + max_amount)); + } } return account_ok ? GNUNET_YES : GNUNET_NO; } diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c index fadfcb30..ee2b3d85 100644 --- a/src/backend/taler-merchant-httpd_private-post-orders.c +++ b/src/backend/taler-merchant-httpd_private-post-orders.c @@ -1982,11 +1982,19 @@ get_acceptable (void *cls, priority = 768; /* stale, no accounts yet */ break; } - GNUNET_break (0 <= - TALER_amount_add ( - &oc->set_exchanges.total_exchange_limit, - &oc->set_exchanges.total_exchange_limit, - &max_amount)); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Exchange %s deposit limit is %s, adding it!\n", + url, + TALER_amount2s (&max_amount)); + GNUNET_assert (0 <= + TALER_amount_add ( + &oc->set_exchanges.total_exchange_limit, + &oc->set_exchanges.total_exchange_limit, + &max_amount)); + GNUNET_assert (GNUNET_OK == + TALER_amount_min (&oc->set_exchanges.total_exchange_limit, + &oc->set_exchanges.total_exchange_limit, + &oc->parse_order.brutto)); j_exchange = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("url", url), @@ -2267,6 +2275,12 @@ set_exchanges (struct OrderContext *oc) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Creating order, but possibly without usable trusted exchanges\n"); } + else + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Can create order: %s is the sum of hard limits from supported exchanges\n", + TALER_amount2s (&oc->set_exchanges.total_exchange_limit)); + } oc->phase++; return false; } |