diff options
author | Özgür Kesim <oec-taler@kesim.org> | 2023-07-27 23:57:07 +0200 |
---|---|---|
committer | Özgür Kesim <oec-taler@kesim.org> | 2023-07-27 23:57:07 +0200 |
commit | 571d43cef3732ed6f491d91a9e767a80008edeb1 (patch) | |
tree | b330d46d7698a07c4cc9c8baf1d2ee7793a4f02a /src/include/taler_pq_lib.h | |
parent | 722e00b1e9869e0ff337d40b28f2ed71d8afcd76 (diff) | |
download | exchange-571d43cef3732ed6f491d91a9e767a80008edeb1.tar.xz |
[WiP] added TALER_AMOUNT type to Postgres - first in age_withdraw
- Added a type TALER_AMOUNT (val INT8, frac INT4) to Postgres.
- Added PLSQL functions/procedures
- amount_normalize(a)
- amount_add(a, b)
- amount_left_minus_right(l, r, diff, ok bool)
- Added PQ-helper functions
- TALER_PQ_query_param_amount_tuple()
- TALER_PQ_result_spec_amount_tuple()
- In table 'age_withdraw', changed fields 'amount_with_fee_val' and '..._frac'
into single field 'amount_with_fee' be of type TALER_AMOUNT
- Changed functions/stored procedures 'do_age_withdraw' and
'get_age_withdraw' to use new APIs.
=> make check runs through without errors,
age-withdraw and -reveal test passes.
Diffstat (limited to 'src/include/taler_pq_lib.h')
-rw-r--r-- | src/include/taler_pq_lib.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/include/taler_pq_lib.h b/src/include/taler_pq_lib.h index db77c53b0..43561703b 100644 --- a/src/include/taler_pq_lib.h +++ b/src/include/taler_pq_lib.h @@ -51,6 +51,19 @@ TALER_PQ_query_param_amount_nbo (const struct TALER_AmountNBO *x); struct GNUNET_PQ_QueryParam TALER_PQ_query_param_amount (const struct TALER_Amount *x); +/** + * Generate query parameter (as record tuple) for an amount, consisting + * of the two components "value" and "fraction" in this order. The + * types must be a 64-bit integer and a 32-bit integer + * respectively. The currency is dropped. + * + * @param db The database context for OID lookup + * @param amount pointer to the query parameter to pass + */ +struct GNUNET_PQ_QueryParam +TALER_PQ_query_param_amount_tuple ( + const struct GNUNET_PQ_Context *db, + const struct TALER_Amount *amount); /** * Generate query parameter for a denomination public @@ -180,6 +193,18 @@ TALER_PQ_result_spec_amount (const char *name, const char *currency, struct TALER_Amount *amount); +/** + * Currency amount expected, from a record-field of (DB) taler_amount type + * + * @param name name of the field in the table + * @param currency currency to use for @a amount + * @param[out] amount where to store the result + * @return array entry for the result specification to use + */ +struct GNUNET_PQ_ResultSpec +TALER_PQ_result_spec_amount_tuple (const char *name, + const char *currency, + struct TALER_Amount *amount); /** * Denomination public key expected. |