Line data Source code
1 : /*
2 : This file is part of TALER
3 : Copyright (C) 2022, 2023 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 insert_deposit_confirmation.c
18 : * @brief Low-level (statement-level) Postgres database access for the exchange
19 : * @author Christian Grothoff
20 : */
21 : #include "taler/taler_pq_lib.h"
22 : #include "auditor-database/insert_deposit_confirmation.h"
23 : #include "pg_helper.h"
24 :
25 :
26 : enum GNUNET_DB_QueryStatus
27 2 : TALER_AUDITORDB_insert_deposit_confirmation (struct
28 : TALER_AUDITORDB_PostgresContext *pg
29 : ,
30 : const struct
31 : TALER_AUDITORDB_DepositConfirmation
32 : *dc)
33 : {
34 2 : struct GNUNET_PQ_QueryParam params[] = {
35 2 : GNUNET_PQ_query_param_auto_from_type (&dc->h_contract_terms),
36 2 : GNUNET_PQ_query_param_auto_from_type (&dc->h_policy),
37 2 : GNUNET_PQ_query_param_auto_from_type (&dc->h_wire),
38 2 : GNUNET_PQ_query_param_timestamp (&dc->exchange_timestamp),
39 2 : GNUNET_PQ_query_param_timestamp (&dc->wire_deadline),
40 2 : GNUNET_PQ_query_param_timestamp (&dc->refund_deadline),
41 2 : TALER_PQ_query_param_amount (pg->conn,
42 : &dc->total_without_fee),
43 2 : GNUNET_PQ_query_param_array_auto_from_type (dc->num_coins,
44 : dc->coin_pubs,
45 : pg->conn),
46 2 : GNUNET_PQ_query_param_array_auto_from_type (dc->num_coins,
47 : dc->coin_sigs,
48 : pg->conn),
49 2 : GNUNET_PQ_query_param_auto_from_type (&dc->merchant),
50 2 : GNUNET_PQ_query_param_auto_from_type (&dc->exchange_sig),
51 2 : GNUNET_PQ_query_param_auto_from_type (&dc->exchange_pub),
52 2 : GNUNET_PQ_query_param_auto_from_type (&dc->master_sig),
53 : GNUNET_PQ_query_param_end
54 : };
55 : enum GNUNET_DB_QueryStatus qs;
56 :
57 2 : PREPARE (pg,
58 : "auditor_deposit_confirmation_insert",
59 : "INSERT INTO auditor_deposit_confirmations "
60 : "(h_contract_terms"
61 : ",h_policy"
62 : ",h_wire"
63 : ",exchange_timestamp"
64 : ",wire_deadline"
65 : ",refund_deadline"
66 : ",total_without_fee"
67 : ",coin_pubs"
68 : ",coin_sigs"
69 : ",merchant_pub"
70 : ",exchange_sig"
71 : ",exchange_pub"
72 : ",master_sig" /* master_sig could be normalized... */
73 : ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13);");
74 2 : qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
75 : "auditor_deposit_confirmation_insert",
76 : params);
77 2 : GNUNET_PQ_cleanup_query_params_closures (params);
78 2 : return qs;
79 : }
|