add long-time overdue convenience function

This commit is contained in:
Christian Grothoff 2021-09-01 11:11:41 +02:00
parent 896bb8f074
commit bf2ce9853e
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
2 changed files with 23 additions and 0 deletions

View File

@ -160,6 +160,17 @@ TALER_amount_set_zero (const char *cur,
struct TALER_Amount *amount);
/**
* 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.
*

View File

@ -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.
*