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/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 "taler/taler_error_codes.h"
23 : #include "taler/taler_pq_lib.h"
24 : #include "exchange-database/get_denomination_info.h"
25 : #include "helper.h"
26 :
27 :
28 : enum GNUNET_DB_QueryStatus
29 0 : TALER_EXCHANGEDB_get_denomination_info (
30 : struct TALER_EXCHANGEDB_PostgresContext *pg,
31 : const struct TALER_DenominationHashP *denom_pub_hash,
32 : uint64_t *denom_serial,
33 : struct TALER_EXCHANGEDB_DenominationKeyInformation *issue)
34 : {
35 : enum GNUNET_DB_QueryStatus qs;
36 : uint64_t serial;
37 0 : struct GNUNET_PQ_QueryParam params[] = {
38 0 : GNUNET_PQ_query_param_auto_from_type (denom_pub_hash),
39 : GNUNET_PQ_query_param_end
40 : };
41 0 : struct GNUNET_PQ_ResultSpec rs[] = {
42 0 : GNUNET_PQ_result_spec_uint64 ("denominations_serial",
43 : &serial),
44 0 : GNUNET_PQ_result_spec_auto_from_type ("master_sig",
45 : &issue->signature),
46 0 : GNUNET_PQ_result_spec_timestamp ("valid_from",
47 : &issue->start),
48 0 : GNUNET_PQ_result_spec_timestamp ("expire_withdraw",
49 : &issue->expire_withdraw),
50 0 : GNUNET_PQ_result_spec_timestamp ("expire_deposit",
51 : &issue->expire_deposit),
52 0 : GNUNET_PQ_result_spec_timestamp ("expire_legal",
53 : &issue->expire_legal),
54 0 : TALER_PQ_RESULT_SPEC_AMOUNT ("coin",
55 : &issue->value),
56 0 : TALER_PQ_RESULT_SPEC_AMOUNT ("fee_withdraw",
57 : &issue->fees.withdraw),
58 0 : TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit",
59 : &issue->fees.deposit),
60 0 : TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refresh",
61 : &issue->fees.refresh),
62 0 : TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refund",
63 : &issue->fees.refund),
64 0 : GNUNET_PQ_result_spec_uint32 ("age_mask",
65 : &issue->age_mask.bits),
66 : GNUNET_PQ_result_spec_end
67 : };
68 :
69 0 : PREPARE (pg,
70 : "denomination_get",
71 : "SELECT"
72 : " denominations_serial"
73 : ",master_sig"
74 : ",valid_from"
75 : ",expire_withdraw"
76 : ",expire_deposit"
77 : ",expire_legal"
78 : ",coin" /* value of this denom */
79 : ",fee_withdraw"
80 : ",fee_deposit"
81 : ",fee_refresh"
82 : ",fee_refund"
83 : ",age_mask"
84 : " FROM denominations"
85 : " WHERE denom_pub_hash=$1;");
86 0 : qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
87 : "denomination_get",
88 : params,
89 : rs);
90 0 : if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
91 0 : return qs;
92 0 : issue->denom_hash = *denom_pub_hash;
93 0 : if (NULL != denom_serial)
94 0 : *denom_serial = serial;
95 0 : return qs;
96 : }
|