merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit c73967523e2a17682e03ade6e96cabe5dd7ff4b3
parent 79d38786dfd484f8043b33cdaca6588c8b5ce2ab
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 28 Jun 2026 23:04:46 +0200

bugs

Diffstat:
Msrc/include/taler/merchant/get-private-statistics-amount-SLUG.h | 4++--
Msrc/lib/merchant_api_get-private-statistics-amount-SLUG.c | 52++++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/src/include/taler/merchant/get-private-statistics-amount-SLUG.h b/src/include/taler/merchant/get-private-statistics-amount-SLUG.h @@ -192,7 +192,7 @@ struct TALER_MERCHANT_GetPrivateStatisticsAmountByBucket * Sum of all amounts falling under the given * SLUG within this timeframe. */ - struct TALER_Amount *cumulative_amounts; + const struct TALER_Amount *cumulative_amounts; /** * Length of array @a cumulative_amounts. @@ -219,7 +219,7 @@ struct TALER_MERCHANT_GetPrivateStatisticsAmountByInterval * Sum of all amounts falling under the given * SLUG within this timeframe. */ - struct TALER_Amount *cumulative_amounts; + const struct TALER_Amount *cumulative_amounts; /** * Length of array @a cumulative_amounts. diff --git a/src/lib/merchant_api_get-private-statistics-amount-SLUG.c b/src/lib/merchant_api_get-private-statistics-amount-SLUG.c @@ -110,6 +110,8 @@ parse_intervals_and_buckets_amt ( { unsigned int resp_buckets_len = json_array_size (jbuckets); unsigned int resp_intervals_len = json_array_size (jintervals); + size_t total_amounts = 0; + size_t amounts_pos = 0; if ( (json_array_size (jbuckets) != (size_t) resp_buckets_len) || (json_array_size (jintervals) != (size_t) resp_intervals_len) || @@ -120,6 +122,49 @@ parse_intervals_and_buckets_amt ( return GNUNET_SYSERR; } { + size_t index; + json_t *value; + + json_array_foreach (jintervals, index, value) { + const json_t *amounts_arr; + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_array_const ("cumulative_amounts", + &amounts_arr), + GNUNET_JSON_spec_end () + }; + + if (GNUNET_OK != + GNUNET_JSON_parse (value, + spec, + NULL, NULL)) + { + GNUNET_break_op (0); + return GNUNET_SYSERR; + } + total_amounts += json_array_size (amounts_arr); + } + + json_array_foreach (jbuckets, index, value) { + const json_t *amounts_arr; + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_array_const ("cumulative_amounts", + &amounts_arr), + GNUNET_JSON_spec_end () + }; + + if (GNUNET_OK != + GNUNET_JSON_parse (value, + spec, + NULL, NULL)) + { + GNUNET_break_op (0); + return GNUNET_SYSERR; + } + total_amounts += json_array_size (amounts_arr); + } + } + { + struct TALER_Amount glob_amt_arr[GNUNET_NZL (total_amounts)]; struct TALER_MERCHANT_GetPrivateStatisticsAmountByBucket resp_buckets[ GNUNET_NZL (resp_buckets_len)]; struct TALER_MERCHANT_GetPrivateStatisticsAmountByInterval resp_intervals[ @@ -152,10 +197,11 @@ parse_intervals_and_buckets_amt ( } amounts_len = json_array_size (amounts_arr); { - struct TALER_Amount amt_arr[GNUNET_NZL (amounts_len)]; + struct TALER_Amount *amt_arr = &glob_amt_arr[amounts_pos]; size_t aindex; json_t *avalue; + amounts_pos += amounts_len; jinterval->cumulative_amount_len = amounts_len; jinterval->cumulative_amounts = amt_arr; json_array_foreach (amounts_arr, aindex, avalue) { @@ -202,10 +248,11 @@ parse_intervals_and_buckets_amt ( } amounts_len = json_array_size (amounts_arr); { - struct TALER_Amount amt_arr[GNUNET_NZL (amounts_len)]; + struct TALER_Amount *amt_arr = &glob_amt_arr[amounts_pos]; size_t aindex; json_t *avalue; + amounts_pos += amounts_len; jbucket->cumulative_amount_len = amounts_len; jbucket->cumulative_amounts = amt_arr; json_array_foreach (amounts_arr, aindex, avalue) { @@ -236,6 +283,7 @@ parse_intervals_and_buckets_amt ( .details.ok.intervals = resp_intervals, .details.ok.intervals_description = intervals_description, }; + sah->cb (sah->cb_cls, &sagr); sah->cb = NULL;