exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit bf2ce9853e640384106f4dd7c242ea1e5e440871
parent 896bb8f074d6b6e091ee79de93b8bec118caa3ca
Author: Christian Grothoff <christian@grothoff.org>
Date:   Wed,  1 Sep 2021 11:11:41 +0200

add long-time overdue convenience function

Diffstat:
Msrc/include/taler_amount_lib.h | 11+++++++++++
Msrc/util/amount.c | 12++++++++++++
2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/src/include/taler_amount_lib.h b/src/include/taler_amount_lib.h @@ -161,6 +161,17 @@ TALER_amount_set_zero (const char *cur, /** + * Test if the given @a amount is zero. + * + * @param amount amount to compare to zero + * @return true if the amount is zero, + * false if it is non-zero or invalid + */ +bool +TALER_amount_is_zero (const struct TALER_Amount *amount); + + +/** * Test if the given amount is valid. * * @param amount amount to check diff --git a/src/util/amount.c b/src/util/amount.c @@ -241,6 +241,18 @@ TALER_amount_is_valid (const struct TALER_Amount *amount) } +bool +TALER_amount_is_zero (const struct TALER_Amount *amount) +{ + if (GNUNET_OK != + TALER_amount_is_valid (amount)) + return false; + return + (0 == amount->value) && + (0 == amount->fraction); +} + + /** * Test if @a a is valid, NBO variant. *