diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-09-10 15:15:49 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-09-10 15:15:59 +0200 |
commit | 7015c4e14885fb02c126472a82893f1dc6657d62 (patch) | |
tree | 39171da5566e4d5842d8eff20035b03699192447 /src/lib | |
parent | 6866e1580e7298acb5affb5b768faf3900875f5c (diff) |
add TALER_amount_min
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/exchange_api_restrictions.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/src/lib/exchange_api_restrictions.c b/src/lib/exchange_api_restrictions.c index dcd6c6f2c..2b502ff7c 100644 --- a/src/lib/exchange_api_restrictions.c +++ b/src/lib/exchange_api_restrictions.c @@ -17,7 +17,7 @@ /** * @file lib/exchange_api_restrictions.c * @brief convenience functions related to account restrictions - * @author Christian Grothoff +a * @author Christian Grothoff */ #include "platform.h" #include "taler_exchange_service.h" @@ -96,3 +96,46 @@ TALER_EXCHANGE_test_account_allowed ( } /* end loop over restrictions */ return GNUNET_YES; } + + +void +TALER_EXCHANGE_keys_evaluate_hard_limits ( + const struct TALER_EXCHANGE_Keys *keys, + enum TALER_KYCLOGIC_KycTriggerEvent event, + struct TALER_Amount *limit) +{ + for (unsigned int i = 0; i<keys->hard_limits_length; i++) + { + const struct TALER_EXCHANGE_AccountLimit *al + = &keys->hard_limits[i]; + + if (event != al->operation_type) + continue; + if (al->soft_limit) + continue; + if (! TALER_amount_cmp_currency (limit, + &al->limit)) + continue; + GNUNET_break (GNUNET_OK == + TALER_amount_min (limit, + limit, + &al->limit)); + } +} + + +bool +TALER_EXCHANGE_keys_evaluate_zero_limits ( + const struct TALER_EXCHANGE_Keys *keys, + enum TALER_KYCLOGIC_KycTriggerEvent event) +{ + for (unsigned int i = 0; i<keys->soft_limits_length; i++) + { + const struct TALER_EXCHANGE_ZeroLimitedOperation *zlo + = &keys->zero_limits[i]; + + if (event == zlo->operation_type) + return true; + } + return false; +} |