Line data Source code
1 : /*
2 : This file is part of TALER
3 : Copyright (C) 2024 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/kycauth_in_insert.c
18 : * @brief Implementation of the kycauth_in_insert function for Postgres
19 : * @author Christian Grothoff
20 : */
21 : #include "taler/taler_pq_lib.h"
22 : #include "exchange-database/kycauth_in_insert.h"
23 : #include "helper.h"
24 :
25 :
26 : enum GNUNET_DB_QueryStatus
27 16 : TALER_EXCHANGEDB_kycauth_in_insert (
28 : struct TALER_EXCHANGEDB_PostgresContext *pg,
29 : const union TALER_AccountPublicKeyP *account_pub,
30 : const struct TALER_Amount *credit_amount,
31 : struct GNUNET_TIME_Timestamp execution_date,
32 : const struct TALER_FullPayto debit_account_uri,
33 : const char *section_name,
34 : uint64_t serial_id)
35 : {
36 : struct TALER_NormalizedPaytoHashP h_normalized_payto;
37 : struct TALER_FullPaytoHashP h_full_payto;
38 :
39 16 : TALER_full_payto_hash (debit_account_uri,
40 : &h_full_payto);
41 16 : TALER_full_payto_normalize_and_hash (debit_account_uri,
42 : &h_normalized_payto);
43 : {
44 16 : struct TALER_EXCHANGEDB_KycCompletedEventP rep = {
45 16 : .header.size = htons (sizeof (rep)),
46 16 : .header.type = htons (TALER_DBEVENT_EXCHANGE_KYC_COMPLETED),
47 : .h_payto = h_normalized_payto
48 : };
49 : char *notify_s
50 16 : = GNUNET_PQ_get_event_notify_channel (&rep.header);
51 16 : struct GNUNET_PQ_QueryParam params[] = {
52 16 : GNUNET_PQ_query_param_auto_from_type (account_pub),
53 16 : GNUNET_PQ_query_param_uint64 (&serial_id),
54 16 : TALER_PQ_query_param_amount (pg->conn,
55 : credit_amount),
56 16 : GNUNET_PQ_query_param_auto_from_type (&h_full_payto),
57 16 : GNUNET_PQ_query_param_auto_from_type (&h_normalized_payto),
58 16 : GNUNET_PQ_query_param_string (debit_account_uri.full_payto),
59 16 : GNUNET_PQ_query_param_string (section_name),
60 16 : GNUNET_PQ_query_param_timestamp (&execution_date),
61 16 : GNUNET_PQ_query_param_string (notify_s),
62 : GNUNET_PQ_query_param_end
63 : };
64 : enum GNUNET_DB_QueryStatus qs;
65 :
66 16 : PREPARE (pg,
67 : "kycauth_in_insert",
68 : "CALL"
69 : " exchange_do_kycauth_in_insert"
70 : " ($1,$2,$3,$4,$5,$6,$7,$8,$9);");
71 16 : qs = GNUNET_PQ_eval_prepared_non_select (
72 : pg->conn,
73 : "kycauth_in_insert",
74 : params);
75 16 : GNUNET_free (notify_s);
76 16 : return qs;
77 : }
78 : }
|