Line data Source code
1 : /*
2 : This file is part of GNUnet
3 : Copyright (C) 2020-2025 Taler Systems SA
4 :
5 : GNUnet is free software: you can redistribute it and/or modify it
6 : under the terms of the GNU Affero General Public License as published
7 : by the Free Software Foundation, either version 3 of the License,
8 : or (at your option) any later version.
9 :
10 : GNUnet is distributed in the hope that it will be useful, but
11 : WITHOUT ANY WARRANTY; without even the implied warranty of
12 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 : Affero General Public License for more details.
14 :
15 : You should have received a copy of the GNU Affero General Public License
16 : along with this program. If not, see <http://www.gnu.org/licenses/>.
17 :
18 : SPDX-License-Identifier: AGPL3.0-or-later
19 : */
20 : /**
21 : * @file exchangedb/insert_records_by_table.c
22 : * @brief replicate_records_by_table implementation
23 : * @author Christian Grothoff
24 : * @author Özgür Kesim
25 : */
26 : #include "taler/taler_error_codes.h"
27 : #include "taler/taler_dbevents.h"
28 : #include "taler/taler_pq_lib.h"
29 : #include "exchange-database/insert_records_by_table.h"
30 : #include "helper.h"
31 : #include <gnunet/gnunet_pq_lib.h>
32 :
33 :
34 : /**
35 : * Signature of helper functions of #TALER_EXCHANGEDB_insert_records_by_table().
36 : *
37 : * @param pg plugin context
38 : * @param td record to insert
39 : * @return transaction status code
40 : */
41 : typedef enum GNUNET_DB_QueryStatus
42 : (*InsertRecordCallback)(struct TALER_EXCHANGEDB_PostgresContext *pg,
43 : const struct TALER_EXCHANGEDB_TableData *td);
44 :
45 :
46 : /**
47 : * Function called with denominations records to insert into table.
48 : *
49 : * @param pg plugin context
50 : * @param td record to insert
51 : */
52 : static enum GNUNET_DB_QueryStatus
53 0 : irbt_cb_table_denominations (struct TALER_EXCHANGEDB_PostgresContext *pg,
54 : const struct TALER_EXCHANGEDB_TableData *td)
55 : {
56 : struct TALER_DenominationHashP denom_hash;
57 0 : struct GNUNET_PQ_QueryParam params[] = {
58 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
59 0 : GNUNET_PQ_query_param_auto_from_type (&denom_hash),
60 0 : GNUNET_PQ_query_param_uint32 (
61 : &td->details.denominations.denom_type),
62 0 : GNUNET_PQ_query_param_uint32 (
63 : &td->details.denominations.age_mask),
64 0 : TALER_PQ_query_param_denom_pub (
65 : &td->details.denominations.denom_pub),
66 0 : GNUNET_PQ_query_param_auto_from_type (
67 : &td->details.denominations.master_sig),
68 0 : GNUNET_PQ_query_param_timestamp (
69 : &td->details.denominations.valid_from),
70 0 : GNUNET_PQ_query_param_timestamp (
71 : &td->details.denominations.expire_withdraw),
72 0 : GNUNET_PQ_query_param_timestamp (
73 : &td->details.denominations.expire_deposit),
74 0 : GNUNET_PQ_query_param_timestamp (
75 : &td->details.denominations.expire_legal),
76 0 : TALER_PQ_query_param_amount (
77 0 : pg->conn,
78 : &td->details.denominations.coin),
79 0 : TALER_PQ_query_param_amount (
80 0 : pg->conn,
81 : &td->details.denominations.fees.withdraw),
82 0 : TALER_PQ_query_param_amount (
83 0 : pg->conn,
84 : &td->details.denominations.fees.deposit),
85 0 : TALER_PQ_query_param_amount (
86 0 : pg->conn,
87 : &td->details.denominations.fees.refresh),
88 0 : TALER_PQ_query_param_amount (
89 0 : pg->conn,
90 : &td->details.denominations.fees.refund),
91 : GNUNET_PQ_query_param_end
92 : };
93 :
94 0 : PREPARE (pg,
95 : "insert_records_by_table_into_table_denominations",
96 : "INSERT INTO denominations"
97 : "(denominations_serial"
98 : ",denom_pub_hash"
99 : ",denom_type"
100 : ",age_mask"
101 : ",denom_pub"
102 : ",master_sig"
103 : ",valid_from"
104 : ",expire_withdraw"
105 : ",expire_deposit"
106 : ",expire_legal"
107 : ",coin"
108 : ",fee_withdraw"
109 : ",fee_deposit"
110 : ",fee_refresh"
111 : ",fee_refund"
112 : ") VALUES "
113 : "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10,"
114 : " $11, $12, $13, $14, $15);");
115 :
116 0 : TALER_denom_pub_hash (
117 : &td->details.denominations.denom_pub,
118 : &denom_hash);
119 :
120 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
121 : "insert_records_by_table_into_table_denominations",
122 : params);
123 : }
124 :
125 :
126 : /**
127 : * Function called with denomination_revocations records to insert into table.
128 : *
129 : * @param pg plugin context
130 : * @param td record to insert
131 : */
132 : static enum GNUNET_DB_QueryStatus
133 0 : irbt_cb_table_denomination_revocations (
134 : struct TALER_EXCHANGEDB_PostgresContext *pg,
135 : const struct TALER_EXCHANGEDB_TableData *td)
136 : {
137 0 : struct GNUNET_PQ_QueryParam params[] = {
138 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
139 0 : GNUNET_PQ_query_param_auto_from_type (
140 : &td->details.denomination_revocations.master_sig),
141 0 : GNUNET_PQ_query_param_uint64 (
142 : &td->details.denomination_revocations.denominations_serial),
143 : GNUNET_PQ_query_param_end
144 : };
145 :
146 0 : PREPARE (pg,
147 : "insert_records_by_table_into_table_denomination_revocations",
148 : "INSERT INTO denomination_revocations"
149 : "(denom_revocations_serial_id"
150 : ",master_sig"
151 : ",denominations_serial"
152 : ") VALUES "
153 : "($1, $2, $3);");
154 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
155 : "insert_records_by_table_into_table_denomination_revocations",
156 : params);
157 : }
158 :
159 :
160 : /**
161 : * Function called with wire target records to insert into table.
162 : *
163 : * @param pg plugin context
164 : * @param td record to insert
165 : */
166 : static enum GNUNET_DB_QueryStatus
167 1 : irbt_cb_table_wire_targets (struct TALER_EXCHANGEDB_PostgresContext *pg,
168 : const struct TALER_EXCHANGEDB_TableData *td)
169 : {
170 : struct TALER_NormalizedPaytoHashP normalized_payto_hash;
171 : struct TALER_FullPaytoHashP full_payto_hash;
172 1 : struct GNUNET_PQ_QueryParam params[] = {
173 1 : GNUNET_PQ_query_param_uint64 (&td->serial),
174 1 : GNUNET_PQ_query_param_auto_from_type (&full_payto_hash),
175 1 : GNUNET_PQ_query_param_auto_from_type (&normalized_payto_hash),
176 1 : GNUNET_PQ_query_param_string (
177 1 : td->details.wire_targets.full_payto_uri.full_payto),
178 : GNUNET_PQ_query_param_end
179 : };
180 :
181 1 : TALER_full_payto_hash (
182 : td->details.wire_targets.full_payto_uri,
183 : &full_payto_hash);
184 1 : TALER_full_payto_normalize_and_hash (
185 : td->details.wire_targets.full_payto_uri,
186 : &normalized_payto_hash);
187 1 : PREPARE (pg,
188 : "insert_records_by_table_into_table_wire_targets",
189 : "INSERT INTO wire_targets"
190 : "(wire_target_serial_id"
191 : ",wire_target_h_payto"
192 : ",h_normalized_payto"
193 : ",payto_uri"
194 : ") VALUES "
195 : "($1, $2, $3, $4);");
196 1 : return GNUNET_PQ_eval_prepared_non_select (
197 : pg->conn,
198 : "insert_records_by_table_into_table_wire_targets",
199 : params);
200 : }
201 :
202 :
203 : /**
204 : * Function called with kyc target records to insert into table.
205 : *
206 : * @param pg plugin context
207 : * @param td record to insert
208 : */
209 : static enum GNUNET_DB_QueryStatus
210 0 : irbt_cb_table_kyc_targets (struct TALER_EXCHANGEDB_PostgresContext *pg,
211 : const struct TALER_EXCHANGEDB_TableData *td)
212 : {
213 0 : struct GNUNET_PQ_QueryParam params[] = {
214 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
215 0 : GNUNET_PQ_query_param_auto_from_type (
216 : &td->details.kyc_targets.h_normalized_payto),
217 0 : GNUNET_PQ_query_param_auto_from_type (
218 : &td->details.kyc_targets.access_token),
219 0 : td->details.kyc_targets.no_account
220 0 : ? GNUNET_PQ_query_param_null ()
221 0 : : GNUNET_PQ_query_param_auto_from_type (
222 : &td->details.kyc_targets.target_pub),
223 0 : GNUNET_PQ_query_param_bool (
224 0 : td->details.kyc_targets.is_wallet),
225 : GNUNET_PQ_query_param_end
226 : };
227 :
228 0 : PREPARE (pg,
229 : "insert_records_by_table_into_table_kyc_targets",
230 : "INSERT INTO kyc_targets"
231 : "(kyc_target_serial_id"
232 : ",h_normalized_payto"
233 : ",access_token"
234 : ",target_pub"
235 : ",is_wallet"
236 : ") VALUES "
237 : "($1, $2, $3, $4, $5);");
238 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
239 : "insert_records_by_table_into_table_kyc_targets",
240 : params);
241 : }
242 :
243 :
244 : /**
245 : * Function called with records to insert into table.
246 : *
247 : * @param pg plugin context
248 : * @param td record to insert
249 : */
250 : static enum GNUNET_DB_QueryStatus
251 0 : irbt_cb_table_legitimization_measures (
252 : struct TALER_EXCHANGEDB_PostgresContext *pg,
253 : const struct TALER_EXCHANGEDB_TableData *td)
254 : {
255 0 : struct GNUNET_PQ_QueryParam params[] = {
256 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
257 0 : GNUNET_PQ_query_param_auto_from_type (
258 : &td->details.legitimization_measures.target_token),
259 0 : GNUNET_PQ_query_param_absolute_time (
260 : &td->details.legitimization_measures.start_time),
261 0 : TALER_PQ_query_param_json (
262 0 : td->details.legitimization_measures.measures),
263 0 : GNUNET_PQ_query_param_uint32 (
264 : &td->details.legitimization_measures.display_priority),
265 : GNUNET_PQ_query_param_end
266 : };
267 :
268 0 : PREPARE (pg,
269 : "insert_records_by_table_into_table_legitimization_measures",
270 : "INSERT INTO legitimization_measures"
271 : "(legitimization_measure_serial_id"
272 : ",access_token"
273 : ",start_time"
274 : ",jmeasures"
275 : ",display_priority"
276 : ") VALUES "
277 : "($1, $2, $3, $4::TEXT::JSONB, $5);");
278 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
279 : "insert_records_by_table_into_table_legitimization_measures",
280 : params);
281 : }
282 :
283 :
284 : /**
285 : * Function called with records to insert into table.
286 : *
287 : * @param pg plugin context
288 : * @param td record to insert
289 : */
290 : static enum GNUNET_DB_QueryStatus
291 0 : irbt_cb_table_legitimization_outcomes (
292 : struct TALER_EXCHANGEDB_PostgresContext *pg,
293 : const struct TALER_EXCHANGEDB_TableData *td)
294 : {
295 0 : struct GNUNET_PQ_QueryParam params[] = {
296 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
297 0 : GNUNET_PQ_query_param_auto_from_type (
298 : &td->details.legitimization_outcomes.h_payto),
299 0 : GNUNET_PQ_query_param_timestamp (
300 : &td->details.legitimization_outcomes.decision_time),
301 0 : GNUNET_PQ_query_param_timestamp (
302 : &td->details.legitimization_outcomes.expiration_time),
303 0 : NULL == td->details.legitimization_outcomes.properties
304 0 : ? GNUNET_PQ_query_param_null ()
305 0 : : TALER_PQ_query_param_json (
306 0 : td->details.legitimization_outcomes.properties),
307 0 : GNUNET_PQ_query_param_bool (
308 0 : td->details.legitimization_outcomes.to_investigate),
309 0 : TALER_PQ_query_param_json (
310 0 : td->details.legitimization_outcomes.new_rules),
311 : GNUNET_PQ_query_param_end
312 : };
313 :
314 0 : PREPARE (pg,
315 : "insert_records_by_table_into_table_legitimization_outcomes",
316 : "INSERT INTO legitimization_outcomes"
317 : "(outcome_serial_id"
318 : ",h_payto"
319 : ",decision_time"
320 : ",expiration_time"
321 : ",jproperties"
322 : ",to_investigate"
323 : ",jnew_rules"
324 : ") VALUES "
325 : "($1, $2, $3, $4, $5::TEXT::JSONB, $6, $7::TEXT::JSONB);");
326 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
327 : "insert_records_by_table_into_table_legitimization_outcomes",
328 : params);
329 : }
330 :
331 :
332 : /**
333 : * Function called with records to insert into table.
334 : *
335 : * @param pg plugin context
336 : * @param td record to insert
337 : */
338 : static enum GNUNET_DB_QueryStatus
339 0 : irbt_cb_table_legitimization_processes (
340 : struct TALER_EXCHANGEDB_PostgresContext *pg,
341 : const struct TALER_EXCHANGEDB_TableData *td)
342 : {
343 0 : struct GNUNET_PQ_QueryParam params[] = {
344 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
345 0 : GNUNET_PQ_query_param_auto_from_type (
346 : &td->details.legitimization_processes.h_payto),
347 0 : GNUNET_PQ_query_param_absolute_time (
348 : &td->details.legitimization_processes.start_time),
349 0 : GNUNET_PQ_query_param_timestamp (
350 : &td->details.legitimization_processes.expiration_time),
351 0 : GNUNET_PQ_query_param_uint64 (
352 : &td->details.legitimization_processes.legitimization_measure_serial_id),
353 0 : GNUNET_PQ_query_param_uint32 (
354 : &td->details.legitimization_processes.measure_index),
355 0 : GNUNET_PQ_query_param_string (
356 0 : td->details.legitimization_processes.provider_name),
357 0 : NULL == td->details.legitimization_processes.provider_user_id
358 0 : ? GNUNET_PQ_query_param_null ()
359 0 : : GNUNET_PQ_query_param_string (
360 0 : td->details.legitimization_processes.provider_user_id),
361 0 : NULL == td->details.legitimization_processes.provider_legitimization_id
362 0 : ? GNUNET_PQ_query_param_null ()
363 0 : : GNUNET_PQ_query_param_string (
364 0 : td->details.legitimization_processes.provider_legitimization_id),
365 0 : NULL == td->details.legitimization_processes.redirect_url
366 0 : ? GNUNET_PQ_query_param_null ()
367 0 : : GNUNET_PQ_query_param_string (
368 0 : td->details.legitimization_processes.redirect_url),
369 : GNUNET_PQ_query_param_end
370 : };
371 :
372 0 : PREPARE (pg,
373 : "insert_records_by_table_into_table_legitimization_processes",
374 : "INSERT INTO legitimization_processes"
375 : "(legitimization_process_serial_id"
376 : ",h_payto"
377 : ",start_time"
378 : ",expiration_time"
379 : ",legitimization_measure_serial_id"
380 : ",measure_index"
381 : ",provider_name"
382 : ",provider_user_id"
383 : ",provider_legitimization_id"
384 : ",redirect_url"
385 : ") VALUES "
386 : "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10);");
387 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
388 : "insert_records_by_table_into_table_legitimization_processes",
389 : params);
390 : }
391 :
392 :
393 : /**
394 : * Function called with reserves records to insert into table.
395 : *
396 : * @param pg plugin context
397 : * @param td record to insert
398 : */
399 : static enum GNUNET_DB_QueryStatus
400 0 : irbt_cb_table_reserves (struct TALER_EXCHANGEDB_PostgresContext *pg,
401 : const struct TALER_EXCHANGEDB_TableData *td)
402 : {
403 0 : struct GNUNET_PQ_QueryParam params[] = {
404 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
405 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.reserves.reserve_pub),
406 0 : GNUNET_PQ_query_param_timestamp (&td->details.reserves.expiration_date),
407 0 : GNUNET_PQ_query_param_timestamp (&td->details.reserves.gc_date),
408 : GNUNET_PQ_query_param_end
409 : };
410 :
411 0 : PREPARE (pg,
412 : "insert_records_by_table_into_table_reserves",
413 : "INSERT INTO reserves"
414 : "(reserve_uuid"
415 : ",reserve_pub"
416 : ",expiration_date"
417 : ",gc_date"
418 : ") VALUES "
419 : "($1, $2, $3, $4);");
420 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
421 : "insert_records_by_table_into_table_reserves",
422 : params);
423 : }
424 :
425 :
426 : /**
427 : * Function called with reserves_in records to insert into table.
428 : *
429 : * @param pg plugin context
430 : * @param td record to insert
431 : */
432 : static enum GNUNET_DB_QueryStatus
433 0 : irbt_cb_table_reserves_in (struct TALER_EXCHANGEDB_PostgresContext *pg,
434 : const struct TALER_EXCHANGEDB_TableData *td)
435 : {
436 0 : struct GNUNET_PQ_QueryParam params[] = {
437 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
438 0 : GNUNET_PQ_query_param_uint64 (&td->details.reserves_in.wire_reference),
439 0 : TALER_PQ_query_param_amount (
440 0 : pg->conn,
441 : &td->details.reserves_in.credit),
442 0 : GNUNET_PQ_query_param_auto_from_type (
443 : &td->details.reserves_in.sender_account_h_payto),
444 0 : GNUNET_PQ_query_param_string (
445 0 : td->details.reserves_in.exchange_account_section),
446 0 : GNUNET_PQ_query_param_timestamp (
447 : &td->details.reserves_in.execution_date),
448 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.reserves_in.reserve_pub),
449 : GNUNET_PQ_query_param_end
450 : };
451 :
452 0 : PREPARE (pg,
453 : "insert_records_by_table_into_table_reserves_in",
454 : "INSERT INTO reserves_in"
455 : "(reserve_in_serial_id"
456 : ",wire_reference"
457 : ",credit"
458 : ",wire_source_h_payto"
459 : ",exchange_account_section"
460 : ",execution_date"
461 : ",reserve_pub"
462 : ") VALUES "
463 : "($1, $2, $3, $4, $5, $6, $7);");
464 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
465 : "insert_records_by_table_into_table_reserves_in",
466 : params);
467 : }
468 :
469 :
470 : /**
471 : * Function called with kycauth_in records to insert into table.
472 : *
473 : * @param pg plugin context
474 : * @param td record to insert
475 : */
476 : static enum GNUNET_DB_QueryStatus
477 0 : irbt_cb_table_kycauths_in (struct TALER_EXCHANGEDB_PostgresContext *pg,
478 : const struct TALER_EXCHANGEDB_TableData *td)
479 : {
480 0 : struct GNUNET_PQ_QueryParam params[] = {
481 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
482 0 : GNUNET_PQ_query_param_uint64 (&td->details.kycauth_in.wire_reference),
483 0 : TALER_PQ_query_param_amount (
484 0 : pg->conn,
485 : &td->details.reserves_in.credit),
486 0 : GNUNET_PQ_query_param_auto_from_type (
487 : &td->details.reserves_in.sender_account_h_payto),
488 0 : GNUNET_PQ_query_param_string (
489 0 : td->details.reserves_in.exchange_account_section),
490 0 : GNUNET_PQ_query_param_timestamp (
491 : &td->details.reserves_in.execution_date),
492 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.kycauth_in.account_pub),
493 : GNUNET_PQ_query_param_end
494 : };
495 :
496 0 : PREPARE (pg,
497 : "insert_records_by_table_into_table_kycauth_in",
498 : "INSERT INTO kycauths_in"
499 : "(kycauth_in_serial_id"
500 : ",wire_reference"
501 : ",credit"
502 : ",wire_source_h_payto"
503 : ",exchange_account_section"
504 : ",execution_date"
505 : ",account_pub"
506 : ") VALUES "
507 : "($1, $2, $3, $4, $5, $6, $7);");
508 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
509 : "insert_records_by_table_into_table_kycauth_in",
510 : params);
511 : }
512 :
513 :
514 : /**
515 : * Function called with reserves_open_requests records to insert into table.
516 : *
517 : * @param pg plugin context
518 : * @param td record to insert
519 : */
520 : static enum GNUNET_DB_QueryStatus
521 0 : irbt_cb_table_reserves_open_requests (
522 : struct TALER_EXCHANGEDB_PostgresContext *pg,
523 : const struct TALER_EXCHANGEDB_TableData *td)
524 : {
525 0 : struct GNUNET_PQ_QueryParam params[] = {
526 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
527 0 : GNUNET_PQ_query_param_auto_from_type (
528 : &td->details.reserves_open_requests.reserve_pub),
529 0 : GNUNET_PQ_query_param_timestamp (
530 : &td->details.reserves_open_requests.request_timestamp),
531 0 : GNUNET_PQ_query_param_timestamp (
532 : &td->details.reserves_open_requests.expiration_date),
533 0 : GNUNET_PQ_query_param_auto_from_type (
534 : &td->details.reserves_open_requests.reserve_sig),
535 0 : TALER_PQ_query_param_amount (
536 0 : pg->conn,
537 : &td->details.reserves_open_requests.reserve_payment),
538 0 : GNUNET_PQ_query_param_uint32 (
539 : &td->details.reserves_open_requests.requested_purse_limit),
540 : GNUNET_PQ_query_param_end
541 : };
542 :
543 0 : PREPARE (pg,
544 : "insert_records_by_table_into_table_reserves_open_requests",
545 : "INSERT INTO reserves_open_requests"
546 : "(open_request_uuid"
547 : ",reserve_pub"
548 : ",request_timestamp"
549 : ",expiration_date"
550 : ",reserve_sig"
551 : ",reserve_payment"
552 : ",requested_purse_limit"
553 : ") VALUES "
554 : "($1, $2, $3, $4, $5, $6, $7);");
555 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
556 : "insert_records_by_table_into_table_reserves_open_requests",
557 : params);
558 : }
559 :
560 :
561 : /**
562 : * Function called with reserves_open_deposits records to insert into table.
563 : *
564 : * @param pg plugin context
565 : * @param td record to insert
566 : */
567 : static enum GNUNET_DB_QueryStatus
568 0 : irbt_cb_table_reserves_open_deposits (
569 : struct TALER_EXCHANGEDB_PostgresContext *pg,
570 : const struct TALER_EXCHANGEDB_TableData *td)
571 : {
572 0 : struct GNUNET_PQ_QueryParam params[] = {
573 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
574 0 : GNUNET_PQ_query_param_auto_from_type (
575 : &td->details.reserves_open_deposits.reserve_sig),
576 0 : GNUNET_PQ_query_param_auto_from_type (
577 : &td->details.reserves_open_deposits.reserve_pub),
578 0 : GNUNET_PQ_query_param_auto_from_type (
579 : &td->details.reserves_open_deposits.coin_pub),
580 0 : GNUNET_PQ_query_param_auto_from_type (
581 : &td->details.reserves_open_deposits.coin_sig),
582 0 : TALER_PQ_query_param_amount (
583 0 : pg->conn,
584 : &td->details.reserves_open_deposits.contribution),
585 : GNUNET_PQ_query_param_end
586 : };
587 :
588 0 : PREPARE (pg,
589 : "insert_records_by_table_into_table_reserves_open_deposits",
590 : "INSERT INTO reserves_open_deposits"
591 : "(reserve_open_deposit_uuid"
592 : ",reserve_sig"
593 : ",reserve_pub"
594 : ",coin_pub"
595 : ",coin_sig"
596 : ",contribution"
597 : ") VALUES "
598 : "($1, $2, $3, $4, $5, $6);");
599 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
600 : "insert_records_by_table_into_table_reserves_open_deposits",
601 : params);
602 : }
603 :
604 :
605 : /**
606 : * Function called with reserves_close records to insert into table.
607 : *
608 : * @param pg plugin context
609 : * @param td record to insert
610 : */
611 : static enum GNUNET_DB_QueryStatus
612 0 : irbt_cb_table_reserves_close (struct TALER_EXCHANGEDB_PostgresContext *pg,
613 : const struct TALER_EXCHANGEDB_TableData *td)
614 : {
615 0 : struct GNUNET_PQ_QueryParam params[] = {
616 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
617 0 : GNUNET_PQ_query_param_timestamp (
618 : &td->details.reserves_close.execution_date),
619 0 : GNUNET_PQ_query_param_auto_from_type (
620 : &td->details.reserves_close.wtid),
621 0 : GNUNET_PQ_query_param_auto_from_type (
622 : &td->details.reserves_close.sender_account_h_payto),
623 0 : TALER_PQ_query_param_amount (
624 0 : pg->conn,
625 : &td->details.reserves_close.amount),
626 0 : TALER_PQ_query_param_amount (
627 0 : pg->conn,
628 : &td->details.reserves_close.closing_fee),
629 0 : GNUNET_PQ_query_param_auto_from_type (
630 : &td->details.reserves_close.reserve_pub),
631 : GNUNET_PQ_query_param_end
632 : };
633 :
634 0 : PREPARE (pg,
635 : "insert_records_by_table_into_table_reserves_close",
636 : "INSERT INTO reserves_close"
637 : "(close_uuid"
638 : ",execution_date"
639 : ",wtid"
640 : ",wire_target_h_payto"
641 : ",amount"
642 : ",closing_fee"
643 : ",reserve_pub"
644 : ") VALUES "
645 : "($1, $2, $3, $4, $5, $6, $7);");
646 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
647 : "insert_records_by_table_into_table_reserves_close",
648 : params);
649 : }
650 :
651 :
652 : /**
653 : * Function called with auditors records to insert into table.
654 : *
655 : * @param pg plugin context
656 : * @param td record to insert
657 : */
658 : static enum GNUNET_DB_QueryStatus
659 0 : irbt_cb_table_auditors (struct TALER_EXCHANGEDB_PostgresContext *pg,
660 : const struct TALER_EXCHANGEDB_TableData *td)
661 : {
662 0 : struct GNUNET_PQ_QueryParam params[] = {
663 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
664 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.auditors.auditor_pub),
665 0 : GNUNET_PQ_query_param_string (td->details.auditors.auditor_name),
666 0 : GNUNET_PQ_query_param_string (td->details.auditors.auditor_url),
667 0 : GNUNET_PQ_query_param_bool (td->details.auditors.is_active),
668 0 : GNUNET_PQ_query_param_timestamp (&td->details.auditors.last_change),
669 : GNUNET_PQ_query_param_end
670 : };
671 :
672 0 : PREPARE (pg,
673 : "insert_records_by_table_into_table_auditors",
674 : "INSERT INTO auditors"
675 : "(auditor_uuid"
676 : ",auditor_pub"
677 : ",auditor_name"
678 : ",auditor_url"
679 : ",is_active"
680 : ",last_change"
681 : ") VALUES "
682 : "($1, $2, $3, $4, $5, $6);");
683 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
684 : "insert_records_by_table_into_table_auditors",
685 : params);
686 : }
687 :
688 :
689 : /**
690 : * Function called with auditor_denom_sigs records to insert into table.
691 : *
692 : * @param pg plugin context
693 : * @param td record to insert
694 : */
695 : static enum GNUNET_DB_QueryStatus
696 0 : irbt_cb_table_auditor_denom_sigs (struct TALER_EXCHANGEDB_PostgresContext *pg,
697 : const struct TALER_EXCHANGEDB_TableData *td)
698 : {
699 0 : struct GNUNET_PQ_QueryParam params[] = {
700 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
701 0 : GNUNET_PQ_query_param_uint64 (&td->details.auditor_denom_sigs.auditor_uuid),
702 0 : GNUNET_PQ_query_param_uint64 (
703 : &td->details.auditor_denom_sigs.denominations_serial),
704 0 : GNUNET_PQ_query_param_auto_from_type (
705 : &td->details.auditor_denom_sigs.auditor_sig),
706 : GNUNET_PQ_query_param_end
707 : };
708 :
709 0 : PREPARE (pg,
710 : "insert_records_by_table_into_table_auditor_denom_sigs",
711 : "INSERT INTO auditor_denom_sigs"
712 : "(auditor_denom_serial"
713 : ",auditor_uuid"
714 : ",denominations_serial"
715 : ",auditor_sig"
716 : ") VALUES "
717 : "($1, $2, $3, $4);");
718 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
719 : "insert_records_by_table_into_table_auditor_denom_sigs",
720 : params);
721 : }
722 :
723 :
724 : /**
725 : * Function called with exchange_sign_keys records to insert into table.
726 : *
727 : * @param pg plugin context
728 : * @param td record to insert
729 : */
730 : static enum GNUNET_DB_QueryStatus
731 0 : irbt_cb_table_exchange_sign_keys (struct TALER_EXCHANGEDB_PostgresContext *pg,
732 : const struct TALER_EXCHANGEDB_TableData *td)
733 : {
734 0 : struct GNUNET_PQ_QueryParam params[] = {
735 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
736 0 : GNUNET_PQ_query_param_auto_from_type (
737 : &td->details.exchange_sign_keys.exchange_pub),
738 0 : GNUNET_PQ_query_param_auto_from_type (
739 : &td->details.exchange_sign_keys.master_sig),
740 0 : GNUNET_PQ_query_param_timestamp (
741 : &td->details.exchange_sign_keys.meta.start),
742 0 : GNUNET_PQ_query_param_timestamp (
743 : &td->details.exchange_sign_keys.meta.expire_sign),
744 0 : GNUNET_PQ_query_param_timestamp (
745 : &td->details.exchange_sign_keys.meta.expire_legal),
746 : GNUNET_PQ_query_param_end
747 : };
748 :
749 0 : PREPARE (pg,
750 : "insert_records_by_table_into_table_exchange_sign_keys",
751 : "INSERT INTO exchange_sign_keys"
752 : "(esk_serial"
753 : ",exchange_pub"
754 : ",master_sig"
755 : ",valid_from"
756 : ",expire_sign"
757 : ",expire_legal"
758 : ") VALUES "
759 : "($1, $2, $3, $4, $5, $6);");
760 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
761 : "insert_records_by_table_into_table_exchange_sign_keys",
762 : params);
763 : }
764 :
765 :
766 : /**
767 : * Function called with signkey_revocations records to insert into table.
768 : *
769 : * @param pg plugin context
770 : * @param td record to insert
771 : */
772 : static enum GNUNET_DB_QueryStatus
773 0 : irbt_cb_table_signkey_revocations (struct TALER_EXCHANGEDB_PostgresContext *pg,
774 : const struct TALER_EXCHANGEDB_TableData *td)
775 : {
776 0 : struct GNUNET_PQ_QueryParam params[] = {
777 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
778 0 : GNUNET_PQ_query_param_uint64 (&td->details.signkey_revocations.esk_serial),
779 0 : GNUNET_PQ_query_param_auto_from_type (
780 : &td->details.signkey_revocations.master_sig),
781 : GNUNET_PQ_query_param_end
782 : };
783 :
784 0 : PREPARE (pg,
785 : "insert_records_by_table_into_table_signkey_revocations",
786 : "INSERT INTO signkey_revocations"
787 : "(signkey_revocations_serial_id"
788 : ",esk_serial"
789 : ",master_sig"
790 : ") VALUES "
791 : "($1, $2, $3);");
792 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
793 : "insert_records_by_table_into_table_signkey_revocations",
794 : params);
795 : }
796 :
797 :
798 : /**
799 : * Function called with known_coins records to insert into table.
800 : *
801 : * @param pg plugin context
802 : * @param td record to insert
803 : */
804 : static enum GNUNET_DB_QueryStatus
805 0 : irbt_cb_table_known_coins (struct TALER_EXCHANGEDB_PostgresContext *pg,
806 : const struct TALER_EXCHANGEDB_TableData *td)
807 : {
808 0 : struct GNUNET_PQ_QueryParam params[] = {
809 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
810 0 : GNUNET_PQ_query_param_auto_from_type (
811 : &td->details.known_coins.coin_pub),
812 0 : TALER_PQ_query_param_denom_sig (
813 : &td->details.known_coins.denom_sig),
814 0 : GNUNET_PQ_query_param_uint64 (
815 : &td->details.known_coins.denominations_serial),
816 : GNUNET_PQ_query_param_end
817 : };
818 :
819 0 : PREPARE (pg,
820 : "insert_records_by_table_into_table_known_coins",
821 : "INSERT INTO known_coins"
822 : "(known_coin_id"
823 : ",coin_pub"
824 : ",denom_sig"
825 : ",denominations_serial"
826 : ") VALUES "
827 : "($1, $2, $3, $4);");
828 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
829 : "insert_records_by_table_into_table_known_coins",
830 : params);
831 : }
832 :
833 :
834 : /**
835 : * Function called with refresh records to insert into table.
836 : *
837 : * @param pg plugin context
838 : * @param td record to insert
839 : */
840 : static enum GNUNET_DB_QueryStatus
841 0 : irbt_cb_table_refresh (struct TALER_EXCHANGEDB_PostgresContext *pg,
842 : const struct TALER_EXCHANGEDB_TableData *td)
843 : {
844 0 : struct GNUNET_PQ_QueryParam params[] = {
845 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
846 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.refresh.rc),
847 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.refresh.execution_date),
848 0 : TALER_PQ_query_param_amount (
849 0 : pg->conn,
850 : &td->details.refresh.amount_with_fee),
851 0 : GNUNET_PQ_query_param_auto_from_type (
852 : &td->details.refresh.old_coin_pub),
853 0 : GNUNET_PQ_query_param_auto_from_type (
854 : &td->details.refresh.old_coin_sig),
855 0 : GNUNET_PQ_query_param_auto_from_type (
856 : &td->details.refresh.refresh_seed),
857 0 : GNUNET_PQ_query_param_uint32 (
858 : &td->details.refresh.noreveal_index),
859 0 : GNUNET_PQ_query_param_auto_from_type (
860 : &td->details.refresh.planchets_h),
861 0 : GNUNET_PQ_query_param_auto_from_type (
862 : &td->details.refresh.selected_h),
863 0 : td->details.refresh.no_blinding_seed
864 0 : ? GNUNET_PQ_query_param_null ()
865 0 : : GNUNET_PQ_query_param_auto_from_type (
866 : &td->details.refresh.blinding_seed),
867 0 : td->details.refresh.no_blinding_seed
868 0 : ? GNUNET_PQ_query_param_null ()
869 0 : : TALER_PQ_query_param_array_cs_r_pub (
870 0 : td->details.refresh.num_cs_r_values,
871 0 : td->details.refresh.cs_r_values,
872 : pg->conn),
873 0 : td->details.refresh.no_blinding_seed
874 0 : ? GNUNET_PQ_query_param_null ()
875 0 : : GNUNET_PQ_query_param_uint64 (
876 : &td->details.refresh.cs_r_choices),
877 0 : GNUNET_PQ_query_param_array_uint64 (
878 0 : td->details.refresh.num_coins,
879 0 : td->details.refresh.denom_serials,
880 : pg->conn),
881 0 : TALER_PQ_query_param_array_blinded_denom_sig (
882 0 : td->details.refresh.num_coins,
883 0 : td->details.refresh.denom_sigs,
884 : pg->conn),
885 : GNUNET_PQ_query_param_end
886 : };
887 : enum GNUNET_DB_QueryStatus qs;
888 :
889 0 : PREPARE (pg,
890 : "insert_records_by_table_into_table_refresh",
891 : "INSERT INTO refresh"
892 : "(refresh_id"
893 : ",rc"
894 : ",execution_date"
895 : ",amount_with_fee"
896 : ",old_coin_pub"
897 : ",old_coin_sig"
898 : ",refresh_seed"
899 : ",noreveal_index"
900 : ",planchets_h"
901 : ",selected_h"
902 : ",blinding_seed"
903 : ",cs_r_values"
904 : ",cs_r_choices"
905 : ",denom_serials"
906 : ",denom_sigs"
907 : ") VALUES "
908 : "($1, $2, $3, $4, $5, $6,$7,$8,$9,$10,$11,$12,$13,$14,$15);");
909 0 : qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
910 : "insert_records_by_table_into_table_refresh",
911 : params);
912 0 : GNUNET_PQ_cleanup_query_params_closures (params);
913 0 : return qs;
914 : }
915 :
916 :
917 : /**
918 : * Function called with batch deposits records to insert into table.
919 : *
920 : * @param pg plugin context
921 : * @param td record to insert
922 : */
923 : static enum GNUNET_DB_QueryStatus
924 0 : irbt_cb_table_batch_deposits (struct TALER_EXCHANGEDB_PostgresContext *pg,
925 : const struct TALER_EXCHANGEDB_TableData *td)
926 : {
927 0 : struct GNUNET_PQ_QueryParam params[] = {
928 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
929 0 : GNUNET_PQ_query_param_uint64 (&td->details.batch_deposits.shard),
930 0 : GNUNET_PQ_query_param_auto_from_type (
931 : &td->details.batch_deposits.merchant_pub),
932 0 : GNUNET_PQ_query_param_timestamp (
933 : &td->details.batch_deposits.wallet_timestamp),
934 0 : GNUNET_PQ_query_param_timestamp (
935 : &td->details.batch_deposits.exchange_timestamp),
936 0 : GNUNET_PQ_query_param_timestamp (
937 : &td->details.batch_deposits.refund_deadline),
938 0 : GNUNET_PQ_query_param_timestamp (&td->details.batch_deposits.wire_deadline),
939 0 : GNUNET_PQ_query_param_auto_from_type (
940 : &td->details.batch_deposits.h_contract_terms),
941 0 : td->details.batch_deposits.no_wallet_data_hash
942 0 : ? GNUNET_PQ_query_param_null ()
943 0 : : GNUNET_PQ_query_param_auto_from_type (
944 : &td->details.batch_deposits.wallet_data_hash),
945 0 : GNUNET_PQ_query_param_auto_from_type (
946 : &td->details.batch_deposits.wire_salt),
947 0 : GNUNET_PQ_query_param_auto_from_type (
948 : &td->details.batch_deposits.wire_target_h_payto),
949 0 : TALER_PQ_query_param_amount (
950 0 : pg->conn,
951 : &td->details.batch_deposits.total_amount),
952 0 : TALER_PQ_query_param_amount (
953 0 : pg->conn,
954 : &td->details.batch_deposits.total_without_fee),
955 0 : GNUNET_PQ_query_param_auto_from_type (
956 : &td->details.batch_deposits.merchant_sig),
957 0 : GNUNET_PQ_query_param_bool (td->details.batch_deposits.done),
958 : GNUNET_PQ_query_param_end
959 : };
960 :
961 0 : PREPARE (pg,
962 : "insert_records_by_table_into_table_batch_deposits",
963 : "INSERT INTO batch_deposits"
964 : "(batch_deposit_serial_id"
965 : ",shard"
966 : ",merchant_pub"
967 : ",wallet_timestamp"
968 : ",exchange_timestamp"
969 : ",refund_deadline"
970 : ",wire_deadline"
971 : ",h_contract_terms"
972 : ",wallet_data_hash"
973 : ",wire_salt"
974 : ",wire_target_h_payto"
975 : ",total_amount"
976 : ",total_without_fee"
977 : ",merchant_sig"
978 : ",done"
979 : ") VALUES "
980 : "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10,"
981 : " $11, $12, $13, $14, $15);");
982 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
983 : "insert_records_by_table_into_table_batch_deposits",
984 : params);
985 : }
986 :
987 :
988 : /**
989 : * Function called with deposits records to insert into table.
990 : *
991 : * @param pg plugin context
992 : * @param td record to insert
993 : */
994 : static enum GNUNET_DB_QueryStatus
995 0 : irbt_cb_table_coin_deposits (struct TALER_EXCHANGEDB_PostgresContext *pg,
996 : const struct TALER_EXCHANGEDB_TableData *td)
997 : {
998 0 : struct GNUNET_PQ_QueryParam params[] = {
999 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1000 0 : GNUNET_PQ_query_param_uint64 (
1001 : &td->details.coin_deposits.batch_deposit_serial_id),
1002 0 : GNUNET_PQ_query_param_auto_from_type (
1003 : &td->details.coin_deposits.coin_pub),
1004 0 : GNUNET_PQ_query_param_auto_from_type (
1005 : &td->details.coin_deposits.coin_sig),
1006 0 : TALER_PQ_query_param_amount (
1007 0 : pg->conn,
1008 : &td->details.coin_deposits.amount_with_fee),
1009 : GNUNET_PQ_query_param_end
1010 : };
1011 :
1012 0 : PREPARE (pg,
1013 : "insert_records_by_table_into_table_coin_deposits",
1014 : "INSERT INTO coin_deposits"
1015 : "(coin_deposit_serial_id"
1016 : ",batch_deposit_serial_id"
1017 : ",coin_pub"
1018 : ",coin_sig"
1019 : ",amount_with_fee"
1020 : ") VALUES "
1021 : "($1, $2, $3, $4, $5);");
1022 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1023 : "insert_records_by_table_into_table_coin_deposits",
1024 : params);
1025 : }
1026 :
1027 :
1028 : /**
1029 : * Function called with refunds records to insert into table.
1030 : *
1031 : * @param pg plugin context
1032 : * @param td record to insert
1033 : */
1034 : static enum GNUNET_DB_QueryStatus
1035 0 : irbt_cb_table_refunds (struct TALER_EXCHANGEDB_PostgresContext *pg,
1036 : const struct TALER_EXCHANGEDB_TableData *td)
1037 : {
1038 0 : struct GNUNET_PQ_QueryParam params[] = {
1039 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1040 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.refunds.coin_pub),
1041 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.refunds.merchant_sig),
1042 0 : GNUNET_PQ_query_param_uint64 (&td->details.refunds.rtransaction_id),
1043 0 : TALER_PQ_query_param_amount (
1044 0 : pg->conn,
1045 : &td->details.refunds.amount_with_fee),
1046 0 : GNUNET_PQ_query_param_uint64 (
1047 : &td->details.refunds.batch_deposit_serial_id),
1048 : GNUNET_PQ_query_param_end
1049 : };
1050 :
1051 0 : PREPARE (pg,
1052 : "insert_records_by_table_into_table_refunds",
1053 : "INSERT INTO refunds"
1054 : "(refund_serial_id"
1055 : ",coin_pub"
1056 : ",merchant_sig"
1057 : ",rtransaction_id"
1058 : ",amount_with_fee"
1059 : ",batch_deposit_serial_id"
1060 : ") VALUES "
1061 : "($1, $2, $3, $4, $5, $6);");
1062 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1063 : "insert_records_by_table_into_table_refunds",
1064 : params);
1065 : }
1066 :
1067 :
1068 : /**
1069 : * Function called with wire_out records to insert into table.
1070 : *
1071 : * @param pg plugin context
1072 : * @param td record to insert
1073 : */
1074 : static enum GNUNET_DB_QueryStatus
1075 0 : irbt_cb_table_wire_out (struct TALER_EXCHANGEDB_PostgresContext *pg,
1076 : const struct TALER_EXCHANGEDB_TableData *td)
1077 : {
1078 0 : struct GNUNET_PQ_QueryParam params[] = {
1079 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1080 0 : GNUNET_PQ_query_param_timestamp (&td->details.wire_out.execution_date),
1081 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.wire_out.wtid_raw),
1082 0 : GNUNET_PQ_query_param_auto_from_type (
1083 : &td->details.wire_out.wire_target_h_payto),
1084 0 : GNUNET_PQ_query_param_string (
1085 0 : td->details.wire_out.exchange_account_section),
1086 0 : TALER_PQ_query_param_amount (
1087 0 : pg->conn,
1088 : &td->details.wire_out.amount),
1089 : GNUNET_PQ_query_param_end
1090 : };
1091 :
1092 0 : PREPARE (pg,
1093 : "insert_records_by_table_into_table_wire_out",
1094 : "INSERT INTO wire_out"
1095 : "(wireout_uuid"
1096 : ",execution_date"
1097 : ",wtid_raw"
1098 : ",wire_target_h_payto"
1099 : ",exchange_account_section"
1100 : ",amount"
1101 : ") VALUES "
1102 : "($1, $2, $3, $4, $5, $6);");
1103 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1104 : "insert_records_by_table_into_table_wire_out",
1105 : params);
1106 : }
1107 :
1108 :
1109 : /**
1110 : * Function called with aggregation_tracking records to insert into table.
1111 : *
1112 : * @param pg plugin context
1113 : * @param td record to insert
1114 : */
1115 : static enum GNUNET_DB_QueryStatus
1116 0 : irbt_cb_table_aggregation_tracking (struct TALER_EXCHANGEDB_PostgresContext *pg,
1117 : const struct TALER_EXCHANGEDB_TableData *td)
1118 : {
1119 0 : struct GNUNET_PQ_QueryParam params[] = {
1120 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1121 0 : GNUNET_PQ_query_param_uint64 (
1122 : &td->details.aggregation_tracking.batch_deposit_serial_id),
1123 0 : GNUNET_PQ_query_param_auto_from_type (
1124 : &td->details.aggregation_tracking.wtid_raw),
1125 : GNUNET_PQ_query_param_end
1126 : };
1127 :
1128 0 : PREPARE (pg,
1129 : "insert_records_by_table_into_table_aggregation_tracking",
1130 : "INSERT INTO aggregation_tracking"
1131 : "(aggregation_serial_id"
1132 : ",batch_deposit_serial_id"
1133 : ",wtid_raw"
1134 : ") VALUES "
1135 : "($1, $2, $3);");
1136 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1137 : "insert_records_by_table_into_table_aggregation_tracking",
1138 : params);
1139 : }
1140 :
1141 :
1142 : /**
1143 : * Function called with aggregation_deferrals records to insert into table.
1144 : *
1145 : * @param pg plugin context
1146 : * @param td record to insert
1147 : */
1148 : static enum GNUNET_DB_QueryStatus
1149 0 : irbt_cb_table_aggregation_deferrals (
1150 : struct TALER_EXCHANGEDB_PostgresContext *pg,
1151 : const struct TALER_EXCHANGEDB_TableData *td)
1152 : {
1153 0 : struct GNUNET_PQ_QueryParam params[] = {
1154 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1155 0 : GNUNET_PQ_query_param_uint64 (
1156 : &td->details.aggregation_deferrals.batch_deposit_serial_id),
1157 0 : GNUNET_PQ_query_param_auto_from_type (
1158 : &td->details.aggregation_deferrals.wtid_raw),
1159 0 : GNUNET_PQ_query_param_auto_from_type (
1160 : &td->details.aggregation_deferrals.wire_target_h_payto),
1161 0 : TALER_PQ_query_param_amount (
1162 0 : pg->conn,
1163 : &td->details.aggregation_deferrals.amount),
1164 0 : GNUNET_PQ_query_param_uint32 (
1165 : &td->details.aggregation_deferrals.deferral_reason),
1166 0 : GNUNET_PQ_query_param_uint64 (
1167 : &td->details.aggregation_deferrals.legitimization_requirement_serial_id),
1168 0 : GNUNET_PQ_query_param_timestamp (
1169 : &td->details.aggregation_deferrals.deferral_time),
1170 : GNUNET_PQ_query_param_end
1171 : };
1172 :
1173 0 : PREPARE (pg,
1174 : "insert_records_by_table_into_table_aggregation_deferrals",
1175 : "INSERT INTO aggregation_deferrals"
1176 : "(aggregation_deferral_serial_id"
1177 : ",batch_deposit_serial_id"
1178 : ",wtid_raw"
1179 : ",wire_target_h_payto"
1180 : ",amount"
1181 : ",deferral_reason"
1182 : ",legitimization_requirement_serial_id"
1183 : ",deferral_time"
1184 : ") VALUES "
1185 : "($1, $2, $3, $4, $5, $6, $7, $8);");
1186 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1187 : "insert_records_by_table_into_table_aggregation_deferrals",
1188 : params);
1189 : }
1190 :
1191 :
1192 : /**
1193 : * Function called with wire_fee records to insert into table.
1194 : *
1195 : * @param pg plugin context
1196 : * @param td record to insert
1197 : */
1198 : static enum GNUNET_DB_QueryStatus
1199 0 : irbt_cb_table_wire_fee (struct TALER_EXCHANGEDB_PostgresContext *pg,
1200 : const struct TALER_EXCHANGEDB_TableData *td)
1201 : {
1202 0 : struct GNUNET_PQ_QueryParam params[] = {
1203 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1204 0 : GNUNET_PQ_query_param_string (td->details.wire_fee.wire_method),
1205 0 : GNUNET_PQ_query_param_timestamp (&td->details.wire_fee.start_date),
1206 0 : GNUNET_PQ_query_param_timestamp (&td->details.wire_fee.end_date),
1207 0 : TALER_PQ_query_param_amount (
1208 0 : pg->conn,
1209 : &td->details.wire_fee.fees.wire),
1210 0 : TALER_PQ_query_param_amount (
1211 0 : pg->conn,
1212 : &td->details.wire_fee.fees.closing),
1213 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.wire_fee.master_sig),
1214 : GNUNET_PQ_query_param_end
1215 : };
1216 :
1217 0 : PREPARE (pg,
1218 : "insert_records_by_table_into_table_wire_fee",
1219 : "INSERT INTO wire_fee"
1220 : "(wire_fee_serial"
1221 : ",wire_method"
1222 : ",start_date"
1223 : ",end_date"
1224 : ",wire_fee"
1225 : ",closing_fee"
1226 : ",master_sig"
1227 : ") VALUES "
1228 : "($1, $2, $3, $4, $5, $6, $7);");
1229 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1230 : "insert_records_by_table_into_table_wire_fee",
1231 : params);
1232 : }
1233 :
1234 :
1235 : /**
1236 : * Function called with wire_fee records to insert into table.
1237 : *
1238 : * @param pg plugin context
1239 : * @param td record to insert
1240 : */
1241 : static enum GNUNET_DB_QueryStatus
1242 0 : irbt_cb_table_global_fee (struct TALER_EXCHANGEDB_PostgresContext *pg,
1243 : const struct TALER_EXCHANGEDB_TableData *td)
1244 : {
1245 0 : struct GNUNET_PQ_QueryParam params[] = {
1246 0 : GNUNET_PQ_query_param_uint64 (
1247 : &td->serial),
1248 0 : GNUNET_PQ_query_param_timestamp (
1249 : &td->details.global_fee.start_date),
1250 0 : GNUNET_PQ_query_param_timestamp (
1251 : &td->details.global_fee.end_date),
1252 0 : TALER_PQ_query_param_amount (
1253 0 : pg->conn,
1254 : &td->details.global_fee.fees.history),
1255 0 : TALER_PQ_query_param_amount (
1256 0 : pg->conn,
1257 : &td->details.global_fee.fees.account),
1258 0 : TALER_PQ_query_param_amount (
1259 0 : pg->conn,
1260 : &td->details.global_fee.fees.purse),
1261 0 : GNUNET_PQ_query_param_relative_time (
1262 : &td->details.global_fee.purse_timeout),
1263 0 : GNUNET_PQ_query_param_relative_time (
1264 : &td->details.global_fee.history_expiration),
1265 0 : GNUNET_PQ_query_param_uint32 (
1266 : &td->details.global_fee.purse_account_limit),
1267 0 : GNUNET_PQ_query_param_auto_from_type (
1268 : &td->details.global_fee.master_sig),
1269 : GNUNET_PQ_query_param_end
1270 : };
1271 :
1272 0 : PREPARE (pg,
1273 : "insert_records_by_table_into_table_global_fee",
1274 : "INSERT INTO global_fee"
1275 : "(global_fee_serial"
1276 : ",start_date"
1277 : ",end_date"
1278 : ",history_fee"
1279 : ",account_fee"
1280 : ",purse_fee"
1281 : ",purse_timeout"
1282 : ",history_expiration"
1283 : ",purse_account_limit"
1284 : ",master_sig"
1285 : ") VALUES "
1286 : "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10);");
1287 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1288 : "insert_records_by_table_into_table_global_fee",
1289 : params);
1290 : }
1291 :
1292 :
1293 : /**
1294 : * Function called with recoup records to insert into table.
1295 : *
1296 : * @param pg plugin context
1297 : * @param td record to insert
1298 : */
1299 : static enum GNUNET_DB_QueryStatus
1300 0 : irbt_cb_table_recoup (struct TALER_EXCHANGEDB_PostgresContext *pg,
1301 : const struct TALER_EXCHANGEDB_TableData *td)
1302 : {
1303 0 : struct GNUNET_PQ_QueryParam params[] = {
1304 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1305 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.recoup.coin_sig),
1306 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.recoup.coin_blind),
1307 0 : TALER_PQ_query_param_amount (
1308 0 : pg->conn,
1309 : &td->details.recoup.amount),
1310 0 : GNUNET_PQ_query_param_timestamp (&td->details.recoup.timestamp),
1311 0 : GNUNET_PQ_query_param_auto_from_type (
1312 : &td->details.recoup.coin_pub),
1313 0 : GNUNET_PQ_query_param_uint64 (&td->details.recoup.withdraw_serial_id),
1314 : GNUNET_PQ_query_param_end
1315 : };
1316 :
1317 0 : PREPARE (pg,
1318 : "insert_records_by_table_into_table_recoup",
1319 : "INSERT INTO recoup"
1320 : "(recoup_uuid"
1321 : ",coin_sig"
1322 : ",coin_blind"
1323 : ",amount"
1324 : ",recoup_timestamp"
1325 : ",coin_pub"
1326 : ",withdraw_id"
1327 : ") VALUES "
1328 : "($1, $2, $3, $4, $5, $6, $7);");
1329 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1330 : "insert_records_by_table_into_table_recoup",
1331 : params);
1332 : }
1333 :
1334 :
1335 : /**
1336 : * Function called with recoup_refresh records to insert into table.
1337 : *
1338 : * @param pg plugin context
1339 : * @param td record to insert
1340 : */
1341 : static enum GNUNET_DB_QueryStatus
1342 0 : irbt_cb_table_recoup_refresh (struct TALER_EXCHANGEDB_PostgresContext *pg,
1343 : const struct TALER_EXCHANGEDB_TableData *td)
1344 : {
1345 0 : struct GNUNET_PQ_QueryParam params[] = {
1346 0 : GNUNET_PQ_query_param_uint64 (
1347 : &td->serial),
1348 0 : GNUNET_PQ_query_param_auto_from_type (
1349 : &td->details.recoup_refresh.coin_sig),
1350 0 : GNUNET_PQ_query_param_auto_from_type (
1351 : &td->details.recoup_refresh.coin_blind),
1352 0 : TALER_PQ_query_param_amount (
1353 0 : pg->conn,
1354 : &td->details.recoup_refresh.amount),
1355 0 : GNUNET_PQ_query_param_timestamp (
1356 : &td->details.recoup_refresh.recoup_timestamp),
1357 0 : GNUNET_PQ_query_param_uint64 (
1358 : &td->details.recoup_refresh.known_coin_id),
1359 0 : GNUNET_PQ_query_param_auto_from_type (
1360 : &td->details.recoup_refresh.coin_pub),
1361 0 : GNUNET_PQ_query_param_uint64 (
1362 : &td->details.recoup_refresh.refresh_id),
1363 : GNUNET_PQ_query_param_end
1364 : };
1365 :
1366 0 : PREPARE (pg,
1367 : "insert_records_by_table_into_table_recoup_refresh",
1368 : "INSERT INTO recoup_refresh"
1369 : "(recoup_refresh_uuid"
1370 : ",coin_sig"
1371 : ",coin_blind"
1372 : ",amount"
1373 : ",recoup_timestamp"
1374 : ",known_coin_id"
1375 : ",coin_pub"
1376 : ",refresh_id"
1377 : ") VALUES "
1378 : "($1, $2, $3, $4, $5, $6, $7, $8);");
1379 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1380 : "insert_records_by_table_into_table_recoup_refresh",
1381 : params);
1382 : }
1383 :
1384 :
1385 : /**
1386 : * Function called with purse_requests records to insert into table.
1387 : *
1388 : * @param pg plugin context
1389 : * @param td record to insert
1390 : */
1391 : static enum GNUNET_DB_QueryStatus
1392 0 : irbt_cb_table_purse_requests (struct TALER_EXCHANGEDB_PostgresContext *pg,
1393 : const struct TALER_EXCHANGEDB_TableData *td)
1394 : {
1395 0 : struct GNUNET_PQ_QueryParam params[] = {
1396 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1397 0 : GNUNET_PQ_query_param_auto_from_type (
1398 : &td->details.purse_requests.purse_pub),
1399 0 : GNUNET_PQ_query_param_auto_from_type (
1400 : &td->details.purse_requests.merge_pub),
1401 0 : GNUNET_PQ_query_param_timestamp (
1402 : &td->details.purse_requests.purse_creation),
1403 0 : GNUNET_PQ_query_param_timestamp (
1404 : &td->details.purse_requests.purse_expiration),
1405 0 : GNUNET_PQ_query_param_auto_from_type (
1406 : &td->details.purse_requests.h_contract_terms),
1407 0 : GNUNET_PQ_query_param_uint32 (&td->details.purse_requests.age_limit),
1408 0 : GNUNET_PQ_query_param_uint32 (&td->details.purse_requests.flags),
1409 0 : TALER_PQ_query_param_amount (
1410 0 : pg->conn,
1411 : &td->details.purse_requests.amount_with_fee),
1412 0 : TALER_PQ_query_param_amount (
1413 0 : pg->conn,
1414 : &td->details.purse_requests.purse_fee),
1415 0 : GNUNET_PQ_query_param_auto_from_type (
1416 : &td->details.purse_requests.purse_sig),
1417 : GNUNET_PQ_query_param_end
1418 : };
1419 :
1420 0 : PREPARE (pg,
1421 : "insert_records_by_table_into_table_purse_requests",
1422 : "INSERT INTO purse_requests"
1423 : "(purse_requests_serial_id"
1424 : ",purse_pub"
1425 : ",merge_pub"
1426 : ",purse_creation"
1427 : ",purse_expiration"
1428 : ",h_contract_terms"
1429 : ",age_limit"
1430 : ",flags"
1431 : ",amount_with_fee"
1432 : ",purse_fee"
1433 : ",purse_sig"
1434 : ") VALUES "
1435 : "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11);");
1436 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1437 : "insert_records_by_table_into_table_purse_requests",
1438 : params);
1439 : }
1440 :
1441 :
1442 : /**
1443 : * Function called with purse_decision records to insert into table.
1444 : *
1445 : * @param pg plugin context
1446 : * @param td record to insert
1447 : */
1448 : static enum GNUNET_DB_QueryStatus
1449 0 : irbt_cb_table_purse_decision (struct TALER_EXCHANGEDB_PostgresContext *pg,
1450 : const struct TALER_EXCHANGEDB_TableData *td)
1451 : {
1452 0 : struct GNUNET_PQ_QueryParam params[] = {
1453 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1454 0 : GNUNET_PQ_query_param_auto_from_type (
1455 : &td->details.purse_decision.purse_pub),
1456 0 : GNUNET_PQ_query_param_timestamp (
1457 : &td->details.purse_decision.action_timestamp),
1458 0 : GNUNET_PQ_query_param_bool (
1459 0 : td->details.purse_decision.refunded),
1460 : GNUNET_PQ_query_param_end
1461 : };
1462 :
1463 0 : PREPARE (pg,
1464 : "insert_records_by_table_into_table_purse_decision",
1465 : "INSERT INTO purse_decision"
1466 : "(purse_decision_serial_id"
1467 : ",purse_pub"
1468 : ",action_timestamp"
1469 : ",refunded"
1470 : ") VALUES "
1471 : "($1, $2, $3, $4);");
1472 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1473 : "insert_records_by_table_into_table_purse_decision",
1474 : params);
1475 : }
1476 :
1477 :
1478 : /**
1479 : * Function called with purse_merges records to insert into table.
1480 : *
1481 : * @param pg plugin context
1482 : * @param td record to insert
1483 : */
1484 : static enum GNUNET_DB_QueryStatus
1485 0 : irbt_cb_table_purse_merges (struct TALER_EXCHANGEDB_PostgresContext *pg,
1486 : const struct TALER_EXCHANGEDB_TableData *td)
1487 : {
1488 0 : struct GNUNET_PQ_QueryParam params[] = {
1489 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1490 0 : GNUNET_PQ_query_param_uint64 (&td->details.purse_merges.partner_serial_id),
1491 0 : GNUNET_PQ_query_param_auto_from_type (
1492 : &td->details.purse_merges.reserve_pub),
1493 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.purse_merges.purse_pub),
1494 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.purse_merges.merge_sig),
1495 0 : GNUNET_PQ_query_param_timestamp (&td->details.purse_merges.merge_timestamp),
1496 : GNUNET_PQ_query_param_end
1497 : };
1498 :
1499 0 : PREPARE (pg,
1500 : "insert_records_by_table_into_table_purse_merges",
1501 : "INSERT INTO purse_merges"
1502 : "(purse_merge_request_serial_id"
1503 : ",partner_serial_id"
1504 : ",reserve_pub"
1505 : ",purse_pub"
1506 : ",merge_sig"
1507 : ",merge_timestamp"
1508 : ") VALUES "
1509 : "($1, $2, $3, $4, $5, $6);");
1510 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1511 : "insert_records_by_table_into_table_purse_merges",
1512 : params);
1513 : }
1514 :
1515 :
1516 : /**
1517 : * Function called with purse_deposits records to insert into table.
1518 : *
1519 : * @param pg plugin context
1520 : * @param td record to insert
1521 : */
1522 : static enum GNUNET_DB_QueryStatus
1523 0 : irbt_cb_table_purse_deposits (struct TALER_EXCHANGEDB_PostgresContext *pg,
1524 : const struct TALER_EXCHANGEDB_TableData *td)
1525 : {
1526 0 : struct GNUNET_PQ_QueryParam params[] = {
1527 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1528 0 : GNUNET_PQ_query_param_uint64 (
1529 : &td->details.purse_deposits.partner_serial_id),
1530 0 : GNUNET_PQ_query_param_auto_from_type (
1531 : &td->details.purse_deposits.purse_pub),
1532 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.purse_deposits.coin_pub),
1533 0 : TALER_PQ_query_param_amount (
1534 0 : pg->conn,
1535 : &td->details.purse_deposits.amount_with_fee),
1536 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.purse_deposits.coin_sig),
1537 : GNUNET_PQ_query_param_end
1538 : };
1539 :
1540 0 : PREPARE (pg,
1541 : "insert_records_by_table_into_table_purse_deposits",
1542 : "INSERT INTO purse_deposits"
1543 : "(purse_deposit_serial_id"
1544 : ",partner_serial_id"
1545 : ",purse_pub"
1546 : ",coin_pub"
1547 : ",amount_with_fee"
1548 : ",coin_sig"
1549 : ") VALUES "
1550 : "($1, $2, $3, $4, $5, $6);");
1551 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1552 : "insert_records_by_table_into_table_purse_deposits",
1553 : params);
1554 : }
1555 :
1556 :
1557 : /**
1558 : x * Function called with account_mergers records to insert into table.
1559 : *
1560 : * @param pg plugin context
1561 : * @param td record to insert
1562 : */
1563 : static enum GNUNET_DB_QueryStatus
1564 0 : irbt_cb_table_account_mergers (struct TALER_EXCHANGEDB_PostgresContext *pg,
1565 : const struct TALER_EXCHANGEDB_TableData *td)
1566 : {
1567 0 : struct GNUNET_PQ_QueryParam params[] = {
1568 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1569 0 : GNUNET_PQ_query_param_auto_from_type (
1570 : &td->details.account_merges.reserve_pub),
1571 0 : GNUNET_PQ_query_param_auto_from_type (
1572 : &td->details.account_merges.reserve_sig),
1573 0 : GNUNET_PQ_query_param_auto_from_type (
1574 : &td->details.account_merges.purse_pub),
1575 0 : GNUNET_PQ_query_param_auto_from_type (
1576 : &td->details.account_merges.wallet_h_payto),
1577 : GNUNET_PQ_query_param_end
1578 : };
1579 :
1580 0 : PREPARE (pg,
1581 : "insert_records_by_table_into_table_account_merges",
1582 : "INSERT INTO account_merges"
1583 : "(account_merge_request_serial_id"
1584 : ",reserve_pub"
1585 : ",reserve_sig"
1586 : ",purse_pub"
1587 : ",wallet_h_payto"
1588 : ") VALUES "
1589 : "($1, $2, $3, $4, $5);");
1590 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1591 : "insert_records_by_table_into_table_account_merges",
1592 : params);
1593 : }
1594 :
1595 :
1596 : /**
1597 : * Function called with history_requests records to insert into table.
1598 : *
1599 : * @param pg plugin context
1600 : * @param td record to insert
1601 : */
1602 : static enum GNUNET_DB_QueryStatus
1603 0 : irbt_cb_table_history_requests (struct TALER_EXCHANGEDB_PostgresContext *pg,
1604 : const struct TALER_EXCHANGEDB_TableData *td)
1605 : {
1606 0 : struct GNUNET_PQ_QueryParam params[] = {
1607 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1608 0 : GNUNET_PQ_query_param_auto_from_type (
1609 : &td->details.history_requests.reserve_pub),
1610 0 : GNUNET_PQ_query_param_timestamp (
1611 : &td->details.history_requests.request_timestamp),
1612 0 : GNUNET_PQ_query_param_auto_from_type (
1613 : &td->details.history_requests.reserve_sig),
1614 0 : TALER_PQ_query_param_amount (
1615 0 : pg->conn,
1616 : &td->details.history_requests.history_fee),
1617 : GNUNET_PQ_query_param_end
1618 : };
1619 :
1620 0 : PREPARE (pg,
1621 : "insert_records_by_table_into_table_history_requests",
1622 : "INSERT INTO history_requests"
1623 : "(history_request_serial_id"
1624 : ",reserve_pub"
1625 : ",request_timestamp"
1626 : ",reserve_sig"
1627 : ",history_fee"
1628 : ") VALUES "
1629 : "($1, $2, $3, $4, $5);");
1630 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1631 : "insert_records_by_table_into_table_history_requests",
1632 : params);
1633 : }
1634 :
1635 :
1636 : /**
1637 : * Function called with close_requests records to insert into table.
1638 : *
1639 : * @param pg plugin context
1640 : * @param td record to insert
1641 : */
1642 : static enum GNUNET_DB_QueryStatus
1643 0 : irbt_cb_table_close_requests (struct TALER_EXCHANGEDB_PostgresContext *pg,
1644 : const struct TALER_EXCHANGEDB_TableData *td)
1645 : {
1646 0 : struct GNUNET_PQ_QueryParam params[] = {
1647 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1648 0 : GNUNET_PQ_query_param_auto_from_type (
1649 : &td->details.close_requests.reserve_pub),
1650 0 : GNUNET_PQ_query_param_timestamp (
1651 : &td->details.close_requests.close_timestamp),
1652 0 : GNUNET_PQ_query_param_auto_from_type (
1653 : &td->details.close_requests.reserve_sig),
1654 0 : TALER_PQ_query_param_amount (
1655 0 : pg->conn,
1656 : &td->details.close_requests.close),
1657 0 : TALER_PQ_query_param_amount (
1658 0 : pg->conn,
1659 : &td->details.close_requests.close_fee),
1660 0 : GNUNET_PQ_query_param_string (
1661 0 : td->details.close_requests.payto_uri.full_payto),
1662 : GNUNET_PQ_query_param_end
1663 : };
1664 :
1665 0 : PREPARE (pg,
1666 : "insert_records_by_table_into_table_close_requests",
1667 : "INSERT INTO close_requests"
1668 : "(close_request_serial_id"
1669 : ",reserve_pub"
1670 : ",close_timestamp"
1671 : ",reserve_sig"
1672 : ",close"
1673 : ",close_fee"
1674 : ",payto_uri"
1675 : ") VALUES "
1676 : "($1, $2, $3, $4, $5, $6, $7);");
1677 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1678 : "insert_records_by_table_into_table_close_requests",
1679 : params);
1680 : }
1681 :
1682 :
1683 : /**
1684 : * Function called with wads_out records to insert into table.
1685 : *
1686 : * @param pg plugin context
1687 : * @param td record to insert
1688 : */
1689 : static enum GNUNET_DB_QueryStatus
1690 0 : irbt_cb_table_wads_out (struct TALER_EXCHANGEDB_PostgresContext *pg,
1691 : const struct TALER_EXCHANGEDB_TableData *td)
1692 : {
1693 0 : struct GNUNET_PQ_QueryParam params[] = {
1694 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1695 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.wads_out.wad_id),
1696 0 : GNUNET_PQ_query_param_uint64 (&td->details.wads_out.partner_serial_id),
1697 0 : TALER_PQ_query_param_amount (
1698 0 : pg->conn,
1699 : &td->details.wads_out.amount),
1700 0 : GNUNET_PQ_query_param_timestamp (&td->details.wads_out.execution_time),
1701 : GNUNET_PQ_query_param_end
1702 : };
1703 :
1704 0 : PREPARE (pg,
1705 : "insert_records_by_table_into_table_wads_out",
1706 : "INSERT INTO wads_out"
1707 : "(wad_out_serial_id"
1708 : ",wad_id"
1709 : ",partner_serial_id"
1710 : ",amount"
1711 : ",execution_time"
1712 : ") VALUES "
1713 : "($1, $2, $3, $4, $5);");
1714 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1715 : "insert_records_by_table_into_table_wads_out",
1716 : params);
1717 : }
1718 :
1719 :
1720 : /**
1721 : * Function called with wads_out_entries records to insert into table.
1722 : *
1723 : * @param pg plugin context
1724 : * @param td record to insert
1725 : */
1726 : static enum GNUNET_DB_QueryStatus
1727 0 : irbt_cb_table_wads_out_entries (struct TALER_EXCHANGEDB_PostgresContext *pg,
1728 : const struct TALER_EXCHANGEDB_TableData *td)
1729 : {
1730 0 : struct GNUNET_PQ_QueryParam params[] = {
1731 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1732 0 : GNUNET_PQ_query_param_uint64 (
1733 : &td->details.wads_out_entries.wad_out_serial_id),
1734 0 : GNUNET_PQ_query_param_auto_from_type (
1735 : &td->details.wads_out_entries.reserve_pub),
1736 0 : GNUNET_PQ_query_param_auto_from_type (
1737 : &td->details.wads_out_entries.purse_pub),
1738 0 : GNUNET_PQ_query_param_auto_from_type (
1739 : &td->details.wads_out_entries.h_contract),
1740 0 : GNUNET_PQ_query_param_timestamp (
1741 : &td->details.wads_out_entries.purse_expiration),
1742 0 : GNUNET_PQ_query_param_timestamp (
1743 : &td->details.wads_out_entries.merge_timestamp),
1744 0 : TALER_PQ_query_param_amount (
1745 0 : pg->conn,
1746 : &td->details.wads_out_entries.amount_with_fee),
1747 0 : TALER_PQ_query_param_amount (
1748 0 : pg->conn,
1749 : &td->details.wads_out_entries.wad_fee),
1750 0 : TALER_PQ_query_param_amount (
1751 0 : pg->conn,
1752 : &td->details.wads_out_entries.deposit_fees),
1753 0 : GNUNET_PQ_query_param_auto_from_type (
1754 : &td->details.wads_out_entries.reserve_sig),
1755 0 : GNUNET_PQ_query_param_auto_from_type (
1756 : &td->details.wads_out_entries.purse_sig),
1757 : GNUNET_PQ_query_param_end
1758 : };
1759 :
1760 0 : PREPARE (pg,
1761 : "insert_records_by_table_into_table_wad_out_entries",
1762 : "INSERT INTO wad_out_entries"
1763 : "(wad_out_entry_serial_id"
1764 : ",wad_out_serial_id"
1765 : ",reserve_pub"
1766 : ",purse_pub"
1767 : ",h_contract"
1768 : ",purse_expiration"
1769 : ",merge_timestamp"
1770 : ",amount_with_fee"
1771 : ",wad_fee"
1772 : ",deposit_fees"
1773 : ",reserve_sig"
1774 : ",purse_sig"
1775 : ") VALUES "
1776 : "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);");
1777 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1778 : "insert_records_by_table_into_table_wad_out_entries",
1779 : params);
1780 : }
1781 :
1782 :
1783 : /**
1784 : * Function called with wads_in records to insert into table.
1785 : *
1786 : * @param pg plugin context
1787 : * @param td record to insert
1788 : */
1789 : static enum GNUNET_DB_QueryStatus
1790 0 : irbt_cb_table_wads_in (struct TALER_EXCHANGEDB_PostgresContext *pg,
1791 : const struct TALER_EXCHANGEDB_TableData *td)
1792 : {
1793 0 : struct GNUNET_PQ_QueryParam params[] = {
1794 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1795 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.wads_in.wad_id),
1796 0 : GNUNET_PQ_query_param_string (td->details.wads_in.origin_exchange_url),
1797 0 : TALER_PQ_query_param_amount (
1798 0 : pg->conn,
1799 : &td->details.wads_in.amount),
1800 0 : GNUNET_PQ_query_param_timestamp (&td->details.wads_in.arrival_time),
1801 : GNUNET_PQ_query_param_end
1802 : };
1803 :
1804 0 : PREPARE (pg,
1805 : "insert_records_by_table_into_table_wads_in",
1806 : "INSERT INTO wads_in"
1807 : "(wad_in_serial_id"
1808 : ",wad_id"
1809 : ",origin_exchange_url"
1810 : ",amount"
1811 : ",arrival_time"
1812 : ") VALUES "
1813 : "($1, $2, $3, $4, $5);");
1814 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1815 : "insert_records_by_table_into_table_wads_in",
1816 : params);
1817 : }
1818 :
1819 :
1820 : /**
1821 : * Function called with wads_in_entries records to insert into table.
1822 : *
1823 : * @param pg plugin context
1824 : * @param td record to insert
1825 : */
1826 : static enum GNUNET_DB_QueryStatus
1827 0 : irbt_cb_table_wads_in_entries (struct TALER_EXCHANGEDB_PostgresContext *pg,
1828 : const struct TALER_EXCHANGEDB_TableData *td)
1829 : {
1830 0 : struct GNUNET_PQ_QueryParam params[] = {
1831 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1832 0 : GNUNET_PQ_query_param_auto_from_type (
1833 : &td->details.wads_in_entries.reserve_pub),
1834 0 : GNUNET_PQ_query_param_auto_from_type (
1835 : &td->details.wads_in_entries.purse_pub),
1836 0 : GNUNET_PQ_query_param_auto_from_type (
1837 : &td->details.wads_in_entries.h_contract),
1838 0 : GNUNET_PQ_query_param_timestamp (
1839 : &td->details.wads_in_entries.purse_expiration),
1840 0 : GNUNET_PQ_query_param_timestamp (
1841 : &td->details.wads_in_entries.merge_timestamp),
1842 0 : TALER_PQ_query_param_amount (
1843 0 : pg->conn,
1844 : &td->details.wads_in_entries.amount_with_fee),
1845 0 : TALER_PQ_query_param_amount (
1846 0 : pg->conn,
1847 : &td->details.wads_in_entries.wad_fee),
1848 0 : TALER_PQ_query_param_amount (
1849 0 : pg->conn,
1850 : &td->details.wads_in_entries.deposit_fees),
1851 0 : GNUNET_PQ_query_param_auto_from_type (
1852 : &td->details.wads_in_entries.reserve_sig),
1853 0 : GNUNET_PQ_query_param_auto_from_type (
1854 : &td->details.wads_in_entries.purse_sig),
1855 : GNUNET_PQ_query_param_end
1856 : };
1857 :
1858 0 : PREPARE (pg,
1859 : "insert_records_by_table_into_table_wad_in_entries",
1860 : "INSERT INTO wad_in_entries"
1861 : "(wad_in_entry_serial_id"
1862 : ",wad_in_serial_id"
1863 : ",reserve_pub"
1864 : ",purse_pub"
1865 : ",h_contract"
1866 : ",purse_expiration"
1867 : ",merge_timestamp"
1868 : ",amount_with_fee"
1869 : ",wad_fee"
1870 : ",deposit_fees"
1871 : ",reserve_sig"
1872 : ",purse_sig"
1873 : ") VALUES "
1874 : "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);");
1875 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1876 : "insert_records_by_table_into_table_wad_in_entries",
1877 : params);
1878 : }
1879 :
1880 :
1881 : /**
1882 : * Function called with profit_drains records to insert into table.
1883 : *
1884 : * @param pg plugin context
1885 : * @param td record to insert
1886 : */
1887 : static enum GNUNET_DB_QueryStatus
1888 0 : irbt_cb_table_profit_drains (struct TALER_EXCHANGEDB_PostgresContext *pg,
1889 : const struct TALER_EXCHANGEDB_TableData *td)
1890 : {
1891 0 : struct GNUNET_PQ_QueryParam params[] = {
1892 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1893 0 : GNUNET_PQ_query_param_auto_from_type (
1894 : &td->details.profit_drains.wtid),
1895 0 : GNUNET_PQ_query_param_string (
1896 0 : td->details.profit_drains.account_section),
1897 0 : GNUNET_PQ_query_param_string (
1898 0 : td->details.profit_drains.payto_uri.full_payto),
1899 0 : GNUNET_PQ_query_param_timestamp (
1900 : &td->details.profit_drains.trigger_date),
1901 0 : TALER_PQ_query_param_amount (
1902 0 : pg->conn,
1903 : &td->details.profit_drains.amount),
1904 0 : GNUNET_PQ_query_param_auto_from_type (
1905 : &td->details.profit_drains.master_sig),
1906 : GNUNET_PQ_query_param_end
1907 : };
1908 :
1909 0 : PREPARE (pg,
1910 : "insert_records_by_table_into_table_profit_drains",
1911 : "INSERT INTO profit_drains"
1912 : "(profit_drain_serial_id"
1913 : ",wtid"
1914 : ",account_section"
1915 : ",payto_uri"
1916 : ",trigger_date"
1917 : ",amount"
1918 : ",master_sig"
1919 : ") VALUES "
1920 : "($1, $2, $3, $4, $5, $6, $7);");
1921 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1922 : "insert_records_by_table_into_table_profit_drains",
1923 : params);
1924 : }
1925 :
1926 :
1927 : /**
1928 : * Function called with aml_staff records to insert into table.
1929 : *
1930 : * @param pg plugin context
1931 : * @param td record to insert
1932 : */
1933 : static enum GNUNET_DB_QueryStatus
1934 0 : irbt_cb_table_aml_staff (struct TALER_EXCHANGEDB_PostgresContext *pg,
1935 : const struct TALER_EXCHANGEDB_TableData *td)
1936 : {
1937 0 : struct GNUNET_PQ_QueryParam params[] = {
1938 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1939 0 : GNUNET_PQ_query_param_auto_from_type (
1940 : &td->details.aml_staff.decider_pub),
1941 0 : GNUNET_PQ_query_param_auto_from_type (
1942 : &td->details.aml_staff.master_sig),
1943 0 : GNUNET_PQ_query_param_string (
1944 0 : td->details.aml_staff.decider_name),
1945 0 : GNUNET_PQ_query_param_bool (
1946 0 : td->details.aml_staff.is_active),
1947 0 : GNUNET_PQ_query_param_bool (
1948 0 : td->details.aml_staff.read_only),
1949 0 : GNUNET_PQ_query_param_timestamp (
1950 : &td->details.aml_staff.last_change),
1951 : GNUNET_PQ_query_param_end
1952 : };
1953 :
1954 0 : PREPARE (pg,
1955 : "insert_records_by_table_into_table_aml_staff",
1956 : "INSERT INTO aml_staff"
1957 : "(aml_staff_uuid"
1958 : ",decider_pub"
1959 : ",master_sig"
1960 : ",decider_name"
1961 : ",is_active"
1962 : ",read_only"
1963 : ",last_change"
1964 : ") VALUES "
1965 : "($1, $2, $3, $4, $5, $6, $7);");
1966 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1967 : "insert_records_by_table_into_table_aml_staff",
1968 : params);
1969 : }
1970 :
1971 :
1972 : /**
1973 : * Function called with kyc_attributes records to insert into table.
1974 : *
1975 : * @param pg plugin context
1976 : * @param td record to insert
1977 : */
1978 : static enum GNUNET_DB_QueryStatus
1979 0 : irbt_cb_table_kyc_attributes (struct TALER_EXCHANGEDB_PostgresContext *pg,
1980 : const struct TALER_EXCHANGEDB_TableData *td)
1981 : {
1982 0 : struct GNUNET_PQ_QueryParam params[] = {
1983 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1984 0 : GNUNET_PQ_query_param_auto_from_type (
1985 : &td->details.kyc_attributes.h_payto),
1986 0 : GNUNET_PQ_query_param_uint64 (
1987 : &td->details.kyc_attributes.legitimization_serial),
1988 0 : GNUNET_PQ_query_param_timestamp (
1989 : &td->details.kyc_attributes.collection_time),
1990 0 : GNUNET_PQ_query_param_timestamp (
1991 : &td->details.kyc_attributes.expiration_time),
1992 0 : NULL == td->details.kyc_attributes.form_name
1993 0 : ? GNUNET_PQ_query_param_null ()
1994 0 : : GNUNET_PQ_query_param_string (
1995 0 : td->details.kyc_attributes.form_name),
1996 0 : GNUNET_PQ_query_param_bool (
1997 0 : td->details.kyc_attributes.by_aml_officer),
1998 0 : GNUNET_PQ_query_param_fixed_size (
1999 0 : td->details.kyc_attributes.encrypted_attributes,
2000 0 : td->details.kyc_attributes.encrypted_attributes_size),
2001 : GNUNET_PQ_query_param_end
2002 : };
2003 :
2004 0 : PREPARE (pg,
2005 : "insert_records_by_table_into_table_kyc_attributes",
2006 : "INSERT INTO kyc_attributes"
2007 : "(kyc_attributes_serial_id"
2008 : ",h_payto"
2009 : ",legitimization_serial"
2010 : ",collection_time"
2011 : ",expiration_time"
2012 : ",form_name"
2013 : ",by_aml_officer"
2014 : ",encrypted_attributes"
2015 : ") VALUES "
2016 : "($1, $2, $3, $4, $5, $6, $7, $8);");
2017 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
2018 : "insert_records_by_table_into_table_kyc_attributes",
2019 : params);
2020 : }
2021 :
2022 :
2023 : /**
2024 : * Function called with aml_history records to insert into table.
2025 : *
2026 : * @param pg plugin context
2027 : * @param td record to insert
2028 : */
2029 : static enum GNUNET_DB_QueryStatus
2030 0 : irbt_cb_table_aml_history (struct TALER_EXCHANGEDB_PostgresContext *pg,
2031 : const struct TALER_EXCHANGEDB_TableData *td)
2032 : {
2033 0 : struct GNUNET_PQ_QueryParam params[] = {
2034 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
2035 0 : GNUNET_PQ_query_param_auto_from_type (
2036 : &td->details.aml_history.h_payto),
2037 0 : GNUNET_PQ_query_param_uint64 (
2038 : &td->details.aml_history.outcome_serial_id),
2039 0 : GNUNET_PQ_query_param_string (
2040 0 : td->details.aml_history.justification),
2041 0 : GNUNET_PQ_query_param_auto_from_type (
2042 : &td->details.aml_history.decider_pub),
2043 0 : GNUNET_PQ_query_param_auto_from_type (
2044 : &td->details.aml_history.decider_sig),
2045 0 : td->details.aml_history.no_kyc_attributes_hash
2046 0 : ? GNUNET_PQ_query_param_null ()
2047 0 : : GNUNET_PQ_query_param_auto_from_type (
2048 : &td->details.aml_history.kyc_attributes_hash),
2049 0 : td->details.aml_history.no_kyc_attributes_serial_id
2050 0 : ? GNUNET_PQ_query_param_null ()
2051 0 : : GNUNET_PQ_query_param_uint64 (
2052 : &td->details.aml_history.kyc_attributes_serial_id),
2053 : GNUNET_PQ_query_param_end
2054 : };
2055 :
2056 0 : PREPARE (pg,
2057 : "insert_records_by_table_into_table_aml_history",
2058 : "INSERT INTO aml_history"
2059 : "(aml_history_serial_id"
2060 : ",h_payto"
2061 : ",outcome_serial_id"
2062 : ",justification"
2063 : ",decider_pub"
2064 : ",decider_sig"
2065 : ",kyc_attributes_hash"
2066 : ",kyc_attributes_serial_id"
2067 : ") VALUES "
2068 : "($1, $2, $3, $4, $5, $6, $7, $8);");
2069 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
2070 : "insert_records_by_table_into_table_aml_history",
2071 : params);
2072 : }
2073 :
2074 :
2075 : /**
2076 : * Function called with kyc_event records to insert into table.
2077 : *
2078 : * @param pg plugin context
2079 : * @param td record to insert
2080 : */
2081 : static enum GNUNET_DB_QueryStatus
2082 0 : irbt_cb_table_kyc_events (struct TALER_EXCHANGEDB_PostgresContext *pg,
2083 : const struct TALER_EXCHANGEDB_TableData *td)
2084 : {
2085 0 : struct GNUNET_PQ_QueryParam params[] = {
2086 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
2087 0 : GNUNET_PQ_query_param_timestamp (
2088 : &td->details.kyc_events.event_timestamp),
2089 0 : GNUNET_PQ_query_param_string (
2090 0 : td->details.kyc_events.event_type),
2091 : GNUNET_PQ_query_param_end
2092 : };
2093 :
2094 0 : PREPARE (pg,
2095 : "insert_records_by_table_into_table_kyc_events",
2096 : "INSERT INTO kyc_events"
2097 : "(kyc_event_serial_id"
2098 : ",event_timestamp"
2099 : ",event_type"
2100 : ") VALUES "
2101 : "($1, $2, $3);");
2102 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
2103 : "insert_records_by_table_into_table_kyc_events",
2104 : params);
2105 : }
2106 :
2107 :
2108 : /**
2109 : * Function called with purse_deletion records to insert into table.
2110 : *
2111 : * @param pg plugin context
2112 : * @param td record to insert
2113 : */
2114 : static enum GNUNET_DB_QueryStatus
2115 0 : irbt_cb_table_purse_deletion (struct TALER_EXCHANGEDB_PostgresContext *pg,
2116 : const struct TALER_EXCHANGEDB_TableData *td)
2117 : {
2118 0 : struct GNUNET_PQ_QueryParam params[] = {
2119 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
2120 0 : GNUNET_PQ_query_param_auto_from_type (
2121 : &td->details.purse_deletion.purse_pub),
2122 0 : GNUNET_PQ_query_param_auto_from_type (
2123 : &td->details.purse_deletion.purse_sig),
2124 : GNUNET_PQ_query_param_end
2125 : };
2126 :
2127 0 : PREPARE (pg,
2128 : "insert_records_by_table_into_table_purse_deletion",
2129 : "INSERT INTO purse_deletion"
2130 : "(purse_deletion_serial_id"
2131 : ",purse_pub"
2132 : ",purse_sig"
2133 : ") VALUES "
2134 : "($1, $2, $3);");
2135 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
2136 : "insert_records_by_table_into_table_purse_deletion",
2137 : params);
2138 : }
2139 :
2140 :
2141 : /**
2142 : * Function called with withdraw records to insert into table.
2143 : *
2144 : * @param pg plugin context
2145 : * @param td record to insert
2146 : */
2147 : static enum GNUNET_DB_QueryStatus
2148 0 : irbt_cb_table_withdraw (
2149 : struct TALER_EXCHANGEDB_PostgresContext *pg,
2150 : const struct TALER_EXCHANGEDB_TableData *td)
2151 : {
2152 0 : struct GNUNET_PQ_QueryParam params[] = {
2153 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
2154 0 : GNUNET_PQ_query_param_auto_from_type (
2155 : &td->details.withdraw.planchets_h),
2156 0 : GNUNET_PQ_query_param_timestamp (
2157 : &td->details.withdraw.execution_date),
2158 0 : TALER_PQ_query_param_amount (
2159 0 : pg->conn,
2160 : &td->details.withdraw.amount_with_fee),
2161 0 : GNUNET_PQ_query_param_auto_from_type (
2162 : &td->details.withdraw.reserve_pub),
2163 0 : GNUNET_PQ_query_param_auto_from_type (
2164 : &td->details.withdraw.reserve_sig),
2165 0 : td->details.withdraw.age_proof_required
2166 0 : ? GNUNET_PQ_query_param_uint16 (
2167 : &td->details.withdraw.max_age)
2168 0 : : GNUNET_PQ_query_param_null (),
2169 0 : td->details.withdraw.age_proof_required
2170 0 : ? GNUNET_PQ_query_param_uint16 (
2171 : &td->details.withdraw.noreveal_index)
2172 0 : : GNUNET_PQ_query_param_null (),
2173 0 : td->details.withdraw.age_proof_required
2174 0 : ? GNUNET_PQ_query_param_auto_from_type (
2175 : &td->details.withdraw.selected_h)
2176 0 : : GNUNET_PQ_query_param_null (),
2177 0 : td->details.withdraw.no_blinding_seed
2178 0 : ? GNUNET_PQ_query_param_null ()
2179 0 : : GNUNET_PQ_query_param_auto_from_type (
2180 : &td->details.withdraw.blinding_seed),
2181 0 : (0 < td->details.withdraw.num_cs_r_values)
2182 0 : ? TALER_PQ_query_param_array_cs_r_pub (
2183 0 : td->details.withdraw.num_cs_r_values,
2184 0 : td->details.withdraw.cs_r_values,
2185 : pg->conn)
2186 0 : : GNUNET_PQ_query_param_null (),
2187 0 : (0 < td->details.withdraw.num_cs_r_values)
2188 0 : ? GNUNET_PQ_query_param_uint64 (
2189 : &td->details.withdraw.cs_r_choices)
2190 0 : : GNUNET_PQ_query_param_null (),
2191 0 : GNUNET_PQ_query_param_array_uint64 (
2192 0 : td->details.withdraw.num_coins,
2193 0 : td->details.withdraw.denom_serials,
2194 : pg->conn),
2195 0 : TALER_PQ_query_param_array_blinded_denom_sig (
2196 0 : td->details.withdraw.num_coins,
2197 0 : td->details.withdraw.denom_sigs,
2198 : pg->conn),
2199 : GNUNET_PQ_query_param_end
2200 : };
2201 : enum GNUNET_DB_QueryStatus qs;
2202 :
2203 0 : PREPARE (pg,
2204 : "insert_records_by_table_into_table_withdraw",
2205 : "INSERT INTO withdraw"
2206 : "(withdraw_id"
2207 : ",planchets_h"
2208 : ",execution_date"
2209 : ",amount_with_fee"
2210 : ",reserve_pub"
2211 : ",reserve_sig"
2212 : ",max_age"
2213 : ",noreveal_index"
2214 : ",selected_h"
2215 : ",blinding_seed"
2216 : ",cs_r_values"
2217 : ",cs_r_choices"
2218 : ",denom_serials"
2219 : ",denom_sigs"
2220 : ") VALUES "
2221 : "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14);");
2222 0 : qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
2223 : "insert_records_by_table_into_table_withdraw",
2224 : params);
2225 0 : GNUNET_PQ_cleanup_query_params_closures (params);
2226 0 : return qs;
2227 : }
2228 :
2229 :
2230 : enum GNUNET_DB_QueryStatus
2231 2 : TALER_EXCHANGEDB_insert_records_by_table (
2232 : struct TALER_EXCHANGEDB_PostgresContext *pg,
2233 : const struct TALER_EXCHANGEDB_TableData *td)
2234 : {
2235 2 : InsertRecordCallback rh = NULL;
2236 :
2237 2 : switch (td->table)
2238 : {
2239 0 : case TALER_EXCHANGEDB_RT_DENOMINATIONS:
2240 0 : rh = &irbt_cb_table_denominations;
2241 0 : break;
2242 0 : case TALER_EXCHANGEDB_RT_DENOMINATION_REVOCATIONS:
2243 0 : rh = &irbt_cb_table_denomination_revocations;
2244 0 : break;
2245 1 : case TALER_EXCHANGEDB_RT_WIRE_TARGETS:
2246 1 : rh = &irbt_cb_table_wire_targets;
2247 1 : break;
2248 0 : case TALER_EXCHANGEDB_RT_KYC_TARGETS:
2249 0 : rh = &irbt_cb_table_kyc_targets;
2250 0 : break;
2251 0 : case TALER_EXCHANGEDB_RT_RESERVES:
2252 0 : rh = &irbt_cb_table_reserves;
2253 0 : break;
2254 0 : case TALER_EXCHANGEDB_RT_RESERVES_IN:
2255 0 : rh = &irbt_cb_table_reserves_in;
2256 0 : break;
2257 0 : case TALER_EXCHANGEDB_RT_KYCAUTHS_IN:
2258 0 : rh = &irbt_cb_table_kycauths_in;
2259 0 : break;
2260 0 : case TALER_EXCHANGEDB_RT_RESERVES_CLOSE:
2261 0 : rh = &irbt_cb_table_reserves_close;
2262 0 : break;
2263 0 : case TALER_EXCHANGEDB_RT_RESERVES_OPEN_REQUESTS:
2264 0 : rh = &irbt_cb_table_reserves_open_requests;
2265 0 : break;
2266 0 : case TALER_EXCHANGEDB_RT_RESERVES_OPEN_DEPOSITS:
2267 0 : rh = &irbt_cb_table_reserves_open_deposits;
2268 0 : break;
2269 0 : case TALER_EXCHANGEDB_RT_AUDITORS:
2270 0 : rh = &irbt_cb_table_auditors;
2271 0 : break;
2272 0 : case TALER_EXCHANGEDB_RT_AUDITOR_DENOM_SIGS:
2273 0 : rh = &irbt_cb_table_auditor_denom_sigs;
2274 0 : break;
2275 0 : case TALER_EXCHANGEDB_RT_EXCHANGE_SIGN_KEYS:
2276 0 : rh = &irbt_cb_table_exchange_sign_keys;
2277 0 : break;
2278 0 : case TALER_EXCHANGEDB_RT_SIGNKEY_REVOCATIONS:
2279 0 : rh = &irbt_cb_table_signkey_revocations;
2280 0 : break;
2281 0 : case TALER_EXCHANGEDB_RT_KNOWN_COINS:
2282 0 : rh = &irbt_cb_table_known_coins;
2283 0 : break;
2284 0 : case TALER_EXCHANGEDB_RT_REFRESH:
2285 0 : rh = &irbt_cb_table_refresh;
2286 0 : break;
2287 0 : case TALER_EXCHANGEDB_RT_BATCH_DEPOSITS:
2288 0 : rh = &irbt_cb_table_batch_deposits;
2289 0 : break;
2290 0 : case TALER_EXCHANGEDB_RT_COIN_DEPOSITS:
2291 0 : rh = &irbt_cb_table_coin_deposits;
2292 0 : break;
2293 0 : case TALER_EXCHANGEDB_RT_REFUNDS:
2294 0 : rh = &irbt_cb_table_refunds;
2295 0 : break;
2296 0 : case TALER_EXCHANGEDB_RT_WIRE_OUT:
2297 0 : rh = &irbt_cb_table_wire_out;
2298 0 : break;
2299 0 : case TALER_EXCHANGEDB_RT_AGGREGATION_TRACKING:
2300 0 : rh = &irbt_cb_table_aggregation_tracking;
2301 0 : break;
2302 0 : case TALER_EXCHANGEDB_RT_AGGREGATION_DEFERRALS:
2303 0 : rh = &irbt_cb_table_aggregation_deferrals;
2304 0 : break;
2305 0 : case TALER_EXCHANGEDB_RT_WIRE_FEE:
2306 0 : rh = &irbt_cb_table_wire_fee;
2307 0 : break;
2308 0 : case TALER_EXCHANGEDB_RT_GLOBAL_FEE:
2309 0 : rh = &irbt_cb_table_global_fee;
2310 0 : break;
2311 0 : case TALER_EXCHANGEDB_RT_RECOUP:
2312 0 : rh = &irbt_cb_table_recoup;
2313 0 : break;
2314 0 : case TALER_EXCHANGEDB_RT_RECOUP_REFRESH:
2315 0 : rh = &irbt_cb_table_recoup_refresh;
2316 0 : break;
2317 0 : case TALER_EXCHANGEDB_RT_PURSE_REQUESTS:
2318 0 : rh = &irbt_cb_table_purse_requests;
2319 0 : break;
2320 0 : case TALER_EXCHANGEDB_RT_PURSE_DECISION:
2321 0 : rh = &irbt_cb_table_purse_decision;
2322 0 : break;
2323 0 : case TALER_EXCHANGEDB_RT_PURSE_MERGES:
2324 0 : rh = &irbt_cb_table_purse_merges;
2325 0 : break;
2326 0 : case TALER_EXCHANGEDB_RT_PURSE_DEPOSITS:
2327 0 : rh = &irbt_cb_table_purse_deposits;
2328 0 : break;
2329 0 : case TALER_EXCHANGEDB_RT_ACCOUNT_MERGES:
2330 0 : rh = &irbt_cb_table_account_mergers;
2331 0 : break;
2332 0 : case TALER_EXCHANGEDB_RT_HISTORY_REQUESTS:
2333 0 : rh = &irbt_cb_table_history_requests;
2334 0 : break;
2335 0 : case TALER_EXCHANGEDB_RT_CLOSE_REQUESTS:
2336 0 : rh = &irbt_cb_table_close_requests;
2337 0 : break;
2338 0 : case TALER_EXCHANGEDB_RT_WADS_OUT:
2339 0 : rh = &irbt_cb_table_wads_out;
2340 0 : break;
2341 0 : case TALER_EXCHANGEDB_RT_WADS_OUT_ENTRIES:
2342 0 : rh = &irbt_cb_table_wads_out_entries;
2343 0 : break;
2344 0 : case TALER_EXCHANGEDB_RT_WADS_IN:
2345 0 : rh = &irbt_cb_table_wads_in;
2346 0 : break;
2347 0 : case TALER_EXCHANGEDB_RT_WADS_IN_ENTRIES:
2348 0 : rh = &irbt_cb_table_wads_in_entries;
2349 0 : break;
2350 0 : case TALER_EXCHANGEDB_RT_PROFIT_DRAINS:
2351 0 : rh = &irbt_cb_table_profit_drains;
2352 0 : break;
2353 0 : case TALER_EXCHANGEDB_RT_AML_STAFF:
2354 0 : rh = &irbt_cb_table_aml_staff;
2355 0 : break;
2356 0 : case TALER_EXCHANGEDB_RT_PURSE_DELETION:
2357 0 : rh = &irbt_cb_table_purse_deletion;
2358 0 : break;
2359 0 : case TALER_EXCHANGEDB_RT_WITHDRAW:
2360 0 : rh = &irbt_cb_table_withdraw;
2361 0 : break;
2362 0 : case TALER_EXCHANGEDB_RT_LEGITIMIZATION_MEASURES:
2363 0 : rh = &irbt_cb_table_legitimization_measures;
2364 0 : break;
2365 0 : case TALER_EXCHANGEDB_RT_LEGITIMIZATION_OUTCOMES:
2366 0 : rh = &irbt_cb_table_legitimization_outcomes;
2367 0 : break;
2368 0 : case TALER_EXCHANGEDB_RT_LEGITIMIZATION_PROCESSES:
2369 0 : rh = &irbt_cb_table_legitimization_processes;
2370 0 : break;
2371 0 : case TALER_EXCHANGEDB_RT_KYC_ATTRIBUTES:
2372 0 : rh = &irbt_cb_table_kyc_attributes;
2373 0 : break;
2374 0 : case TALER_EXCHANGEDB_RT_AML_HISTORY:
2375 0 : rh = &irbt_cb_table_aml_history;
2376 0 : break;
2377 0 : case TALER_EXCHANGEDB_RT_KYC_EVENTS:
2378 0 : rh = &irbt_cb_table_kyc_events;
2379 0 : break;
2380 : }
2381 2 : if (NULL == rh)
2382 : {
2383 1 : GNUNET_break (0);
2384 1 : return GNUNET_DB_STATUS_HARD_ERROR;
2385 : }
2386 1 : return rh (pg,
2387 : td);
2388 : }
2389 :
2390 :
2391 : /* end of insert_records_by_table.c */
|