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/iterate_records_by_table.c
22 : * @brief implementation of lookup_records_by_table
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/iterate_records_by_table.h"
30 : #include "helper.h"
31 : #include <gnunet/gnunet_pq_lib.h>
32 :
33 :
34 : /**
35 : * Closure for callbacks used by #postgres_lookup_records_by_table.
36 : */
37 : struct LookupRecordsByTableContext
38 : {
39 : /**
40 : * Plugin context.
41 : */
42 : struct TALER_EXCHANGEDB_PostgresContext *pg;
43 :
44 : /**
45 : * Function to call with the results.
46 : */
47 : TALER_EXCHANGEDB_ReplicationCallback cb;
48 :
49 : /**
50 : * Closure for @a cb.
51 : */
52 : void *cb_cls;
53 :
54 : /**
55 : * Set to true on errors.
56 : */
57 : bool error;
58 : };
59 :
60 :
61 : /**
62 : * Function called with denominations table entries.
63 : *
64 : * @param cls closure
65 : * @param result the postgres result
66 : * @param num_results the number of results in @a result
67 : */
68 : static void
69 3 : lrbt_cb_table_denominations (void *cls,
70 : PGresult *result,
71 : unsigned int num_results)
72 : {
73 3 : struct LookupRecordsByTableContext *ctx = cls;
74 3 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
75 3 : struct TALER_EXCHANGEDB_TableData td = {
76 : .table = TALER_EXCHANGEDB_RT_DENOMINATIONS
77 : };
78 :
79 4 : for (unsigned int i = 0; i<num_results; i++)
80 : {
81 1 : struct GNUNET_PQ_ResultSpec rs[] = {
82 1 : GNUNET_PQ_result_spec_uint64 (
83 : "serial",
84 : &td.serial),
85 1 : GNUNET_PQ_result_spec_uint32 (
86 : "denom_type",
87 : &td.details.denominations.denom_type),
88 1 : GNUNET_PQ_result_spec_uint32 (
89 : "age_mask",
90 : &td.details.denominations.age_mask),
91 1 : TALER_PQ_result_spec_denom_pub (
92 : "denom_pub",
93 : &td.details.denominations.denom_pub),
94 1 : GNUNET_PQ_result_spec_auto_from_type (
95 : "master_sig",
96 : &td.details.denominations.master_sig),
97 1 : GNUNET_PQ_result_spec_timestamp (
98 : "valid_from",
99 : &td.details.denominations.valid_from),
100 1 : GNUNET_PQ_result_spec_timestamp (
101 : "expire_withdraw",
102 : &td.details.denominations.
103 : expire_withdraw),
104 1 : GNUNET_PQ_result_spec_timestamp (
105 : "expire_deposit",
106 : &td.details.denominations.
107 : expire_deposit),
108 1 : GNUNET_PQ_result_spec_timestamp (
109 : "expire_legal",
110 : &td.details.denominations.expire_legal),
111 1 : TALER_PQ_RESULT_SPEC_AMOUNT (
112 : "coin",
113 : &td.details.denominations.coin),
114 1 : TALER_PQ_RESULT_SPEC_AMOUNT (
115 : "fee_withdraw",
116 : &td.details.denominations.fees.withdraw),
117 1 : TALER_PQ_RESULT_SPEC_AMOUNT (
118 : "fee_deposit",
119 : &td.details.denominations.fees.deposit),
120 1 : TALER_PQ_RESULT_SPEC_AMOUNT (
121 : "fee_refresh",
122 : &td.details.denominations.fees.refresh),
123 1 : TALER_PQ_RESULT_SPEC_AMOUNT (
124 : "fee_refund",
125 : &td.details.denominations.fees.refund),
126 : GNUNET_PQ_result_spec_end
127 : };
128 :
129 1 : if (GNUNET_OK !=
130 1 : GNUNET_PQ_extract_result (result,
131 : rs,
132 : i))
133 : {
134 0 : GNUNET_break (0);
135 0 : ctx->error = true;
136 0 : return;
137 : }
138 1 : ctx->cb (ctx->cb_cls,
139 : &td);
140 1 : GNUNET_PQ_cleanup_result (rs);
141 : }
142 : }
143 :
144 :
145 : /**
146 : * Function called with denomination_revocations table entries.
147 : *
148 : * @param cls closure
149 : * @param result the postgres result
150 : * @param num_results the number of results in @a result
151 : */
152 : static void
153 1 : lrbt_cb_table_denomination_revocations (void *cls,
154 : PGresult *result,
155 : unsigned int num_results)
156 : {
157 1 : struct LookupRecordsByTableContext *ctx = cls;
158 1 : struct TALER_EXCHANGEDB_TableData td = {
159 : .table = TALER_EXCHANGEDB_RT_DENOMINATION_REVOCATIONS
160 : };
161 :
162 1 : for (unsigned int i = 0; i<num_results; i++)
163 : {
164 0 : struct GNUNET_PQ_ResultSpec rs[] = {
165 0 : GNUNET_PQ_result_spec_uint64 ("serial",
166 : &td.serial),
167 0 : GNUNET_PQ_result_spec_uint64 (
168 : "denominations_serial",
169 : &td.details.denomination_revocations.denominations_serial),
170 0 : GNUNET_PQ_result_spec_auto_from_type (
171 : "master_sig",
172 : &td.details.denomination_revocations.master_sig),
173 : GNUNET_PQ_result_spec_end
174 : };
175 :
176 0 : if (GNUNET_OK !=
177 0 : GNUNET_PQ_extract_result (result,
178 : rs,
179 : i))
180 : {
181 0 : GNUNET_break (0);
182 0 : ctx->error = true;
183 0 : return;
184 : }
185 0 : ctx->cb (ctx->cb_cls,
186 : &td);
187 0 : GNUNET_PQ_cleanup_result (rs);
188 : }
189 : }
190 :
191 :
192 : /**
193 : * Function called with wire_targets table entries.
194 : *
195 : * @param cls closure
196 : * @param result the postgres result
197 : * @param num_results the number of results in @a result
198 : */
199 : static void
200 5 : lrbt_cb_table_wire_targets (void *cls,
201 : PGresult *result,
202 : unsigned int num_results)
203 : {
204 5 : struct LookupRecordsByTableContext *ctx = cls;
205 5 : struct TALER_EXCHANGEDB_TableData td = {
206 : .table = TALER_EXCHANGEDB_RT_WIRE_TARGETS
207 : };
208 :
209 12 : for (unsigned int i = 0; i<num_results; i++)
210 : {
211 7 : struct GNUNET_PQ_ResultSpec rs[] = {
212 7 : GNUNET_PQ_result_spec_uint64 (
213 : "serial",
214 : &td.serial),
215 7 : GNUNET_PQ_result_spec_string (
216 : "payto_uri",
217 : &td.details.wire_targets.full_payto_uri.full_payto),
218 : GNUNET_PQ_result_spec_end
219 : };
220 :
221 7 : if (GNUNET_OK !=
222 7 : GNUNET_PQ_extract_result (result,
223 : rs,
224 : i))
225 : {
226 0 : GNUNET_break (0);
227 0 : ctx->error = true;
228 0 : return;
229 : }
230 7 : ctx->cb (ctx->cb_cls,
231 : &td);
232 7 : GNUNET_PQ_cleanup_result (rs);
233 : }
234 : }
235 :
236 :
237 : /**
238 : * Function called with wire_targets table entries.
239 : *
240 : * @param cls closure
241 : * @param result the postgres result
242 : * @param num_results the number of results in @a result
243 : */
244 : static void
245 1 : lrbt_cb_table_kyc_targets (void *cls,
246 : PGresult *result,
247 : unsigned int num_results)
248 : {
249 1 : struct LookupRecordsByTableContext *ctx = cls;
250 1 : struct TALER_EXCHANGEDB_TableData td = {
251 : .table = TALER_EXCHANGEDB_RT_KYC_TARGETS
252 : };
253 :
254 1 : for (unsigned int i = 0; i<num_results; i++)
255 : {
256 0 : struct GNUNET_PQ_ResultSpec rs[] = {
257 0 : GNUNET_PQ_result_spec_uint64 (
258 : "serial",
259 : &td.serial),
260 0 : GNUNET_PQ_result_spec_auto_from_type (
261 : "h_normalized_payto",
262 : &td.details.kyc_targets.h_normalized_payto),
263 0 : GNUNET_PQ_result_spec_auto_from_type (
264 : "access_token",
265 : &td.details.kyc_targets.access_token),
266 0 : GNUNET_PQ_result_spec_allow_null (
267 : GNUNET_PQ_result_spec_auto_from_type (
268 : "target_pub",
269 : &td.details.kyc_targets.target_pub),
270 : &td.details.kyc_targets.no_account),
271 0 : GNUNET_PQ_result_spec_bool (
272 : "is_wallet",
273 : &td.details.kyc_targets.is_wallet),
274 : GNUNET_PQ_result_spec_end
275 : };
276 :
277 0 : if (GNUNET_OK !=
278 0 : GNUNET_PQ_extract_result (result,
279 : rs,
280 : i))
281 : {
282 0 : GNUNET_break (0);
283 0 : ctx->error = true;
284 0 : return;
285 : }
286 0 : ctx->cb (ctx->cb_cls,
287 : &td);
288 0 : GNUNET_PQ_cleanup_result (rs);
289 : }
290 : }
291 :
292 :
293 : /**
294 : * Function called with reserves table entries.
295 : *
296 : * @param cls closure
297 : * @param result the postgres result
298 : * @param num_results the number of results in @a result
299 : */
300 : static void
301 1 : lrbt_cb_table_reserves (void *cls,
302 : PGresult *result,
303 : unsigned int num_results)
304 : {
305 1 : struct LookupRecordsByTableContext *ctx = cls;
306 1 : struct TALER_EXCHANGEDB_TableData td = {
307 : .table = TALER_EXCHANGEDB_RT_RESERVES
308 : };
309 :
310 1 : for (unsigned int i = 0; i<num_results; i++)
311 : {
312 0 : struct GNUNET_PQ_ResultSpec rs[] = {
313 0 : GNUNET_PQ_result_spec_uint64 ("serial",
314 : &td.serial),
315 0 : GNUNET_PQ_result_spec_auto_from_type ("reserve_pub",
316 : &td.details.reserves.reserve_pub),
317 0 : GNUNET_PQ_result_spec_timestamp ("expiration_date",
318 : &td.details.reserves.expiration_date),
319 0 : GNUNET_PQ_result_spec_timestamp ("gc_date",
320 : &td.details.reserves.gc_date),
321 : GNUNET_PQ_result_spec_end
322 : };
323 :
324 0 : if (GNUNET_OK !=
325 0 : GNUNET_PQ_extract_result (result,
326 : rs,
327 : i))
328 : {
329 0 : GNUNET_break (0);
330 0 : ctx->error = true;
331 0 : return;
332 : }
333 0 : ctx->cb (ctx->cb_cls,
334 : &td);
335 0 : GNUNET_PQ_cleanup_result (rs);
336 : }
337 : }
338 :
339 :
340 : /**
341 : * Function called with reserves_in table entries.
342 : *
343 : * @param cls closure
344 : * @param result the postgres result
345 : * @param num_results the number of results in @a result
346 : */
347 : static void
348 1 : lrbt_cb_table_reserves_in (void *cls,
349 : PGresult *result,
350 : unsigned int num_results)
351 : {
352 1 : struct LookupRecordsByTableContext *ctx = cls;
353 1 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
354 1 : struct TALER_EXCHANGEDB_TableData td = {
355 : .table = TALER_EXCHANGEDB_RT_RESERVES_IN
356 : };
357 :
358 1 : for (unsigned int i = 0; i<num_results; i++)
359 : {
360 0 : struct GNUNET_PQ_ResultSpec rs[] = {
361 0 : GNUNET_PQ_result_spec_uint64 (
362 : "serial",
363 : &td.serial),
364 0 : GNUNET_PQ_result_spec_auto_from_type (
365 : "reserve_pub",
366 : &td.details.reserves_in.reserve_pub),
367 0 : GNUNET_PQ_result_spec_uint64 (
368 : "wire_reference",
369 : &td.details.reserves_in.wire_reference),
370 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
371 : "credit",
372 : &td.details.reserves_in.credit),
373 0 : GNUNET_PQ_result_spec_auto_from_type (
374 : "wire_source_h_payto",
375 : &td.details.reserves_in.sender_account_h_payto),
376 0 : GNUNET_PQ_result_spec_string (
377 : "exchange_account_section",
378 : &td.details.reserves_in.exchange_account_section),
379 0 : GNUNET_PQ_result_spec_timestamp (
380 : "execution_date",
381 : &td.details.reserves_in.execution_date),
382 : GNUNET_PQ_result_spec_end
383 : };
384 :
385 0 : if (GNUNET_OK !=
386 0 : GNUNET_PQ_extract_result (result,
387 : rs,
388 : i))
389 : {
390 0 : GNUNET_break (0);
391 0 : ctx->error = true;
392 0 : return;
393 : }
394 0 : ctx->cb (ctx->cb_cls,
395 : &td);
396 0 : GNUNET_PQ_cleanup_result (rs);
397 : }
398 : }
399 :
400 :
401 : /**
402 : * Function called with kycauth_in table entries.
403 : *
404 : * @param cls closure
405 : * @param result the postgres result
406 : * @param num_results the number of results in @a result
407 : */
408 : static void
409 1 : lrbt_cb_table_kycauth_in (void *cls,
410 : PGresult *result,
411 : unsigned int num_results)
412 : {
413 1 : struct LookupRecordsByTableContext *ctx = cls;
414 1 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
415 1 : struct TALER_EXCHANGEDB_TableData td = {
416 : .table = TALER_EXCHANGEDB_RT_KYCAUTHS_IN
417 : };
418 :
419 1 : for (unsigned int i = 0; i<num_results; i++)
420 : {
421 0 : struct GNUNET_PQ_ResultSpec rs[] = {
422 0 : GNUNET_PQ_result_spec_uint64 (
423 : "serial",
424 : &td.serial),
425 0 : GNUNET_PQ_result_spec_auto_from_type (
426 : "account_pub",
427 : &td.details.kycauth_in.account_pub),
428 0 : GNUNET_PQ_result_spec_uint64 (
429 : "wire_reference",
430 : &td.details.kycauth_in.wire_reference),
431 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
432 : "credit",
433 : &td.details.kycauth_in.credit),
434 0 : GNUNET_PQ_result_spec_auto_from_type (
435 : "wire_source_h_payto",
436 : &td.details.kycauth_in.sender_account_h_payto),
437 0 : GNUNET_PQ_result_spec_string (
438 : "exchange_account_section",
439 : &td.details.kycauth_in.exchange_account_section),
440 0 : GNUNET_PQ_result_spec_timestamp (
441 : "execution_date",
442 : &td.details.kycauth_in.execution_date),
443 : GNUNET_PQ_result_spec_end
444 : };
445 :
446 0 : if (GNUNET_OK !=
447 0 : GNUNET_PQ_extract_result (result,
448 : rs,
449 : i))
450 : {
451 0 : GNUNET_break (0);
452 0 : ctx->error = true;
453 0 : return;
454 : }
455 0 : ctx->cb (ctx->cb_cls,
456 : &td);
457 0 : GNUNET_PQ_cleanup_result (rs);
458 : }
459 : }
460 :
461 :
462 : /**
463 : * Function called with reserves_close table entries.
464 : *
465 : * @param cls closure
466 : * @param result the postgres result
467 : * @param num_results the number of results in @a result
468 : */
469 : static void
470 1 : lrbt_cb_table_reserves_close (void *cls,
471 : PGresult *result,
472 : unsigned int num_results)
473 : {
474 1 : struct LookupRecordsByTableContext *ctx = cls;
475 1 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
476 1 : struct TALER_EXCHANGEDB_TableData td = {
477 : .table = TALER_EXCHANGEDB_RT_RESERVES_CLOSE
478 : };
479 :
480 1 : for (unsigned int i = 0; i<num_results; i++)
481 : {
482 0 : struct GNUNET_PQ_ResultSpec rs[] = {
483 0 : GNUNET_PQ_result_spec_uint64 (
484 : "serial",
485 : &td.serial),
486 0 : GNUNET_PQ_result_spec_auto_from_type (
487 : "reserve_pub",
488 : &td.details.reserves_close.reserve_pub),
489 0 : GNUNET_PQ_result_spec_timestamp (
490 : "execution_date",
491 : &td.details.reserves_close.execution_date),
492 0 : GNUNET_PQ_result_spec_auto_from_type (
493 : "wtid",
494 : &td.details.reserves_close.wtid),
495 0 : GNUNET_PQ_result_spec_auto_from_type (
496 : "wire_target_h_payto",
497 : &td.details.reserves_close.sender_account_h_payto),
498 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
499 : "amount",
500 : &td.details.reserves_close.amount),
501 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
502 : "closing_fee",
503 : &td.details.reserves_close.closing_fee),
504 : GNUNET_PQ_result_spec_end
505 : };
506 :
507 0 : if (GNUNET_OK !=
508 0 : GNUNET_PQ_extract_result (result,
509 : rs,
510 : i))
511 : {
512 0 : GNUNET_break (0);
513 0 : ctx->error = true;
514 0 : return;
515 : }
516 0 : ctx->cb (ctx->cb_cls,
517 : &td);
518 0 : GNUNET_PQ_cleanup_result (rs);
519 : }
520 : }
521 :
522 :
523 : /**
524 : * Function called with reserves_open_requests table entries.
525 : *
526 : * @param cls closure
527 : * @param result the postgres result
528 : * @param num_results the number of results in @a result
529 : */
530 : static void
531 1 : lrbt_cb_table_reserves_open_requests (void *cls,
532 : PGresult *result,
533 : unsigned int num_results)
534 : {
535 1 : struct LookupRecordsByTableContext *ctx = cls;
536 1 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
537 1 : struct TALER_EXCHANGEDB_TableData td = {
538 : .table = TALER_EXCHANGEDB_RT_RESERVES_OPEN_REQUESTS
539 : };
540 :
541 1 : for (unsigned int i = 0; i<num_results; i++)
542 : {
543 0 : struct GNUNET_PQ_ResultSpec rs[] = {
544 0 : GNUNET_PQ_result_spec_uint64 ("serial",
545 : &td.serial),
546 0 : GNUNET_PQ_result_spec_auto_from_type (
547 : "reserve_pub",
548 : &td.details.reserves_open_requests.reserve_pub),
549 0 : GNUNET_PQ_result_spec_timestamp (
550 : "request_timestamp",
551 : &td.details.reserves_open_requests.request_timestamp),
552 0 : GNUNET_PQ_result_spec_timestamp (
553 : "expiration_date",
554 : &td.details.reserves_open_requests.expiration_date),
555 0 : GNUNET_PQ_result_spec_auto_from_type (
556 : "reserve_sig",
557 : &td.details.reserves_open_requests.reserve_sig),
558 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
559 : "reserve_payment",
560 : &td.details.reserves_open_requests.reserve_payment),
561 0 : GNUNET_PQ_result_spec_uint32 (
562 : "requested_purse_limit",
563 : &td.details.reserves_open_requests.requested_purse_limit),
564 : GNUNET_PQ_result_spec_end
565 : };
566 :
567 0 : if (GNUNET_OK !=
568 0 : GNUNET_PQ_extract_result (result,
569 : rs,
570 : i))
571 : {
572 0 : GNUNET_break (0);
573 0 : ctx->error = true;
574 0 : return;
575 : }
576 0 : ctx->cb (ctx->cb_cls,
577 : &td);
578 0 : GNUNET_PQ_cleanup_result (rs);
579 : }
580 : }
581 :
582 :
583 : /**
584 : * Function called with reserves_open_deposits table entries.
585 : *
586 : * @param cls closure
587 : * @param result the postgres result
588 : * @param num_results the number of results in @a result
589 : */
590 : static void
591 1 : lrbt_cb_table_reserves_open_deposits (void *cls,
592 : PGresult *result,
593 : unsigned int num_results)
594 : {
595 1 : struct LookupRecordsByTableContext *ctx = cls;
596 1 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
597 1 : struct TALER_EXCHANGEDB_TableData td = {
598 : .table = TALER_EXCHANGEDB_RT_RESERVES_OPEN_DEPOSITS
599 : };
600 :
601 1 : for (unsigned int i = 0; i<num_results; i++)
602 : {
603 0 : struct GNUNET_PQ_ResultSpec rs[] = {
604 0 : GNUNET_PQ_result_spec_uint64 ("serial",
605 : &td.serial),
606 0 : GNUNET_PQ_result_spec_auto_from_type (
607 : "reserve_sig",
608 : &td.details.reserves_open_deposits.reserve_sig),
609 0 : GNUNET_PQ_result_spec_auto_from_type (
610 : "reserve_pub",
611 : &td.details.reserves_open_deposits.reserve_pub),
612 0 : GNUNET_PQ_result_spec_auto_from_type (
613 : "coin_pub",
614 : &td.details.reserves_open_deposits.coin_pub),
615 0 : GNUNET_PQ_result_spec_auto_from_type (
616 : "coin_sig",
617 : &td.details.reserves_open_deposits.coin_sig),
618 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
619 : "contribution",
620 : &td.details.reserves_open_deposits.contribution),
621 : GNUNET_PQ_result_spec_end
622 : };
623 :
624 0 : if (GNUNET_OK !=
625 0 : GNUNET_PQ_extract_result (result,
626 : rs,
627 : i))
628 : {
629 0 : GNUNET_break (0);
630 0 : ctx->error = true;
631 0 : return;
632 : }
633 0 : ctx->cb (ctx->cb_cls,
634 : &td);
635 0 : GNUNET_PQ_cleanup_result (rs);
636 : }
637 : }
638 :
639 :
640 : /**
641 : * Function called with auditors table entries.
642 : *
643 : * @param cls closure
644 : * @param result the postgres result
645 : * @param num_results the number of results in @a result
646 : */
647 : static void
648 1 : lrbt_cb_table_auditors (void *cls,
649 : PGresult *result,
650 : unsigned int num_results)
651 : {
652 1 : struct LookupRecordsByTableContext *ctx = cls;
653 1 : struct TALER_EXCHANGEDB_TableData td = {
654 : .table = TALER_EXCHANGEDB_RT_AUDITORS
655 : };
656 :
657 1 : for (unsigned int i = 0; i<num_results; i++)
658 : {
659 0 : struct GNUNET_PQ_ResultSpec rs[] = {
660 0 : GNUNET_PQ_result_spec_uint64 ("serial",
661 : &td.serial),
662 0 : GNUNET_PQ_result_spec_auto_from_type ("auditor_pub",
663 : &td.details.auditors.auditor_pub),
664 0 : GNUNET_PQ_result_spec_string ("auditor_url",
665 : &td.details.auditors.auditor_url),
666 0 : GNUNET_PQ_result_spec_string ("auditor_name",
667 : &td.details.auditors.auditor_name),
668 0 : GNUNET_PQ_result_spec_bool ("is_active",
669 : &td.details.auditors.is_active),
670 0 : GNUNET_PQ_result_spec_timestamp ("last_change",
671 : &td.details.auditors.last_change),
672 : GNUNET_PQ_result_spec_end
673 : };
674 :
675 0 : if (GNUNET_OK !=
676 0 : GNUNET_PQ_extract_result (result,
677 : rs,
678 : i))
679 : {
680 0 : GNUNET_break (0);
681 0 : ctx->error = true;
682 0 : return;
683 : }
684 0 : ctx->cb (ctx->cb_cls,
685 : &td);
686 0 : GNUNET_PQ_cleanup_result (rs);
687 : }
688 : }
689 :
690 :
691 : /**
692 : * Function called with auditor_denom_sigs table entries.
693 : *
694 : * @param cls closure
695 : * @param result the postgres result
696 : * @param num_results the number of results in @a result
697 : */
698 : static void
699 1 : lrbt_cb_table_auditor_denom_sigs (void *cls,
700 : PGresult *result,
701 : unsigned int num_results)
702 : {
703 1 : struct LookupRecordsByTableContext *ctx = cls;
704 1 : struct TALER_EXCHANGEDB_TableData td = {
705 : .table = TALER_EXCHANGEDB_RT_AUDITOR_DENOM_SIGS
706 : };
707 :
708 1 : for (unsigned int i = 0; i<num_results; i++)
709 : {
710 0 : struct GNUNET_PQ_ResultSpec rs[] = {
711 0 : GNUNET_PQ_result_spec_uint64 (
712 : "serial",
713 : &td.serial),
714 0 : GNUNET_PQ_result_spec_uint64 (
715 : "auditor_uuid",
716 : &td.details.auditor_denom_sigs.auditor_uuid),
717 0 : GNUNET_PQ_result_spec_uint64 (
718 : "denominations_serial",
719 : &td.details.auditor_denom_sigs.denominations_serial),
720 0 : GNUNET_PQ_result_spec_auto_from_type (
721 : "auditor_sig",
722 : &td.details.auditor_denom_sigs.auditor_sig),
723 : GNUNET_PQ_result_spec_end
724 : };
725 :
726 0 : if (GNUNET_OK !=
727 0 : GNUNET_PQ_extract_result (result,
728 : rs,
729 : i))
730 : {
731 0 : GNUNET_break (0);
732 0 : ctx->error = true;
733 0 : return;
734 : }
735 0 : ctx->cb (ctx->cb_cls,
736 : &td);
737 0 : GNUNET_PQ_cleanup_result (rs);
738 : }
739 : }
740 :
741 :
742 : /**
743 : * Function called with exchange_sign_keys table entries.
744 : *
745 : * @param cls closure
746 : * @param result the postgres result
747 : * @param num_results the number of results in @a result
748 : */
749 : static void
750 1 : lrbt_cb_table_exchange_sign_keys (void *cls,
751 : PGresult *result,
752 : unsigned int num_results)
753 : {
754 1 : struct LookupRecordsByTableContext *ctx = cls;
755 1 : struct TALER_EXCHANGEDB_TableData td = {
756 : .table = TALER_EXCHANGEDB_RT_EXCHANGE_SIGN_KEYS
757 : };
758 :
759 1 : for (unsigned int i = 0; i<num_results; i++)
760 : {
761 0 : struct GNUNET_PQ_ResultSpec rs[] = {
762 0 : GNUNET_PQ_result_spec_uint64 ("serial",
763 : &td.serial),
764 0 : GNUNET_PQ_result_spec_auto_from_type ("exchange_pub",
765 : &td.details.exchange_sign_keys.
766 : exchange_pub),
767 0 : GNUNET_PQ_result_spec_auto_from_type ("master_sig",
768 : &td.details.exchange_sign_keys.
769 : master_sig),
770 0 : GNUNET_PQ_result_spec_timestamp ("valid_from",
771 : &td.details.exchange_sign_keys.meta.
772 : start),
773 0 : GNUNET_PQ_result_spec_timestamp ("expire_sign",
774 : &td.details.exchange_sign_keys.meta.
775 : expire_sign),
776 0 : GNUNET_PQ_result_spec_timestamp ("expire_legal",
777 : &td.details.exchange_sign_keys.meta.
778 : expire_legal),
779 : GNUNET_PQ_result_spec_end
780 : };
781 :
782 0 : if (GNUNET_OK !=
783 0 : GNUNET_PQ_extract_result (result,
784 : rs,
785 : i))
786 : {
787 0 : GNUNET_break (0);
788 0 : ctx->error = true;
789 0 : return;
790 : }
791 0 : ctx->cb (ctx->cb_cls,
792 : &td);
793 0 : GNUNET_PQ_cleanup_result (rs);
794 : }
795 : }
796 :
797 :
798 : /**
799 : * Function called with signkey_revocations table entries.
800 : *
801 : * @param cls closure
802 : * @param result the postgres result
803 : * @param num_results the number of results in @a result
804 : */
805 : static void
806 1 : lrbt_cb_table_signkey_revocations (void *cls,
807 : PGresult *result,
808 : unsigned int num_results)
809 : {
810 1 : struct LookupRecordsByTableContext *ctx = cls;
811 1 : struct TALER_EXCHANGEDB_TableData td = {
812 : .table = TALER_EXCHANGEDB_RT_SIGNKEY_REVOCATIONS
813 : };
814 :
815 1 : for (unsigned int i = 0; i<num_results; i++)
816 : {
817 0 : struct GNUNET_PQ_ResultSpec rs[] = {
818 0 : GNUNET_PQ_result_spec_uint64 ("serial",
819 : &td.serial),
820 0 : GNUNET_PQ_result_spec_uint64 ("esk_serial",
821 : &td.details.signkey_revocations.esk_serial),
822 0 : GNUNET_PQ_result_spec_auto_from_type ("master_sig",
823 : &td.details.signkey_revocations.
824 : master_sig),
825 : GNUNET_PQ_result_spec_end
826 : };
827 :
828 0 : if (GNUNET_OK !=
829 0 : GNUNET_PQ_extract_result (result,
830 : rs,
831 : i))
832 : {
833 0 : GNUNET_break (0);
834 0 : ctx->error = true;
835 0 : return;
836 : }
837 0 : ctx->cb (ctx->cb_cls,
838 : &td);
839 0 : GNUNET_PQ_cleanup_result (rs);
840 : }
841 : }
842 :
843 :
844 : /**
845 : * Function called with known_coins table entries.
846 : *
847 : * @param cls closure
848 : * @param result the postgres result
849 : * @param num_results the number of results in @a result
850 : */
851 : static void
852 1 : lrbt_cb_table_known_coins (void *cls,
853 : PGresult *result,
854 : unsigned int num_results)
855 : {
856 1 : struct LookupRecordsByTableContext *ctx = cls;
857 1 : struct TALER_EXCHANGEDB_TableData td = {
858 : .table = TALER_EXCHANGEDB_RT_KNOWN_COINS
859 : };
860 :
861 1 : for (unsigned int i = 0; i<num_results; i++)
862 : {
863 0 : struct GNUNET_PQ_ResultSpec rs[] = {
864 0 : GNUNET_PQ_result_spec_uint64 (
865 : "serial",
866 : &td.serial),
867 0 : GNUNET_PQ_result_spec_auto_from_type (
868 : "coin_pub",
869 : &td.details.known_coins.coin_pub),
870 0 : TALER_PQ_result_spec_denom_sig (
871 : "denom_sig",
872 : &td.details.known_coins.denom_sig),
873 0 : GNUNET_PQ_result_spec_uint64 (
874 : "denominations_serial",
875 : &td.details.known_coins.denominations_serial),
876 : GNUNET_PQ_result_spec_end
877 : };
878 :
879 0 : if (GNUNET_OK !=
880 0 : GNUNET_PQ_extract_result (result,
881 : rs,
882 : i))
883 : {
884 0 : GNUNET_break (0);
885 0 : ctx->error = true;
886 0 : return;
887 : }
888 0 : ctx->cb (ctx->cb_cls,
889 : &td);
890 0 : GNUNET_PQ_cleanup_result (rs);
891 : }
892 : }
893 :
894 :
895 : /**
896 : * Function called with refresh table entries.
897 : *
898 : * @param cls closure
899 : * @param result the postgres result
900 : * @param num_results the number of results in @a result
901 : */
902 : static void
903 3 : lrbt_cb_table_refresh (void *cls,
904 : PGresult *result,
905 : unsigned int num_results)
906 : {
907 3 : struct LookupRecordsByTableContext *ctx = cls;
908 3 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
909 3 : struct TALER_EXCHANGEDB_TableData td = {
910 : .table = TALER_EXCHANGEDB_RT_REFRESH
911 : };
912 :
913 13 : for (unsigned int i = 0; i<num_results; i++)
914 : {
915 : bool no_cs_r_values;
916 : bool no_cs_r_choices;
917 : bool no_transfer_pubs;
918 : size_t num_denom_sigs;
919 : size_t num_transfer_pubs;
920 10 : struct GNUNET_PQ_ResultSpec rs[] = {
921 10 : GNUNET_PQ_result_spec_uint64 (
922 : "serial",
923 : &td.serial),
924 10 : GNUNET_PQ_result_spec_auto_from_type (
925 : "rc",
926 : &td.details.refresh.rc),
927 10 : GNUNET_PQ_result_spec_auto_from_type (
928 : "execution_date",
929 : &td.details.refresh.execution_date),
930 10 : TALER_PQ_RESULT_SPEC_AMOUNT (
931 : "amount_with_fee",
932 : &td.details.refresh.amount_with_fee),
933 10 : GNUNET_PQ_result_spec_auto_from_type (
934 : "old_coin_pub",
935 : &td.details.refresh.old_coin_pub),
936 10 : GNUNET_PQ_result_spec_auto_from_type (
937 : "old_coin_sig",
938 : &td.details.refresh.old_coin_sig),
939 10 : GNUNET_PQ_result_spec_auto_from_type (
940 : "refresh_seed",
941 : &td.details.refresh.refresh_seed),
942 10 : GNUNET_PQ_result_spec_uint32 (
943 : "noreveal_index",
944 : &td.details.refresh.noreveal_index),
945 10 : GNUNET_PQ_result_spec_auto_from_type (
946 : "planchets_h",
947 : &td.details.refresh.planchets_h),
948 10 : GNUNET_PQ_result_spec_auto_from_type (
949 : "selected_h",
950 : &td.details.refresh.selected_h),
951 10 : GNUNET_PQ_result_spec_allow_null (
952 : GNUNET_PQ_result_spec_auto_from_type (
953 : "blinding_seed",
954 : &td.details.refresh.blinding_seed),
955 : &td.details.refresh.no_blinding_seed),
956 10 : GNUNET_PQ_result_spec_allow_null (
957 : TALER_PQ_result_spec_array_cs_r_pub (
958 : pg->conn,
959 : "cs_r_values",
960 : &td.details.refresh.num_cs_r_values,
961 : &td.details.refresh.cs_r_values),
962 : &no_cs_r_values),
963 10 : GNUNET_PQ_result_spec_allow_null (
964 : GNUNET_PQ_result_spec_uint64 (
965 : "cs_r_choices",
966 : &td.details.refresh.cs_r_choices),
967 : &no_cs_r_choices),
968 10 : GNUNET_PQ_result_spec_array_uint64 (
969 : pg->conn,
970 : "denom_serials",
971 : &td.details.refresh.num_coins,
972 : &td.details.refresh.denom_serials),
973 10 : TALER_PQ_result_spec_array_blinded_denom_sig (
974 : pg->conn,
975 : "denom_sigs",
976 : &num_denom_sigs,
977 : &td.details.refresh.denom_sigs),
978 10 : GNUNET_PQ_result_spec_allow_null (
979 : GNUNET_PQ_result_spec_array_fixed_size (
980 : pg->conn,
981 : "transfer_pubs",
982 : sizeof (*td.details.refresh.transfer_pubs),
983 : &num_transfer_pubs,
984 : (void **) &td.details.refresh.transfer_pubs),
985 : &no_transfer_pubs),
986 10 : GNUNET_PQ_result_spec_bool (
987 : "revealed",
988 : &td.details.refresh.revealed),
989 10 : GNUNET_PQ_result_spec_uint32 (
990 : "rc_version",
991 : &td.details.refresh.rc_version),
992 : GNUNET_PQ_result_spec_end
993 : };
994 :
995 10 : td.details.refresh.transfer_pubs = NULL;
996 10 : if (GNUNET_OK !=
997 10 : GNUNET_PQ_extract_result (result,
998 : rs,
999 : i))
1000 : {
1001 0 : GNUNET_break (0);
1002 0 : ctx->error = true;
1003 0 : GNUNET_PQ_cleanup_result (rs);
1004 0 : return;
1005 : }
1006 10 : if ( (num_denom_sigs != td.details.refresh.num_coins) ||
1007 10 : ( (! no_transfer_pubs) &&
1008 6 : (num_transfer_pubs != td.details.refresh.num_coins) ) )
1009 : {
1010 0 : GNUNET_break (0);
1011 0 : ctx->error = true;
1012 0 : GNUNET_PQ_cleanup_result (rs);
1013 0 : return;
1014 : }
1015 10 : ctx->cb (ctx->cb_cls,
1016 : &td);
1017 10 : GNUNET_PQ_cleanup_result (rs);
1018 : }
1019 : }
1020 :
1021 :
1022 : /**
1023 : * Function called with batch deposits table entries.
1024 : *
1025 : * @param cls closure
1026 : * @param result the postgres result
1027 : * @param num_results the number of results in @a result
1028 : */
1029 : static void
1030 1 : lrbt_cb_table_batch_deposits (void *cls,
1031 : PGresult *result,
1032 : unsigned int num_results)
1033 : {
1034 1 : struct LookupRecordsByTableContext *ctx = cls;
1035 1 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
1036 1 : struct TALER_EXCHANGEDB_TableData td = {
1037 : .table = TALER_EXCHANGEDB_RT_BATCH_DEPOSITS
1038 : };
1039 :
1040 1 : for (unsigned int i = 0; i<num_results; i++)
1041 : {
1042 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1043 0 : GNUNET_PQ_result_spec_uint64 (
1044 : "serial",
1045 : &td.serial),
1046 0 : GNUNET_PQ_result_spec_uint64 (
1047 : "shard",
1048 : &td.details.batch_deposits.shard),
1049 0 : GNUNET_PQ_result_spec_auto_from_type (
1050 : "merchant_pub",
1051 : &td.details.batch_deposits.merchant_pub),
1052 0 : GNUNET_PQ_result_spec_timestamp (
1053 : "wallet_timestamp",
1054 : &td.details.batch_deposits.wallet_timestamp),
1055 0 : GNUNET_PQ_result_spec_timestamp (
1056 : "exchange_timestamp",
1057 : &td.details.batch_deposits.exchange_timestamp),
1058 0 : GNUNET_PQ_result_spec_timestamp (
1059 : "refund_deadline",
1060 : &td.details.batch_deposits.refund_deadline),
1061 0 : GNUNET_PQ_result_spec_timestamp (
1062 : "wire_deadline",
1063 : &td.details.batch_deposits.wire_deadline),
1064 0 : GNUNET_PQ_result_spec_auto_from_type (
1065 : "h_contract_terms",
1066 : &td.details.batch_deposits.h_contract_terms),
1067 0 : GNUNET_PQ_result_spec_allow_null (
1068 : GNUNET_PQ_result_spec_auto_from_type (
1069 : "wallet_data_hash",
1070 : &td.details.batch_deposits.wallet_data_hash),
1071 : &td.details.batch_deposits.no_wallet_data_hash),
1072 0 : GNUNET_PQ_result_spec_auto_from_type (
1073 : "wire_salt",
1074 : &td.details.batch_deposits.wire_salt),
1075 0 : GNUNET_PQ_result_spec_auto_from_type (
1076 : "wire_target_h_payto",
1077 : &td.details.batch_deposits.wire_target_h_payto),
1078 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1079 : "total_amount",
1080 : &td.details.batch_deposits.total_amount),
1081 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1082 : "total_without_fee",
1083 : &td.details.batch_deposits.total_without_fee),
1084 0 : GNUNET_PQ_result_spec_auto_from_type (
1085 : "merchant_sig",
1086 : &td.details.batch_deposits.merchant_sig),
1087 0 : GNUNET_PQ_result_spec_bool (
1088 : "done",
1089 : &td.details.batch_deposits.done),
1090 : GNUNET_PQ_result_spec_end
1091 : };
1092 :
1093 0 : if (GNUNET_OK !=
1094 0 : GNUNET_PQ_extract_result (result,
1095 : rs,
1096 : i))
1097 : {
1098 0 : GNUNET_break (0);
1099 0 : ctx->error = true;
1100 0 : return;
1101 : }
1102 0 : ctx->cb (ctx->cb_cls,
1103 : &td);
1104 0 : GNUNET_PQ_cleanup_result (rs);
1105 : }
1106 : }
1107 :
1108 :
1109 : /**
1110 : * Function called with coin deposits table entries.
1111 : *
1112 : * @param cls closure
1113 : * @param result the postgres result
1114 : * @param num_results the number of results in @a result
1115 : */
1116 : static void
1117 1 : lrbt_cb_table_coin_deposits (void *cls,
1118 : PGresult *result,
1119 : unsigned int num_results)
1120 : {
1121 1 : struct LookupRecordsByTableContext *ctx = cls;
1122 1 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
1123 1 : struct TALER_EXCHANGEDB_TableData td = {
1124 : .table = TALER_EXCHANGEDB_RT_COIN_DEPOSITS
1125 : };
1126 :
1127 1 : for (unsigned int i = 0; i<num_results; i++)
1128 : {
1129 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1130 0 : GNUNET_PQ_result_spec_uint64 (
1131 : "serial",
1132 : &td.serial),
1133 0 : GNUNET_PQ_result_spec_uint64 (
1134 : "batch_deposit_serial_id",
1135 : &td.details.coin_deposits.batch_deposit_serial_id),
1136 0 : GNUNET_PQ_result_spec_auto_from_type (
1137 : "coin_pub",
1138 : &td.details.coin_deposits.coin_pub),
1139 0 : GNUNET_PQ_result_spec_auto_from_type (
1140 : "coin_sig",
1141 : &td.details.coin_deposits.coin_sig),
1142 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1143 : "amount_with_fee",
1144 : &td.details.coin_deposits.amount_with_fee),
1145 : GNUNET_PQ_result_spec_end
1146 : };
1147 :
1148 0 : if (GNUNET_OK !=
1149 0 : GNUNET_PQ_extract_result (result,
1150 : rs,
1151 : i))
1152 : {
1153 0 : GNUNET_break (0);
1154 0 : ctx->error = true;
1155 0 : return;
1156 : }
1157 0 : ctx->cb (ctx->cb_cls,
1158 : &td);
1159 0 : GNUNET_PQ_cleanup_result (rs);
1160 : }
1161 : }
1162 :
1163 :
1164 : /**
1165 : * Function called with refunds table entries.
1166 : *
1167 : * @param cls closure
1168 : * @param result the postgres result
1169 : * @param num_results the number of results in @a result
1170 : */
1171 : static void
1172 1 : lrbt_cb_table_refunds (void *cls,
1173 : PGresult *result,
1174 : unsigned int num_results)
1175 : {
1176 1 : struct LookupRecordsByTableContext *ctx = cls;
1177 1 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
1178 1 : struct TALER_EXCHANGEDB_TableData td = {
1179 : .table = TALER_EXCHANGEDB_RT_REFUNDS
1180 : };
1181 :
1182 1 : for (unsigned int i = 0; i<num_results; i++)
1183 : {
1184 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1185 0 : GNUNET_PQ_result_spec_uint64 (
1186 : "serial",
1187 : &td.serial),
1188 0 : GNUNET_PQ_result_spec_auto_from_type (
1189 : "coin_pub",
1190 : &td.details.refunds.coin_pub),
1191 0 : GNUNET_PQ_result_spec_auto_from_type (
1192 : "merchant_sig",
1193 : &td.details.refunds.merchant_sig),
1194 0 : GNUNET_PQ_result_spec_uint64 (
1195 : "rtransaction_id",
1196 : &td.details.refunds.rtransaction_id),
1197 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1198 : "amount_with_fee",
1199 : &td.details.refunds.amount_with_fee),
1200 0 : GNUNET_PQ_result_spec_uint64 (
1201 : "batch_deposit_serial_id",
1202 : &td.details.refunds.batch_deposit_serial_id),
1203 : GNUNET_PQ_result_spec_end
1204 : };
1205 :
1206 0 : if (GNUNET_OK !=
1207 0 : GNUNET_PQ_extract_result (result,
1208 : rs,
1209 : i))
1210 : {
1211 0 : GNUNET_break (0);
1212 0 : ctx->error = true;
1213 0 : return;
1214 : }
1215 0 : ctx->cb (ctx->cb_cls,
1216 : &td);
1217 0 : GNUNET_PQ_cleanup_result (rs);
1218 : }
1219 : }
1220 :
1221 :
1222 : /**
1223 : * Function called with wire_out table entries.
1224 : *
1225 : * @param cls closure
1226 : * @param result the postgres result
1227 : * @param num_results the number of results in @a result
1228 : */
1229 : static void
1230 1 : lrbt_cb_table_wire_out (void *cls,
1231 : PGresult *result,
1232 : unsigned int num_results)
1233 : {
1234 1 : struct LookupRecordsByTableContext *ctx = cls;
1235 1 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
1236 1 : struct TALER_EXCHANGEDB_TableData td = {
1237 : .table = TALER_EXCHANGEDB_RT_WIRE_OUT
1238 : };
1239 :
1240 1 : for (unsigned int i = 0; i<num_results; i++)
1241 : {
1242 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1243 0 : GNUNET_PQ_result_spec_uint64 ("serial",
1244 : &td.serial),
1245 0 : GNUNET_PQ_result_spec_timestamp (
1246 : "execution_date",
1247 : &td.details.wire_out.execution_date),
1248 0 : GNUNET_PQ_result_spec_auto_from_type (
1249 : "wtid_raw",
1250 : &td.details.wire_out.wtid_raw),
1251 0 : GNUNET_PQ_result_spec_auto_from_type (
1252 : "wire_target_h_payto",
1253 : &td.details.wire_out.wire_target_h_payto),
1254 0 : GNUNET_PQ_result_spec_string (
1255 : "exchange_account_section",
1256 : &td.details.wire_out.exchange_account_section),
1257 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1258 : "amount",
1259 : &td.details.wire_out.amount),
1260 : GNUNET_PQ_result_spec_end
1261 : };
1262 :
1263 0 : if (GNUNET_OK !=
1264 0 : GNUNET_PQ_extract_result (result,
1265 : rs,
1266 : i))
1267 : {
1268 0 : GNUNET_break (0);
1269 0 : ctx->error = true;
1270 0 : return;
1271 : }
1272 0 : ctx->cb (ctx->cb_cls,
1273 : &td);
1274 0 : GNUNET_PQ_cleanup_result (rs);
1275 : }
1276 : }
1277 :
1278 :
1279 : /**
1280 : * Function called with aggregation_deferrals table entries.
1281 : *
1282 : * @param cls closure
1283 : * @param result the postgres result
1284 : * @param num_results the number of results in @a result
1285 : */
1286 : static void
1287 1 : lrbt_cb_table_aggregation_deferrals (void *cls,
1288 : PGresult *result,
1289 : unsigned int num_results)
1290 : {
1291 1 : struct LookupRecordsByTableContext *ctx = cls;
1292 1 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
1293 1 : struct TALER_EXCHANGEDB_TableData td = {
1294 : .table = TALER_EXCHANGEDB_RT_AGGREGATION_DEFERRALS
1295 : };
1296 :
1297 1 : for (unsigned int i = 0; i<num_results; i++)
1298 : {
1299 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1300 0 : GNUNET_PQ_result_spec_uint64 (
1301 : "serial",
1302 : &td.serial),
1303 0 : GNUNET_PQ_result_spec_uint64 (
1304 : "batch_deposit_serial_id",
1305 : &td.details.aggregation_deferrals.batch_deposit_serial_id),
1306 0 : GNUNET_PQ_result_spec_auto_from_type (
1307 : "wtid_raw",
1308 : &td.details.aggregation_deferrals.wtid_raw),
1309 0 : GNUNET_PQ_result_spec_auto_from_type (
1310 : "wire_target_h_payto",
1311 : &td.details.aggregation_deferrals.wire_target_h_payto),
1312 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1313 : "amount",
1314 : &td.details.aggregation_deferrals.amount),
1315 0 : GNUNET_PQ_result_spec_uint32 (
1316 : "deferral_reason",
1317 : &td.details.aggregation_deferrals.deferral_reason),
1318 0 : GNUNET_PQ_result_spec_uint64 (
1319 : "legitimization_requirement_serial_id",
1320 : &td.details.aggregation_deferrals.legitimization_requirement_serial_id),
1321 0 : GNUNET_PQ_result_spec_timestamp (
1322 : "deferral_time",
1323 : &td.details.aggregation_deferrals.deferral_time),
1324 : GNUNET_PQ_result_spec_end
1325 : };
1326 :
1327 0 : if (GNUNET_OK !=
1328 0 : GNUNET_PQ_extract_result (result,
1329 : rs,
1330 : i))
1331 : {
1332 0 : GNUNET_break (0);
1333 0 : ctx->error = true;
1334 0 : return;
1335 : }
1336 0 : ctx->cb (ctx->cb_cls,
1337 : &td);
1338 0 : GNUNET_PQ_cleanup_result (rs);
1339 : }
1340 : }
1341 :
1342 :
1343 : /**
1344 : * Function called with aggregation_tracking table entries.
1345 : *
1346 : * @param cls closure
1347 : * @param result the postgres result
1348 : * @param num_results the number of results in @a result
1349 : */
1350 : static void
1351 1 : lrbt_cb_table_aggregation_tracking (void *cls,
1352 : PGresult *result,
1353 : unsigned int num_results)
1354 : {
1355 1 : struct LookupRecordsByTableContext *ctx = cls;
1356 1 : struct TALER_EXCHANGEDB_TableData td = {
1357 : .table = TALER_EXCHANGEDB_RT_AGGREGATION_TRACKING
1358 : };
1359 :
1360 1 : for (unsigned int i = 0; i<num_results; i++)
1361 : {
1362 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1363 0 : GNUNET_PQ_result_spec_uint64 (
1364 : "serial",
1365 : &td.serial),
1366 0 : GNUNET_PQ_result_spec_uint64 (
1367 : "batch_deposit_serial_id",
1368 : &td.details.aggregation_tracking.batch_deposit_serial_id),
1369 0 : GNUNET_PQ_result_spec_auto_from_type (
1370 : "wtid_raw",
1371 : &td.details.aggregation_tracking.wtid_raw),
1372 : GNUNET_PQ_result_spec_end
1373 : };
1374 :
1375 0 : if (GNUNET_OK !=
1376 0 : GNUNET_PQ_extract_result (result,
1377 : rs,
1378 : i))
1379 : {
1380 0 : GNUNET_break (0);
1381 0 : ctx->error = true;
1382 0 : return;
1383 : }
1384 0 : ctx->cb (ctx->cb_cls,
1385 : &td);
1386 0 : GNUNET_PQ_cleanup_result (rs);
1387 : }
1388 : }
1389 :
1390 :
1391 : /**
1392 : * Function called with wire_fee table entries.
1393 : *
1394 : * @param cls closure
1395 : * @param result the postgres result
1396 : * @param num_results the number of results in @a result
1397 : */
1398 : static void
1399 1 : lrbt_cb_table_wire_fee (void *cls,
1400 : PGresult *result,
1401 : unsigned int num_results)
1402 : {
1403 1 : struct LookupRecordsByTableContext *ctx = cls;
1404 1 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
1405 1 : struct TALER_EXCHANGEDB_TableData td = {
1406 : .table = TALER_EXCHANGEDB_RT_WIRE_FEE
1407 : };
1408 :
1409 1 : for (unsigned int i = 0; i<num_results; i++)
1410 : {
1411 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1412 0 : GNUNET_PQ_result_spec_uint64 ("serial",
1413 : &td.serial),
1414 0 : GNUNET_PQ_result_spec_string ("wire_method",
1415 : &td.details.wire_fee.wire_method),
1416 0 : GNUNET_PQ_result_spec_timestamp ("start_date",
1417 : &td.details.wire_fee.start_date),
1418 0 : GNUNET_PQ_result_spec_timestamp ("end_date",
1419 : &td.details.wire_fee.end_date),
1420 0 : TALER_PQ_RESULT_SPEC_AMOUNT ("wire_fee",
1421 : &td.details.wire_fee.fees.wire),
1422 0 : TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee",
1423 : &td.details.wire_fee.fees.closing),
1424 0 : GNUNET_PQ_result_spec_auto_from_type ("master_sig",
1425 : &td.details.wire_fee.master_sig),
1426 : GNUNET_PQ_result_spec_end
1427 : };
1428 :
1429 0 : if (GNUNET_OK !=
1430 0 : GNUNET_PQ_extract_result (result,
1431 : rs,
1432 : i))
1433 : {
1434 0 : GNUNET_break (0);
1435 0 : ctx->error = true;
1436 0 : return;
1437 : }
1438 0 : ctx->cb (ctx->cb_cls,
1439 : &td);
1440 0 : GNUNET_PQ_cleanup_result (rs);
1441 : }
1442 : }
1443 :
1444 :
1445 : /**
1446 : * Function called with wire_fee table entries.
1447 : *
1448 : * @param cls closure
1449 : * @param result the postgres result
1450 : * @param num_results the number of results in @a result
1451 : */
1452 : static void
1453 1 : lrbt_cb_table_global_fee (void *cls,
1454 : PGresult *result,
1455 : unsigned int num_results)
1456 : {
1457 1 : struct LookupRecordsByTableContext *ctx = cls;
1458 1 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
1459 1 : struct TALER_EXCHANGEDB_TableData td = {
1460 : .table = TALER_EXCHANGEDB_RT_GLOBAL_FEE
1461 : };
1462 :
1463 1 : for (unsigned int i = 0; i<num_results; i++)
1464 : {
1465 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1466 0 : GNUNET_PQ_result_spec_uint64 (
1467 : "serial",
1468 : &td.serial),
1469 0 : GNUNET_PQ_result_spec_timestamp (
1470 : "start_date",
1471 : &td.details.global_fee.start_date),
1472 0 : GNUNET_PQ_result_spec_timestamp (
1473 : "end_date",
1474 : &td.details.global_fee.end_date),
1475 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1476 : "history_fee",
1477 : &td.details.global_fee.fees.history),
1478 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1479 : "account_fee",
1480 : &td.details.global_fee.fees.account),
1481 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1482 : "purse_fee",
1483 : &td.details.global_fee.fees.purse),
1484 0 : GNUNET_PQ_result_spec_relative_time (
1485 : "purse_timeout",
1486 : &td.details.global_fee.purse_timeout),
1487 0 : GNUNET_PQ_result_spec_relative_time (
1488 : "history_expiration",
1489 : &td.details.global_fee.history_expiration),
1490 0 : GNUNET_PQ_result_spec_uint32 (
1491 : "purse_account_limit",
1492 : &td.details.global_fee.purse_account_limit),
1493 0 : GNUNET_PQ_result_spec_auto_from_type (
1494 : "master_sig",
1495 : &td.details.global_fee.master_sig),
1496 : GNUNET_PQ_result_spec_end
1497 : };
1498 :
1499 0 : if (GNUNET_OK !=
1500 0 : GNUNET_PQ_extract_result (result,
1501 : rs,
1502 : i))
1503 : {
1504 0 : GNUNET_break (0);
1505 0 : ctx->error = true;
1506 0 : return;
1507 : }
1508 0 : ctx->cb (ctx->cb_cls,
1509 : &td);
1510 0 : GNUNET_PQ_cleanup_result (rs);
1511 : }
1512 : }
1513 :
1514 :
1515 : /**
1516 : * Function called with recoup table entries.
1517 : *
1518 : * @param cls closure
1519 : * @param result the postgres result
1520 : * @param num_results the number of results in @a result
1521 : */
1522 : static void
1523 3 : lrbt_cb_table_recoup (void *cls,
1524 : PGresult *result,
1525 : unsigned int num_results)
1526 : {
1527 3 : struct LookupRecordsByTableContext *ctx = cls;
1528 3 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
1529 3 : struct TALER_EXCHANGEDB_TableData td = {
1530 : .table = TALER_EXCHANGEDB_RT_RECOUP
1531 : };
1532 :
1533 5 : for (unsigned int i = 0; i<num_results; i++)
1534 : {
1535 2 : struct GNUNET_PQ_ResultSpec rs[] = {
1536 2 : GNUNET_PQ_result_spec_uint64 ("serial",
1537 : &td.serial),
1538 2 : GNUNET_PQ_result_spec_auto_from_type ("coin_sig",
1539 : &td.details.recoup.coin_sig),
1540 2 : GNUNET_PQ_result_spec_auto_from_type ("coin_blind",
1541 : &td.details.recoup.coin_blind),
1542 2 : TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
1543 : &td.details.recoup.amount),
1544 2 : GNUNET_PQ_result_spec_timestamp ("recoup_timestamp",
1545 : &td.details.recoup.timestamp),
1546 2 : GNUNET_PQ_result_spec_auto_from_type (
1547 : "coin_pub",
1548 : &td.details.recoup.coin_pub),
1549 2 : GNUNET_PQ_result_spec_uint64 ("withdraw_id",
1550 : &td.details.recoup.withdraw_serial_id),
1551 2 : GNUNET_PQ_result_spec_uint32 ("coin_index",
1552 : &td.details.recoup.coin_index),
1553 : GNUNET_PQ_result_spec_end
1554 : };
1555 :
1556 2 : if (GNUNET_OK !=
1557 2 : GNUNET_PQ_extract_result (result,
1558 : rs,
1559 : i))
1560 : {
1561 0 : GNUNET_break (0);
1562 0 : ctx->error = true;
1563 0 : return;
1564 : }
1565 2 : ctx->cb (ctx->cb_cls,
1566 : &td);
1567 2 : GNUNET_PQ_cleanup_result (rs);
1568 : }
1569 : }
1570 :
1571 :
1572 : /**
1573 : * Function called with recoup_refresh table entries.
1574 : *
1575 : * @param cls closure
1576 : * @param result the postgres result
1577 : * @param num_results the number of results in @a result
1578 : */
1579 : static void
1580 3 : lrbt_cb_table_recoup_refresh (void *cls,
1581 : PGresult *result,
1582 : unsigned int num_results)
1583 : {
1584 3 : struct LookupRecordsByTableContext *ctx = cls;
1585 3 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
1586 3 : struct TALER_EXCHANGEDB_TableData td = {
1587 : .table = TALER_EXCHANGEDB_RT_RECOUP_REFRESH
1588 : };
1589 :
1590 5 : for (unsigned int i = 0; i<num_results; i++)
1591 : {
1592 2 : struct GNUNET_PQ_ResultSpec rs[] = {
1593 2 : GNUNET_PQ_result_spec_uint64 (
1594 : "serial",
1595 : &td.serial),
1596 2 : GNUNET_PQ_result_spec_auto_from_type (
1597 : "coin_sig",
1598 : &td.details.recoup_refresh.coin_sig),
1599 2 : GNUNET_PQ_result_spec_auto_from_type (
1600 : "coin_blind",
1601 : &td.details.recoup_refresh.coin_blind),
1602 2 : TALER_PQ_RESULT_SPEC_AMOUNT (
1603 : "amount",
1604 : &td.details.recoup_refresh.amount),
1605 2 : GNUNET_PQ_result_spec_timestamp (
1606 : "recoup_timestamp",
1607 : &td.details.recoup_refresh.recoup_timestamp),
1608 2 : GNUNET_PQ_result_spec_uint64 (
1609 : "known_coin_id",
1610 : &td.details.recoup_refresh.known_coin_id),
1611 2 : GNUNET_PQ_result_spec_auto_from_type (
1612 : "coin_pub",
1613 : &td.details.recoup_refresh.coin_pub),
1614 2 : GNUNET_PQ_result_spec_uint64 (
1615 : "refresh_id",
1616 : &td.details.recoup_refresh.refresh_id),
1617 2 : GNUNET_PQ_result_spec_uint32 (
1618 : "coin_index",
1619 : &td.details.recoup_refresh.coin_index),
1620 : GNUNET_PQ_result_spec_end
1621 : };
1622 :
1623 2 : if (GNUNET_OK !=
1624 2 : GNUNET_PQ_extract_result (result,
1625 : rs,
1626 : i))
1627 : {
1628 0 : GNUNET_break (0);
1629 0 : ctx->error = true;
1630 0 : return;
1631 : }
1632 2 : ctx->cb (ctx->cb_cls,
1633 : &td);
1634 2 : GNUNET_PQ_cleanup_result (rs);
1635 : }
1636 : }
1637 :
1638 :
1639 : /**
1640 : * Function called with purse_requests table entries.
1641 : *
1642 : * @param cls closure
1643 : * @param result the postgres result
1644 : * @param num_results the number of results in @a result
1645 : */
1646 : static void
1647 1 : lrbt_cb_table_purse_requests (void *cls,
1648 : PGresult *result,
1649 : unsigned int num_results)
1650 : {
1651 1 : struct LookupRecordsByTableContext *ctx = cls;
1652 1 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
1653 1 : struct TALER_EXCHANGEDB_TableData td = {
1654 : .table = TALER_EXCHANGEDB_RT_PURSE_REQUESTS
1655 : };
1656 :
1657 1 : for (unsigned int i = 0; i<num_results; i++)
1658 : {
1659 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1660 0 : GNUNET_PQ_result_spec_uint64 (
1661 : "purse_requests_serial_id",
1662 : &td.serial),
1663 0 : GNUNET_PQ_result_spec_auto_from_type (
1664 : "purse_pub",
1665 : &td.details.purse_requests.purse_pub),
1666 0 : GNUNET_PQ_result_spec_auto_from_type (
1667 : "merge_pub",
1668 : &td.details.purse_requests.merge_pub),
1669 0 : GNUNET_PQ_result_spec_timestamp (
1670 : "purse_creation",
1671 : &td.details.purse_requests.purse_creation),
1672 0 : GNUNET_PQ_result_spec_timestamp (
1673 : "purse_expiration",
1674 : &td.details.purse_requests.purse_expiration),
1675 0 : GNUNET_PQ_result_spec_auto_from_type (
1676 : "h_contract_terms",
1677 : &td.details.purse_requests.h_contract_terms),
1678 0 : GNUNET_PQ_result_spec_uint32 (
1679 : "age_limit",
1680 : &td.details.purse_requests.age_limit),
1681 0 : GNUNET_PQ_result_spec_uint32 (
1682 : "flags",
1683 : &td.details.purse_requests.flags),
1684 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1685 : "amount_with_fee",
1686 : &td.details.purse_requests.amount_with_fee),
1687 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1688 : "purse_fee",
1689 : &td.details.purse_requests.purse_fee),
1690 0 : GNUNET_PQ_result_spec_auto_from_type (
1691 : "purse_sig",
1692 : &td.details.purse_requests.purse_sig),
1693 : GNUNET_PQ_result_spec_end
1694 : };
1695 :
1696 0 : if (GNUNET_OK !=
1697 0 : GNUNET_PQ_extract_result (result,
1698 : rs,
1699 : i))
1700 : {
1701 0 : GNUNET_break (0);
1702 0 : ctx->error = true;
1703 0 : return;
1704 : }
1705 0 : ctx->cb (ctx->cb_cls,
1706 : &td);
1707 0 : GNUNET_PQ_cleanup_result (rs);
1708 : }
1709 : }
1710 :
1711 :
1712 : /**
1713 : * Function called with purse_decision table entries.
1714 : *
1715 : * @param cls closure
1716 : * @param result the postgres result
1717 : * @param num_results the number of results in @a result
1718 : */
1719 : static void
1720 1 : lrbt_cb_table_purse_decision (void *cls,
1721 : PGresult *result,
1722 : unsigned int num_results)
1723 : {
1724 1 : struct LookupRecordsByTableContext *ctx = cls;
1725 1 : struct TALER_EXCHANGEDB_TableData td = {
1726 : .table = TALER_EXCHANGEDB_RT_PURSE_DECISION
1727 : };
1728 :
1729 1 : for (unsigned int i = 0; i<num_results; i++)
1730 : {
1731 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1732 0 : GNUNET_PQ_result_spec_uint64 (
1733 : "purse_decision_serial_id",
1734 : &td.serial),
1735 0 : GNUNET_PQ_result_spec_auto_from_type (
1736 : "purse_pub",
1737 : &td.details.purse_decision.purse_pub),
1738 0 : GNUNET_PQ_result_spec_timestamp (
1739 : "action_timestamp",
1740 : &td.details.purse_decision.action_timestamp),
1741 0 : GNUNET_PQ_result_spec_bool (
1742 : "refunded",
1743 : &td.details.purse_decision.refunded),
1744 : GNUNET_PQ_result_spec_end
1745 : };
1746 :
1747 0 : if (GNUNET_OK !=
1748 0 : GNUNET_PQ_extract_result (result,
1749 : rs,
1750 : i))
1751 : {
1752 0 : GNUNET_break (0);
1753 0 : ctx->error = true;
1754 0 : return;
1755 : }
1756 0 : ctx->cb (ctx->cb_cls,
1757 : &td);
1758 0 : GNUNET_PQ_cleanup_result (rs);
1759 : }
1760 : }
1761 :
1762 :
1763 : /**
1764 : * Function called with purse_merges table entries.
1765 : *
1766 : * @param cls closure
1767 : * @param result the postgres result
1768 : * @param num_results the number of results in @a result
1769 : */
1770 : static void
1771 1 : lrbt_cb_table_purse_merges (void *cls,
1772 : PGresult *result,
1773 : unsigned int num_results)
1774 : {
1775 1 : struct LookupRecordsByTableContext *ctx = cls;
1776 1 : struct TALER_EXCHANGEDB_TableData td = {
1777 : .table = TALER_EXCHANGEDB_RT_PURSE_MERGES
1778 : };
1779 :
1780 1 : for (unsigned int i = 0; i<num_results; i++)
1781 : {
1782 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1783 0 : GNUNET_PQ_result_spec_uint64 (
1784 : "purse_merge_request_serial_id",
1785 : &td.serial),
1786 0 : GNUNET_PQ_result_spec_uint64 (
1787 : "partner_serial_id",
1788 : &td.details.purse_merges.partner_serial_id),
1789 0 : GNUNET_PQ_result_spec_auto_from_type (
1790 : "reserve_pub",
1791 : &td.details.purse_merges.reserve_pub),
1792 0 : GNUNET_PQ_result_spec_auto_from_type (
1793 : "purse_pub",
1794 : &td.details.purse_merges.purse_pub),
1795 0 : GNUNET_PQ_result_spec_auto_from_type (
1796 : "merge_sig",
1797 : &td.details.purse_merges.merge_sig),
1798 0 : GNUNET_PQ_result_spec_timestamp (
1799 : "merge_timestamp",
1800 : &td.details.purse_merges.merge_timestamp),
1801 : GNUNET_PQ_result_spec_end
1802 : };
1803 :
1804 0 : if (GNUNET_OK !=
1805 0 : GNUNET_PQ_extract_result (result,
1806 : rs,
1807 : i))
1808 : {
1809 0 : GNUNET_break (0);
1810 0 : ctx->error = true;
1811 0 : return;
1812 : }
1813 0 : ctx->cb (ctx->cb_cls,
1814 : &td);
1815 0 : GNUNET_PQ_cleanup_result (rs);
1816 : }
1817 : }
1818 :
1819 :
1820 : /**
1821 : * Function called with purse_deposits table entries.
1822 : *
1823 : * @param cls closure
1824 : * @param result the postgres result
1825 : * @param num_results the number of results in @a result
1826 : */
1827 : static void
1828 1 : lrbt_cb_table_purse_deposits (void *cls,
1829 : PGresult *result,
1830 : unsigned int num_results)
1831 : {
1832 1 : struct LookupRecordsByTableContext *ctx = cls;
1833 1 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
1834 1 : struct TALER_EXCHANGEDB_TableData td = {
1835 : .table = TALER_EXCHANGEDB_RT_PURSE_DEPOSITS
1836 : };
1837 :
1838 1 : for (unsigned int i = 0; i<num_results; i++)
1839 : {
1840 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1841 0 : GNUNET_PQ_result_spec_uint64 (
1842 : "purse_deposit_serial_id",
1843 : &td.serial),
1844 0 : GNUNET_PQ_result_spec_uint64 (
1845 : "partner_serial_id",
1846 : &td.details.purse_deposits.partner_serial_id),
1847 0 : GNUNET_PQ_result_spec_auto_from_type (
1848 : "purse_pub",
1849 : &td.details.purse_deposits.purse_pub),
1850 0 : GNUNET_PQ_result_spec_auto_from_type (
1851 : "coin_pub",
1852 : &td.details.purse_deposits.coin_pub),
1853 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1854 : "amount_with_fee",
1855 : &td.details.purse_deposits.amount_with_fee),
1856 0 : GNUNET_PQ_result_spec_auto_from_type (
1857 : "coin_sig",
1858 : &td.details.purse_deposits.coin_sig),
1859 : GNUNET_PQ_result_spec_end
1860 : };
1861 :
1862 0 : if (GNUNET_OK !=
1863 0 : GNUNET_PQ_extract_result (result,
1864 : rs,
1865 : i))
1866 : {
1867 0 : GNUNET_break (0);
1868 0 : ctx->error = true;
1869 0 : return;
1870 : }
1871 0 : ctx->cb (ctx->cb_cls,
1872 : &td);
1873 0 : GNUNET_PQ_cleanup_result (rs);
1874 : }
1875 : }
1876 :
1877 :
1878 : /**
1879 : * Function called with account_merges table entries.
1880 : *
1881 : * @param cls closure
1882 : * @param result the postgres result
1883 : * @param num_results the number of results in @a result
1884 : */
1885 : static void
1886 1 : lrbt_cb_table_account_merges (void *cls,
1887 : PGresult *result,
1888 : unsigned int num_results)
1889 : {
1890 1 : struct LookupRecordsByTableContext *ctx = cls;
1891 1 : struct TALER_EXCHANGEDB_TableData td = {
1892 : .table = TALER_EXCHANGEDB_RT_ACCOUNT_MERGES
1893 : };
1894 :
1895 1 : for (unsigned int i = 0; i<num_results; i++)
1896 : {
1897 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1898 0 : GNUNET_PQ_result_spec_uint64 (
1899 : "account_merge_request_serial_id",
1900 : &td.serial),
1901 0 : GNUNET_PQ_result_spec_auto_from_type (
1902 : "reserve_pub",
1903 : &td.details.account_merges.reserve_pub),
1904 0 : GNUNET_PQ_result_spec_auto_from_type (
1905 : "reserve_sig",
1906 : &td.details.account_merges.reserve_sig),
1907 0 : GNUNET_PQ_result_spec_auto_from_type (
1908 : "purse_pub",
1909 : &td.details.account_merges.purse_pub),
1910 0 : GNUNET_PQ_result_spec_auto_from_type (
1911 : "wallet_h_payto",
1912 : &td.details.account_merges.wallet_h_payto),
1913 : GNUNET_PQ_result_spec_end
1914 : };
1915 :
1916 0 : if (GNUNET_OK !=
1917 0 : GNUNET_PQ_extract_result (result,
1918 : rs,
1919 : i))
1920 : {
1921 0 : GNUNET_break (0);
1922 0 : ctx->error = true;
1923 0 : return;
1924 : }
1925 0 : ctx->cb (ctx->cb_cls,
1926 : &td);
1927 0 : GNUNET_PQ_cleanup_result (rs);
1928 : }
1929 : }
1930 :
1931 :
1932 : /**
1933 : * Function called with history_requests table entries.
1934 : *
1935 : * @param cls closure
1936 : * @param result the postgres result
1937 : * @param num_results the number of results in @a result
1938 : */
1939 : static void
1940 1 : lrbt_cb_table_history_requests (void *cls,
1941 : PGresult *result,
1942 : unsigned int num_results)
1943 : {
1944 1 : struct LookupRecordsByTableContext *ctx = cls;
1945 1 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
1946 1 : struct TALER_EXCHANGEDB_TableData td = {
1947 : .table = TALER_EXCHANGEDB_RT_HISTORY_REQUESTS
1948 : };
1949 :
1950 1 : for (unsigned int i = 0; i<num_results; i++)
1951 : {
1952 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1953 0 : GNUNET_PQ_result_spec_uint64 (
1954 : "history_request_serial_id",
1955 : &td.serial),
1956 0 : GNUNET_PQ_result_spec_auto_from_type (
1957 : "reserve_pub",
1958 : &td.details.history_requests.reserve_pub),
1959 0 : GNUNET_PQ_result_spec_timestamp (
1960 : "request_timestamp",
1961 : &td.details.history_requests.request_timestamp),
1962 0 : GNUNET_PQ_result_spec_auto_from_type (
1963 : "reserve_sig",
1964 : &td.details.history_requests.reserve_sig),
1965 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1966 : "history_fee",
1967 : &td.details.history_requests.history_fee),
1968 : GNUNET_PQ_result_spec_end
1969 : };
1970 :
1971 0 : if (GNUNET_OK !=
1972 0 : GNUNET_PQ_extract_result (result,
1973 : rs,
1974 : i))
1975 : {
1976 0 : GNUNET_break (0);
1977 0 : ctx->error = true;
1978 0 : return;
1979 : }
1980 0 : ctx->cb (ctx->cb_cls,
1981 : &td);
1982 0 : GNUNET_PQ_cleanup_result (rs);
1983 : }
1984 : }
1985 :
1986 :
1987 : /**
1988 : * Function called with close_requests table entries.
1989 : *
1990 : * @param cls closure
1991 : * @param result the postgres result
1992 : * @param num_results the number of results in @a result
1993 : */
1994 : static void
1995 1 : lrbt_cb_table_close_requests (void *cls,
1996 : PGresult *result,
1997 : unsigned int num_results)
1998 : {
1999 1 : struct LookupRecordsByTableContext *ctx = cls;
2000 1 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
2001 1 : struct TALER_EXCHANGEDB_TableData td = {
2002 : .table = TALER_EXCHANGEDB_RT_CLOSE_REQUESTS
2003 : };
2004 :
2005 1 : for (unsigned int i = 0; i<num_results; i++)
2006 : {
2007 0 : struct GNUNET_PQ_ResultSpec rs[] = {
2008 0 : GNUNET_PQ_result_spec_uint64 (
2009 : "close_request_serial_id",
2010 : &td.serial),
2011 0 : GNUNET_PQ_result_spec_auto_from_type (
2012 : "reserve_pub",
2013 : &td.details.close_requests.reserve_pub),
2014 0 : GNUNET_PQ_result_spec_timestamp (
2015 : "close_timestamp",
2016 : &td.details.close_requests.close_timestamp),
2017 0 : GNUNET_PQ_result_spec_auto_from_type (
2018 : "reserve_sig",
2019 : &td.details.close_requests.reserve_sig),
2020 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
2021 : "close",
2022 : &td.details.close_requests.close),
2023 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
2024 : "close_fee",
2025 : &td.details.close_requests.close_fee),
2026 0 : GNUNET_PQ_result_spec_string (
2027 : "payto_uri",
2028 : &td.details.close_requests.payto_uri.full_payto),
2029 : GNUNET_PQ_result_spec_end
2030 : };
2031 :
2032 0 : if (GNUNET_OK !=
2033 0 : GNUNET_PQ_extract_result (result,
2034 : rs,
2035 : i))
2036 : {
2037 0 : GNUNET_break (0);
2038 0 : ctx->error = true;
2039 0 : return;
2040 : }
2041 0 : ctx->cb (ctx->cb_cls,
2042 : &td);
2043 0 : GNUNET_PQ_cleanup_result (rs);
2044 : }
2045 : }
2046 :
2047 :
2048 : /**
2049 : * Function called with wads_out table entries.
2050 : *
2051 : * @param cls closure
2052 : * @param result the postgres result
2053 : * @param num_results the number of results in @a result
2054 : */
2055 : static void
2056 1 : lrbt_cb_table_wads_out (void *cls,
2057 : PGresult *result,
2058 : unsigned int num_results)
2059 : {
2060 1 : struct LookupRecordsByTableContext *ctx = cls;
2061 1 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
2062 1 : struct TALER_EXCHANGEDB_TableData td = {
2063 : .table = TALER_EXCHANGEDB_RT_WADS_OUT
2064 : };
2065 :
2066 1 : for (unsigned int i = 0; i<num_results; i++)
2067 : {
2068 0 : struct GNUNET_PQ_ResultSpec rs[] = {
2069 0 : GNUNET_PQ_result_spec_uint64 (
2070 : "wad_out_serial_id",
2071 : &td.serial),
2072 0 : GNUNET_PQ_result_spec_auto_from_type (
2073 : "wad_id",
2074 : &td.details.wads_out.wad_id),
2075 0 : GNUNET_PQ_result_spec_uint64 (
2076 : "partner_serial_id",
2077 : &td.details.wads_out.partner_serial_id),
2078 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
2079 : "amount",
2080 : &td.details.wads_out.amount),
2081 0 : GNUNET_PQ_result_spec_timestamp (
2082 : "execution_time",
2083 : &td.details.wads_out.execution_time),
2084 : GNUNET_PQ_result_spec_end
2085 : };
2086 :
2087 0 : if (GNUNET_OK !=
2088 0 : GNUNET_PQ_extract_result (result,
2089 : rs,
2090 : i))
2091 : {
2092 0 : GNUNET_break (0);
2093 0 : ctx->error = true;
2094 0 : return;
2095 : }
2096 0 : ctx->cb (ctx->cb_cls,
2097 : &td);
2098 0 : GNUNET_PQ_cleanup_result (rs);
2099 : }
2100 : }
2101 :
2102 :
2103 : /**
2104 : * Function called with wads_out_entries table entries.
2105 : *
2106 : * @param cls closure
2107 : * @param result the postgres result
2108 : * @param num_results the number of results in @a result
2109 : */
2110 : static void
2111 1 : lrbt_cb_table_wads_out_entries (void *cls,
2112 : PGresult *result,
2113 : unsigned int num_results)
2114 : {
2115 1 : struct LookupRecordsByTableContext *ctx = cls;
2116 1 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
2117 1 : struct TALER_EXCHANGEDB_TableData td = {
2118 : .table = TALER_EXCHANGEDB_RT_WADS_OUT_ENTRIES
2119 : };
2120 :
2121 1 : for (unsigned int i = 0; i<num_results; i++)
2122 : {
2123 0 : struct GNUNET_PQ_ResultSpec rs[] = {
2124 0 : GNUNET_PQ_result_spec_uint64 (
2125 : "wad_out_entry_serial_id",
2126 : &td.serial),
2127 0 : GNUNET_PQ_result_spec_uint64 (
2128 : "wad_out_serial_id",
2129 : &td.details.wads_out_entries.wad_out_serial_id),
2130 0 : GNUNET_PQ_result_spec_auto_from_type (
2131 : "reserve_pub",
2132 : &td.details.wads_out_entries.reserve_pub),
2133 0 : GNUNET_PQ_result_spec_auto_from_type (
2134 : "purse_pub",
2135 : &td.details.wads_out_entries.purse_pub),
2136 0 : GNUNET_PQ_result_spec_auto_from_type (
2137 : "h_contract",
2138 : &td.details.wads_out_entries.h_contract),
2139 0 : GNUNET_PQ_result_spec_timestamp (
2140 : "purse_expiration",
2141 : &td.details.wads_out_entries.purse_expiration),
2142 0 : GNUNET_PQ_result_spec_timestamp (
2143 : "merge_timestamp",
2144 : &td.details.wads_out_entries.merge_timestamp),
2145 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
2146 : "amount_with_fee",
2147 : &td.details.wads_out_entries.amount_with_fee),
2148 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
2149 : "wad_fee",
2150 : &td.details.wads_out_entries.wad_fee),
2151 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
2152 : "deposit_fees",
2153 : &td.details.wads_out_entries.deposit_fees),
2154 0 : GNUNET_PQ_result_spec_auto_from_type (
2155 : "reserve_sig",
2156 : &td.details.wads_out_entries.reserve_sig),
2157 0 : GNUNET_PQ_result_spec_auto_from_type (
2158 : "purse_sig",
2159 : &td.details.wads_out_entries.purse_sig),
2160 : GNUNET_PQ_result_spec_end
2161 : };
2162 :
2163 0 : if (GNUNET_OK !=
2164 0 : GNUNET_PQ_extract_result (result,
2165 : rs,
2166 : i))
2167 : {
2168 0 : GNUNET_break (0);
2169 0 : ctx->error = true;
2170 0 : return;
2171 : }
2172 0 : ctx->cb (ctx->cb_cls,
2173 : &td);
2174 0 : GNUNET_PQ_cleanup_result (rs);
2175 : }
2176 : }
2177 :
2178 :
2179 : /**
2180 : * Function called with wads_in table entries.
2181 : *
2182 : * @param cls closure
2183 : * @param result the postgres result
2184 : * @param num_results the number of results in @a result
2185 : */
2186 : static void
2187 1 : lrbt_cb_table_wads_in (void *cls,
2188 : PGresult *result,
2189 : unsigned int num_results)
2190 : {
2191 1 : struct LookupRecordsByTableContext *ctx = cls;
2192 1 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
2193 1 : struct TALER_EXCHANGEDB_TableData td = {
2194 : .table = TALER_EXCHANGEDB_RT_WADS_IN
2195 : };
2196 :
2197 1 : for (unsigned int i = 0; i<num_results; i++)
2198 : {
2199 0 : struct GNUNET_PQ_ResultSpec rs[] = {
2200 0 : GNUNET_PQ_result_spec_uint64 (
2201 : "wad_in_serial_id",
2202 : &td.serial),
2203 0 : GNUNET_PQ_result_spec_auto_from_type (
2204 : "wad_id",
2205 : &td.details.wads_in.wad_id),
2206 0 : GNUNET_PQ_result_spec_string (
2207 : "origin_exchange_url",
2208 : &td.details.wads_in.origin_exchange_url),
2209 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
2210 : "amount",
2211 : &td.details.wads_in.amount),
2212 0 : GNUNET_PQ_result_spec_timestamp (
2213 : "arrival_time",
2214 : &td.details.wads_in.arrival_time),
2215 : GNUNET_PQ_result_spec_end
2216 : };
2217 :
2218 0 : if (GNUNET_OK !=
2219 0 : GNUNET_PQ_extract_result (result,
2220 : rs,
2221 : i))
2222 : {
2223 0 : GNUNET_break (0);
2224 0 : ctx->error = true;
2225 0 : return;
2226 : }
2227 0 : ctx->cb (ctx->cb_cls,
2228 : &td);
2229 0 : GNUNET_PQ_cleanup_result (rs);
2230 : }
2231 : }
2232 :
2233 :
2234 : /**
2235 : * Function called with wads_in_entries table entries.
2236 : *
2237 : * @param cls closure
2238 : * @param result the postgres result
2239 : * @param num_results the number of results in @a result
2240 : */
2241 : static void
2242 1 : lrbt_cb_table_wads_in_entries (void *cls,
2243 : PGresult *result,
2244 : unsigned int num_results)
2245 : {
2246 1 : struct LookupRecordsByTableContext *ctx = cls;
2247 1 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
2248 1 : struct TALER_EXCHANGEDB_TableData td = {
2249 : .table = TALER_EXCHANGEDB_RT_WADS_IN_ENTRIES
2250 : };
2251 :
2252 1 : for (unsigned int i = 0; i<num_results; i++)
2253 : {
2254 0 : struct GNUNET_PQ_ResultSpec rs[] = {
2255 0 : GNUNET_PQ_result_spec_uint64 (
2256 : "wad_in_entry_serial_id",
2257 : &td.serial),
2258 0 : GNUNET_PQ_result_spec_uint64 (
2259 : "wad_in_serial_id",
2260 : &td.details.wads_in_entries.wad_in_serial_id),
2261 0 : GNUNET_PQ_result_spec_auto_from_type (
2262 : "reserve_pub",
2263 : &td.details.wads_in_entries.reserve_pub),
2264 0 : GNUNET_PQ_result_spec_auto_from_type (
2265 : "purse_pub",
2266 : &td.details.wads_in_entries.purse_pub),
2267 0 : GNUNET_PQ_result_spec_auto_from_type (
2268 : "h_contract",
2269 : &td.details.wads_in_entries.h_contract),
2270 0 : GNUNET_PQ_result_spec_timestamp (
2271 : "purse_expiration",
2272 : &td.details.wads_in_entries.purse_expiration),
2273 0 : GNUNET_PQ_result_spec_timestamp (
2274 : "merge_timestamp",
2275 : &td.details.wads_in_entries.merge_timestamp),
2276 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
2277 : "amount_with_fee",
2278 : &td.details.wads_in_entries.amount_with_fee),
2279 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
2280 : "wad_fee",
2281 : &td.details.wads_in_entries.wad_fee),
2282 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
2283 : "deposit_fees",
2284 : &td.details.wads_in_entries.deposit_fees),
2285 0 : GNUNET_PQ_result_spec_auto_from_type (
2286 : "reserve_sig",
2287 : &td.details.wads_in_entries.reserve_sig),
2288 0 : GNUNET_PQ_result_spec_auto_from_type (
2289 : "purse_sig",
2290 : &td.details.wads_in_entries.purse_sig),
2291 : GNUNET_PQ_result_spec_end
2292 : };
2293 :
2294 0 : if (GNUNET_OK !=
2295 0 : GNUNET_PQ_extract_result (result,
2296 : rs,
2297 : i))
2298 : {
2299 0 : GNUNET_break (0);
2300 0 : ctx->error = true;
2301 0 : return;
2302 : }
2303 0 : ctx->cb (ctx->cb_cls,
2304 : &td);
2305 0 : GNUNET_PQ_cleanup_result (rs);
2306 : }
2307 : }
2308 :
2309 :
2310 : /**
2311 : * Function called with profit_drains table entries.
2312 : *
2313 : * @param cls closure
2314 : * @param result the postgres result
2315 : * @param num_results the number of results in @a result
2316 : */
2317 : static void
2318 1 : lrbt_cb_table_profit_drains (void *cls,
2319 : PGresult *result,
2320 : unsigned int num_results)
2321 : {
2322 1 : struct LookupRecordsByTableContext *ctx = cls;
2323 1 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
2324 1 : struct TALER_EXCHANGEDB_TableData td = {
2325 : .table = TALER_EXCHANGEDB_RT_PROFIT_DRAINS
2326 : };
2327 :
2328 1 : for (unsigned int i = 0; i<num_results; i++)
2329 : {
2330 0 : struct GNUNET_PQ_ResultSpec rs[] = {
2331 0 : GNUNET_PQ_result_spec_uint64 (
2332 : "profit_drain_serial_id",
2333 : &td.serial),
2334 0 : GNUNET_PQ_result_spec_auto_from_type (
2335 : "wtid",
2336 : &td.details.profit_drains.wtid),
2337 0 : GNUNET_PQ_result_spec_string (
2338 : "account_section",
2339 : &td.details.profit_drains.account_section),
2340 0 : GNUNET_PQ_result_spec_string (
2341 : "payto_uri",
2342 : &td.details.profit_drains.payto_uri.full_payto),
2343 0 : GNUNET_PQ_result_spec_timestamp (
2344 : "trigger_date",
2345 : &td.details.profit_drains.trigger_date),
2346 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
2347 : "amount",
2348 : &td.details.profit_drains.amount),
2349 0 : GNUNET_PQ_result_spec_auto_from_type (
2350 : "master_sig",
2351 : &td.details.profit_drains.master_sig),
2352 : GNUNET_PQ_result_spec_end
2353 : };
2354 :
2355 0 : if (GNUNET_OK !=
2356 0 : GNUNET_PQ_extract_result (result,
2357 : rs,
2358 : i))
2359 : {
2360 0 : GNUNET_break (0);
2361 0 : ctx->error = true;
2362 0 : return;
2363 : }
2364 0 : ctx->cb (ctx->cb_cls,
2365 : &td);
2366 0 : GNUNET_PQ_cleanup_result (rs);
2367 : }
2368 : }
2369 :
2370 :
2371 : /**
2372 : * Function called with aml_staff table entries.
2373 : *
2374 : * @param cls closure
2375 : * @param result the postgres result
2376 : * @param num_results the number of results in @a result
2377 : */
2378 : static void
2379 1 : lrbt_cb_table_aml_staff (void *cls,
2380 : PGresult *result,
2381 : unsigned int num_results)
2382 : {
2383 1 : struct LookupRecordsByTableContext *ctx = cls;
2384 1 : struct TALER_EXCHANGEDB_TableData td = {
2385 : .table = TALER_EXCHANGEDB_RT_AML_STAFF
2386 : };
2387 :
2388 1 : for (unsigned int i = 0; i<num_results; i++)
2389 : {
2390 0 : struct GNUNET_PQ_ResultSpec rs[] = {
2391 0 : GNUNET_PQ_result_spec_uint64 (
2392 : "aml_staff_uuid",
2393 : &td.serial),
2394 0 : GNUNET_PQ_result_spec_auto_from_type (
2395 : "decider_pub",
2396 : &td.details.aml_staff.decider_pub),
2397 0 : GNUNET_PQ_result_spec_auto_from_type (
2398 : "master_sig",
2399 : &td.details.aml_staff.master_sig),
2400 0 : GNUNET_PQ_result_spec_string (
2401 : "decider_name",
2402 : &td.details.aml_staff.decider_name),
2403 0 : GNUNET_PQ_result_spec_bool (
2404 : "is_active",
2405 : &td.details.aml_staff.is_active),
2406 0 : GNUNET_PQ_result_spec_bool (
2407 : "read_only",
2408 : &td.details.aml_staff.read_only),
2409 0 : GNUNET_PQ_result_spec_timestamp (
2410 : "last_change",
2411 : &td.details.aml_staff.last_change),
2412 : GNUNET_PQ_result_spec_end
2413 : };
2414 :
2415 0 : if (GNUNET_OK !=
2416 0 : GNUNET_PQ_extract_result (result,
2417 : rs,
2418 : i))
2419 : {
2420 0 : GNUNET_break (0);
2421 0 : ctx->error = true;
2422 0 : return;
2423 : }
2424 0 : ctx->cb (ctx->cb_cls,
2425 : &td);
2426 0 : GNUNET_PQ_cleanup_result (rs);
2427 : }
2428 : }
2429 :
2430 :
2431 : /**
2432 : * Function called with purse_deletion table entries.
2433 : *
2434 : * @param cls closure
2435 : * @param result the postgres result
2436 : * @param num_results the number of results in @a result
2437 : */
2438 : static void
2439 1 : lrbt_cb_table_purse_deletion (void *cls,
2440 : PGresult *result,
2441 : unsigned int num_results)
2442 : {
2443 1 : struct LookupRecordsByTableContext *ctx = cls;
2444 1 : struct TALER_EXCHANGEDB_TableData td = {
2445 : .table = TALER_EXCHANGEDB_RT_PURSE_DELETION
2446 : };
2447 :
2448 1 : for (unsigned int i = 0; i<num_results; i++)
2449 : {
2450 0 : struct GNUNET_PQ_ResultSpec rs[] = {
2451 0 : GNUNET_PQ_result_spec_uint64 (
2452 : "purse_deletion_serial_id",
2453 : &td.serial),
2454 0 : GNUNET_PQ_result_spec_auto_from_type (
2455 : "purse_sig",
2456 : &td.details.purse_deletion.purse_sig),
2457 0 : GNUNET_PQ_result_spec_auto_from_type (
2458 : "purse_pub",
2459 : &td.details.purse_deletion.purse_pub),
2460 : GNUNET_PQ_result_spec_end
2461 : };
2462 :
2463 0 : if (GNUNET_OK !=
2464 0 : GNUNET_PQ_extract_result (result,
2465 : rs,
2466 : i))
2467 : {
2468 0 : GNUNET_break (0);
2469 0 : ctx->error = true;
2470 0 : return;
2471 : }
2472 0 : ctx->cb (ctx->cb_cls,
2473 : &td);
2474 0 : GNUNET_PQ_cleanup_result (rs);
2475 : }
2476 : }
2477 :
2478 :
2479 : /**
2480 : * Function called with withdraw table entries.
2481 : *
2482 : * @param cls closure
2483 : * @param result the postgres result
2484 : * @param num_results the number of results in @a result
2485 : */
2486 : static void
2487 1 : lrbt_cb_table_withdraw (void *cls,
2488 : PGresult *result,
2489 : unsigned int num_results)
2490 : {
2491 1 : struct LookupRecordsByTableContext *ctx = cls;
2492 1 : struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg;
2493 1 : struct TALER_EXCHANGEDB_TableData td = {
2494 : .table = TALER_EXCHANGEDB_RT_WITHDRAW
2495 : };
2496 :
2497 1 : for (unsigned int i = 0; i<num_results; i++)
2498 : {
2499 : bool no_max_age;
2500 : bool no_noreveal_index;
2501 : bool no_selected_h;
2502 : bool no_cs_r_values;
2503 : bool no_cs_r_choices;
2504 : size_t num_sigs;
2505 0 : struct GNUNET_PQ_ResultSpec rs[] = {
2506 0 : GNUNET_PQ_result_spec_uint64 (
2507 : "withdraw_id",
2508 : &td.serial),
2509 0 : GNUNET_PQ_result_spec_auto_from_type (
2510 : "planchets_h",
2511 : &td.details.withdraw.planchets_h),
2512 0 : GNUNET_PQ_result_spec_timestamp (
2513 : "execution_date",
2514 : &td.details.withdraw.execution_date),
2515 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
2516 : "amount_with_fee",
2517 : &td.details.withdraw.amount_with_fee),
2518 0 : GNUNET_PQ_result_spec_auto_from_type (
2519 : "reserve_pub",
2520 : &td.details.withdraw.reserve_pub),
2521 0 : GNUNET_PQ_result_spec_auto_from_type (
2522 : "reserve_sig",
2523 : &td.details.withdraw.reserve_sig),
2524 0 : GNUNET_PQ_result_spec_allow_null (
2525 : GNUNET_PQ_result_spec_uint16 (
2526 : "max_age",
2527 : &td.details.withdraw.max_age),
2528 : &no_max_age),
2529 0 : GNUNET_PQ_result_spec_allow_null (
2530 : GNUNET_PQ_result_spec_uint16 (
2531 : "noreveal_index",
2532 : &td.details.withdraw.noreveal_index),
2533 : &no_noreveal_index),
2534 0 : GNUNET_PQ_result_spec_allow_null (
2535 : GNUNET_PQ_result_spec_auto_from_type (
2536 : "selected_h",
2537 : &td.details.withdraw.selected_h),
2538 : &no_selected_h),
2539 0 : GNUNET_PQ_result_spec_allow_null (
2540 : GNUNET_PQ_result_spec_auto_from_type (
2541 : "blinding_seed",
2542 : &td.details.withdraw.blinding_seed),
2543 : &td.details.withdraw.no_blinding_seed),
2544 0 : GNUNET_PQ_result_spec_allow_null (
2545 : TALER_PQ_result_spec_array_cs_r_pub (
2546 : pg->conn,
2547 : "cs_r_values",
2548 : &td.details.withdraw.num_cs_r_values,
2549 : &td.details.withdraw.cs_r_values),
2550 : &no_cs_r_values),
2551 0 : GNUNET_PQ_result_spec_allow_null (
2552 : GNUNET_PQ_result_spec_uint64 (
2553 : "cs_r_choices",
2554 : &td.details.withdraw.cs_r_choices),
2555 : &no_cs_r_choices),
2556 0 : GNUNET_PQ_result_spec_array_uint64 (
2557 : pg->conn,
2558 : "denom_serials",
2559 : &td.details.withdraw.num_coins,
2560 : &td.details.withdraw.denom_serials),
2561 0 : TALER_PQ_result_spec_array_blinded_denom_sig (
2562 : pg->conn,
2563 : "denom_sigs",
2564 : &num_sigs,
2565 : &td.details.withdraw.denom_sigs),
2566 : GNUNET_PQ_result_spec_end
2567 : };
2568 :
2569 0 : if (GNUNET_OK !=
2570 0 : GNUNET_PQ_extract_result (result,
2571 : rs,
2572 : i))
2573 : {
2574 0 : GNUNET_break (0);
2575 0 : ctx->error = true;
2576 0 : GNUNET_PQ_cleanup_result (rs);
2577 0 : return;
2578 : }
2579 0 : if (num_sigs != td.details.withdraw.num_coins)
2580 : {
2581 0 : GNUNET_break (0);
2582 0 : ctx->error = true;
2583 0 : GNUNET_PQ_cleanup_result (rs);
2584 0 : return;
2585 : }
2586 0 : if (no_max_age != no_noreveal_index)
2587 : {
2588 0 : GNUNET_break (0);
2589 0 : ctx->error = true;
2590 0 : GNUNET_PQ_cleanup_result (rs);
2591 0 : return;
2592 : }
2593 0 : if (no_max_age != no_selected_h)
2594 : {
2595 0 : GNUNET_break (0);
2596 0 : ctx->error = true;
2597 0 : GNUNET_PQ_cleanup_result (rs);
2598 0 : return;
2599 : }
2600 0 : if (no_cs_r_values != no_cs_r_choices)
2601 : {
2602 0 : GNUNET_break (0);
2603 0 : ctx->error = true;
2604 0 : GNUNET_PQ_cleanup_result (rs);
2605 0 : return;
2606 : }
2607 0 : if (no_cs_r_values != td.details.withdraw.no_blinding_seed)
2608 : {
2609 0 : GNUNET_break (0);
2610 0 : ctx->error = true;
2611 0 : GNUNET_PQ_cleanup_result (rs);
2612 0 : return;
2613 : }
2614 0 : td.details.withdraw.age_proof_required = ! no_max_age;
2615 0 : ctx->cb (ctx->cb_cls,
2616 : &td);
2617 0 : GNUNET_PQ_cleanup_result (rs);
2618 : }
2619 : }
2620 :
2621 :
2622 : /**
2623 : * Function called with legitimization_measures table entries.
2624 : *
2625 : * @param cls closure
2626 : * @param result the postgres result
2627 : * @param num_results the number of results in @a result
2628 : */
2629 : static void
2630 1 : lrbt_cb_table_legitimization_measures (void *cls,
2631 : PGresult *result,
2632 : unsigned int num_results)
2633 : {
2634 1 : struct LookupRecordsByTableContext *ctx = cls;
2635 1 : struct TALER_EXCHANGEDB_TableData td = {
2636 : .table = TALER_EXCHANGEDB_RT_LEGITIMIZATION_MEASURES
2637 : };
2638 :
2639 1 : for (unsigned int i = 0; i<num_results; i++)
2640 : {
2641 0 : struct GNUNET_PQ_ResultSpec rs[] = {
2642 0 : GNUNET_PQ_result_spec_uint64 ("serial",
2643 : &td.serial),
2644 0 : GNUNET_PQ_result_spec_auto_from_type (
2645 : "access_token",
2646 : &td.details.legitimization_measures.target_token),
2647 0 : GNUNET_PQ_result_spec_absolute_time (
2648 : "start_time",
2649 : &td.details.legitimization_measures.start_time),
2650 0 : TALER_PQ_result_spec_json (
2651 : "jmeasures",
2652 : &td.details.legitimization_measures.measures),
2653 0 : GNUNET_PQ_result_spec_uint32 (
2654 : "display_priority",
2655 : &td.details.legitimization_measures.display_priority),
2656 : GNUNET_PQ_result_spec_end
2657 : };
2658 :
2659 0 : if (GNUNET_OK !=
2660 0 : GNUNET_PQ_extract_result (result,
2661 : rs,
2662 : i))
2663 : {
2664 0 : GNUNET_break (0);
2665 0 : ctx->error = true;
2666 0 : return;
2667 : }
2668 0 : ctx->cb (ctx->cb_cls,
2669 : &td);
2670 0 : GNUNET_PQ_cleanup_result (rs);
2671 : }
2672 : }
2673 :
2674 :
2675 : /**
2676 : * Function called with legitimization_outcomes table entries.
2677 : *
2678 : * @param cls closure
2679 : * @param result the postgres result
2680 : * @param num_results the number of results in @a result
2681 : */
2682 : static void
2683 1 : lrbt_cb_table_legitimization_outcomes (void *cls,
2684 : PGresult *result,
2685 : unsigned int num_results)
2686 : {
2687 1 : struct LookupRecordsByTableContext *ctx = cls;
2688 1 : struct TALER_EXCHANGEDB_TableData td = {
2689 : .table = TALER_EXCHANGEDB_RT_LEGITIMIZATION_OUTCOMES
2690 : };
2691 :
2692 1 : for (unsigned int i = 0; i<num_results; i++)
2693 : {
2694 0 : struct GNUNET_PQ_ResultSpec rs[] = {
2695 0 : GNUNET_PQ_result_spec_uint64 ("serial",
2696 : &td.serial),
2697 0 : GNUNET_PQ_result_spec_auto_from_type (
2698 : "h_payto",
2699 : &td.details.legitimization_outcomes.h_payto),
2700 0 : GNUNET_PQ_result_spec_timestamp (
2701 : "decision_time",
2702 : &td.details.legitimization_outcomes.decision_time),
2703 0 : GNUNET_PQ_result_spec_timestamp (
2704 : "expiration_time",
2705 : &td.details.legitimization_outcomes.expiration_time),
2706 0 : GNUNET_PQ_result_spec_allow_null (
2707 : TALER_PQ_result_spec_json (
2708 : "jproperties",
2709 : &td.details.legitimization_outcomes.properties),
2710 : NULL),
2711 0 : GNUNET_PQ_result_spec_bool (
2712 : "to_investigate",
2713 : &td.details.legitimization_outcomes.to_investigate),
2714 0 : TALER_PQ_result_spec_json (
2715 : "jnew_rules",
2716 : &td.details.legitimization_outcomes.new_rules),
2717 : GNUNET_PQ_result_spec_end
2718 : };
2719 :
2720 0 : if (GNUNET_OK !=
2721 0 : GNUNET_PQ_extract_result (result,
2722 : rs,
2723 : i))
2724 : {
2725 0 : GNUNET_break (0);
2726 0 : ctx->error = true;
2727 0 : return;
2728 : }
2729 0 : ctx->cb (ctx->cb_cls,
2730 : &td);
2731 0 : GNUNET_PQ_cleanup_result (rs);
2732 : }
2733 : }
2734 :
2735 :
2736 : /**
2737 : * Function called with legitimization_processes table entries.
2738 : *
2739 : * @param cls closure
2740 : * @param result the postgres result
2741 : * @param num_results the number of results in @a result
2742 : */
2743 : static void
2744 1 : lrbt_cb_table_legitimization_processes (void *cls,
2745 : PGresult *result,
2746 : unsigned int num_results)
2747 : {
2748 1 : struct LookupRecordsByTableContext *ctx = cls;
2749 1 : struct TALER_EXCHANGEDB_TableData td = {
2750 : .table = TALER_EXCHANGEDB_RT_LEGITIMIZATION_PROCESSES
2751 : };
2752 :
2753 1 : for (unsigned int i = 0; i<num_results; i++)
2754 : {
2755 0 : struct GNUNET_PQ_ResultSpec rs[] = {
2756 0 : GNUNET_PQ_result_spec_uint64 ("serial",
2757 : &td.serial),
2758 0 : GNUNET_PQ_result_spec_auto_from_type (
2759 : "h_payto",
2760 : &td.details.legitimization_processes.h_payto),
2761 0 : GNUNET_PQ_result_spec_absolute_time (
2762 : "start_time",
2763 : &td.details.legitimization_processes.start_time),
2764 0 : GNUNET_PQ_result_spec_timestamp (
2765 : "expiration_time",
2766 : &td.details.legitimization_processes.expiration_time),
2767 0 : GNUNET_PQ_result_spec_uint64 (
2768 : "legitimization_measure_serial_id",
2769 : &td.details.legitimization_processes.legitimization_measure_serial_id),
2770 0 : GNUNET_PQ_result_spec_uint32 (
2771 : "measure_index",
2772 : &td.details.legitimization_processes.measure_index),
2773 0 : GNUNET_PQ_result_spec_string (
2774 : "provider_name",
2775 : &td.details.legitimization_processes.provider_name),
2776 0 : GNUNET_PQ_result_spec_allow_null (
2777 : GNUNET_PQ_result_spec_string (
2778 : "provider_user_id",
2779 : &td.details.legitimization_processes.provider_user_id),
2780 : NULL),
2781 0 : GNUNET_PQ_result_spec_allow_null (
2782 : GNUNET_PQ_result_spec_string (
2783 : "provider_legitimization_id",
2784 : &td.details.legitimization_processes.provider_legitimization_id),
2785 : NULL),
2786 0 : GNUNET_PQ_result_spec_allow_null (
2787 : GNUNET_PQ_result_spec_string (
2788 : "redirect_url",
2789 : &td.details.legitimization_processes.redirect_url),
2790 : NULL),
2791 : GNUNET_PQ_result_spec_end
2792 : };
2793 :
2794 0 : if (GNUNET_OK !=
2795 0 : GNUNET_PQ_extract_result (result,
2796 : rs,
2797 : i))
2798 : {
2799 0 : GNUNET_break (0);
2800 0 : ctx->error = true;
2801 0 : return;
2802 : }
2803 0 : ctx->cb (ctx->cb_cls,
2804 : &td);
2805 0 : GNUNET_PQ_cleanup_result (rs);
2806 : }
2807 : }
2808 :
2809 :
2810 : /**
2811 : * Function called with kyc_attributes table entries.
2812 : *
2813 : * @param cls closure
2814 : * @param result the postgres result
2815 : * @param num_results the number of results in @a result
2816 : */
2817 : static void
2818 1 : lrbt_cb_table_kyc_attributes (void *cls,
2819 : PGresult *result,
2820 : unsigned int num_results)
2821 : {
2822 1 : struct LookupRecordsByTableContext *ctx = cls;
2823 1 : struct TALER_EXCHANGEDB_TableData td = {
2824 : .table = TALER_EXCHANGEDB_RT_KYC_ATTRIBUTES
2825 : };
2826 :
2827 1 : for (unsigned int i = 0; i<num_results; i++)
2828 : {
2829 0 : struct GNUNET_PQ_ResultSpec rs[] = {
2830 0 : GNUNET_PQ_result_spec_uint64 (
2831 : "kyc_attributes_serial_id",
2832 : &td.serial),
2833 0 : GNUNET_PQ_result_spec_auto_from_type (
2834 : "h_payto",
2835 : &td.details.kyc_attributes.h_payto),
2836 0 : GNUNET_PQ_result_spec_uint64 (
2837 : "legitimization_serial",
2838 : &td.details.kyc_attributes.legitimization_serial),
2839 0 : GNUNET_PQ_result_spec_timestamp (
2840 : "collection_time",
2841 : &td.details.kyc_attributes.collection_time),
2842 0 : GNUNET_PQ_result_spec_timestamp (
2843 : "expiration_time",
2844 : &td.details.kyc_attributes.expiration_time),
2845 0 : GNUNET_PQ_result_spec_allow_null (
2846 : GNUNET_PQ_result_spec_string (
2847 : "form_name",
2848 : &td.details.kyc_attributes.form_name),
2849 : NULL),
2850 0 : GNUNET_PQ_result_spec_bool (
2851 : "by_aml_officer",
2852 : &td.details.kyc_attributes.by_aml_officer),
2853 0 : GNUNET_PQ_result_spec_variable_size (
2854 : "encrypted_attributes",
2855 : &td.details.kyc_attributes.encrypted_attributes,
2856 : &td.details.kyc_attributes.encrypted_attributes_size),
2857 : GNUNET_PQ_result_spec_end
2858 : };
2859 :
2860 0 : if (GNUNET_OK !=
2861 0 : GNUNET_PQ_extract_result (result,
2862 : rs,
2863 : i))
2864 : {
2865 0 : GNUNET_break (0);
2866 0 : ctx->error = true;
2867 0 : return;
2868 : }
2869 0 : ctx->cb (ctx->cb_cls,
2870 : &td);
2871 0 : GNUNET_PQ_cleanup_result (rs);
2872 : }
2873 : }
2874 :
2875 :
2876 : /**
2877 : * Function called with aml_history table entries.
2878 : *
2879 : * @param cls closure
2880 : * @param result the postgres result
2881 : * @param num_results the number of results in @a result
2882 : */
2883 : static void
2884 1 : lrbt_cb_table_aml_history (void *cls,
2885 : PGresult *result,
2886 : unsigned int num_results)
2887 : {
2888 1 : struct LookupRecordsByTableContext *ctx = cls;
2889 1 : struct TALER_EXCHANGEDB_TableData td = {
2890 : .table = TALER_EXCHANGEDB_RT_AML_HISTORY
2891 : };
2892 :
2893 1 : for (unsigned int i = 0; i<num_results; i++)
2894 : {
2895 0 : struct GNUNET_PQ_ResultSpec rs[] = {
2896 0 : GNUNET_PQ_result_spec_uint64 (
2897 : "aml_history_serial_id",
2898 : &td.serial),
2899 0 : GNUNET_PQ_result_spec_auto_from_type (
2900 : "h_payto",
2901 : &td.details.aml_history.h_payto),
2902 0 : GNUNET_PQ_result_spec_uint64 (
2903 : "outcome_serial_id",
2904 : &td.details.aml_history.outcome_serial_id),
2905 0 : GNUNET_PQ_result_spec_string (
2906 : "justification",
2907 : &td.details.aml_history.justification),
2908 0 : GNUNET_PQ_result_spec_auto_from_type (
2909 : "decider_pub",
2910 : &td.details.aml_history.decider_pub),
2911 0 : GNUNET_PQ_result_spec_auto_from_type (
2912 : "decider_sig",
2913 : &td.details.aml_history.decider_sig),
2914 0 : GNUNET_PQ_result_spec_allow_null (
2915 : GNUNET_PQ_result_spec_auto_from_type (
2916 : "kyc_attributes_hash",
2917 : &td.details.aml_history.kyc_attributes_hash),
2918 : &td.details.aml_history.no_kyc_attributes_hash),
2919 0 : GNUNET_PQ_result_spec_allow_null (
2920 : GNUNET_PQ_result_spec_uint64 (
2921 : "kyc_attributes_serial_id",
2922 : &td.details.aml_history.kyc_attributes_serial_id),
2923 : &td.details.aml_history.no_kyc_attributes_serial_id),
2924 : GNUNET_PQ_result_spec_end
2925 : };
2926 :
2927 0 : if (GNUNET_OK !=
2928 0 : GNUNET_PQ_extract_result (result,
2929 : rs,
2930 : i))
2931 : {
2932 0 : GNUNET_break (0);
2933 0 : ctx->error = true;
2934 0 : return;
2935 : }
2936 0 : ctx->cb (ctx->cb_cls,
2937 : &td);
2938 0 : GNUNET_PQ_cleanup_result (rs);
2939 : }
2940 : }
2941 :
2942 :
2943 : /**
2944 : * Function called with kyc_events table entries.
2945 : *
2946 : * @param cls closure
2947 : * @param result the postgres result
2948 : * @param num_results the number of results in @a result
2949 : */
2950 : static void
2951 1 : lrbt_cb_table_kyc_events (void *cls,
2952 : PGresult *result,
2953 : unsigned int num_results)
2954 : {
2955 1 : struct LookupRecordsByTableContext *ctx = cls;
2956 1 : struct TALER_EXCHANGEDB_TableData td = {
2957 : .table = TALER_EXCHANGEDB_RT_KYC_EVENTS
2958 : };
2959 :
2960 1 : for (unsigned int i = 0; i<num_results; i++)
2961 : {
2962 0 : struct GNUNET_PQ_ResultSpec rs[] = {
2963 0 : GNUNET_PQ_result_spec_uint64 (
2964 : "serial",
2965 : &td.serial),
2966 0 : GNUNET_PQ_result_spec_timestamp (
2967 : "event_timestamp",
2968 : &td.details.kyc_events.event_timestamp),
2969 0 : GNUNET_PQ_result_spec_string (
2970 : "event_type",
2971 : &td.details.kyc_events.event_type),
2972 : GNUNET_PQ_result_spec_end
2973 : };
2974 :
2975 0 : if (GNUNET_OK !=
2976 0 : GNUNET_PQ_extract_result (result,
2977 : rs,
2978 : i))
2979 : {
2980 0 : GNUNET_break (0);
2981 0 : ctx->error = true;
2982 0 : return;
2983 : }
2984 0 : ctx->cb (ctx->cb_cls,
2985 : &td);
2986 0 : GNUNET_PQ_cleanup_result (rs);
2987 : }
2988 : }
2989 :
2990 :
2991 : /**
2992 : * Assign statement to @a n and PREPARE
2993 : * @a sql under name @a n.
2994 : */
2995 : #define XPREPARE(n,sql) \
2996 : statement = n; \
2997 : PREPARE (pg, n, sql);
2998 :
2999 :
3000 : enum GNUNET_DB_QueryStatus
3001 60 : TALER_EXCHANGEDB_iterate_records_by_table (
3002 : struct TALER_EXCHANGEDB_PostgresContext *pg,
3003 : enum TALER_EXCHANGEDB_ReplicatedTable table,
3004 : uint64_t serial,
3005 : TALER_EXCHANGEDB_ReplicationCallback cb,
3006 : void *cb_cls)
3007 : {
3008 60 : struct GNUNET_PQ_QueryParam params[] = {
3009 60 : GNUNET_PQ_query_param_uint64 (&serial),
3010 : GNUNET_PQ_query_param_end
3011 : };
3012 60 : struct LookupRecordsByTableContext ctx = {
3013 : .pg = pg,
3014 : .cb = cb,
3015 : .cb_cls = cb_cls
3016 : };
3017 60 : GNUNET_PQ_PostgresResultHandler rh = NULL;
3018 60 : const char *statement = NULL;
3019 : enum GNUNET_DB_QueryStatus qs;
3020 :
3021 60 : switch (table)
3022 : {
3023 3 : case TALER_EXCHANGEDB_RT_DENOMINATIONS:
3024 3 : XPREPARE ("select_above_serial_by_table_denominations",
3025 : "SELECT"
3026 : " denominations_serial AS serial"
3027 : ",denom_type"
3028 : ",denom_pub"
3029 : ",master_sig"
3030 : ",valid_from"
3031 : ",expire_withdraw"
3032 : ",expire_deposit"
3033 : ",expire_legal"
3034 : ",coin"
3035 : ",fee_withdraw"
3036 : ",fee_deposit"
3037 : ",fee_refresh"
3038 : ",fee_refund"
3039 : ",age_mask"
3040 : " FROM denominations"
3041 : " WHERE denominations_serial > $1"
3042 : " ORDER BY denominations_serial ASC;");
3043 3 : rh = &lrbt_cb_table_denominations;
3044 3 : break;
3045 1 : case TALER_EXCHANGEDB_RT_DENOMINATION_REVOCATIONS:
3046 1 : XPREPARE ("select_above_serial_by_table_denomination_revocations",
3047 : "SELECT"
3048 : " denom_revocations_serial_id AS serial"
3049 : ",master_sig"
3050 : ",denominations_serial"
3051 : " FROM denomination_revocations"
3052 : " WHERE denom_revocations_serial_id > $1"
3053 : " ORDER BY denom_revocations_serial_id ASC;");
3054 1 : rh = &lrbt_cb_table_denomination_revocations;
3055 1 : break;
3056 5 : case TALER_EXCHANGEDB_RT_WIRE_TARGETS:
3057 5 : XPREPARE ("select_above_serial_by_table_wire_targets",
3058 : "SELECT"
3059 : " wire_target_serial_id AS serial"
3060 : ",payto_uri"
3061 : " FROM wire_targets"
3062 : " WHERE wire_target_serial_id > $1"
3063 : " ORDER BY wire_target_serial_id ASC;");
3064 5 : rh = &lrbt_cb_table_wire_targets;
3065 5 : break;
3066 1 : case TALER_EXCHANGEDB_RT_KYC_TARGETS:
3067 1 : XPREPARE ("select_above_serial_by_table_kyc_targets",
3068 : "SELECT"
3069 : " kyc_target_serial_id AS serial"
3070 : ",h_normalized_payto"
3071 : ",access_token"
3072 : ",target_pub"
3073 : ",is_wallet"
3074 : " FROM kyc_targets"
3075 : " WHERE kyc_target_serial_id > $1"
3076 : " ORDER BY kyc_target_serial_id ASC;");
3077 1 : rh = &lrbt_cb_table_kyc_targets;
3078 1 : break;
3079 1 : case TALER_EXCHANGEDB_RT_RESERVES:
3080 1 : XPREPARE ("select_above_serial_by_table_reserves",
3081 : "SELECT"
3082 : " reserve_uuid AS serial"
3083 : ",reserve_pub"
3084 : ",expiration_date"
3085 : ",gc_date"
3086 : " FROM reserves"
3087 : " WHERE reserve_uuid > $1"
3088 : " ORDER BY reserve_uuid ASC;");
3089 1 : rh = &lrbt_cb_table_reserves;
3090 1 : break;
3091 1 : case TALER_EXCHANGEDB_RT_RESERVES_IN:
3092 1 : XPREPARE ("select_above_serial_by_table_reserves_in",
3093 : "SELECT"
3094 : " reserve_in_serial_id AS serial"
3095 : ",reserve_pub"
3096 : ",wire_reference"
3097 : ",credit"
3098 : ",wire_source_h_payto"
3099 : ",exchange_account_section"
3100 : ",execution_date"
3101 : " FROM reserves_in"
3102 : " WHERE reserve_in_serial_id > $1"
3103 : " ORDER BY reserve_in_serial_id ASC;");
3104 1 : rh = &lrbt_cb_table_reserves_in;
3105 1 : break;
3106 1 : case TALER_EXCHANGEDB_RT_KYCAUTHS_IN:
3107 1 : XPREPARE ("select_above_serial_by_table_kycauth_in",
3108 : "SELECT"
3109 : " kycauth_in_serial_id AS serial"
3110 : ",account_pub"
3111 : ",wire_reference"
3112 : ",credit"
3113 : ",wire_source_h_payto"
3114 : ",exchange_account_section"
3115 : ",execution_date"
3116 : " FROM kycauths_in"
3117 : " WHERE kycauth_in_serial_id > $1"
3118 : " ORDER BY kycauth_in_serial_id ASC;");
3119 1 : rh = &lrbt_cb_table_kycauth_in;
3120 1 : break;
3121 1 : case TALER_EXCHANGEDB_RT_RESERVES_CLOSE:
3122 1 : XPREPARE ("select_above_serial_by_table_reserves_close",
3123 : "SELECT"
3124 : " close_uuid AS serial"
3125 : ",reserve_pub"
3126 : ",execution_date"
3127 : ",wtid"
3128 : ",wire_target_h_payto"
3129 : ",amount"
3130 : ",closing_fee"
3131 : " FROM reserves_close"
3132 : " WHERE close_uuid > $1"
3133 : " ORDER BY close_uuid ASC;");
3134 1 : rh = &lrbt_cb_table_reserves_close;
3135 1 : break;
3136 1 : case TALER_EXCHANGEDB_RT_RESERVES_OPEN_REQUESTS:
3137 1 : XPREPARE ("select_above_serial_by_table_reserves_open_requests",
3138 : "SELECT"
3139 : " open_request_uuid AS serial"
3140 : ",reserve_pub"
3141 : ",request_timestamp"
3142 : ",expiration_date"
3143 : ",reserve_sig"
3144 : ",reserve_payment"
3145 : ",requested_purse_limit"
3146 : " FROM reserves_open_requests"
3147 : " WHERE open_request_uuid > $1"
3148 : " ORDER BY open_request_uuid ASC;");
3149 1 : rh = &lrbt_cb_table_reserves_open_requests;
3150 1 : break;
3151 1 : case TALER_EXCHANGEDB_RT_RESERVES_OPEN_DEPOSITS:
3152 1 : XPREPARE ("select_above_serial_by_table_reserves_open_deposits",
3153 : "SELECT"
3154 : " reserve_open_deposit_uuid AS serial"
3155 : ",reserve_sig"
3156 : ",reserve_pub"
3157 : ",coin_pub"
3158 : ",coin_sig"
3159 : ",contribution"
3160 : " FROM reserves_open_deposits"
3161 : " WHERE reserve_open_deposit_uuid > $1"
3162 : " ORDER BY reserve_open_deposit_uuid ASC;");
3163 1 : rh = &lrbt_cb_table_reserves_open_deposits;
3164 1 : break;
3165 1 : case TALER_EXCHANGEDB_RT_AUDITORS:
3166 1 : XPREPARE ("select_above_serial_by_table_auditors",
3167 : "SELECT"
3168 : " auditor_uuid AS serial"
3169 : ",auditor_pub"
3170 : ",auditor_name"
3171 : ",auditor_url"
3172 : ",is_active"
3173 : ",last_change"
3174 : " FROM auditors"
3175 : " WHERE auditor_uuid > $1"
3176 : " ORDER BY auditor_uuid ASC;");
3177 1 : rh = &lrbt_cb_table_auditors;
3178 1 : break;
3179 1 : case TALER_EXCHANGEDB_RT_AUDITOR_DENOM_SIGS:
3180 1 : XPREPARE ("select_above_serial_by_table_auditor_denom_sigs",
3181 : "SELECT"
3182 : " auditor_denom_serial AS serial"
3183 : ",auditor_uuid"
3184 : ",denominations_serial"
3185 : ",auditor_sig"
3186 : " FROM auditor_denom_sigs"
3187 : " WHERE auditor_denom_serial > $1"
3188 : " ORDER BY auditor_denom_serial ASC;");
3189 1 : rh = &lrbt_cb_table_auditor_denom_sigs;
3190 1 : break;
3191 1 : case TALER_EXCHANGEDB_RT_EXCHANGE_SIGN_KEYS:
3192 1 : XPREPARE ("select_above_serial_by_table_exchange_sign_keys",
3193 : "SELECT"
3194 : " esk_serial AS serial"
3195 : ",exchange_pub"
3196 : ",master_sig"
3197 : ",valid_from"
3198 : ",expire_sign"
3199 : ",expire_legal"
3200 : " FROM exchange_sign_keys"
3201 : " WHERE esk_serial > $1"
3202 : " ORDER BY esk_serial ASC;");
3203 1 : rh = &lrbt_cb_table_exchange_sign_keys;
3204 1 : break;
3205 1 : case TALER_EXCHANGEDB_RT_SIGNKEY_REVOCATIONS:
3206 1 : XPREPARE ("select_above_serial_by_table_signkey_revocations",
3207 : "SELECT"
3208 : " signkey_revocations_serial_id AS serial"
3209 : ",esk_serial"
3210 : ",master_sig"
3211 : " FROM signkey_revocations"
3212 : " WHERE signkey_revocations_serial_id > $1"
3213 : " ORDER BY signkey_revocations_serial_id ASC;");
3214 1 : rh = &lrbt_cb_table_signkey_revocations;
3215 1 : break;
3216 1 : case TALER_EXCHANGEDB_RT_KNOWN_COINS:
3217 1 : XPREPARE ("select_above_serial_by_table_known_coins",
3218 : "SELECT"
3219 : " known_coin_id AS serial"
3220 : ",coin_pub"
3221 : ",denom_sig"
3222 : ",denominations_serial"
3223 : " FROM known_coins"
3224 : " WHERE known_coin_id > $1"
3225 : " ORDER BY known_coin_id ASC;");
3226 1 : rh = &lrbt_cb_table_known_coins;
3227 1 : break;
3228 3 : case TALER_EXCHANGEDB_RT_REFRESH:
3229 3 : XPREPARE ("select_above_serial_by_table_refresh",
3230 : "SELECT"
3231 : " refresh_id AS serial"
3232 : ",rc"
3233 : ",execution_date"
3234 : ",amount_with_fee"
3235 : ",old_coin_pub"
3236 : ",old_coin_sig"
3237 : ",refresh_seed"
3238 : ",noreveal_index"
3239 : ",planchets_h"
3240 : ",selected_h"
3241 : ",blinding_seed"
3242 : ",cs_r_values"
3243 : ",cs_r_choices"
3244 : ",denom_serials"
3245 : ",denom_sigs"
3246 : ",transfer_pubs"
3247 : ",revealed"
3248 : ",rc_version"
3249 : " FROM refresh"
3250 : " WHERE refresh_id > $1"
3251 : " ORDER BY refresh_id ASC;");
3252 3 : rh = &lrbt_cb_table_refresh;
3253 3 : break;
3254 1 : case TALER_EXCHANGEDB_RT_BATCH_DEPOSITS:
3255 1 : XPREPARE ("select_above_serial_by_table_batch_deposits",
3256 : "SELECT"
3257 : " batch_deposit_serial_id AS serial"
3258 : ",shard"
3259 : ",merchant_pub"
3260 : ",wallet_timestamp"
3261 : ",exchange_timestamp"
3262 : ",refund_deadline"
3263 : ",wire_deadline"
3264 : ",h_contract_terms"
3265 : ",wallet_data_hash"
3266 : ",wire_salt"
3267 : ",wire_target_h_payto"
3268 : ",total_amount"
3269 : ",total_without_fee"
3270 : ",merchant_sig"
3271 : ",done"
3272 : " FROM batch_deposits"
3273 : " WHERE batch_deposit_serial_id > $1"
3274 : " ORDER BY batch_deposit_serial_id ASC;");
3275 1 : rh = &lrbt_cb_table_batch_deposits;
3276 1 : break;
3277 1 : case TALER_EXCHANGEDB_RT_COIN_DEPOSITS:
3278 1 : XPREPARE ("select_above_serial_by_table_coin_deposits",
3279 : "SELECT"
3280 : " coin_deposit_serial_id AS serial"
3281 : ",batch_deposit_serial_id"
3282 : ",coin_pub"
3283 : ",coin_sig"
3284 : ",amount_with_fee"
3285 : " FROM coin_deposits"
3286 : " WHERE coin_deposit_serial_id > $1"
3287 : " ORDER BY coin_deposit_serial_id ASC;");
3288 1 : rh = &lrbt_cb_table_coin_deposits;
3289 1 : break;
3290 1 : case TALER_EXCHANGEDB_RT_REFUNDS:
3291 1 : XPREPARE ("select_above_serial_by_table_refunds",
3292 : "SELECT"
3293 : " refund_serial_id AS serial"
3294 : ",coin_pub"
3295 : ",merchant_sig"
3296 : ",rtransaction_id"
3297 : ",amount_with_fee"
3298 : ",batch_deposit_serial_id"
3299 : " FROM refunds"
3300 : " WHERE refund_serial_id > $1"
3301 : " ORDER BY refund_serial_id ASC;");
3302 1 : rh = &lrbt_cb_table_refunds;
3303 1 : break;
3304 1 : case TALER_EXCHANGEDB_RT_WIRE_OUT:
3305 1 : XPREPARE ("select_above_serial_by_table_wire_out",
3306 : "SELECT"
3307 : " wireout_uuid AS serial"
3308 : ",execution_date"
3309 : ",wtid_raw"
3310 : ",wire_target_h_payto"
3311 : ",exchange_account_section"
3312 : ",amount"
3313 : " FROM wire_out"
3314 : " WHERE wireout_uuid > $1"
3315 : " ORDER BY wireout_uuid ASC;");
3316 1 : rh = &lrbt_cb_table_wire_out;
3317 1 : break;
3318 1 : case TALER_EXCHANGEDB_RT_AGGREGATION_TRACKING:
3319 1 : XPREPARE ("select_above_serial_by_table_aggregation_tracking",
3320 : "SELECT"
3321 : " aggregation_serial_id AS serial"
3322 : ",batch_deposit_serial_id"
3323 : ",wtid_raw"
3324 : " FROM aggregation_tracking"
3325 : " WHERE aggregation_serial_id > $1"
3326 : " ORDER BY aggregation_serial_id ASC;");
3327 1 : rh = &lrbt_cb_table_aggregation_tracking;
3328 1 : break;
3329 1 : case TALER_EXCHANGEDB_RT_AGGREGATION_DEFERRALS:
3330 1 : XPREPARE ("select_above_serial_by_table_aggregation_deferrals",
3331 : "SELECT"
3332 : " aggregation_deferral_serial_id AS serial"
3333 : ",batch_deposit_serial_id"
3334 : ",wtid_raw"
3335 : ",wire_target_h_payto"
3336 : ",amount"
3337 : ",deferral_reason"
3338 : ",legitimization_requirement_serial_id"
3339 : ",deferral_time"
3340 : " FROM aggregation_deferrals"
3341 : " WHERE aggregation_deferral_serial_id > $1"
3342 : " ORDER BY aggregation_deferral_serial_id ASC;");
3343 1 : rh = &lrbt_cb_table_aggregation_deferrals;
3344 1 : break;
3345 1 : case TALER_EXCHANGEDB_RT_WIRE_FEE:
3346 1 : XPREPARE ("select_above_serial_by_table_wire_fee",
3347 : "SELECT"
3348 : " wire_fee_serial AS serial"
3349 : ",wire_method"
3350 : ",start_date"
3351 : ",end_date"
3352 : ",wire_fee"
3353 : ",closing_fee"
3354 : ",master_sig"
3355 : " FROM wire_fee"
3356 : " WHERE wire_fee_serial > $1"
3357 : " ORDER BY wire_fee_serial ASC;");
3358 1 : rh = &lrbt_cb_table_wire_fee;
3359 1 : break;
3360 1 : case TALER_EXCHANGEDB_RT_GLOBAL_FEE:
3361 1 : XPREPARE ("select_above_serial_by_table_global_fee",
3362 : "SELECT"
3363 : " global_fee_serial AS serial"
3364 : ",start_date"
3365 : ",end_date"
3366 : ",history_fee"
3367 : ",account_fee"
3368 : ",purse_fee"
3369 : ",purse_timeout"
3370 : ",history_expiration"
3371 : ",purse_account_limit"
3372 : ",master_sig"
3373 : " FROM global_fee"
3374 : " WHERE global_fee_serial > $1"
3375 : " ORDER BY global_fee_serial ASC;");
3376 1 : rh = &lrbt_cb_table_global_fee;
3377 1 : break;
3378 3 : case TALER_EXCHANGEDB_RT_RECOUP:
3379 3 : XPREPARE ("select_above_serial_by_table_recoup",
3380 : "SELECT"
3381 : " recoup_uuid AS serial"
3382 : ",coin_sig"
3383 : ",coin_blind"
3384 : ",amount"
3385 : ",recoup_timestamp"
3386 : ",coin_pub"
3387 : ",withdraw_id"
3388 : ",coin_index"
3389 : " FROM recoup"
3390 : " WHERE recoup_uuid > $1"
3391 : " ORDER BY recoup_uuid ASC;");
3392 3 : rh = &lrbt_cb_table_recoup;
3393 3 : break;
3394 3 : case TALER_EXCHANGEDB_RT_RECOUP_REFRESH:
3395 3 : XPREPARE ("select_above_serial_by_table_recoup_refresh",
3396 : "SELECT"
3397 : " recoup_refresh_uuid AS serial"
3398 : ",coin_sig"
3399 : ",coin_blind"
3400 : ",amount"
3401 : ",recoup_timestamp"
3402 : ",coin_pub"
3403 : ",known_coin_id"
3404 : ",refresh_id"
3405 : ",coin_index"
3406 : " FROM recoup_refresh"
3407 : " WHERE recoup_refresh_uuid > $1"
3408 : " ORDER BY recoup_refresh_uuid ASC;");
3409 3 : rh = &lrbt_cb_table_recoup_refresh;
3410 3 : break;
3411 1 : case TALER_EXCHANGEDB_RT_PURSE_REQUESTS:
3412 1 : XPREPARE ("select_above_serial_by_table_purse_requests",
3413 : "SELECT"
3414 : " purse_requests_serial_id"
3415 : ",purse_pub"
3416 : ",merge_pub"
3417 : ",purse_creation"
3418 : ",purse_expiration"
3419 : ",h_contract_terms"
3420 : ",age_limit"
3421 : ",flags"
3422 : ",amount_with_fee"
3423 : ",purse_fee"
3424 : ",purse_sig"
3425 : " FROM purse_requests"
3426 : " WHERE purse_requests_serial_id > $1"
3427 : " ORDER BY purse_requests_serial_id ASC;");
3428 1 : rh = &lrbt_cb_table_purse_requests;
3429 1 : break;
3430 1 : case TALER_EXCHANGEDB_RT_PURSE_DECISION:
3431 1 : XPREPARE ("select_above_serial_by_table_purse_decision",
3432 : "SELECT"
3433 : " purse_decision_serial_id"
3434 : ",purse_pub"
3435 : ",action_timestamp"
3436 : ",refunded"
3437 : " FROM purse_decision"
3438 : " WHERE purse_decision_serial_id > $1"
3439 : " ORDER BY purse_decision_serial_id ASC;");
3440 1 : rh = &lrbt_cb_table_purse_decision;
3441 1 : break;
3442 1 : case TALER_EXCHANGEDB_RT_PURSE_MERGES:
3443 1 : XPREPARE ("select_above_serial_by_table_purse_merges",
3444 : "SELECT"
3445 : " purse_merge_request_serial_id"
3446 : ",partner_serial_id"
3447 : ",reserve_pub"
3448 : ",purse_pub"
3449 : ",merge_sig"
3450 : ",merge_timestamp"
3451 : " FROM purse_merges"
3452 : " WHERE purse_merge_request_serial_id > $1"
3453 : " ORDER BY purse_merge_request_serial_id ASC;");
3454 1 : rh = &lrbt_cb_table_purse_merges;
3455 1 : break;
3456 1 : case TALER_EXCHANGEDB_RT_PURSE_DEPOSITS:
3457 1 : XPREPARE ("select_above_serial_by_table_purse_deposits",
3458 : "SELECT"
3459 : " purse_deposit_serial_id"
3460 : ",partner_serial_id"
3461 : ",purse_pub"
3462 : ",coin_pub"
3463 : ",amount_with_fee"
3464 : ",coin_sig"
3465 : " FROM purse_deposits"
3466 : " WHERE purse_deposit_serial_id > $1"
3467 : " ORDER BY purse_deposit_serial_id ASC;");
3468 1 : rh = &lrbt_cb_table_purse_deposits;
3469 1 : break;
3470 1 : case TALER_EXCHANGEDB_RT_ACCOUNT_MERGES:
3471 1 : XPREPARE ("select_above_serial_by_table_account_merges",
3472 : "SELECT"
3473 : " account_merge_request_serial_id"
3474 : ",reserve_pub"
3475 : ",reserve_sig"
3476 : ",purse_pub"
3477 : ",wallet_h_payto"
3478 : " FROM account_merges"
3479 : " WHERE account_merge_request_serial_id > $1"
3480 : " ORDER BY account_merge_request_serial_id ASC;");
3481 1 : rh = &lrbt_cb_table_account_merges;
3482 1 : break;
3483 1 : case TALER_EXCHANGEDB_RT_HISTORY_REQUESTS:
3484 1 : XPREPARE ("select_above_serial_by_table_history_requests",
3485 : "SELECT"
3486 : " history_request_serial_id"
3487 : ",reserve_pub"
3488 : ",request_timestamp"
3489 : ",reserve_sig"
3490 : ",history_fee"
3491 : " FROM history_requests"
3492 : " WHERE history_request_serial_id > $1"
3493 : " ORDER BY history_request_serial_id ASC;");
3494 1 : rh = &lrbt_cb_table_history_requests;
3495 1 : break;
3496 1 : case TALER_EXCHANGEDB_RT_CLOSE_REQUESTS:
3497 1 : XPREPARE ("select_above_serial_by_table_close_requests",
3498 : "SELECT"
3499 : " close_request_serial_id"
3500 : ",reserve_pub"
3501 : ",close_timestamp"
3502 : ",reserve_sig"
3503 : ",close"
3504 : ",close_fee"
3505 : ",payto_uri"
3506 : " FROM close_requests"
3507 : " WHERE close_request_serial_id > $1"
3508 : " ORDER BY close_request_serial_id ASC;");
3509 1 : rh = &lrbt_cb_table_close_requests;
3510 1 : break;
3511 1 : case TALER_EXCHANGEDB_RT_WADS_OUT:
3512 1 : XPREPARE ("select_above_serial_by_table_wads_out",
3513 : "SELECT"
3514 : " wad_out_serial_id"
3515 : ",wad_id"
3516 : ",partner_serial_id"
3517 : ",amount"
3518 : ",execution_time"
3519 : " FROM wads_out"
3520 : " WHERE wad_out_serial_id > $1"
3521 : " ORDER BY wad_out_serial_id ASC;");
3522 1 : rh = &lrbt_cb_table_wads_out;
3523 1 : break;
3524 1 : case TALER_EXCHANGEDB_RT_WADS_OUT_ENTRIES:
3525 1 : XPREPARE ("select_above_serial_by_table_wads_out_entries",
3526 : "SELECT"
3527 : " wad_out_entry_serial_id"
3528 : ",wad_out_serial_id"
3529 : ",reserve_pub"
3530 : ",purse_pub"
3531 : ",h_contract"
3532 : ",purse_expiration"
3533 : ",merge_timestamp"
3534 : ",amount_with_fee"
3535 : ",wad_fee"
3536 : ",deposit_fees"
3537 : ",reserve_sig"
3538 : ",purse_sig"
3539 : " FROM wad_out_entries"
3540 : " WHERE wad_out_entry_serial_id > $1"
3541 : " ORDER BY wad_out_entry_serial_id ASC;");
3542 1 : rh = &lrbt_cb_table_wads_out_entries;
3543 1 : break;
3544 1 : case TALER_EXCHANGEDB_RT_WADS_IN:
3545 1 : XPREPARE ("select_above_serial_by_table_wads_in",
3546 : "SELECT"
3547 : " wad_in_serial_id"
3548 : ",wad_id"
3549 : ",origin_exchange_url"
3550 : ",amount"
3551 : ",arrival_time"
3552 : " FROM wads_in"
3553 : " WHERE wad_in_serial_id > $1"
3554 : " ORDER BY wad_in_serial_id ASC;");
3555 1 : rh = &lrbt_cb_table_wads_in;
3556 1 : break;
3557 1 : case TALER_EXCHANGEDB_RT_WADS_IN_ENTRIES:
3558 1 : XPREPARE ("select_above_serial_by_table_wads_in_entries",
3559 : "SELECT"
3560 : " wad_in_entry_serial_id"
3561 : ",wad_in_serial_id"
3562 : ",reserve_pub"
3563 : ",purse_pub"
3564 : ",h_contract"
3565 : ",purse_expiration"
3566 : ",merge_timestamp"
3567 : ",amount_with_fee"
3568 : ",wad_fee"
3569 : ",deposit_fees"
3570 : ",reserve_sig"
3571 : ",purse_sig"
3572 : " FROM wad_in_entries"
3573 : " WHERE wad_in_entry_serial_id > $1"
3574 : " ORDER BY wad_in_entry_serial_id ASC;");
3575 1 : rh = &lrbt_cb_table_wads_in_entries;
3576 1 : break;
3577 1 : case TALER_EXCHANGEDB_RT_PROFIT_DRAINS:
3578 1 : XPREPARE ("select_above_serial_by_table_profit_drains",
3579 : "SELECT"
3580 : " profit_drain_serial_id"
3581 : ",wtid"
3582 : ",account_section"
3583 : ",payto_uri"
3584 : ",trigger_date"
3585 : ",amount"
3586 : ",master_sig"
3587 : " FROM profit_drains"
3588 : " WHERE profit_drain_serial_id > $1"
3589 : " ORDER BY profit_drain_serial_id ASC;");
3590 1 : rh = &lrbt_cb_table_profit_drains;
3591 1 : break;
3592 :
3593 1 : case TALER_EXCHANGEDB_RT_AML_STAFF:
3594 1 : XPREPARE ("select_above_serial_by_table_aml_staff",
3595 : "SELECT"
3596 : " aml_staff_uuid"
3597 : ",decider_pub"
3598 : ",master_sig"
3599 : ",decider_name"
3600 : ",is_active"
3601 : ",read_only"
3602 : ",last_change"
3603 : " FROM aml_staff"
3604 : " WHERE aml_staff_uuid > $1"
3605 : " ORDER BY aml_staff_uuid ASC;");
3606 1 : rh = &lrbt_cb_table_aml_staff;
3607 1 : break;
3608 1 : case TALER_EXCHANGEDB_RT_PURSE_DELETION:
3609 1 : XPREPARE ("select_above_serial_by_table_purse_deletion",
3610 : "SELECT"
3611 : " purse_deletion_serial_id"
3612 : ",purse_pub"
3613 : ",purse_sig"
3614 : " FROM purse_deletion"
3615 : " WHERE purse_deletion_serial_id > $1"
3616 : " ORDER BY purse_deletion_serial_id ASC;");
3617 1 : rh = &lrbt_cb_table_purse_deletion;
3618 1 : break;
3619 1 : case TALER_EXCHANGEDB_RT_WITHDRAW:
3620 1 : XPREPARE ("select_above_serial_by_table_withdraw",
3621 : "SELECT"
3622 : " withdraw_id"
3623 : ",planchets_h"
3624 : ",execution_date"
3625 : ",amount_with_fee"
3626 : ",reserve_pub"
3627 : ",reserve_sig"
3628 : ",max_age"
3629 : ",noreveal_index"
3630 : ",selected_h"
3631 : ",blinding_seed"
3632 : ",cs_r_values"
3633 : ",cs_r_choices"
3634 : ",denom_serials"
3635 : ",denom_sigs"
3636 : " FROM withdraw"
3637 : " WHERE withdraw_id > $1"
3638 : " ORDER BY withdraw_id ASC;");
3639 1 : rh = &lrbt_cb_table_withdraw;
3640 1 : break;
3641 1 : case TALER_EXCHANGEDB_RT_LEGITIMIZATION_MEASURES:
3642 1 : XPREPARE ("select_above_serial_by_table_legitimization_measures",
3643 : "SELECT"
3644 : " legitimization_measure_serial_id AS serial"
3645 : ",access_token"
3646 : ",start_time"
3647 : ",jmeasures::TEXT"
3648 : ",display_priority"
3649 : " FROM legitimization_measures"
3650 : " WHERE legitimization_measure_serial_id > $1"
3651 : " ORDER BY legitimization_measure_serial_id ASC;");
3652 1 : rh = &lrbt_cb_table_legitimization_measures;
3653 1 : break;
3654 1 : case TALER_EXCHANGEDB_RT_LEGITIMIZATION_OUTCOMES:
3655 1 : XPREPARE ("select_above_serial_by_table_legitimization_outcomes",
3656 : "SELECT"
3657 : " outcome_serial_id AS serial"
3658 : ",h_payto"
3659 : ",decision_time"
3660 : ",expiration_time"
3661 : ",jproperties::TEXT"
3662 : ",to_investigate"
3663 : ",jnew_rules::TEXT"
3664 : " FROM legitimization_outcomes"
3665 : " WHERE outcome_serial_id > $1"
3666 : " ORDER BY outcome_serial_id ASC;");
3667 1 : rh = &lrbt_cb_table_legitimization_outcomes;
3668 1 : break;
3669 1 : case TALER_EXCHANGEDB_RT_LEGITIMIZATION_PROCESSES:
3670 1 : XPREPARE ("select_above_serial_by_table_legitimization_processes",
3671 : "SELECT"
3672 : " legitimization_process_serial_id AS serial"
3673 : ",h_payto"
3674 : ",start_time"
3675 : ",expiration_time"
3676 : ",legitimization_measure_serial_id"
3677 : ",measure_index"
3678 : ",provider_name"
3679 : ",provider_user_id"
3680 : ",provider_legitimization_id"
3681 : ",redirect_url"
3682 : " FROM legitimization_processes"
3683 : " WHERE legitimization_process_serial_id > $1"
3684 : " ORDER BY legitimization_process_serial_id ASC;");
3685 1 : rh = &lrbt_cb_table_legitimization_processes;
3686 1 : break;
3687 1 : case TALER_EXCHANGEDB_RT_KYC_ATTRIBUTES:
3688 1 : XPREPARE ("select_above_serial_by_table_kyc_attributes",
3689 : "SELECT"
3690 : " kyc_attributes_serial_id"
3691 : ",h_payto"
3692 : ",legitimization_serial"
3693 : ",collection_time"
3694 : ",expiration_time"
3695 : ",form_name"
3696 : ",by_aml_officer"
3697 : ",encrypted_attributes"
3698 : " FROM kyc_attributes"
3699 : " WHERE kyc_attributes_serial_id > $1"
3700 : " ORDER BY kyc_attributes_serial_id ASC;");
3701 1 : rh = &lrbt_cb_table_kyc_attributes;
3702 1 : break;
3703 1 : case TALER_EXCHANGEDB_RT_AML_HISTORY:
3704 1 : XPREPARE ("select_above_serial_by_table_aml_history",
3705 : "SELECT"
3706 : " aml_history_serial_id"
3707 : ",h_payto"
3708 : ",outcome_serial_id"
3709 : ",justification"
3710 : ",decider_pub"
3711 : ",decider_sig"
3712 : ",kyc_attributes_hash"
3713 : ",kyc_attributes_serial_id"
3714 : " FROM aml_history"
3715 : " WHERE aml_history_serial_id > $1"
3716 : " ORDER BY aml_history_serial_id ASC;");
3717 1 : rh = &lrbt_cb_table_aml_history;
3718 1 : break;
3719 1 : case TALER_EXCHANGEDB_RT_KYC_EVENTS:
3720 1 : XPREPARE ("select_above_serial_by_table_kyc_events",
3721 : "SELECT"
3722 : " kyc_event_serial_id AS serial"
3723 : ",event_timestamp"
3724 : ",event_type"
3725 : " FROM kyc_events"
3726 : " WHERE kyc_event_serial_id > $1"
3727 : " ORDER BY kyc_event_serial_id ASC;");
3728 1 : rh = &lrbt_cb_table_kyc_events;
3729 1 : break;
3730 : }
3731 60 : if (NULL == rh)
3732 : {
3733 1 : GNUNET_break (0);
3734 1 : return GNUNET_DB_STATUS_HARD_ERROR;
3735 : }
3736 :
3737 59 : qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
3738 : statement,
3739 : params,
3740 : rh,
3741 : &ctx);
3742 59 : if (qs < 0)
3743 : {
3744 0 : GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
3745 : "Failed to run `%s'\n",
3746 : statement);
3747 0 : return qs;
3748 : }
3749 59 : if (ctx.error)
3750 : {
3751 0 : GNUNET_break (0);
3752 0 : return GNUNET_DB_STATUS_HARD_ERROR;
3753 : }
3754 59 : return qs;
3755 : }
3756 :
3757 :
3758 : #undef XPREPARE
3759 :
3760 : /* end of lookup_records_by_table.c */
|