diff options
Diffstat (limited to 'src/backend/taler-merchant-httpd_helper.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_helper.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/src/backend/taler-merchant-httpd_helper.c b/src/backend/taler-merchant-httpd_helper.c index 595b82cf..a5de1781 100644 --- a/src/backend/taler-merchant-httpd_helper.c +++ b/src/backend/taler-merchant-httpd_helper.c @@ -88,7 +88,6 @@ TMH_payto_uri_array_valid (const json_t *payto_uris) return payto_ok; } - bool TMH_location_object_valid (const json_t *location) { @@ -316,6 +315,49 @@ TMH_image_data_url_valid (const char *image_data_url) return true; } +bool +TMH_template_contract_valid (const json_t *template_contract) +{ + const char *summary; + struct TALER_Amount amount = { .value = 0}; + uint32_t minimum_age = 0; + struct GNUNET_TIME_Relative pay_duration= { 0 }; + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_string ("summary", + &summary), + NULL), + GNUNET_JSON_spec_mark_optional ( + TALER_JSON_spec_amount ("amount", + TMH_currency, + &amount), + NULL), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_uint32 ("minimum_age", + &minimum_age), + NULL), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_relative_time ("pay_duration", + &pay_duration), + NULL), + GNUNET_JSON_spec_end () + }; + const char *ename; + unsigned int eline; + + if (GNUNET_OK != + GNUNET_JSON_parse (template_contract, + spec, + &ename, + &eline)) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Invalid template_contract for field %s\n", + ename); + return false; + } + return true; +} bool TMH_taxes_array_valid (const json_t *taxes) |