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 1 : irbt_cb_table_refresh (struct TALER_EXCHANGEDB_PostgresContext *pg,
842 : const struct TALER_EXCHANGEDB_TableData *td)
843 : {
844 1 : struct GNUNET_PQ_QueryParam params[] = {
845 1 : GNUNET_PQ_query_param_uint64 (&td->serial),
846 1 : GNUNET_PQ_query_param_auto_from_type (&td->details.refresh.rc),
847 1 : GNUNET_PQ_query_param_auto_from_type (&td->details.refresh.execution_date),
848 1 : TALER_PQ_query_param_amount (
849 1 : pg->conn,
850 : &td->details.refresh.amount_with_fee),
851 1 : GNUNET_PQ_query_param_auto_from_type (
852 : &td->details.refresh.old_coin_pub),
853 1 : GNUNET_PQ_query_param_auto_from_type (
854 : &td->details.refresh.old_coin_sig),
855 1 : GNUNET_PQ_query_param_auto_from_type (
856 : &td->details.refresh.refresh_seed),
857 1 : GNUNET_PQ_query_param_uint32 (
858 : &td->details.refresh.noreveal_index),
859 1 : GNUNET_PQ_query_param_auto_from_type (
860 : &td->details.refresh.planchets_h),
861 1 : GNUNET_PQ_query_param_auto_from_type (
862 : &td->details.refresh.selected_h),
863 1 : td->details.refresh.no_blinding_seed
864 1 : ? GNUNET_PQ_query_param_null ()
865 1 : : GNUNET_PQ_query_param_auto_from_type (
866 : &td->details.refresh.blinding_seed),
867 1 : td->details.refresh.no_blinding_seed
868 1 : ? GNUNET_PQ_query_param_null ()
869 1 : : 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 1 : td->details.refresh.no_blinding_seed
874 1 : ? GNUNET_PQ_query_param_null ()
875 1 : : GNUNET_PQ_query_param_uint64 (
876 : &td->details.refresh.cs_r_choices),
877 1 : GNUNET_PQ_query_param_array_uint64 (
878 1 : td->details.refresh.num_coins,
879 1 : td->details.refresh.denom_serials,
880 : pg->conn),
881 1 : TALER_PQ_query_param_array_blinded_denom_sig (
882 1 : td->details.refresh.num_coins,
883 1 : td->details.refresh.denom_sigs,
884 : pg->conn),
885 1 : (NULL == td->details.refresh.transfer_pubs)
886 0 : ? GNUNET_PQ_query_param_null ()
887 1 : : GNUNET_PQ_query_param_array_auto_from_type (
888 : td->details.refresh.num_coins,
889 : td->details.refresh.transfer_pubs,
890 : pg->conn),
891 1 : GNUNET_PQ_query_param_bool (td->details.refresh.revealed),
892 1 : GNUNET_PQ_query_param_uint32 (
893 : &td->details.refresh.rc_version),
894 : GNUNET_PQ_query_param_end
895 : };
896 : enum GNUNET_DB_QueryStatus qs;
897 :
898 1 : PREPARE (pg,
899 : "insert_records_by_table_into_table_refresh",
900 : "INSERT INTO refresh"
901 : "(refresh_id"
902 : ",rc"
903 : ",execution_date"
904 : ",amount_with_fee"
905 : ",old_coin_pub"
906 : ",old_coin_sig"
907 : ",refresh_seed"
908 : ",noreveal_index"
909 : ",planchets_h"
910 : ",selected_h"
911 : ",blinding_seed"
912 : ",cs_r_values"
913 : ",cs_r_choices"
914 : ",denom_serials"
915 : ",denom_sigs"
916 : ",transfer_pubs"
917 : ",revealed"
918 : ",rc_version"
919 : ") VALUES "
920 : "($1, $2, $3, $4, $5, $6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,"
921 : "$18);");
922 1 : qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
923 : "insert_records_by_table_into_table_refresh",
924 : params);
925 1 : GNUNET_PQ_cleanup_query_params_closures (params);
926 1 : return qs;
927 : }
928 :
929 :
930 : /**
931 : * Function called with batch deposits records to insert into table.
932 : *
933 : * @param pg plugin context
934 : * @param td record to insert
935 : */
936 : static enum GNUNET_DB_QueryStatus
937 0 : irbt_cb_table_batch_deposits (struct TALER_EXCHANGEDB_PostgresContext *pg,
938 : const struct TALER_EXCHANGEDB_TableData *td)
939 : {
940 0 : struct GNUNET_PQ_QueryParam params[] = {
941 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
942 0 : GNUNET_PQ_query_param_uint64 (&td->details.batch_deposits.shard),
943 0 : GNUNET_PQ_query_param_auto_from_type (
944 : &td->details.batch_deposits.merchant_pub),
945 0 : GNUNET_PQ_query_param_timestamp (
946 : &td->details.batch_deposits.wallet_timestamp),
947 0 : GNUNET_PQ_query_param_timestamp (
948 : &td->details.batch_deposits.exchange_timestamp),
949 0 : GNUNET_PQ_query_param_timestamp (
950 : &td->details.batch_deposits.refund_deadline),
951 0 : GNUNET_PQ_query_param_timestamp (&td->details.batch_deposits.wire_deadline),
952 0 : GNUNET_PQ_query_param_auto_from_type (
953 : &td->details.batch_deposits.h_contract_terms),
954 0 : td->details.batch_deposits.no_wallet_data_hash
955 0 : ? GNUNET_PQ_query_param_null ()
956 0 : : GNUNET_PQ_query_param_auto_from_type (
957 : &td->details.batch_deposits.wallet_data_hash),
958 0 : GNUNET_PQ_query_param_auto_from_type (
959 : &td->details.batch_deposits.wire_salt),
960 0 : GNUNET_PQ_query_param_auto_from_type (
961 : &td->details.batch_deposits.wire_target_h_payto),
962 0 : TALER_PQ_query_param_amount (
963 0 : pg->conn,
964 : &td->details.batch_deposits.total_amount),
965 0 : TALER_PQ_query_param_amount (
966 0 : pg->conn,
967 : &td->details.batch_deposits.total_without_fee),
968 0 : GNUNET_PQ_query_param_auto_from_type (
969 : &td->details.batch_deposits.merchant_sig),
970 0 : GNUNET_PQ_query_param_bool (td->details.batch_deposits.done),
971 : GNUNET_PQ_query_param_end
972 : };
973 :
974 0 : PREPARE (pg,
975 : "insert_records_by_table_into_table_batch_deposits",
976 : "INSERT INTO batch_deposits"
977 : "(batch_deposit_serial_id"
978 : ",shard"
979 : ",merchant_pub"
980 : ",wallet_timestamp"
981 : ",exchange_timestamp"
982 : ",refund_deadline"
983 : ",wire_deadline"
984 : ",h_contract_terms"
985 : ",wallet_data_hash"
986 : ",wire_salt"
987 : ",wire_target_h_payto"
988 : ",total_amount"
989 : ",total_without_fee"
990 : ",merchant_sig"
991 : ",done"
992 : ") VALUES "
993 : "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10,"
994 : " $11, $12, $13, $14, $15);");
995 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
996 : "insert_records_by_table_into_table_batch_deposits",
997 : params);
998 : }
999 :
1000 :
1001 : /**
1002 : * Function called with deposits records to insert into table.
1003 : *
1004 : * @param pg plugin context
1005 : * @param td record to insert
1006 : */
1007 : static enum GNUNET_DB_QueryStatus
1008 0 : irbt_cb_table_coin_deposits (struct TALER_EXCHANGEDB_PostgresContext *pg,
1009 : const struct TALER_EXCHANGEDB_TableData *td)
1010 : {
1011 0 : struct GNUNET_PQ_QueryParam params[] = {
1012 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1013 0 : GNUNET_PQ_query_param_uint64 (
1014 : &td->details.coin_deposits.batch_deposit_serial_id),
1015 0 : GNUNET_PQ_query_param_auto_from_type (
1016 : &td->details.coin_deposits.coin_pub),
1017 0 : GNUNET_PQ_query_param_auto_from_type (
1018 : &td->details.coin_deposits.coin_sig),
1019 0 : TALER_PQ_query_param_amount (
1020 0 : pg->conn,
1021 : &td->details.coin_deposits.amount_with_fee),
1022 : GNUNET_PQ_query_param_end
1023 : };
1024 :
1025 0 : PREPARE (pg,
1026 : "insert_records_by_table_into_table_coin_deposits",
1027 : "INSERT INTO coin_deposits"
1028 : "(coin_deposit_serial_id"
1029 : ",batch_deposit_serial_id"
1030 : ",coin_pub"
1031 : ",coin_sig"
1032 : ",amount_with_fee"
1033 : ") VALUES "
1034 : "($1, $2, $3, $4, $5);");
1035 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1036 : "insert_records_by_table_into_table_coin_deposits",
1037 : params);
1038 : }
1039 :
1040 :
1041 : /**
1042 : * Function called with refunds records to insert into table.
1043 : *
1044 : * @param pg plugin context
1045 : * @param td record to insert
1046 : */
1047 : static enum GNUNET_DB_QueryStatus
1048 0 : irbt_cb_table_refunds (struct TALER_EXCHANGEDB_PostgresContext *pg,
1049 : const struct TALER_EXCHANGEDB_TableData *td)
1050 : {
1051 0 : struct GNUNET_PQ_QueryParam params[] = {
1052 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1053 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.refunds.coin_pub),
1054 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.refunds.merchant_sig),
1055 0 : GNUNET_PQ_query_param_uint64 (&td->details.refunds.rtransaction_id),
1056 0 : TALER_PQ_query_param_amount (
1057 0 : pg->conn,
1058 : &td->details.refunds.amount_with_fee),
1059 0 : GNUNET_PQ_query_param_uint64 (
1060 : &td->details.refunds.batch_deposit_serial_id),
1061 : GNUNET_PQ_query_param_end
1062 : };
1063 :
1064 0 : PREPARE (pg,
1065 : "insert_records_by_table_into_table_refunds",
1066 : "INSERT INTO refunds"
1067 : "(refund_serial_id"
1068 : ",coin_pub"
1069 : ",merchant_sig"
1070 : ",rtransaction_id"
1071 : ",amount_with_fee"
1072 : ",batch_deposit_serial_id"
1073 : ") VALUES "
1074 : "($1, $2, $3, $4, $5, $6);");
1075 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1076 : "insert_records_by_table_into_table_refunds",
1077 : params);
1078 : }
1079 :
1080 :
1081 : /**
1082 : * Function called with wire_out records to insert into table.
1083 : *
1084 : * @param pg plugin context
1085 : * @param td record to insert
1086 : */
1087 : static enum GNUNET_DB_QueryStatus
1088 0 : irbt_cb_table_wire_out (struct TALER_EXCHANGEDB_PostgresContext *pg,
1089 : const struct TALER_EXCHANGEDB_TableData *td)
1090 : {
1091 0 : struct GNUNET_PQ_QueryParam params[] = {
1092 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1093 0 : GNUNET_PQ_query_param_timestamp (&td->details.wire_out.execution_date),
1094 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.wire_out.wtid_raw),
1095 0 : GNUNET_PQ_query_param_auto_from_type (
1096 : &td->details.wire_out.wire_target_h_payto),
1097 0 : GNUNET_PQ_query_param_string (
1098 0 : td->details.wire_out.exchange_account_section),
1099 0 : TALER_PQ_query_param_amount (
1100 0 : pg->conn,
1101 : &td->details.wire_out.amount),
1102 : GNUNET_PQ_query_param_end
1103 : };
1104 :
1105 0 : PREPARE (pg,
1106 : "insert_records_by_table_into_table_wire_out",
1107 : "INSERT INTO wire_out"
1108 : "(wireout_uuid"
1109 : ",execution_date"
1110 : ",wtid_raw"
1111 : ",wire_target_h_payto"
1112 : ",exchange_account_section"
1113 : ",amount"
1114 : ") VALUES "
1115 : "($1, $2, $3, $4, $5, $6);");
1116 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1117 : "insert_records_by_table_into_table_wire_out",
1118 : params);
1119 : }
1120 :
1121 :
1122 : /**
1123 : * Function called with aggregation_tracking records to insert into table.
1124 : *
1125 : * @param pg plugin context
1126 : * @param td record to insert
1127 : */
1128 : static enum GNUNET_DB_QueryStatus
1129 0 : irbt_cb_table_aggregation_tracking (struct TALER_EXCHANGEDB_PostgresContext *pg,
1130 : const struct TALER_EXCHANGEDB_TableData *td)
1131 : {
1132 0 : struct GNUNET_PQ_QueryParam params[] = {
1133 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1134 0 : GNUNET_PQ_query_param_uint64 (
1135 : &td->details.aggregation_tracking.batch_deposit_serial_id),
1136 0 : GNUNET_PQ_query_param_auto_from_type (
1137 : &td->details.aggregation_tracking.wtid_raw),
1138 : GNUNET_PQ_query_param_end
1139 : };
1140 :
1141 0 : PREPARE (pg,
1142 : "insert_records_by_table_into_table_aggregation_tracking",
1143 : "INSERT INTO aggregation_tracking"
1144 : "(aggregation_serial_id"
1145 : ",batch_deposit_serial_id"
1146 : ",wtid_raw"
1147 : ") VALUES "
1148 : "($1, $2, $3);");
1149 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1150 : "insert_records_by_table_into_table_aggregation_tracking",
1151 : params);
1152 : }
1153 :
1154 :
1155 : /**
1156 : * Function called with aggregation_deferrals records to insert into table.
1157 : *
1158 : * @param pg plugin context
1159 : * @param td record to insert
1160 : */
1161 : static enum GNUNET_DB_QueryStatus
1162 0 : irbt_cb_table_aggregation_deferrals (
1163 : struct TALER_EXCHANGEDB_PostgresContext *pg,
1164 : const struct TALER_EXCHANGEDB_TableData *td)
1165 : {
1166 0 : struct GNUNET_PQ_QueryParam params[] = {
1167 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1168 0 : GNUNET_PQ_query_param_uint64 (
1169 : &td->details.aggregation_deferrals.batch_deposit_serial_id),
1170 0 : GNUNET_PQ_query_param_auto_from_type (
1171 : &td->details.aggregation_deferrals.wtid_raw),
1172 0 : GNUNET_PQ_query_param_auto_from_type (
1173 : &td->details.aggregation_deferrals.wire_target_h_payto),
1174 0 : TALER_PQ_query_param_amount (
1175 0 : pg->conn,
1176 : &td->details.aggregation_deferrals.amount),
1177 0 : GNUNET_PQ_query_param_uint32 (
1178 : &td->details.aggregation_deferrals.deferral_reason),
1179 0 : GNUNET_PQ_query_param_uint64 (
1180 : &td->details.aggregation_deferrals.legitimization_requirement_serial_id),
1181 0 : GNUNET_PQ_query_param_timestamp (
1182 : &td->details.aggregation_deferrals.deferral_time),
1183 : GNUNET_PQ_query_param_end
1184 : };
1185 :
1186 0 : PREPARE (pg,
1187 : "insert_records_by_table_into_table_aggregation_deferrals",
1188 : "INSERT INTO aggregation_deferrals"
1189 : "(aggregation_deferral_serial_id"
1190 : ",batch_deposit_serial_id"
1191 : ",wtid_raw"
1192 : ",wire_target_h_payto"
1193 : ",amount"
1194 : ",deferral_reason"
1195 : ",legitimization_requirement_serial_id"
1196 : ",deferral_time"
1197 : ") VALUES "
1198 : "($1, $2, $3, $4, $5, $6, $7, $8);");
1199 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1200 : "insert_records_by_table_into_table_aggregation_deferrals",
1201 : params);
1202 : }
1203 :
1204 :
1205 : /**
1206 : * Function called with wire_fee records to insert into table.
1207 : *
1208 : * @param pg plugin context
1209 : * @param td record to insert
1210 : */
1211 : static enum GNUNET_DB_QueryStatus
1212 0 : irbt_cb_table_wire_fee (struct TALER_EXCHANGEDB_PostgresContext *pg,
1213 : const struct TALER_EXCHANGEDB_TableData *td)
1214 : {
1215 0 : struct GNUNET_PQ_QueryParam params[] = {
1216 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1217 0 : GNUNET_PQ_query_param_string (td->details.wire_fee.wire_method),
1218 0 : GNUNET_PQ_query_param_timestamp (&td->details.wire_fee.start_date),
1219 0 : GNUNET_PQ_query_param_timestamp (&td->details.wire_fee.end_date),
1220 0 : TALER_PQ_query_param_amount (
1221 0 : pg->conn,
1222 : &td->details.wire_fee.fees.wire),
1223 0 : TALER_PQ_query_param_amount (
1224 0 : pg->conn,
1225 : &td->details.wire_fee.fees.closing),
1226 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.wire_fee.master_sig),
1227 : GNUNET_PQ_query_param_end
1228 : };
1229 :
1230 0 : PREPARE (pg,
1231 : "insert_records_by_table_into_table_wire_fee",
1232 : "INSERT INTO wire_fee"
1233 : "(wire_fee_serial"
1234 : ",wire_method"
1235 : ",start_date"
1236 : ",end_date"
1237 : ",wire_fee"
1238 : ",closing_fee"
1239 : ",master_sig"
1240 : ") VALUES "
1241 : "($1, $2, $3, $4, $5, $6, $7);");
1242 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1243 : "insert_records_by_table_into_table_wire_fee",
1244 : params);
1245 : }
1246 :
1247 :
1248 : /**
1249 : * Function called with wire_fee records to insert into table.
1250 : *
1251 : * @param pg plugin context
1252 : * @param td record to insert
1253 : */
1254 : static enum GNUNET_DB_QueryStatus
1255 0 : irbt_cb_table_global_fee (struct TALER_EXCHANGEDB_PostgresContext *pg,
1256 : const struct TALER_EXCHANGEDB_TableData *td)
1257 : {
1258 0 : struct GNUNET_PQ_QueryParam params[] = {
1259 0 : GNUNET_PQ_query_param_uint64 (
1260 : &td->serial),
1261 0 : GNUNET_PQ_query_param_timestamp (
1262 : &td->details.global_fee.start_date),
1263 0 : GNUNET_PQ_query_param_timestamp (
1264 : &td->details.global_fee.end_date),
1265 0 : TALER_PQ_query_param_amount (
1266 0 : pg->conn,
1267 : &td->details.global_fee.fees.history),
1268 0 : TALER_PQ_query_param_amount (
1269 0 : pg->conn,
1270 : &td->details.global_fee.fees.account),
1271 0 : TALER_PQ_query_param_amount (
1272 0 : pg->conn,
1273 : &td->details.global_fee.fees.purse),
1274 0 : GNUNET_PQ_query_param_relative_time (
1275 : &td->details.global_fee.purse_timeout),
1276 0 : GNUNET_PQ_query_param_relative_time (
1277 : &td->details.global_fee.history_expiration),
1278 0 : GNUNET_PQ_query_param_uint32 (
1279 : &td->details.global_fee.purse_account_limit),
1280 0 : GNUNET_PQ_query_param_auto_from_type (
1281 : &td->details.global_fee.master_sig),
1282 : GNUNET_PQ_query_param_end
1283 : };
1284 :
1285 0 : PREPARE (pg,
1286 : "insert_records_by_table_into_table_global_fee",
1287 : "INSERT INTO global_fee"
1288 : "(global_fee_serial"
1289 : ",start_date"
1290 : ",end_date"
1291 : ",history_fee"
1292 : ",account_fee"
1293 : ",purse_fee"
1294 : ",purse_timeout"
1295 : ",history_expiration"
1296 : ",purse_account_limit"
1297 : ",master_sig"
1298 : ") VALUES "
1299 : "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10);");
1300 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1301 : "insert_records_by_table_into_table_global_fee",
1302 : params);
1303 : }
1304 :
1305 :
1306 : /**
1307 : * Function called with recoup records to insert into table.
1308 : *
1309 : * @param pg plugin context
1310 : * @param td record to insert
1311 : */
1312 : static enum GNUNET_DB_QueryStatus
1313 1 : irbt_cb_table_recoup (struct TALER_EXCHANGEDB_PostgresContext *pg,
1314 : const struct TALER_EXCHANGEDB_TableData *td)
1315 : {
1316 1 : struct GNUNET_PQ_QueryParam params[] = {
1317 1 : GNUNET_PQ_query_param_uint64 (&td->serial),
1318 1 : GNUNET_PQ_query_param_auto_from_type (&td->details.recoup.coin_sig),
1319 1 : GNUNET_PQ_query_param_auto_from_type (&td->details.recoup.coin_blind),
1320 1 : TALER_PQ_query_param_amount (
1321 1 : pg->conn,
1322 : &td->details.recoup.amount),
1323 1 : GNUNET_PQ_query_param_timestamp (&td->details.recoup.timestamp),
1324 1 : GNUNET_PQ_query_param_auto_from_type (
1325 : &td->details.recoup.coin_pub),
1326 1 : GNUNET_PQ_query_param_uint64 (&td->details.recoup.withdraw_serial_id),
1327 1 : GNUNET_PQ_query_param_uint32 (&td->details.recoup.coin_index),
1328 : GNUNET_PQ_query_param_end
1329 : };
1330 :
1331 1 : PREPARE (pg,
1332 : "insert_records_by_table_into_table_recoup",
1333 : "INSERT INTO recoup"
1334 : "(recoup_uuid"
1335 : ",coin_sig"
1336 : ",coin_blind"
1337 : ",amount"
1338 : ",recoup_timestamp"
1339 : ",coin_pub"
1340 : ",withdraw_id"
1341 : ",coin_index"
1342 : ") VALUES "
1343 : "($1, $2, $3, $4, $5, $6, $7, $8);");
1344 1 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1345 : "insert_records_by_table_into_table_recoup",
1346 : params);
1347 : }
1348 :
1349 :
1350 : /**
1351 : * Function called with recoup_refresh records to insert into table.
1352 : *
1353 : * @param pg plugin context
1354 : * @param td record to insert
1355 : */
1356 : static enum GNUNET_DB_QueryStatus
1357 1 : irbt_cb_table_recoup_refresh (struct TALER_EXCHANGEDB_PostgresContext *pg,
1358 : const struct TALER_EXCHANGEDB_TableData *td)
1359 : {
1360 1 : struct GNUNET_PQ_QueryParam params[] = {
1361 1 : GNUNET_PQ_query_param_uint64 (
1362 : &td->serial),
1363 1 : GNUNET_PQ_query_param_auto_from_type (
1364 : &td->details.recoup_refresh.coin_sig),
1365 1 : GNUNET_PQ_query_param_auto_from_type (
1366 : &td->details.recoup_refresh.coin_blind),
1367 1 : TALER_PQ_query_param_amount (
1368 1 : pg->conn,
1369 : &td->details.recoup_refresh.amount),
1370 1 : GNUNET_PQ_query_param_timestamp (
1371 : &td->details.recoup_refresh.recoup_timestamp),
1372 1 : GNUNET_PQ_query_param_uint64 (
1373 : &td->details.recoup_refresh.known_coin_id),
1374 1 : GNUNET_PQ_query_param_auto_from_type (
1375 : &td->details.recoup_refresh.coin_pub),
1376 1 : GNUNET_PQ_query_param_uint64 (
1377 : &td->details.recoup_refresh.refresh_id),
1378 1 : GNUNET_PQ_query_param_uint32 (
1379 : &td->details.recoup_refresh.coin_index),
1380 : GNUNET_PQ_query_param_end
1381 : };
1382 :
1383 1 : PREPARE (pg,
1384 : "insert_records_by_table_into_table_recoup_refresh",
1385 : "INSERT INTO recoup_refresh"
1386 : "(recoup_refresh_uuid"
1387 : ",coin_sig"
1388 : ",coin_blind"
1389 : ",amount"
1390 : ",recoup_timestamp"
1391 : ",known_coin_id"
1392 : ",coin_pub"
1393 : ",refresh_id"
1394 : ",coin_index"
1395 : ") VALUES "
1396 : "($1, $2, $3, $4, $5, $6, $7, $8, $9);");
1397 1 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1398 : "insert_records_by_table_into_table_recoup_refresh",
1399 : params);
1400 : }
1401 :
1402 :
1403 : /**
1404 : * Function called with purse_requests records to insert into table.
1405 : *
1406 : * @param pg plugin context
1407 : * @param td record to insert
1408 : */
1409 : static enum GNUNET_DB_QueryStatus
1410 0 : irbt_cb_table_purse_requests (struct TALER_EXCHANGEDB_PostgresContext *pg,
1411 : const struct TALER_EXCHANGEDB_TableData *td)
1412 : {
1413 0 : struct GNUNET_PQ_QueryParam params[] = {
1414 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1415 0 : GNUNET_PQ_query_param_auto_from_type (
1416 : &td->details.purse_requests.purse_pub),
1417 0 : GNUNET_PQ_query_param_auto_from_type (
1418 : &td->details.purse_requests.merge_pub),
1419 0 : GNUNET_PQ_query_param_timestamp (
1420 : &td->details.purse_requests.purse_creation),
1421 0 : GNUNET_PQ_query_param_timestamp (
1422 : &td->details.purse_requests.purse_expiration),
1423 0 : GNUNET_PQ_query_param_auto_from_type (
1424 : &td->details.purse_requests.h_contract_terms),
1425 0 : GNUNET_PQ_query_param_uint32 (&td->details.purse_requests.age_limit),
1426 0 : GNUNET_PQ_query_param_uint32 (&td->details.purse_requests.flags),
1427 0 : TALER_PQ_query_param_amount (
1428 0 : pg->conn,
1429 : &td->details.purse_requests.amount_with_fee),
1430 0 : TALER_PQ_query_param_amount (
1431 0 : pg->conn,
1432 : &td->details.purse_requests.purse_fee),
1433 0 : GNUNET_PQ_query_param_auto_from_type (
1434 : &td->details.purse_requests.purse_sig),
1435 : GNUNET_PQ_query_param_end
1436 : };
1437 :
1438 0 : PREPARE (pg,
1439 : "insert_records_by_table_into_table_purse_requests",
1440 : "INSERT INTO purse_requests"
1441 : "(purse_requests_serial_id"
1442 : ",purse_pub"
1443 : ",merge_pub"
1444 : ",purse_creation"
1445 : ",purse_expiration"
1446 : ",h_contract_terms"
1447 : ",age_limit"
1448 : ",flags"
1449 : ",amount_with_fee"
1450 : ",purse_fee"
1451 : ",purse_sig"
1452 : ") VALUES "
1453 : "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11);");
1454 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1455 : "insert_records_by_table_into_table_purse_requests",
1456 : params);
1457 : }
1458 :
1459 :
1460 : /**
1461 : * Function called with purse_decision records to insert into table.
1462 : *
1463 : * @param pg plugin context
1464 : * @param td record to insert
1465 : */
1466 : static enum GNUNET_DB_QueryStatus
1467 0 : irbt_cb_table_purse_decision (struct TALER_EXCHANGEDB_PostgresContext *pg,
1468 : const struct TALER_EXCHANGEDB_TableData *td)
1469 : {
1470 0 : struct GNUNET_PQ_QueryParam params[] = {
1471 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1472 0 : GNUNET_PQ_query_param_auto_from_type (
1473 : &td->details.purse_decision.purse_pub),
1474 0 : GNUNET_PQ_query_param_timestamp (
1475 : &td->details.purse_decision.action_timestamp),
1476 0 : GNUNET_PQ_query_param_bool (
1477 0 : td->details.purse_decision.refunded),
1478 : GNUNET_PQ_query_param_end
1479 : };
1480 :
1481 0 : PREPARE (pg,
1482 : "insert_records_by_table_into_table_purse_decision",
1483 : "INSERT INTO purse_decision"
1484 : "(purse_decision_serial_id"
1485 : ",purse_pub"
1486 : ",action_timestamp"
1487 : ",refunded"
1488 : ") VALUES "
1489 : "($1, $2, $3, $4);");
1490 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1491 : "insert_records_by_table_into_table_purse_decision",
1492 : params);
1493 : }
1494 :
1495 :
1496 : /**
1497 : * Function called with purse_merges records to insert into table.
1498 : *
1499 : * @param pg plugin context
1500 : * @param td record to insert
1501 : */
1502 : static enum GNUNET_DB_QueryStatus
1503 0 : irbt_cb_table_purse_merges (struct TALER_EXCHANGEDB_PostgresContext *pg,
1504 : const struct TALER_EXCHANGEDB_TableData *td)
1505 : {
1506 0 : struct GNUNET_PQ_QueryParam params[] = {
1507 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1508 0 : GNUNET_PQ_query_param_uint64 (&td->details.purse_merges.partner_serial_id),
1509 0 : GNUNET_PQ_query_param_auto_from_type (
1510 : &td->details.purse_merges.reserve_pub),
1511 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.purse_merges.purse_pub),
1512 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.purse_merges.merge_sig),
1513 0 : GNUNET_PQ_query_param_timestamp (&td->details.purse_merges.merge_timestamp),
1514 : GNUNET_PQ_query_param_end
1515 : };
1516 :
1517 0 : PREPARE (pg,
1518 : "insert_records_by_table_into_table_purse_merges",
1519 : "INSERT INTO purse_merges"
1520 : "(purse_merge_request_serial_id"
1521 : ",partner_serial_id"
1522 : ",reserve_pub"
1523 : ",purse_pub"
1524 : ",merge_sig"
1525 : ",merge_timestamp"
1526 : ") VALUES "
1527 : "($1, $2, $3, $4, $5, $6);");
1528 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1529 : "insert_records_by_table_into_table_purse_merges",
1530 : params);
1531 : }
1532 :
1533 :
1534 : /**
1535 : * Function called with purse_deposits records to insert into table.
1536 : *
1537 : * @param pg plugin context
1538 : * @param td record to insert
1539 : */
1540 : static enum GNUNET_DB_QueryStatus
1541 0 : irbt_cb_table_purse_deposits (struct TALER_EXCHANGEDB_PostgresContext *pg,
1542 : const struct TALER_EXCHANGEDB_TableData *td)
1543 : {
1544 0 : struct GNUNET_PQ_QueryParam params[] = {
1545 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1546 0 : GNUNET_PQ_query_param_uint64 (
1547 : &td->details.purse_deposits.partner_serial_id),
1548 0 : GNUNET_PQ_query_param_auto_from_type (
1549 : &td->details.purse_deposits.purse_pub),
1550 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.purse_deposits.coin_pub),
1551 0 : TALER_PQ_query_param_amount (
1552 0 : pg->conn,
1553 : &td->details.purse_deposits.amount_with_fee),
1554 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.purse_deposits.coin_sig),
1555 : GNUNET_PQ_query_param_end
1556 : };
1557 :
1558 0 : PREPARE (pg,
1559 : "insert_records_by_table_into_table_purse_deposits",
1560 : "INSERT INTO purse_deposits"
1561 : "(purse_deposit_serial_id"
1562 : ",partner_serial_id"
1563 : ",purse_pub"
1564 : ",coin_pub"
1565 : ",amount_with_fee"
1566 : ",coin_sig"
1567 : ") VALUES "
1568 : "($1, $2, $3, $4, $5, $6);");
1569 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1570 : "insert_records_by_table_into_table_purse_deposits",
1571 : params);
1572 : }
1573 :
1574 :
1575 : /**
1576 : x * Function called with account_mergers records to insert into table.
1577 : *
1578 : * @param pg plugin context
1579 : * @param td record to insert
1580 : */
1581 : static enum GNUNET_DB_QueryStatus
1582 0 : irbt_cb_table_account_mergers (struct TALER_EXCHANGEDB_PostgresContext *pg,
1583 : const struct TALER_EXCHANGEDB_TableData *td)
1584 : {
1585 0 : struct GNUNET_PQ_QueryParam params[] = {
1586 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1587 0 : GNUNET_PQ_query_param_auto_from_type (
1588 : &td->details.account_merges.reserve_pub),
1589 0 : GNUNET_PQ_query_param_auto_from_type (
1590 : &td->details.account_merges.reserve_sig),
1591 0 : GNUNET_PQ_query_param_auto_from_type (
1592 : &td->details.account_merges.purse_pub),
1593 0 : GNUNET_PQ_query_param_auto_from_type (
1594 : &td->details.account_merges.wallet_h_payto),
1595 : GNUNET_PQ_query_param_end
1596 : };
1597 :
1598 0 : PREPARE (pg,
1599 : "insert_records_by_table_into_table_account_merges",
1600 : "INSERT INTO account_merges"
1601 : "(account_merge_request_serial_id"
1602 : ",reserve_pub"
1603 : ",reserve_sig"
1604 : ",purse_pub"
1605 : ",wallet_h_payto"
1606 : ") VALUES "
1607 : "($1, $2, $3, $4, $5);");
1608 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1609 : "insert_records_by_table_into_table_account_merges",
1610 : params);
1611 : }
1612 :
1613 :
1614 : /**
1615 : * Function called with history_requests records to insert into table.
1616 : *
1617 : * @param pg plugin context
1618 : * @param td record to insert
1619 : */
1620 : static enum GNUNET_DB_QueryStatus
1621 0 : irbt_cb_table_history_requests (struct TALER_EXCHANGEDB_PostgresContext *pg,
1622 : const struct TALER_EXCHANGEDB_TableData *td)
1623 : {
1624 0 : struct GNUNET_PQ_QueryParam params[] = {
1625 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1626 0 : GNUNET_PQ_query_param_auto_from_type (
1627 : &td->details.history_requests.reserve_pub),
1628 0 : GNUNET_PQ_query_param_timestamp (
1629 : &td->details.history_requests.request_timestamp),
1630 0 : GNUNET_PQ_query_param_auto_from_type (
1631 : &td->details.history_requests.reserve_sig),
1632 0 : TALER_PQ_query_param_amount (
1633 0 : pg->conn,
1634 : &td->details.history_requests.history_fee),
1635 : GNUNET_PQ_query_param_end
1636 : };
1637 :
1638 0 : PREPARE (pg,
1639 : "insert_records_by_table_into_table_history_requests",
1640 : "INSERT INTO history_requests"
1641 : "(history_request_serial_id"
1642 : ",reserve_pub"
1643 : ",request_timestamp"
1644 : ",reserve_sig"
1645 : ",history_fee"
1646 : ") VALUES "
1647 : "($1, $2, $3, $4, $5);");
1648 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1649 : "insert_records_by_table_into_table_history_requests",
1650 : params);
1651 : }
1652 :
1653 :
1654 : /**
1655 : * Function called with close_requests records to insert into table.
1656 : *
1657 : * @param pg plugin context
1658 : * @param td record to insert
1659 : */
1660 : static enum GNUNET_DB_QueryStatus
1661 0 : irbt_cb_table_close_requests (struct TALER_EXCHANGEDB_PostgresContext *pg,
1662 : const struct TALER_EXCHANGEDB_TableData *td)
1663 : {
1664 0 : struct GNUNET_PQ_QueryParam params[] = {
1665 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1666 0 : GNUNET_PQ_query_param_auto_from_type (
1667 : &td->details.close_requests.reserve_pub),
1668 0 : GNUNET_PQ_query_param_timestamp (
1669 : &td->details.close_requests.close_timestamp),
1670 0 : GNUNET_PQ_query_param_auto_from_type (
1671 : &td->details.close_requests.reserve_sig),
1672 0 : TALER_PQ_query_param_amount (
1673 0 : pg->conn,
1674 : &td->details.close_requests.close),
1675 0 : TALER_PQ_query_param_amount (
1676 0 : pg->conn,
1677 : &td->details.close_requests.close_fee),
1678 0 : GNUNET_PQ_query_param_string (
1679 0 : td->details.close_requests.payto_uri.full_payto),
1680 : GNUNET_PQ_query_param_end
1681 : };
1682 :
1683 0 : PREPARE (pg,
1684 : "insert_records_by_table_into_table_close_requests",
1685 : "INSERT INTO close_requests"
1686 : "(close_request_serial_id"
1687 : ",reserve_pub"
1688 : ",close_timestamp"
1689 : ",reserve_sig"
1690 : ",close"
1691 : ",close_fee"
1692 : ",payto_uri"
1693 : ") VALUES "
1694 : "($1, $2, $3, $4, $5, $6, $7);");
1695 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1696 : "insert_records_by_table_into_table_close_requests",
1697 : params);
1698 : }
1699 :
1700 :
1701 : /**
1702 : * Function called with wads_out records to insert into table.
1703 : *
1704 : * @param pg plugin context
1705 : * @param td record to insert
1706 : */
1707 : static enum GNUNET_DB_QueryStatus
1708 0 : irbt_cb_table_wads_out (struct TALER_EXCHANGEDB_PostgresContext *pg,
1709 : const struct TALER_EXCHANGEDB_TableData *td)
1710 : {
1711 0 : struct GNUNET_PQ_QueryParam params[] = {
1712 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1713 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.wads_out.wad_id),
1714 0 : GNUNET_PQ_query_param_uint64 (&td->details.wads_out.partner_serial_id),
1715 0 : TALER_PQ_query_param_amount (
1716 0 : pg->conn,
1717 : &td->details.wads_out.amount),
1718 0 : GNUNET_PQ_query_param_timestamp (&td->details.wads_out.execution_time),
1719 : GNUNET_PQ_query_param_end
1720 : };
1721 :
1722 0 : PREPARE (pg,
1723 : "insert_records_by_table_into_table_wads_out",
1724 : "INSERT INTO wads_out"
1725 : "(wad_out_serial_id"
1726 : ",wad_id"
1727 : ",partner_serial_id"
1728 : ",amount"
1729 : ",execution_time"
1730 : ") VALUES "
1731 : "($1, $2, $3, $4, $5);");
1732 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1733 : "insert_records_by_table_into_table_wads_out",
1734 : params);
1735 : }
1736 :
1737 :
1738 : /**
1739 : * Function called with wads_out_entries records to insert into table.
1740 : *
1741 : * @param pg plugin context
1742 : * @param td record to insert
1743 : */
1744 : static enum GNUNET_DB_QueryStatus
1745 0 : irbt_cb_table_wads_out_entries (struct TALER_EXCHANGEDB_PostgresContext *pg,
1746 : const struct TALER_EXCHANGEDB_TableData *td)
1747 : {
1748 0 : struct GNUNET_PQ_QueryParam params[] = {
1749 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1750 0 : GNUNET_PQ_query_param_uint64 (
1751 : &td->details.wads_out_entries.wad_out_serial_id),
1752 0 : GNUNET_PQ_query_param_auto_from_type (
1753 : &td->details.wads_out_entries.reserve_pub),
1754 0 : GNUNET_PQ_query_param_auto_from_type (
1755 : &td->details.wads_out_entries.purse_pub),
1756 0 : GNUNET_PQ_query_param_auto_from_type (
1757 : &td->details.wads_out_entries.h_contract),
1758 0 : GNUNET_PQ_query_param_timestamp (
1759 : &td->details.wads_out_entries.purse_expiration),
1760 0 : GNUNET_PQ_query_param_timestamp (
1761 : &td->details.wads_out_entries.merge_timestamp),
1762 0 : TALER_PQ_query_param_amount (
1763 0 : pg->conn,
1764 : &td->details.wads_out_entries.amount_with_fee),
1765 0 : TALER_PQ_query_param_amount (
1766 0 : pg->conn,
1767 : &td->details.wads_out_entries.wad_fee),
1768 0 : TALER_PQ_query_param_amount (
1769 0 : pg->conn,
1770 : &td->details.wads_out_entries.deposit_fees),
1771 0 : GNUNET_PQ_query_param_auto_from_type (
1772 : &td->details.wads_out_entries.reserve_sig),
1773 0 : GNUNET_PQ_query_param_auto_from_type (
1774 : &td->details.wads_out_entries.purse_sig),
1775 : GNUNET_PQ_query_param_end
1776 : };
1777 :
1778 0 : PREPARE (pg,
1779 : "insert_records_by_table_into_table_wad_out_entries",
1780 : "INSERT INTO wad_out_entries"
1781 : "(wad_out_entry_serial_id"
1782 : ",wad_out_serial_id"
1783 : ",reserve_pub"
1784 : ",purse_pub"
1785 : ",h_contract"
1786 : ",purse_expiration"
1787 : ",merge_timestamp"
1788 : ",amount_with_fee"
1789 : ",wad_fee"
1790 : ",deposit_fees"
1791 : ",reserve_sig"
1792 : ",purse_sig"
1793 : ") VALUES "
1794 : "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);");
1795 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1796 : "insert_records_by_table_into_table_wad_out_entries",
1797 : params);
1798 : }
1799 :
1800 :
1801 : /**
1802 : * Function called with wads_in records to insert into table.
1803 : *
1804 : * @param pg plugin context
1805 : * @param td record to insert
1806 : */
1807 : static enum GNUNET_DB_QueryStatus
1808 0 : irbt_cb_table_wads_in (struct TALER_EXCHANGEDB_PostgresContext *pg,
1809 : const struct TALER_EXCHANGEDB_TableData *td)
1810 : {
1811 0 : struct GNUNET_PQ_QueryParam params[] = {
1812 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1813 0 : GNUNET_PQ_query_param_auto_from_type (&td->details.wads_in.wad_id),
1814 0 : GNUNET_PQ_query_param_string (td->details.wads_in.origin_exchange_url),
1815 0 : TALER_PQ_query_param_amount (
1816 0 : pg->conn,
1817 : &td->details.wads_in.amount),
1818 0 : GNUNET_PQ_query_param_timestamp (&td->details.wads_in.arrival_time),
1819 : GNUNET_PQ_query_param_end
1820 : };
1821 :
1822 0 : PREPARE (pg,
1823 : "insert_records_by_table_into_table_wads_in",
1824 : "INSERT INTO wads_in"
1825 : "(wad_in_serial_id"
1826 : ",wad_id"
1827 : ",origin_exchange_url"
1828 : ",amount"
1829 : ",arrival_time"
1830 : ") VALUES "
1831 : "($1, $2, $3, $4, $5);");
1832 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1833 : "insert_records_by_table_into_table_wads_in",
1834 : params);
1835 : }
1836 :
1837 :
1838 : /**
1839 : * Function called with wads_in_entries records to insert into table.
1840 : *
1841 : * @param pg plugin context
1842 : * @param td record to insert
1843 : */
1844 : static enum GNUNET_DB_QueryStatus
1845 0 : irbt_cb_table_wads_in_entries (struct TALER_EXCHANGEDB_PostgresContext *pg,
1846 : const struct TALER_EXCHANGEDB_TableData *td)
1847 : {
1848 0 : struct GNUNET_PQ_QueryParam params[] = {
1849 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1850 0 : GNUNET_PQ_query_param_uint64 (
1851 : &td->details.wads_in_entries.wad_in_serial_id),
1852 0 : GNUNET_PQ_query_param_auto_from_type (
1853 : &td->details.wads_in_entries.reserve_pub),
1854 0 : GNUNET_PQ_query_param_auto_from_type (
1855 : &td->details.wads_in_entries.purse_pub),
1856 0 : GNUNET_PQ_query_param_auto_from_type (
1857 : &td->details.wads_in_entries.h_contract),
1858 0 : GNUNET_PQ_query_param_timestamp (
1859 : &td->details.wads_in_entries.purse_expiration),
1860 0 : GNUNET_PQ_query_param_timestamp (
1861 : &td->details.wads_in_entries.merge_timestamp),
1862 0 : TALER_PQ_query_param_amount (
1863 0 : pg->conn,
1864 : &td->details.wads_in_entries.amount_with_fee),
1865 0 : TALER_PQ_query_param_amount (
1866 0 : pg->conn,
1867 : &td->details.wads_in_entries.wad_fee),
1868 0 : TALER_PQ_query_param_amount (
1869 0 : pg->conn,
1870 : &td->details.wads_in_entries.deposit_fees),
1871 0 : GNUNET_PQ_query_param_auto_from_type (
1872 : &td->details.wads_in_entries.reserve_sig),
1873 0 : GNUNET_PQ_query_param_auto_from_type (
1874 : &td->details.wads_in_entries.purse_sig),
1875 : GNUNET_PQ_query_param_end
1876 : };
1877 :
1878 0 : PREPARE (pg,
1879 : "insert_records_by_table_into_table_wad_in_entries",
1880 : "INSERT INTO wad_in_entries"
1881 : "(wad_in_entry_serial_id"
1882 : ",wad_in_serial_id"
1883 : ",reserve_pub"
1884 : ",purse_pub"
1885 : ",h_contract"
1886 : ",purse_expiration"
1887 : ",merge_timestamp"
1888 : ",amount_with_fee"
1889 : ",wad_fee"
1890 : ",deposit_fees"
1891 : ",reserve_sig"
1892 : ",purse_sig"
1893 : ") VALUES "
1894 : "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);");
1895 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1896 : "insert_records_by_table_into_table_wad_in_entries",
1897 : params);
1898 : }
1899 :
1900 :
1901 : /**
1902 : * Function called with profit_drains records to insert into table.
1903 : *
1904 : * @param pg plugin context
1905 : * @param td record to insert
1906 : */
1907 : static enum GNUNET_DB_QueryStatus
1908 0 : irbt_cb_table_profit_drains (struct TALER_EXCHANGEDB_PostgresContext *pg,
1909 : const struct TALER_EXCHANGEDB_TableData *td)
1910 : {
1911 0 : struct GNUNET_PQ_QueryParam params[] = {
1912 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1913 0 : GNUNET_PQ_query_param_auto_from_type (
1914 : &td->details.profit_drains.wtid),
1915 0 : GNUNET_PQ_query_param_string (
1916 0 : td->details.profit_drains.account_section),
1917 0 : GNUNET_PQ_query_param_string (
1918 0 : td->details.profit_drains.payto_uri.full_payto),
1919 0 : GNUNET_PQ_query_param_timestamp (
1920 : &td->details.profit_drains.trigger_date),
1921 0 : TALER_PQ_query_param_amount (
1922 0 : pg->conn,
1923 : &td->details.profit_drains.amount),
1924 0 : GNUNET_PQ_query_param_auto_from_type (
1925 : &td->details.profit_drains.master_sig),
1926 : GNUNET_PQ_query_param_end
1927 : };
1928 :
1929 0 : PREPARE (pg,
1930 : "insert_records_by_table_into_table_profit_drains",
1931 : "INSERT INTO profit_drains"
1932 : "(profit_drain_serial_id"
1933 : ",wtid"
1934 : ",account_section"
1935 : ",payto_uri"
1936 : ",trigger_date"
1937 : ",amount"
1938 : ",master_sig"
1939 : ") VALUES "
1940 : "($1, $2, $3, $4, $5, $6, $7);");
1941 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1942 : "insert_records_by_table_into_table_profit_drains",
1943 : params);
1944 : }
1945 :
1946 :
1947 : /**
1948 : * Function called with aml_staff records to insert into table.
1949 : *
1950 : * @param pg plugin context
1951 : * @param td record to insert
1952 : */
1953 : static enum GNUNET_DB_QueryStatus
1954 0 : irbt_cb_table_aml_staff (struct TALER_EXCHANGEDB_PostgresContext *pg,
1955 : const struct TALER_EXCHANGEDB_TableData *td)
1956 : {
1957 0 : struct GNUNET_PQ_QueryParam params[] = {
1958 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
1959 0 : GNUNET_PQ_query_param_auto_from_type (
1960 : &td->details.aml_staff.decider_pub),
1961 0 : GNUNET_PQ_query_param_auto_from_type (
1962 : &td->details.aml_staff.master_sig),
1963 0 : GNUNET_PQ_query_param_string (
1964 0 : td->details.aml_staff.decider_name),
1965 0 : GNUNET_PQ_query_param_bool (
1966 0 : td->details.aml_staff.is_active),
1967 0 : GNUNET_PQ_query_param_bool (
1968 0 : td->details.aml_staff.read_only),
1969 0 : GNUNET_PQ_query_param_timestamp (
1970 : &td->details.aml_staff.last_change),
1971 : GNUNET_PQ_query_param_end
1972 : };
1973 :
1974 0 : PREPARE (pg,
1975 : "insert_records_by_table_into_table_aml_staff",
1976 : "INSERT INTO aml_staff"
1977 : "(aml_staff_uuid"
1978 : ",decider_pub"
1979 : ",master_sig"
1980 : ",decider_name"
1981 : ",is_active"
1982 : ",read_only"
1983 : ",last_change"
1984 : ") VALUES "
1985 : "($1, $2, $3, $4, $5, $6, $7);");
1986 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
1987 : "insert_records_by_table_into_table_aml_staff",
1988 : params);
1989 : }
1990 :
1991 :
1992 : /**
1993 : * Function called with kyc_attributes records to insert into table.
1994 : *
1995 : * @param pg plugin context
1996 : * @param td record to insert
1997 : */
1998 : static enum GNUNET_DB_QueryStatus
1999 0 : irbt_cb_table_kyc_attributes (struct TALER_EXCHANGEDB_PostgresContext *pg,
2000 : const struct TALER_EXCHANGEDB_TableData *td)
2001 : {
2002 0 : struct GNUNET_PQ_QueryParam params[] = {
2003 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
2004 0 : GNUNET_PQ_query_param_auto_from_type (
2005 : &td->details.kyc_attributes.h_payto),
2006 0 : GNUNET_PQ_query_param_uint64 (
2007 : &td->details.kyc_attributes.legitimization_serial),
2008 0 : GNUNET_PQ_query_param_timestamp (
2009 : &td->details.kyc_attributes.collection_time),
2010 0 : GNUNET_PQ_query_param_timestamp (
2011 : &td->details.kyc_attributes.expiration_time),
2012 0 : NULL == td->details.kyc_attributes.form_name
2013 0 : ? GNUNET_PQ_query_param_null ()
2014 0 : : GNUNET_PQ_query_param_string (
2015 0 : td->details.kyc_attributes.form_name),
2016 0 : GNUNET_PQ_query_param_bool (
2017 0 : td->details.kyc_attributes.by_aml_officer),
2018 0 : GNUNET_PQ_query_param_fixed_size (
2019 0 : td->details.kyc_attributes.encrypted_attributes,
2020 0 : td->details.kyc_attributes.encrypted_attributes_size),
2021 : GNUNET_PQ_query_param_end
2022 : };
2023 :
2024 0 : PREPARE (pg,
2025 : "insert_records_by_table_into_table_kyc_attributes",
2026 : "INSERT INTO kyc_attributes"
2027 : "(kyc_attributes_serial_id"
2028 : ",h_payto"
2029 : ",legitimization_serial"
2030 : ",collection_time"
2031 : ",expiration_time"
2032 : ",form_name"
2033 : ",by_aml_officer"
2034 : ",encrypted_attributes"
2035 : ") VALUES "
2036 : "($1, $2, $3, $4, $5, $6, $7, $8);");
2037 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
2038 : "insert_records_by_table_into_table_kyc_attributes",
2039 : params);
2040 : }
2041 :
2042 :
2043 : /**
2044 : * Function called with aml_history records to insert into table.
2045 : *
2046 : * @param pg plugin context
2047 : * @param td record to insert
2048 : */
2049 : static enum GNUNET_DB_QueryStatus
2050 0 : irbt_cb_table_aml_history (struct TALER_EXCHANGEDB_PostgresContext *pg,
2051 : const struct TALER_EXCHANGEDB_TableData *td)
2052 : {
2053 0 : struct GNUNET_PQ_QueryParam params[] = {
2054 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
2055 0 : GNUNET_PQ_query_param_auto_from_type (
2056 : &td->details.aml_history.h_payto),
2057 0 : GNUNET_PQ_query_param_uint64 (
2058 : &td->details.aml_history.outcome_serial_id),
2059 0 : GNUNET_PQ_query_param_string (
2060 0 : td->details.aml_history.justification),
2061 0 : GNUNET_PQ_query_param_auto_from_type (
2062 : &td->details.aml_history.decider_pub),
2063 0 : GNUNET_PQ_query_param_auto_from_type (
2064 : &td->details.aml_history.decider_sig),
2065 0 : td->details.aml_history.no_kyc_attributes_hash
2066 0 : ? GNUNET_PQ_query_param_null ()
2067 0 : : GNUNET_PQ_query_param_auto_from_type (
2068 : &td->details.aml_history.kyc_attributes_hash),
2069 0 : td->details.aml_history.no_kyc_attributes_serial_id
2070 0 : ? GNUNET_PQ_query_param_null ()
2071 0 : : GNUNET_PQ_query_param_uint64 (
2072 : &td->details.aml_history.kyc_attributes_serial_id),
2073 : GNUNET_PQ_query_param_end
2074 : };
2075 :
2076 0 : PREPARE (pg,
2077 : "insert_records_by_table_into_table_aml_history",
2078 : "INSERT INTO aml_history"
2079 : "(aml_history_serial_id"
2080 : ",h_payto"
2081 : ",outcome_serial_id"
2082 : ",justification"
2083 : ",decider_pub"
2084 : ",decider_sig"
2085 : ",kyc_attributes_hash"
2086 : ",kyc_attributes_serial_id"
2087 : ") VALUES "
2088 : "($1, $2, $3, $4, $5, $6, $7, $8);");
2089 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
2090 : "insert_records_by_table_into_table_aml_history",
2091 : params);
2092 : }
2093 :
2094 :
2095 : /**
2096 : * Function called with kyc_event records to insert into table.
2097 : *
2098 : * @param pg plugin context
2099 : * @param td record to insert
2100 : */
2101 : static enum GNUNET_DB_QueryStatus
2102 0 : irbt_cb_table_kyc_events (struct TALER_EXCHANGEDB_PostgresContext *pg,
2103 : const struct TALER_EXCHANGEDB_TableData *td)
2104 : {
2105 0 : struct GNUNET_PQ_QueryParam params[] = {
2106 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
2107 0 : GNUNET_PQ_query_param_timestamp (
2108 : &td->details.kyc_events.event_timestamp),
2109 0 : GNUNET_PQ_query_param_string (
2110 0 : td->details.kyc_events.event_type),
2111 : GNUNET_PQ_query_param_end
2112 : };
2113 :
2114 0 : PREPARE (pg,
2115 : "insert_records_by_table_into_table_kyc_events",
2116 : "INSERT INTO kyc_events"
2117 : "(kyc_event_serial_id"
2118 : ",event_timestamp"
2119 : ",event_type"
2120 : ") VALUES "
2121 : "($1, $2, $3);");
2122 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
2123 : "insert_records_by_table_into_table_kyc_events",
2124 : params);
2125 : }
2126 :
2127 :
2128 : /**
2129 : * Function called with purse_deletion records to insert into table.
2130 : *
2131 : * @param pg plugin context
2132 : * @param td record to insert
2133 : */
2134 : static enum GNUNET_DB_QueryStatus
2135 0 : irbt_cb_table_purse_deletion (struct TALER_EXCHANGEDB_PostgresContext *pg,
2136 : const struct TALER_EXCHANGEDB_TableData *td)
2137 : {
2138 0 : struct GNUNET_PQ_QueryParam params[] = {
2139 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
2140 0 : GNUNET_PQ_query_param_auto_from_type (
2141 : &td->details.purse_deletion.purse_pub),
2142 0 : GNUNET_PQ_query_param_auto_from_type (
2143 : &td->details.purse_deletion.purse_sig),
2144 : GNUNET_PQ_query_param_end
2145 : };
2146 :
2147 0 : PREPARE (pg,
2148 : "insert_records_by_table_into_table_purse_deletion",
2149 : "INSERT INTO purse_deletion"
2150 : "(purse_deletion_serial_id"
2151 : ",purse_pub"
2152 : ",purse_sig"
2153 : ") VALUES "
2154 : "($1, $2, $3);");
2155 0 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
2156 : "insert_records_by_table_into_table_purse_deletion",
2157 : params);
2158 : }
2159 :
2160 :
2161 : /**
2162 : * Function called with withdraw records to insert into table.
2163 : *
2164 : * @param pg plugin context
2165 : * @param td record to insert
2166 : */
2167 : static enum GNUNET_DB_QueryStatus
2168 0 : irbt_cb_table_withdraw (
2169 : struct TALER_EXCHANGEDB_PostgresContext *pg,
2170 : const struct TALER_EXCHANGEDB_TableData *td)
2171 : {
2172 0 : struct GNUNET_PQ_QueryParam params[] = {
2173 0 : GNUNET_PQ_query_param_uint64 (&td->serial),
2174 0 : GNUNET_PQ_query_param_auto_from_type (
2175 : &td->details.withdraw.planchets_h),
2176 0 : GNUNET_PQ_query_param_timestamp (
2177 : &td->details.withdraw.execution_date),
2178 0 : TALER_PQ_query_param_amount (
2179 0 : pg->conn,
2180 : &td->details.withdraw.amount_with_fee),
2181 0 : GNUNET_PQ_query_param_auto_from_type (
2182 : &td->details.withdraw.reserve_pub),
2183 0 : GNUNET_PQ_query_param_auto_from_type (
2184 : &td->details.withdraw.reserve_sig),
2185 0 : td->details.withdraw.age_proof_required
2186 0 : ? GNUNET_PQ_query_param_uint16 (
2187 : &td->details.withdraw.max_age)
2188 0 : : GNUNET_PQ_query_param_null (),
2189 0 : td->details.withdraw.age_proof_required
2190 0 : ? GNUNET_PQ_query_param_uint16 (
2191 : &td->details.withdraw.noreveal_index)
2192 0 : : GNUNET_PQ_query_param_null (),
2193 0 : td->details.withdraw.age_proof_required
2194 0 : ? GNUNET_PQ_query_param_auto_from_type (
2195 : &td->details.withdraw.selected_h)
2196 0 : : GNUNET_PQ_query_param_null (),
2197 0 : td->details.withdraw.no_blinding_seed
2198 0 : ? GNUNET_PQ_query_param_null ()
2199 0 : : GNUNET_PQ_query_param_auto_from_type (
2200 : &td->details.withdraw.blinding_seed),
2201 0 : (0 < td->details.withdraw.num_cs_r_values)
2202 0 : ? TALER_PQ_query_param_array_cs_r_pub (
2203 0 : td->details.withdraw.num_cs_r_values,
2204 0 : td->details.withdraw.cs_r_values,
2205 : pg->conn)
2206 0 : : GNUNET_PQ_query_param_null (),
2207 0 : (0 < td->details.withdraw.num_cs_r_values)
2208 0 : ? GNUNET_PQ_query_param_uint64 (
2209 : &td->details.withdraw.cs_r_choices)
2210 0 : : GNUNET_PQ_query_param_null (),
2211 0 : GNUNET_PQ_query_param_array_uint64 (
2212 0 : td->details.withdraw.num_coins,
2213 0 : td->details.withdraw.denom_serials,
2214 : pg->conn),
2215 0 : TALER_PQ_query_param_array_blinded_denom_sig (
2216 0 : td->details.withdraw.num_coins,
2217 0 : td->details.withdraw.denom_sigs,
2218 : pg->conn),
2219 : GNUNET_PQ_query_param_end
2220 : };
2221 : enum GNUNET_DB_QueryStatus qs;
2222 :
2223 0 : PREPARE (pg,
2224 : "insert_records_by_table_into_table_withdraw",
2225 : "INSERT INTO withdraw"
2226 : "(withdraw_id"
2227 : ",planchets_h"
2228 : ",execution_date"
2229 : ",amount_with_fee"
2230 : ",reserve_pub"
2231 : ",reserve_sig"
2232 : ",max_age"
2233 : ",noreveal_index"
2234 : ",selected_h"
2235 : ",blinding_seed"
2236 : ",cs_r_values"
2237 : ",cs_r_choices"
2238 : ",denom_serials"
2239 : ",denom_sigs"
2240 : ") VALUES "
2241 : "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14);");
2242 0 : qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
2243 : "insert_records_by_table_into_table_withdraw",
2244 : params);
2245 0 : GNUNET_PQ_cleanup_query_params_closures (params);
2246 0 : return qs;
2247 : }
2248 :
2249 :
2250 : enum GNUNET_DB_QueryStatus
2251 5 : TALER_EXCHANGEDB_insert_records_by_table (
2252 : struct TALER_EXCHANGEDB_PostgresContext *pg,
2253 : const struct TALER_EXCHANGEDB_TableData *td)
2254 : {
2255 5 : InsertRecordCallback rh = NULL;
2256 :
2257 5 : switch (td->table)
2258 : {
2259 0 : case TALER_EXCHANGEDB_RT_DENOMINATIONS:
2260 0 : rh = &irbt_cb_table_denominations;
2261 0 : break;
2262 0 : case TALER_EXCHANGEDB_RT_DENOMINATION_REVOCATIONS:
2263 0 : rh = &irbt_cb_table_denomination_revocations;
2264 0 : break;
2265 1 : case TALER_EXCHANGEDB_RT_WIRE_TARGETS:
2266 1 : rh = &irbt_cb_table_wire_targets;
2267 1 : break;
2268 0 : case TALER_EXCHANGEDB_RT_KYC_TARGETS:
2269 0 : rh = &irbt_cb_table_kyc_targets;
2270 0 : break;
2271 0 : case TALER_EXCHANGEDB_RT_RESERVES:
2272 0 : rh = &irbt_cb_table_reserves;
2273 0 : break;
2274 0 : case TALER_EXCHANGEDB_RT_RESERVES_IN:
2275 0 : rh = &irbt_cb_table_reserves_in;
2276 0 : break;
2277 0 : case TALER_EXCHANGEDB_RT_KYCAUTHS_IN:
2278 0 : rh = &irbt_cb_table_kycauths_in;
2279 0 : break;
2280 0 : case TALER_EXCHANGEDB_RT_RESERVES_CLOSE:
2281 0 : rh = &irbt_cb_table_reserves_close;
2282 0 : break;
2283 0 : case TALER_EXCHANGEDB_RT_RESERVES_OPEN_REQUESTS:
2284 0 : rh = &irbt_cb_table_reserves_open_requests;
2285 0 : break;
2286 0 : case TALER_EXCHANGEDB_RT_RESERVES_OPEN_DEPOSITS:
2287 0 : rh = &irbt_cb_table_reserves_open_deposits;
2288 0 : break;
2289 0 : case TALER_EXCHANGEDB_RT_AUDITORS:
2290 0 : rh = &irbt_cb_table_auditors;
2291 0 : break;
2292 0 : case TALER_EXCHANGEDB_RT_AUDITOR_DENOM_SIGS:
2293 0 : rh = &irbt_cb_table_auditor_denom_sigs;
2294 0 : break;
2295 0 : case TALER_EXCHANGEDB_RT_EXCHANGE_SIGN_KEYS:
2296 0 : rh = &irbt_cb_table_exchange_sign_keys;
2297 0 : break;
2298 0 : case TALER_EXCHANGEDB_RT_SIGNKEY_REVOCATIONS:
2299 0 : rh = &irbt_cb_table_signkey_revocations;
2300 0 : break;
2301 0 : case TALER_EXCHANGEDB_RT_KNOWN_COINS:
2302 0 : rh = &irbt_cb_table_known_coins;
2303 0 : break;
2304 1 : case TALER_EXCHANGEDB_RT_REFRESH:
2305 1 : rh = &irbt_cb_table_refresh;
2306 1 : break;
2307 0 : case TALER_EXCHANGEDB_RT_BATCH_DEPOSITS:
2308 0 : rh = &irbt_cb_table_batch_deposits;
2309 0 : break;
2310 0 : case TALER_EXCHANGEDB_RT_COIN_DEPOSITS:
2311 0 : rh = &irbt_cb_table_coin_deposits;
2312 0 : break;
2313 0 : case TALER_EXCHANGEDB_RT_REFUNDS:
2314 0 : rh = &irbt_cb_table_refunds;
2315 0 : break;
2316 0 : case TALER_EXCHANGEDB_RT_WIRE_OUT:
2317 0 : rh = &irbt_cb_table_wire_out;
2318 0 : break;
2319 0 : case TALER_EXCHANGEDB_RT_AGGREGATION_TRACKING:
2320 0 : rh = &irbt_cb_table_aggregation_tracking;
2321 0 : break;
2322 0 : case TALER_EXCHANGEDB_RT_AGGREGATION_DEFERRALS:
2323 0 : rh = &irbt_cb_table_aggregation_deferrals;
2324 0 : break;
2325 0 : case TALER_EXCHANGEDB_RT_WIRE_FEE:
2326 0 : rh = &irbt_cb_table_wire_fee;
2327 0 : break;
2328 0 : case TALER_EXCHANGEDB_RT_GLOBAL_FEE:
2329 0 : rh = &irbt_cb_table_global_fee;
2330 0 : break;
2331 1 : case TALER_EXCHANGEDB_RT_RECOUP:
2332 1 : rh = &irbt_cb_table_recoup;
2333 1 : break;
2334 1 : case TALER_EXCHANGEDB_RT_RECOUP_REFRESH:
2335 1 : rh = &irbt_cb_table_recoup_refresh;
2336 1 : break;
2337 0 : case TALER_EXCHANGEDB_RT_PURSE_REQUESTS:
2338 0 : rh = &irbt_cb_table_purse_requests;
2339 0 : break;
2340 0 : case TALER_EXCHANGEDB_RT_PURSE_DECISION:
2341 0 : rh = &irbt_cb_table_purse_decision;
2342 0 : break;
2343 0 : case TALER_EXCHANGEDB_RT_PURSE_MERGES:
2344 0 : rh = &irbt_cb_table_purse_merges;
2345 0 : break;
2346 0 : case TALER_EXCHANGEDB_RT_PURSE_DEPOSITS:
2347 0 : rh = &irbt_cb_table_purse_deposits;
2348 0 : break;
2349 0 : case TALER_EXCHANGEDB_RT_ACCOUNT_MERGES:
2350 0 : rh = &irbt_cb_table_account_mergers;
2351 0 : break;
2352 0 : case TALER_EXCHANGEDB_RT_HISTORY_REQUESTS:
2353 0 : rh = &irbt_cb_table_history_requests;
2354 0 : break;
2355 0 : case TALER_EXCHANGEDB_RT_CLOSE_REQUESTS:
2356 0 : rh = &irbt_cb_table_close_requests;
2357 0 : break;
2358 0 : case TALER_EXCHANGEDB_RT_WADS_OUT:
2359 0 : rh = &irbt_cb_table_wads_out;
2360 0 : break;
2361 0 : case TALER_EXCHANGEDB_RT_WADS_OUT_ENTRIES:
2362 0 : rh = &irbt_cb_table_wads_out_entries;
2363 0 : break;
2364 0 : case TALER_EXCHANGEDB_RT_WADS_IN:
2365 0 : rh = &irbt_cb_table_wads_in;
2366 0 : break;
2367 0 : case TALER_EXCHANGEDB_RT_WADS_IN_ENTRIES:
2368 0 : rh = &irbt_cb_table_wads_in_entries;
2369 0 : break;
2370 0 : case TALER_EXCHANGEDB_RT_PROFIT_DRAINS:
2371 0 : rh = &irbt_cb_table_profit_drains;
2372 0 : break;
2373 0 : case TALER_EXCHANGEDB_RT_AML_STAFF:
2374 0 : rh = &irbt_cb_table_aml_staff;
2375 0 : break;
2376 0 : case TALER_EXCHANGEDB_RT_PURSE_DELETION:
2377 0 : rh = &irbt_cb_table_purse_deletion;
2378 0 : break;
2379 0 : case TALER_EXCHANGEDB_RT_WITHDRAW:
2380 0 : rh = &irbt_cb_table_withdraw;
2381 0 : break;
2382 0 : case TALER_EXCHANGEDB_RT_LEGITIMIZATION_MEASURES:
2383 0 : rh = &irbt_cb_table_legitimization_measures;
2384 0 : break;
2385 0 : case TALER_EXCHANGEDB_RT_LEGITIMIZATION_OUTCOMES:
2386 0 : rh = &irbt_cb_table_legitimization_outcomes;
2387 0 : break;
2388 0 : case TALER_EXCHANGEDB_RT_LEGITIMIZATION_PROCESSES:
2389 0 : rh = &irbt_cb_table_legitimization_processes;
2390 0 : break;
2391 0 : case TALER_EXCHANGEDB_RT_KYC_ATTRIBUTES:
2392 0 : rh = &irbt_cb_table_kyc_attributes;
2393 0 : break;
2394 0 : case TALER_EXCHANGEDB_RT_AML_HISTORY:
2395 0 : rh = &irbt_cb_table_aml_history;
2396 0 : break;
2397 0 : case TALER_EXCHANGEDB_RT_KYC_EVENTS:
2398 0 : rh = &irbt_cb_table_kyc_events;
2399 0 : break;
2400 : }
2401 5 : if (NULL == rh)
2402 : {
2403 1 : GNUNET_break (0);
2404 1 : return GNUNET_DB_STATUS_HARD_ERROR;
2405 : }
2406 4 : return rh (pg,
2407 : td);
2408 : }
2409 :
2410 :
2411 : /* end of insert_records_by_table.c */
|