Line data Source code
1 : /*
2 : This file is part of TALER
3 : Copyright (C) 2022,2025 Taler Systems SA
4 :
5 : TALER is free software; you can redistribute it and/or modify it under the
6 : terms of the GNU General Public License as published by the Free Software
7 : Foundation; either version 3, or (at your option) any later version.
8 :
9 : TALER is distributed in the hope that it will be useful, but WITHOUT ANY
10 : WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 : A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 :
13 : You should have received a copy of the GNU General Public License along with
14 : TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
15 : */
16 : /**
17 : * @file exchangedb/pg_get_denomination_info.c
18 : * @brief Implementation of the get_denomination_info function for Postgres
19 : * @author Christian Grothoff
20 : * @author Özgür Kesim
21 : */
22 : #include "platform.h"
23 : #include "taler_error_codes.h"
24 : #include "taler_dbevents.h"
25 : #include "taler_pq_lib.h"
26 : #include "pg_get_denomination_info.h"
27 : #include "pg_helper.h"
28 :
29 :
30 : enum GNUNET_DB_QueryStatus
31 0 : TEH_PG_get_denomination_info (
32 : void *cls,
33 : const struct TALER_DenominationHashP *denom_pub_hash,
34 : uint64_t *denom_serial,
35 : struct TALER_EXCHANGEDB_DenominationKeyInformation *issue)
36 : {
37 0 : struct PostgresClosure *pg = cls;
38 : enum GNUNET_DB_QueryStatus qs;
39 : uint64_t serial;
40 0 : struct GNUNET_PQ_QueryParam params[] = {
41 0 : GNUNET_PQ_query_param_auto_from_type (denom_pub_hash),
42 : GNUNET_PQ_query_param_end
43 : };
44 0 : struct GNUNET_PQ_ResultSpec rs[] = {
45 0 : GNUNET_PQ_result_spec_uint64 ("denominations_serial",
46 : &serial),
47 0 : GNUNET_PQ_result_spec_auto_from_type ("master_sig",
48 : &issue->signature),
49 0 : GNUNET_PQ_result_spec_timestamp ("valid_from",
50 : &issue->start),
51 0 : GNUNET_PQ_result_spec_timestamp ("expire_withdraw",
52 : &issue->expire_withdraw),
53 0 : GNUNET_PQ_result_spec_timestamp ("expire_deposit",
54 : &issue->expire_deposit),
55 0 : GNUNET_PQ_result_spec_timestamp ("expire_legal",
56 : &issue->expire_legal),
57 0 : TALER_PQ_RESULT_SPEC_AMOUNT ("coin",
58 : &issue->value),
59 0 : TALER_PQ_RESULT_SPEC_AMOUNT ("fee_withdraw",
60 : &issue->fees.withdraw),
61 0 : TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit",
62 : &issue->fees.deposit),
63 0 : TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refresh",
64 : &issue->fees.refresh),
65 0 : TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refund",
66 : &issue->fees.refund),
67 0 : GNUNET_PQ_result_spec_uint32 ("age_mask",
68 : &issue->age_mask.bits),
69 : GNUNET_PQ_result_spec_end
70 : };
71 :
72 0 : PREPARE (pg,
73 : "denomination_get",
74 : "SELECT"
75 : " denominations_serial"
76 : ",master_sig"
77 : ",valid_from"
78 : ",expire_withdraw"
79 : ",expire_deposit"
80 : ",expire_legal"
81 : ",coin" /* value of this denom */
82 : ",fee_withdraw"
83 : ",fee_deposit"
84 : ",fee_refresh"
85 : ",fee_refund"
86 : ",age_mask"
87 : " FROM denominations"
88 : " WHERE denom_pub_hash=$1;");
89 0 : qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
90 : "denomination_get",
91 : params,
92 : rs);
93 0 : if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
94 0 : return qs;
95 0 : issue->denom_hash = *denom_pub_hash;
96 0 : if (NULL != denom_serial)
97 0 : *denom_serial = serial;
98 0 : return qs;
99 : }
|