Line data Source code
1 : /*
2 : This file is part of GNUnet
3 : Copyright (C) 2020, 2021, 2022 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/lrbt_callbacks.c
22 : * @brief callbacks used by postgres_lookup_records_by_table, to be
23 : * inlined into the plugin
24 : * @author Christian Grothoff
25 : */
26 :
27 :
28 : /**
29 : * Function called with denominations table entries.
30 : *
31 : * @param cls closure
32 : * @param result the postgres result
33 : * @param num_results the number of results in @a result
34 : */
35 : static void
36 0 : lrbt_cb_table_denominations (void *cls,
37 : PGresult *result,
38 : unsigned int num_results)
39 : {
40 0 : struct LookupRecordsByTableContext *ctx = cls;
41 0 : struct PostgresClosure *pg = ctx->pg;
42 0 : struct TALER_EXCHANGEDB_TableData td = {
43 : .table = TALER_EXCHANGEDB_RT_DENOMINATIONS
44 : };
45 :
46 0 : for (unsigned int i = 0; i<num_results; i++)
47 : {
48 0 : struct GNUNET_PQ_ResultSpec rs[] = {
49 0 : GNUNET_PQ_result_spec_uint64 (
50 : "serial",
51 : &td.serial),
52 0 : GNUNET_PQ_result_spec_uint32 (
53 : "denom_type",
54 : &td.details.denominations.denom_type),
55 0 : GNUNET_PQ_result_spec_uint32 (
56 : "age_mask",
57 : &td.details.denominations.age_mask),
58 0 : TALER_PQ_result_spec_denom_pub (
59 : "denom_pub",
60 : &td.details.denominations.denom_pub),
61 0 : GNUNET_PQ_result_spec_auto_from_type (
62 : "master_sig",
63 : &td.details.denominations.master_sig),
64 0 : GNUNET_PQ_result_spec_timestamp (
65 : "valid_from",
66 : &td.details.denominations.valid_from),
67 0 : GNUNET_PQ_result_spec_timestamp (
68 : "expire_withdraw",
69 : &td.details.denominations.
70 : expire_withdraw),
71 0 : GNUNET_PQ_result_spec_timestamp (
72 : "expire_deposit",
73 : &td.details.denominations.
74 : expire_deposit),
75 0 : GNUNET_PQ_result_spec_timestamp (
76 : "expire_legal",
77 : &td.details.denominations.expire_legal),
78 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
79 : "coin",
80 : &td.details.denominations.coin),
81 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
82 : "fee_withdraw",
83 : &td.details.denominations.fees.withdraw),
84 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
85 : "fee_deposit",
86 : &td.details.denominations.fees.deposit),
87 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
88 : "fee_refresh",
89 : &td.details.denominations.fees.refresh),
90 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
91 : "fee_refund",
92 : &td.details.denominations.fees.refund),
93 : GNUNET_PQ_result_spec_end
94 : };
95 :
96 0 : if (GNUNET_OK !=
97 0 : GNUNET_PQ_extract_result (result,
98 : rs,
99 : i))
100 : {
101 0 : GNUNET_break (0);
102 0 : ctx->error = true;
103 0 : return;
104 : }
105 0 : ctx->cb (ctx->cb_cls,
106 : &td);
107 0 : GNUNET_PQ_cleanup_result (rs);
108 : }
109 : }
110 :
111 :
112 : /**
113 : * Function called with denomination_revocations table entries.
114 : *
115 : * @param cls closure
116 : * @param result the postgres result
117 : * @param num_results the number of results in @a result
118 : */
119 : static void
120 0 : lrbt_cb_table_denomination_revocations (void *cls,
121 : PGresult *result,
122 : unsigned int num_results)
123 : {
124 0 : struct LookupRecordsByTableContext *ctx = cls;
125 0 : struct TALER_EXCHANGEDB_TableData td = {
126 : .table = TALER_EXCHANGEDB_RT_DENOMINATION_REVOCATIONS
127 : };
128 :
129 0 : for (unsigned int i = 0; i<num_results; i++)
130 : {
131 0 : struct GNUNET_PQ_ResultSpec rs[] = {
132 0 : GNUNET_PQ_result_spec_uint64 ("serial",
133 : &td.serial),
134 0 : GNUNET_PQ_result_spec_uint64 (
135 : "denominations_serial",
136 : &td.details.denomination_revocations.denominations_serial),
137 0 : GNUNET_PQ_result_spec_auto_from_type (
138 : "master_sig",
139 : &td.details.denomination_revocations.master_sig),
140 : GNUNET_PQ_result_spec_end
141 : };
142 :
143 0 : if (GNUNET_OK !=
144 0 : GNUNET_PQ_extract_result (result,
145 : rs,
146 : i))
147 : {
148 0 : GNUNET_break (0);
149 0 : ctx->error = true;
150 0 : return;
151 : }
152 0 : ctx->cb (ctx->cb_cls,
153 : &td);
154 0 : GNUNET_PQ_cleanup_result (rs);
155 : }
156 : }
157 :
158 :
159 : /**
160 : * Function called with wire_targets table entries.
161 : *
162 : * @param cls closure
163 : * @param result the postgres result
164 : * @param num_results the number of results in @a result
165 : */
166 : static void
167 0 : lrbt_cb_table_wire_targets (void *cls,
168 : PGresult *result,
169 : unsigned int num_results)
170 : {
171 0 : struct LookupRecordsByTableContext *ctx = cls;
172 0 : struct TALER_EXCHANGEDB_TableData td = {
173 : .table = TALER_EXCHANGEDB_RT_WIRE_TARGETS
174 : };
175 :
176 0 : for (unsigned int i = 0; i<num_results; i++)
177 : {
178 0 : struct GNUNET_PQ_ResultSpec rs[] = {
179 0 : GNUNET_PQ_result_spec_uint64 ("serial",
180 : &td.serial),
181 0 : GNUNET_PQ_result_spec_string ("payto_uri",
182 : &td.details.wire_targets.payto_uri),
183 : GNUNET_PQ_result_spec_end
184 : };
185 :
186 0 : if (GNUNET_OK !=
187 0 : GNUNET_PQ_extract_result (result,
188 : rs,
189 : i))
190 : {
191 0 : GNUNET_break (0);
192 0 : ctx->error = true;
193 0 : return;
194 : }
195 0 : ctx->cb (ctx->cb_cls,
196 : &td);
197 0 : GNUNET_PQ_cleanup_result (rs);
198 : }
199 : }
200 :
201 :
202 : /**
203 : * Function called with reserves table entries.
204 : *
205 : * @param cls closure
206 : * @param result the postgres result
207 : * @param num_results the number of results in @a result
208 : */
209 : static void
210 0 : lrbt_cb_table_reserves (void *cls,
211 : PGresult *result,
212 : unsigned int num_results)
213 : {
214 0 : struct LookupRecordsByTableContext *ctx = cls;
215 0 : struct TALER_EXCHANGEDB_TableData td = {
216 : .table = TALER_EXCHANGEDB_RT_RESERVES
217 : };
218 :
219 0 : for (unsigned int i = 0; i<num_results; i++)
220 : {
221 0 : struct GNUNET_PQ_ResultSpec rs[] = {
222 0 : GNUNET_PQ_result_spec_uint64 ("serial",
223 : &td.serial),
224 0 : GNUNET_PQ_result_spec_auto_from_type ("reserve_pub",
225 : &td.details.reserves.reserve_pub),
226 0 : GNUNET_PQ_result_spec_timestamp ("expiration_date",
227 : &td.details.reserves.expiration_date),
228 0 : GNUNET_PQ_result_spec_timestamp ("gc_date",
229 : &td.details.reserves.gc_date),
230 : GNUNET_PQ_result_spec_end
231 : };
232 :
233 0 : if (GNUNET_OK !=
234 0 : GNUNET_PQ_extract_result (result,
235 : rs,
236 : i))
237 : {
238 0 : GNUNET_break (0);
239 0 : ctx->error = true;
240 0 : return;
241 : }
242 0 : ctx->cb (ctx->cb_cls,
243 : &td);
244 0 : GNUNET_PQ_cleanup_result (rs);
245 : }
246 : }
247 :
248 :
249 : /**
250 : * Function called with reserves_in table entries.
251 : *
252 : * @param cls closure
253 : * @param result the postgres result
254 : * @param num_results the number of results in @a result
255 : */
256 : static void
257 0 : lrbt_cb_table_reserves_in (void *cls,
258 : PGresult *result,
259 : unsigned int num_results)
260 : {
261 0 : struct LookupRecordsByTableContext *ctx = cls;
262 0 : struct PostgresClosure *pg = ctx->pg;
263 0 : struct TALER_EXCHANGEDB_TableData td = {
264 : .table = TALER_EXCHANGEDB_RT_RESERVES_IN
265 : };
266 :
267 0 : for (unsigned int i = 0; i<num_results; i++)
268 : {
269 0 : struct GNUNET_PQ_ResultSpec rs[] = {
270 0 : GNUNET_PQ_result_spec_uint64 (
271 : "serial",
272 : &td.serial),
273 0 : GNUNET_PQ_result_spec_auto_from_type (
274 : "reserve_pub",
275 : &td.details.reserves_in.reserve_pub),
276 0 : GNUNET_PQ_result_spec_uint64 (
277 : "wire_reference",
278 : &td.details.reserves_in.wire_reference),
279 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
280 : "credit",
281 : &td.details.reserves_in.credit),
282 0 : GNUNET_PQ_result_spec_auto_from_type (
283 : "wire_source_h_payto",
284 : &td.details.reserves_in.sender_account_h_payto),
285 0 : GNUNET_PQ_result_spec_string (
286 : "exchange_account_section",
287 : &td.details.reserves_in.exchange_account_section),
288 0 : GNUNET_PQ_result_spec_timestamp (
289 : "execution_date",
290 : &td.details.reserves_in.execution_date),
291 : GNUNET_PQ_result_spec_end
292 : };
293 :
294 0 : if (GNUNET_OK !=
295 0 : GNUNET_PQ_extract_result (result,
296 : rs,
297 : i))
298 : {
299 0 : GNUNET_break (0);
300 0 : ctx->error = true;
301 0 : return;
302 : }
303 0 : ctx->cb (ctx->cb_cls,
304 : &td);
305 0 : GNUNET_PQ_cleanup_result (rs);
306 : }
307 : }
308 :
309 :
310 : /**
311 : * Function called with reserves_close table entries.
312 : *
313 : * @param cls closure
314 : * @param result the postgres result
315 : * @param num_results the number of results in @a result
316 : */
317 : static void
318 0 : lrbt_cb_table_reserves_close (void *cls,
319 : PGresult *result,
320 : unsigned int num_results)
321 : {
322 0 : struct LookupRecordsByTableContext *ctx = cls;
323 0 : struct PostgresClosure *pg = ctx->pg;
324 0 : struct TALER_EXCHANGEDB_TableData td = {
325 : .table = TALER_EXCHANGEDB_RT_RESERVES_CLOSE
326 : };
327 :
328 0 : for (unsigned int i = 0; i<num_results; i++)
329 : {
330 0 : struct GNUNET_PQ_ResultSpec rs[] = {
331 0 : GNUNET_PQ_result_spec_uint64 (
332 : "serial",
333 : &td.serial),
334 0 : GNUNET_PQ_result_spec_auto_from_type (
335 : "reserve_pub",
336 : &td.details.reserves_close.reserve_pub),
337 0 : GNUNET_PQ_result_spec_timestamp (
338 : "execution_date",
339 : &td.details.reserves_close.execution_date),
340 0 : GNUNET_PQ_result_spec_auto_from_type (
341 : "wtid",
342 : &td.details.reserves_close.wtid),
343 0 : GNUNET_PQ_result_spec_auto_from_type (
344 : "wire_target_h_payto",
345 : &td.details.reserves_close.sender_account_h_payto),
346 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
347 : "amount",
348 : &td.details.reserves_close.amount),
349 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
350 : "closing_fee",
351 : &td.details.reserves_close.closing_fee),
352 : GNUNET_PQ_result_spec_end
353 : };
354 :
355 0 : if (GNUNET_OK !=
356 0 : GNUNET_PQ_extract_result (result,
357 : rs,
358 : i))
359 : {
360 0 : GNUNET_break (0);
361 0 : ctx->error = true;
362 0 : return;
363 : }
364 0 : ctx->cb (ctx->cb_cls,
365 : &td);
366 0 : GNUNET_PQ_cleanup_result (rs);
367 : }
368 : }
369 :
370 :
371 : /**
372 : * Function called with reserves_out table entries.
373 : *
374 : * @param cls closure
375 : * @param result the postgres result
376 : * @param num_results the number of results in @a result
377 : */
378 : static void
379 0 : lrbt_cb_table_reserves_out (void *cls,
380 : PGresult *result,
381 : unsigned int num_results)
382 : {
383 0 : struct LookupRecordsByTableContext *ctx = cls;
384 0 : struct PostgresClosure *pg = ctx->pg;
385 0 : struct TALER_EXCHANGEDB_TableData td = {
386 : .table = TALER_EXCHANGEDB_RT_RESERVES_OUT
387 : };
388 :
389 0 : for (unsigned int i = 0; i<num_results; i++)
390 : {
391 0 : struct GNUNET_PQ_ResultSpec rs[] = {
392 0 : GNUNET_PQ_result_spec_uint64 (
393 : "serial",
394 : &td.serial),
395 0 : GNUNET_PQ_result_spec_auto_from_type (
396 : "h_blind_ev",
397 : &td.details.reserves_out.h_blind_ev),
398 0 : GNUNET_PQ_result_spec_uint64 (
399 : "denominations_serial",
400 : &td.details.reserves_out.denominations_serial),
401 0 : TALER_PQ_result_spec_blinded_denom_sig (
402 : "denom_sig",
403 : &td.details.reserves_out.denom_sig),
404 0 : GNUNET_PQ_result_spec_uint64 (
405 : "reserve_uuid",
406 : &td.details.reserves_out.reserve_uuid),
407 0 : GNUNET_PQ_result_spec_auto_from_type (
408 : "reserve_sig",
409 : &td.details.reserves_out.reserve_sig),
410 0 : GNUNET_PQ_result_spec_timestamp (
411 : "execution_date",
412 : &td.details.reserves_out.execution_date),
413 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
414 : "amount_with_fee",
415 : &td.details.reserves_out.amount_with_fee),
416 : GNUNET_PQ_result_spec_end
417 : };
418 :
419 0 : if (GNUNET_OK !=
420 0 : GNUNET_PQ_extract_result (result,
421 : rs,
422 : i))
423 : {
424 0 : GNUNET_break (0);
425 0 : ctx->error = true;
426 0 : return;
427 : }
428 0 : ctx->cb (ctx->cb_cls,
429 : &td);
430 0 : GNUNET_PQ_cleanup_result (rs);
431 : }
432 : }
433 :
434 :
435 : /**
436 : * Function called with auditors table entries.
437 : *
438 : * @param cls closure
439 : * @param result the postgres result
440 : * @param num_results the number of results in @a result
441 : */
442 : static void
443 0 : lrbt_cb_table_auditors (void *cls,
444 : PGresult *result,
445 : unsigned int num_results)
446 : {
447 0 : struct LookupRecordsByTableContext *ctx = cls;
448 0 : struct TALER_EXCHANGEDB_TableData td = {
449 : .table = TALER_EXCHANGEDB_RT_AUDITORS
450 : };
451 :
452 0 : for (unsigned int i = 0; i<num_results; i++)
453 : {
454 0 : struct GNUNET_PQ_ResultSpec rs[] = {
455 0 : GNUNET_PQ_result_spec_uint64 ("serial",
456 : &td.serial),
457 0 : GNUNET_PQ_result_spec_auto_from_type ("auditor_pub",
458 : &td.details.auditors.auditor_pub),
459 0 : GNUNET_PQ_result_spec_string ("auditor_url",
460 : &td.details.auditors.auditor_url),
461 0 : GNUNET_PQ_result_spec_string ("auditor_name",
462 : &td.details.auditors.auditor_name),
463 0 : GNUNET_PQ_result_spec_bool ("is_active",
464 : &td.details.auditors.is_active),
465 0 : GNUNET_PQ_result_spec_timestamp ("last_change",
466 : &td.details.auditors.last_change),
467 : GNUNET_PQ_result_spec_end
468 : };
469 :
470 0 : if (GNUNET_OK !=
471 0 : GNUNET_PQ_extract_result (result,
472 : rs,
473 : i))
474 : {
475 0 : GNUNET_break (0);
476 0 : ctx->error = true;
477 0 : return;
478 : }
479 0 : ctx->cb (ctx->cb_cls,
480 : &td);
481 0 : GNUNET_PQ_cleanup_result (rs);
482 : }
483 : }
484 :
485 :
486 : /**
487 : * Function called with auditor_denom_sigs table entries.
488 : *
489 : * @param cls closure
490 : * @param result the postgres result
491 : * @param num_results the number of results in @a result
492 : */
493 : static void
494 0 : lrbt_cb_table_auditor_denom_sigs (void *cls,
495 : PGresult *result,
496 : unsigned int num_results)
497 : {
498 0 : struct LookupRecordsByTableContext *ctx = cls;
499 0 : struct TALER_EXCHANGEDB_TableData td = {
500 : .table = TALER_EXCHANGEDB_RT_AUDITOR_DENOM_SIGS
501 : };
502 :
503 0 : for (unsigned int i = 0; i<num_results; i++)
504 : {
505 0 : struct GNUNET_PQ_ResultSpec rs[] = {
506 0 : GNUNET_PQ_result_spec_uint64 (
507 : "serial",
508 : &td.serial),
509 0 : GNUNET_PQ_result_spec_uint64 (
510 : "auditor_uuid",
511 : &td.details.auditor_denom_sigs.auditor_uuid),
512 0 : GNUNET_PQ_result_spec_uint64 (
513 : "denominations_serial",
514 : &td.details.auditor_denom_sigs.denominations_serial),
515 0 : GNUNET_PQ_result_spec_auto_from_type (
516 : "auditor_sig",
517 : &td.details.auditor_denom_sigs.auditor_sig),
518 : GNUNET_PQ_result_spec_end
519 : };
520 :
521 0 : if (GNUNET_OK !=
522 0 : GNUNET_PQ_extract_result (result,
523 : rs,
524 : i))
525 : {
526 0 : GNUNET_break (0);
527 0 : ctx->error = true;
528 0 : return;
529 : }
530 0 : ctx->cb (ctx->cb_cls,
531 : &td);
532 0 : GNUNET_PQ_cleanup_result (rs);
533 : }
534 : }
535 :
536 :
537 : /**
538 : * Function called with exchange_sign_keys table entries.
539 : *
540 : * @param cls closure
541 : * @param result the postgres result
542 : * @param num_results the number of results in @a result
543 : */
544 : static void
545 0 : lrbt_cb_table_exchange_sign_keys (void *cls,
546 : PGresult *result,
547 : unsigned int num_results)
548 : {
549 0 : struct LookupRecordsByTableContext *ctx = cls;
550 0 : struct TALER_EXCHANGEDB_TableData td = {
551 : .table = TALER_EXCHANGEDB_RT_EXCHANGE_SIGN_KEYS
552 : };
553 :
554 0 : for (unsigned int i = 0; i<num_results; i++)
555 : {
556 0 : struct GNUNET_PQ_ResultSpec rs[] = {
557 0 : GNUNET_PQ_result_spec_uint64 ("serial",
558 : &td.serial),
559 0 : GNUNET_PQ_result_spec_auto_from_type ("exchange_pub",
560 : &td.details.exchange_sign_keys.
561 : exchange_pub),
562 0 : GNUNET_PQ_result_spec_auto_from_type ("master_sig",
563 : &td.details.exchange_sign_keys.
564 : master_sig),
565 0 : GNUNET_PQ_result_spec_timestamp ("valid_from",
566 : &td.details.exchange_sign_keys.meta.
567 : start),
568 0 : GNUNET_PQ_result_spec_timestamp ("expire_sign",
569 : &td.details.exchange_sign_keys.meta.
570 : expire_sign),
571 0 : GNUNET_PQ_result_spec_timestamp ("expire_legal",
572 : &td.details.exchange_sign_keys.meta.
573 : expire_legal),
574 : GNUNET_PQ_result_spec_end
575 : };
576 :
577 0 : if (GNUNET_OK !=
578 0 : GNUNET_PQ_extract_result (result,
579 : rs,
580 : i))
581 : {
582 0 : GNUNET_break (0);
583 0 : ctx->error = true;
584 0 : return;
585 : }
586 0 : ctx->cb (ctx->cb_cls,
587 : &td);
588 0 : GNUNET_PQ_cleanup_result (rs);
589 : }
590 : }
591 :
592 :
593 : /**
594 : * Function called with signkey_revocations table entries.
595 : *
596 : * @param cls closure
597 : * @param result the postgres result
598 : * @param num_results the number of results in @a result
599 : */
600 : static void
601 0 : lrbt_cb_table_signkey_revocations (void *cls,
602 : PGresult *result,
603 : unsigned int num_results)
604 : {
605 0 : struct LookupRecordsByTableContext *ctx = cls;
606 0 : struct TALER_EXCHANGEDB_TableData td = {
607 : .table = TALER_EXCHANGEDB_RT_SIGNKEY_REVOCATIONS
608 : };
609 :
610 0 : for (unsigned int i = 0; i<num_results; i++)
611 : {
612 0 : struct GNUNET_PQ_ResultSpec rs[] = {
613 0 : GNUNET_PQ_result_spec_uint64 ("serial",
614 : &td.serial),
615 0 : GNUNET_PQ_result_spec_uint64 ("esk_serial",
616 : &td.details.signkey_revocations.esk_serial),
617 0 : GNUNET_PQ_result_spec_auto_from_type ("master_sig",
618 : &td.details.signkey_revocations.
619 : master_sig),
620 : GNUNET_PQ_result_spec_end
621 : };
622 :
623 0 : if (GNUNET_OK !=
624 0 : GNUNET_PQ_extract_result (result,
625 : rs,
626 : i))
627 : {
628 0 : GNUNET_break (0);
629 0 : ctx->error = true;
630 0 : return;
631 : }
632 0 : ctx->cb (ctx->cb_cls,
633 : &td);
634 0 : GNUNET_PQ_cleanup_result (rs);
635 : }
636 : }
637 :
638 :
639 : /**
640 : * Function called with known_coins table entries.
641 : *
642 : * @param cls closure
643 : * @param result the postgres result
644 : * @param num_results the number of results in @a result
645 : */
646 : static void
647 0 : lrbt_cb_table_known_coins (void *cls,
648 : PGresult *result,
649 : unsigned int num_results)
650 : {
651 0 : struct LookupRecordsByTableContext *ctx = cls;
652 0 : struct TALER_EXCHANGEDB_TableData td = {
653 : .table = TALER_EXCHANGEDB_RT_KNOWN_COINS
654 : };
655 :
656 0 : for (unsigned int i = 0; i<num_results; i++)
657 : {
658 0 : struct GNUNET_PQ_ResultSpec rs[] = {
659 0 : GNUNET_PQ_result_spec_uint64 (
660 : "serial",
661 : &td.serial),
662 0 : GNUNET_PQ_result_spec_auto_from_type (
663 : "coin_pub",
664 : &td.details.known_coins.coin_pub),
665 0 : TALER_PQ_result_spec_denom_sig (
666 : "denom_sig",
667 : &td.details.known_coins.denom_sig),
668 0 : GNUNET_PQ_result_spec_uint64 (
669 : "denominations_serial",
670 : &td.details.known_coins.denominations_serial),
671 : GNUNET_PQ_result_spec_end
672 : };
673 :
674 0 : if (GNUNET_OK !=
675 0 : GNUNET_PQ_extract_result (result,
676 : rs,
677 : i))
678 : {
679 0 : GNUNET_break (0);
680 0 : ctx->error = true;
681 0 : return;
682 : }
683 0 : ctx->cb (ctx->cb_cls,
684 : &td);
685 0 : GNUNET_PQ_cleanup_result (rs);
686 : }
687 : }
688 :
689 :
690 : /**
691 : * Function called with refresh_commitments table entries.
692 : *
693 : * @param cls closure
694 : * @param result the postgres result
695 : * @param num_results the number of results in @a result
696 : */
697 : static void
698 0 : lrbt_cb_table_refresh_commitments (void *cls,
699 : PGresult *result,
700 : unsigned int num_results)
701 : {
702 0 : struct LookupRecordsByTableContext *ctx = cls;
703 0 : struct PostgresClosure *pg = ctx->pg;
704 0 : struct TALER_EXCHANGEDB_TableData td = {
705 : .table = TALER_EXCHANGEDB_RT_REFRESH_COMMITMENTS
706 : };
707 :
708 0 : 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_auto_from_type (
715 : "rc",
716 : &td.details.refresh_commitments.rc),
717 0 : GNUNET_PQ_result_spec_auto_from_type (
718 : "old_coin_sig",
719 : &td.details.refresh_commitments.old_coin_sig),
720 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
721 : "amount_with_fee",
722 : &td.details.refresh_commitments.amount_with_fee),
723 0 : GNUNET_PQ_result_spec_uint32 (
724 : "noreveal_index",
725 : &td.details.refresh_commitments.noreveal_index),
726 0 : GNUNET_PQ_result_spec_auto_from_type (
727 : "old_coin_pub",
728 : &td.details.refresh_commitments.old_coin_pub),
729 : GNUNET_PQ_result_spec_end
730 : };
731 :
732 0 : if (GNUNET_OK !=
733 0 : GNUNET_PQ_extract_result (result,
734 : rs,
735 : i))
736 : {
737 0 : GNUNET_break (0);
738 0 : ctx->error = true;
739 0 : return;
740 : }
741 0 : ctx->cb (ctx->cb_cls,
742 : &td);
743 0 : GNUNET_PQ_cleanup_result (rs);
744 : }
745 : }
746 :
747 :
748 : /**
749 : * Function called with refresh_revealed_coins table entries.
750 : *
751 : * @param cls closure
752 : * @param result the postgres result
753 : * @param num_results the number of results in @a result
754 : */
755 : static void
756 0 : lrbt_cb_table_refresh_revealed_coins (void *cls,
757 : PGresult *result,
758 : unsigned int num_results)
759 : {
760 0 : struct LookupRecordsByTableContext *ctx = cls;
761 0 : struct TALER_EXCHANGEDB_TableData td = {
762 : .table = TALER_EXCHANGEDB_RT_REFRESH_REVEALED_COINS
763 : };
764 :
765 0 : for (unsigned int i = 0; i<num_results; i++)
766 : {
767 0 : struct GNUNET_PQ_ResultSpec rs[] = {
768 0 : GNUNET_PQ_result_spec_uint64 (
769 : "serial",
770 : &td.serial),
771 0 : GNUNET_PQ_result_spec_uint32 (
772 : "freshcoin_index",
773 : &td.details.refresh_revealed_coins.freshcoin_index),
774 0 : GNUNET_PQ_result_spec_auto_from_type (
775 : "link_sig",
776 : &td.details.refresh_revealed_coins.link_sig),
777 0 : GNUNET_PQ_result_spec_variable_size (
778 : "coin_ev",
779 : (void **) &td.details.refresh_revealed_coins.coin_ev,
780 : &td.details.refresh_revealed_coins.coin_ev_size),
781 0 : TALER_PQ_result_spec_blinded_denom_sig (
782 : "ev_sig",
783 : &td.details.refresh_revealed_coins.ev_sig),
784 0 : TALER_PQ_result_spec_exchange_withdraw_values (
785 : "ewv",
786 : &td.details.refresh_revealed_coins.ewv),
787 0 : GNUNET_PQ_result_spec_uint64 (
788 : "denominations_serial",
789 : &td.details.refresh_revealed_coins.denominations_serial),
790 0 : GNUNET_PQ_result_spec_uint64 (
791 : "melt_serial_id",
792 : &td.details.refresh_revealed_coins.melt_serial_id),
793 : GNUNET_PQ_result_spec_end
794 : };
795 :
796 0 : if (GNUNET_OK !=
797 0 : GNUNET_PQ_extract_result (result,
798 : rs,
799 : i))
800 : {
801 0 : GNUNET_break (0);
802 0 : ctx->error = true;
803 0 : return;
804 : }
805 0 : ctx->cb (ctx->cb_cls,
806 : &td);
807 0 : GNUNET_PQ_cleanup_result (rs);
808 : }
809 : }
810 :
811 :
812 : /**
813 : * Function called with refresh_transfer_keys table entries.
814 : *
815 : * @param cls closure
816 : * @param result the postgres result
817 : * @param num_results the number of results in @a result
818 : */
819 : static void
820 0 : lrbt_cb_table_refresh_transfer_keys (void *cls,
821 : PGresult *result,
822 : unsigned int num_results)
823 : {
824 0 : struct LookupRecordsByTableContext *ctx = cls;
825 0 : struct TALER_EXCHANGEDB_TableData td = {
826 : .table = TALER_EXCHANGEDB_RT_REFRESH_TRANSFER_KEYS
827 : };
828 :
829 0 : for (unsigned int i = 0; i<num_results; i++)
830 : {
831 : void *tpriv;
832 : size_t tpriv_size;
833 0 : struct GNUNET_PQ_ResultSpec rs[] = {
834 0 : GNUNET_PQ_result_spec_uint64 ("serial",
835 : &td.serial),
836 0 : GNUNET_PQ_result_spec_auto_from_type ("transfer_pub",
837 : &td.details.refresh_transfer_keys.tp),
838 0 : GNUNET_PQ_result_spec_variable_size ("transfer_privs",
839 : &tpriv,
840 : &tpriv_size),
841 0 : GNUNET_PQ_result_spec_uint64 ("melt_serial_id",
842 : &td.details.refresh_transfer_keys.
843 : melt_serial_id),
844 : GNUNET_PQ_result_spec_end
845 : };
846 :
847 0 : if (GNUNET_OK !=
848 0 : GNUNET_PQ_extract_result (result,
849 : rs,
850 : i))
851 : {
852 0 : GNUNET_break (0);
853 0 : ctx->error = true;
854 0 : return;
855 : }
856 : /* Both conditions should be identical, but we conservatively also guard against
857 : unwarranted changes to the structure here. */
858 0 : if ( (tpriv_size !=
859 0 : sizeof (td.details.refresh_transfer_keys.tprivs)) ||
860 0 : (tpriv_size !=
861 : (TALER_CNC_KAPPA - 1) * sizeof (struct TALER_TransferPrivateKeyP)) )
862 : {
863 0 : GNUNET_break (0);
864 0 : GNUNET_PQ_cleanup_result (rs);
865 0 : ctx->error = true;
866 0 : return;
867 : }
868 0 : memcpy (&td.details.refresh_transfer_keys.tprivs[0],
869 : tpriv,
870 : tpriv_size);
871 0 : ctx->cb (ctx->cb_cls,
872 : &td);
873 0 : GNUNET_PQ_cleanup_result (rs);
874 : }
875 : }
876 :
877 :
878 : /**
879 : * Function called with deposits table entries.
880 : *
881 : * @param cls closure
882 : * @param result the postgres result
883 : * @param num_results the number of results in @a result
884 : */
885 : static void
886 0 : lrbt_cb_table_deposits (void *cls,
887 : PGresult *result,
888 : unsigned int num_results)
889 : {
890 0 : struct LookupRecordsByTableContext *ctx = cls;
891 0 : struct PostgresClosure *pg = ctx->pg;
892 0 : struct TALER_EXCHANGEDB_TableData td = {
893 : .table = TALER_EXCHANGEDB_RT_DEPOSITS
894 : };
895 :
896 0 : for (unsigned int i = 0; i<num_results; i++)
897 : {
898 : bool no_extension;
899 0 : struct GNUNET_PQ_ResultSpec rs[] = {
900 0 : GNUNET_PQ_result_spec_uint64 (
901 : "serial",
902 : &td.serial),
903 0 : GNUNET_PQ_result_spec_uint64 (
904 : "shard",
905 : &td.details.deposits.shard),
906 0 : GNUNET_PQ_result_spec_uint64 (
907 : "known_coin_id",
908 : &td.details.deposits.known_coin_id),
909 0 : GNUNET_PQ_result_spec_auto_from_type (
910 : "coin_pub",
911 : &td.details.deposits.coin_pub),
912 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
913 : "amount_with_fee",
914 : &td.details.deposits.amount_with_fee),
915 0 : GNUNET_PQ_result_spec_timestamp (
916 : "wallet_timestamp",
917 : &td.details.deposits.wallet_timestamp),
918 0 : GNUNET_PQ_result_spec_timestamp (
919 : "exchange_timestamp",
920 : &td.details.deposits.exchange_timestamp),
921 0 : GNUNET_PQ_result_spec_timestamp (
922 : "refund_deadline",
923 : &td.details.deposits.refund_deadline),
924 0 : GNUNET_PQ_result_spec_timestamp (
925 : "wire_deadline",
926 : &td.details.deposits.wire_deadline),
927 0 : GNUNET_PQ_result_spec_auto_from_type (
928 : "merchant_pub",
929 : &td.details.deposits.merchant_pub),
930 0 : GNUNET_PQ_result_spec_auto_from_type (
931 : "h_contract_terms",
932 : &td.details.deposits.h_contract_terms),
933 0 : GNUNET_PQ_result_spec_auto_from_type (
934 : "coin_sig",
935 : &td.details.deposits.coin_sig),
936 0 : GNUNET_PQ_result_spec_auto_from_type (
937 : "wire_salt",
938 : &td.details.deposits.wire_salt),
939 0 : GNUNET_PQ_result_spec_auto_from_type (
940 : "wire_target_h_payto",
941 : &td.details.deposits.wire_target_h_payto),
942 0 : GNUNET_PQ_result_spec_auto_from_type (
943 : "extension_blocked",
944 : &td.details.deposits.extension_blocked),
945 0 : GNUNET_PQ_result_spec_allow_null (
946 : GNUNET_PQ_result_spec_uint64 (
947 : "extension_details_serial_id",
948 : &td.details.deposits.extension_details_serial_id),
949 : &no_extension),
950 : GNUNET_PQ_result_spec_end
951 : };
952 :
953 0 : if (GNUNET_OK !=
954 0 : GNUNET_PQ_extract_result (result,
955 : rs,
956 : i))
957 : {
958 0 : GNUNET_break (0);
959 0 : ctx->error = true;
960 0 : return;
961 : }
962 0 : ctx->cb (ctx->cb_cls,
963 : &td);
964 0 : GNUNET_PQ_cleanup_result (rs);
965 : }
966 : }
967 :
968 :
969 : /**
970 : * Function called with refunds table entries.
971 : *
972 : * @param cls closure
973 : * @param result the postgres result
974 : * @param num_results the number of results in @a result
975 : */
976 : static void
977 0 : lrbt_cb_table_refunds (void *cls,
978 : PGresult *result,
979 : unsigned int num_results)
980 : {
981 0 : struct LookupRecordsByTableContext *ctx = cls;
982 0 : struct PostgresClosure *pg = ctx->pg;
983 0 : struct TALER_EXCHANGEDB_TableData td = {
984 : .table = TALER_EXCHANGEDB_RT_REFUNDS
985 : };
986 :
987 0 : for (unsigned int i = 0; i<num_results; i++)
988 : {
989 0 : struct GNUNET_PQ_ResultSpec rs[] = {
990 0 : GNUNET_PQ_result_spec_uint64 (
991 : "serial",
992 : &td.serial),
993 0 : GNUNET_PQ_result_spec_auto_from_type (
994 : "coin_pub",
995 : &td.details.refunds.coin_pub),
996 0 : GNUNET_PQ_result_spec_auto_from_type (
997 : "merchant_sig",
998 : &td.details.refunds.merchant_sig),
999 0 : GNUNET_PQ_result_spec_uint64 (
1000 : "rtransaction_id",
1001 : &td.details.refunds.rtransaction_id),
1002 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1003 : "amount_with_fee",
1004 : &td.details.refunds.amount_with_fee),
1005 0 : GNUNET_PQ_result_spec_uint64 (
1006 : "deposit_serial_id",
1007 : &td.details.refunds.deposit_serial_id),
1008 : GNUNET_PQ_result_spec_end
1009 : };
1010 :
1011 0 : if (GNUNET_OK !=
1012 0 : GNUNET_PQ_extract_result (result,
1013 : rs,
1014 : i))
1015 : {
1016 0 : GNUNET_break (0);
1017 0 : ctx->error = true;
1018 0 : return;
1019 : }
1020 0 : ctx->cb (ctx->cb_cls,
1021 : &td);
1022 0 : GNUNET_PQ_cleanup_result (rs);
1023 : }
1024 : }
1025 :
1026 :
1027 : /**
1028 : * Function called with wire_out table entries.
1029 : *
1030 : * @param cls closure
1031 : * @param result the postgres result
1032 : * @param num_results the number of results in @a result
1033 : */
1034 : static void
1035 0 : lrbt_cb_table_wire_out (void *cls,
1036 : PGresult *result,
1037 : unsigned int num_results)
1038 : {
1039 0 : struct LookupRecordsByTableContext *ctx = cls;
1040 0 : struct PostgresClosure *pg = ctx->pg;
1041 0 : struct TALER_EXCHANGEDB_TableData td = {
1042 : .table = TALER_EXCHANGEDB_RT_WIRE_OUT
1043 : };
1044 :
1045 0 : for (unsigned int i = 0; i<num_results; i++)
1046 : {
1047 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1048 0 : GNUNET_PQ_result_spec_uint64 ("serial",
1049 : &td.serial),
1050 0 : GNUNET_PQ_result_spec_timestamp (
1051 : "execution_date",
1052 : &td.details.wire_out.execution_date),
1053 0 : GNUNET_PQ_result_spec_auto_from_type (
1054 : "wtid_raw",
1055 : &td.details.wire_out.wtid_raw),
1056 0 : GNUNET_PQ_result_spec_auto_from_type (
1057 : "wire_target_h_payto",
1058 : &td.details.wire_out.wire_target_h_payto),
1059 0 : GNUNET_PQ_result_spec_string (
1060 : "exchange_account_section",
1061 : &td.details.wire_out.exchange_account_section),
1062 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1063 : "amount",
1064 : &td.details.wire_out.amount),
1065 : GNUNET_PQ_result_spec_end
1066 : };
1067 :
1068 0 : if (GNUNET_OK !=
1069 0 : GNUNET_PQ_extract_result (result,
1070 : rs,
1071 : i))
1072 : {
1073 0 : GNUNET_break (0);
1074 0 : ctx->error = true;
1075 0 : return;
1076 : }
1077 0 : ctx->cb (ctx->cb_cls,
1078 : &td);
1079 0 : GNUNET_PQ_cleanup_result (rs);
1080 : }
1081 : }
1082 :
1083 :
1084 : /**
1085 : * Function called with aggregation_tracking table entries.
1086 : *
1087 : * @param cls closure
1088 : * @param result the postgres result
1089 : * @param num_results the number of results in @a result
1090 : */
1091 : static void
1092 0 : lrbt_cb_table_aggregation_tracking (void *cls,
1093 : PGresult *result,
1094 : unsigned int num_results)
1095 : {
1096 0 : struct LookupRecordsByTableContext *ctx = cls;
1097 0 : struct TALER_EXCHANGEDB_TableData td = {
1098 : .table = TALER_EXCHANGEDB_RT_AGGREGATION_TRACKING
1099 : };
1100 :
1101 0 : for (unsigned int i = 0; i<num_results; i++)
1102 : {
1103 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1104 0 : GNUNET_PQ_result_spec_uint64 (
1105 : "serial",
1106 : &td.serial),
1107 0 : GNUNET_PQ_result_spec_uint64 (
1108 : "deposit_serial_id",
1109 : &td.details.aggregation_tracking.deposit_serial_id),
1110 0 : GNUNET_PQ_result_spec_auto_from_type (
1111 : "wtid_raw",
1112 : &td.details.aggregation_tracking.wtid_raw),
1113 : GNUNET_PQ_result_spec_end
1114 : };
1115 :
1116 0 : if (GNUNET_OK !=
1117 0 : GNUNET_PQ_extract_result (result,
1118 : rs,
1119 : i))
1120 : {
1121 0 : GNUNET_break (0);
1122 0 : ctx->error = true;
1123 0 : return;
1124 : }
1125 0 : ctx->cb (ctx->cb_cls,
1126 : &td);
1127 0 : GNUNET_PQ_cleanup_result (rs);
1128 : }
1129 : }
1130 :
1131 :
1132 : /**
1133 : * Function called with wire_fee table entries.
1134 : *
1135 : * @param cls closure
1136 : * @param result the postgres result
1137 : * @param num_results the number of results in @a result
1138 : */
1139 : static void
1140 0 : lrbt_cb_table_wire_fee (void *cls,
1141 : PGresult *result,
1142 : unsigned int num_results)
1143 : {
1144 0 : struct LookupRecordsByTableContext *ctx = cls;
1145 0 : struct PostgresClosure *pg = ctx->pg;
1146 0 : struct TALER_EXCHANGEDB_TableData td = {
1147 : .table = TALER_EXCHANGEDB_RT_WIRE_FEE
1148 : };
1149 :
1150 0 : for (unsigned int i = 0; i<num_results; i++)
1151 : {
1152 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1153 0 : GNUNET_PQ_result_spec_uint64 ("serial",
1154 : &td.serial),
1155 0 : GNUNET_PQ_result_spec_string ("wire_method",
1156 : &td.details.wire_fee.wire_method),
1157 0 : GNUNET_PQ_result_spec_timestamp ("start_date",
1158 : &td.details.wire_fee.start_date),
1159 0 : GNUNET_PQ_result_spec_timestamp ("end_date",
1160 : &td.details.wire_fee.end_date),
1161 0 : TALER_PQ_RESULT_SPEC_AMOUNT ("wire_fee",
1162 : &td.details.wire_fee.fees.wire),
1163 0 : TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee",
1164 : &td.details.wire_fee.fees.closing),
1165 0 : TALER_PQ_RESULT_SPEC_AMOUNT ("wad_fee",
1166 : &td.details.wire_fee.fees.wad),
1167 0 : GNUNET_PQ_result_spec_auto_from_type ("master_sig",
1168 : &td.details.wire_fee.master_sig),
1169 : GNUNET_PQ_result_spec_end
1170 : };
1171 :
1172 0 : if (GNUNET_OK !=
1173 0 : GNUNET_PQ_extract_result (result,
1174 : rs,
1175 : i))
1176 : {
1177 0 : GNUNET_break (0);
1178 0 : ctx->error = true;
1179 0 : return;
1180 : }
1181 0 : ctx->cb (ctx->cb_cls,
1182 : &td);
1183 0 : GNUNET_PQ_cleanup_result (rs);
1184 : }
1185 : }
1186 :
1187 :
1188 : /**
1189 : * Function called with wire_fee table entries.
1190 : *
1191 : * @param cls closure
1192 : * @param result the postgres result
1193 : * @param num_results the number of results in @a result
1194 : */
1195 : static void
1196 0 : lrbt_cb_table_global_fee (void *cls,
1197 : PGresult *result,
1198 : unsigned int num_results)
1199 : {
1200 0 : struct LookupRecordsByTableContext *ctx = cls;
1201 0 : struct PostgresClosure *pg = ctx->pg;
1202 0 : struct TALER_EXCHANGEDB_TableData td = {
1203 : .table = TALER_EXCHANGEDB_RT_GLOBAL_FEE
1204 : };
1205 :
1206 0 : for (unsigned int i = 0; i<num_results; i++)
1207 : {
1208 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1209 0 : GNUNET_PQ_result_spec_uint64 (
1210 : "serial",
1211 : &td.serial),
1212 0 : GNUNET_PQ_result_spec_timestamp (
1213 : "start_date",
1214 : &td.details.global_fee.start_date),
1215 0 : GNUNET_PQ_result_spec_timestamp (
1216 : "end_date",
1217 : &td.details.global_fee.end_date),
1218 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1219 : "history_fee",
1220 : &td.details.global_fee.fees.history),
1221 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1222 : "kyc_fee",
1223 : &td.details.global_fee.fees.kyc),
1224 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1225 : "account_fee",
1226 : &td.details.global_fee.fees.account),
1227 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1228 : "purse_fee",
1229 : &td.details.global_fee.fees.purse),
1230 0 : GNUNET_PQ_result_spec_relative_time (
1231 : "purse_timeout",
1232 : &td.details.global_fee.purse_timeout),
1233 0 : GNUNET_PQ_result_spec_relative_time (
1234 : "kyc_timeout",
1235 : &td.details.global_fee.kyc_timeout),
1236 0 : GNUNET_PQ_result_spec_relative_time (
1237 : "history_expiration",
1238 : &td.details.global_fee.history_expiration),
1239 0 : GNUNET_PQ_result_spec_uint32 (
1240 : "purse_account_limit",
1241 : &td.details.global_fee.purse_account_limit),
1242 0 : GNUNET_PQ_result_spec_auto_from_type (
1243 : "master_sig",
1244 : &td.details.global_fee.master_sig),
1245 : GNUNET_PQ_result_spec_end
1246 : };
1247 :
1248 0 : if (GNUNET_OK !=
1249 0 : GNUNET_PQ_extract_result (result,
1250 : rs,
1251 : i))
1252 : {
1253 0 : GNUNET_break (0);
1254 0 : ctx->error = true;
1255 0 : return;
1256 : }
1257 0 : ctx->cb (ctx->cb_cls,
1258 : &td);
1259 0 : GNUNET_PQ_cleanup_result (rs);
1260 : }
1261 : }
1262 :
1263 :
1264 : /**
1265 : * Function called with recoup table entries.
1266 : *
1267 : * @param cls closure
1268 : * @param result the postgres result
1269 : * @param num_results the number of results in @a result
1270 : */
1271 : static void
1272 0 : lrbt_cb_table_recoup (void *cls,
1273 : PGresult *result,
1274 : unsigned int num_results)
1275 : {
1276 0 : struct LookupRecordsByTableContext *ctx = cls;
1277 0 : struct PostgresClosure *pg = ctx->pg;
1278 0 : struct TALER_EXCHANGEDB_TableData td = {
1279 : .table = TALER_EXCHANGEDB_RT_RECOUP
1280 : };
1281 :
1282 0 : for (unsigned int i = 0; i<num_results; i++)
1283 : {
1284 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1285 0 : GNUNET_PQ_result_spec_uint64 ("serial",
1286 : &td.serial),
1287 0 : GNUNET_PQ_result_spec_auto_from_type ("coin_sig",
1288 : &td.details.recoup.coin_sig),
1289 0 : GNUNET_PQ_result_spec_auto_from_type ("coin_blind",
1290 : &td.details.recoup.coin_blind),
1291 0 : TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
1292 : &td.details.recoup.amount),
1293 0 : GNUNET_PQ_result_spec_timestamp ("recoup_timestamp",
1294 : &td.details.recoup.timestamp),
1295 0 : GNUNET_PQ_result_spec_auto_from_type (
1296 : "coin_pub",
1297 : &td.details.recoup.coin_pub),
1298 0 : GNUNET_PQ_result_spec_uint64 ("reserve_out_serial_id",
1299 : &td.details.recoup.reserve_out_serial_id),
1300 : GNUNET_PQ_result_spec_end
1301 : };
1302 :
1303 0 : if (GNUNET_OK !=
1304 0 : GNUNET_PQ_extract_result (result,
1305 : rs,
1306 : i))
1307 : {
1308 0 : GNUNET_break (0);
1309 0 : ctx->error = true;
1310 0 : return;
1311 : }
1312 0 : ctx->cb (ctx->cb_cls,
1313 : &td);
1314 0 : GNUNET_PQ_cleanup_result (rs);
1315 : }
1316 : }
1317 :
1318 :
1319 : /**
1320 : * Function called with recoup_refresh table entries.
1321 : *
1322 : * @param cls closure
1323 : * @param result the postgres result
1324 : * @param num_results the number of results in @a result
1325 : */
1326 : static void
1327 0 : lrbt_cb_table_recoup_refresh (void *cls,
1328 : PGresult *result,
1329 : unsigned int num_results)
1330 : {
1331 0 : struct LookupRecordsByTableContext *ctx = cls;
1332 0 : struct PostgresClosure *pg = ctx->pg;
1333 0 : struct TALER_EXCHANGEDB_TableData td = {
1334 : .table = TALER_EXCHANGEDB_RT_RECOUP_REFRESH
1335 : };
1336 :
1337 0 : for (unsigned int i = 0; i<num_results; i++)
1338 : {
1339 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1340 0 : GNUNET_PQ_result_spec_uint64 ("serial",
1341 : &td.serial),
1342 0 : GNUNET_PQ_result_spec_auto_from_type ("coin_sig",
1343 : &td.details.recoup_refresh.coin_sig),
1344 0 : GNUNET_PQ_result_spec_auto_from_type (
1345 : "coin_blind",
1346 : &td.details.recoup_refresh.coin_blind),
1347 0 : TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
1348 : &td.details.recoup_refresh.amount),
1349 0 : GNUNET_PQ_result_spec_timestamp ("recoup_timestamp",
1350 : &td.details.recoup_refresh.timestamp),
1351 0 : GNUNET_PQ_result_spec_uint64 ("known_coin_id",
1352 : &td.details.recoup_refresh.known_coin_id),
1353 0 : GNUNET_PQ_result_spec_auto_from_type (
1354 : "coin_pub",
1355 : &td.details.recoup_refresh.coin_pub),
1356 0 : GNUNET_PQ_result_spec_uint64 ("rrc_serial",
1357 : &td.details.recoup_refresh.rrc_serial),
1358 : GNUNET_PQ_result_spec_end
1359 : };
1360 :
1361 0 : if (GNUNET_OK !=
1362 0 : GNUNET_PQ_extract_result (result,
1363 : rs,
1364 : i))
1365 : {
1366 0 : GNUNET_break (0);
1367 0 : ctx->error = true;
1368 0 : return;
1369 : }
1370 0 : ctx->cb (ctx->cb_cls,
1371 : &td);
1372 0 : GNUNET_PQ_cleanup_result (rs);
1373 : }
1374 : }
1375 :
1376 :
1377 : /**
1378 : * Function called with extensions table entries.
1379 : *
1380 : * @param cls closure
1381 : * @param result the postgres result
1382 : * @param num_results the number of results in @a result
1383 : */
1384 : static void
1385 0 : lrbt_cb_table_extensions (void *cls,
1386 : PGresult *result,
1387 : unsigned int num_results)
1388 : {
1389 0 : struct LookupRecordsByTableContext *ctx = cls;
1390 0 : struct TALER_EXCHANGEDB_TableData td = {
1391 : .table = TALER_EXCHANGEDB_RT_EXTENSIONS
1392 : };
1393 0 : bool no_config = false;
1394 :
1395 0 : for (unsigned int i = 0; i<num_results; i++)
1396 : {
1397 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1398 0 : GNUNET_PQ_result_spec_uint64 ("extension_id",
1399 : &td.serial),
1400 0 : GNUNET_PQ_result_spec_string ("name",
1401 : &td.details.extensions.name),
1402 0 : GNUNET_PQ_result_spec_allow_null (
1403 : GNUNET_PQ_result_spec_string ("config",
1404 : &td.details.extensions.config),
1405 : &no_config),
1406 : GNUNET_PQ_result_spec_end
1407 : };
1408 :
1409 0 : if (GNUNET_OK !=
1410 0 : GNUNET_PQ_extract_result (result,
1411 : rs,
1412 : i))
1413 : {
1414 0 : GNUNET_break (0);
1415 0 : ctx->error = true;
1416 0 : return;
1417 : }
1418 0 : ctx->cb (ctx->cb_cls,
1419 : &td);
1420 0 : GNUNET_PQ_cleanup_result (rs);
1421 : }
1422 : }
1423 :
1424 :
1425 : /**
1426 : * Function called with extension_details table entries.
1427 : *
1428 : * @param cls closure
1429 : * @param result the postgres result
1430 : * @param num_results the number of results in @a result
1431 : */
1432 : static void
1433 0 : lrbt_cb_table_extension_details (void *cls,
1434 : PGresult *result,
1435 : unsigned int num_results)
1436 : {
1437 0 : struct LookupRecordsByTableContext *ctx = cls;
1438 0 : struct TALER_EXCHANGEDB_TableData td = {
1439 : .table = TALER_EXCHANGEDB_RT_EXTENSION_DETAILS
1440 : };
1441 :
1442 0 : for (unsigned int i = 0; i<num_results; i++)
1443 : {
1444 0 : bool no_config = false;
1445 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1446 0 : GNUNET_PQ_result_spec_uint64 ("extension_details_serial_id",
1447 : &td.serial),
1448 0 : GNUNET_PQ_result_spec_allow_null (
1449 : GNUNET_PQ_result_spec_string ("extension_options",
1450 : &td.details.extension_details.
1451 : extension_options),
1452 : &no_config),
1453 : GNUNET_PQ_result_spec_end
1454 : };
1455 :
1456 0 : if (GNUNET_OK !=
1457 0 : GNUNET_PQ_extract_result (result,
1458 : rs,
1459 : i))
1460 : {
1461 0 : GNUNET_break (0);
1462 0 : ctx->error = true;
1463 0 : return;
1464 : }
1465 0 : ctx->cb (ctx->cb_cls,
1466 : &td);
1467 0 : GNUNET_PQ_cleanup_result (rs);
1468 : }
1469 : }
1470 :
1471 :
1472 : /**
1473 : * Function called with purse_requests table entries.
1474 : *
1475 : * @param cls closure
1476 : * @param result the postgres result
1477 : * @param num_results the number of results in @a result
1478 : */
1479 : static void
1480 0 : lrbt_cb_table_purse_requests (void *cls,
1481 : PGresult *result,
1482 : unsigned int num_results)
1483 : {
1484 0 : struct LookupRecordsByTableContext *ctx = cls;
1485 0 : struct PostgresClosure *pg = ctx->pg;
1486 0 : struct TALER_EXCHANGEDB_TableData td = {
1487 : .table = TALER_EXCHANGEDB_RT_PURSE_REQUESTS
1488 : };
1489 :
1490 0 : for (unsigned int i = 0; i<num_results; i++)
1491 : {
1492 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1493 0 : GNUNET_PQ_result_spec_uint64 (
1494 : "purse_requests_serial_id",
1495 : &td.serial),
1496 0 : GNUNET_PQ_result_spec_auto_from_type (
1497 : "purse_pub",
1498 : &td.details.purse_requests.purse_pub),
1499 0 : GNUNET_PQ_result_spec_auto_from_type (
1500 : "merge_pub",
1501 : &td.details.purse_requests.merge_pub),
1502 0 : GNUNET_PQ_result_spec_timestamp (
1503 : "purse_creation",
1504 : &td.details.purse_requests.purse_creation),
1505 0 : GNUNET_PQ_result_spec_timestamp (
1506 : "purse_expiration",
1507 : &td.details.purse_requests.purse_expiration),
1508 0 : GNUNET_PQ_result_spec_auto_from_type (
1509 : "h_contract_terms",
1510 : &td.details.purse_requests.h_contract_terms),
1511 0 : GNUNET_PQ_result_spec_uint32 (
1512 : "age_limit",
1513 : &td.details.purse_requests.age_limit),
1514 0 : GNUNET_PQ_result_spec_uint32 (
1515 : "flags",
1516 : &td.details.purse_requests.flags),
1517 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1518 : "amount_with_fee",
1519 : &td.details.purse_requests.amount_with_fee),
1520 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1521 : "purse_fee",
1522 : &td.details.purse_requests.purse_fee),
1523 0 : GNUNET_PQ_result_spec_auto_from_type (
1524 : "purse_sig",
1525 : &td.details.purse_requests.purse_sig),
1526 : GNUNET_PQ_result_spec_end
1527 : };
1528 :
1529 0 : if (GNUNET_OK !=
1530 0 : GNUNET_PQ_extract_result (result,
1531 : rs,
1532 : i))
1533 : {
1534 0 : GNUNET_break (0);
1535 0 : ctx->error = true;
1536 0 : return;
1537 : }
1538 0 : ctx->cb (ctx->cb_cls,
1539 : &td);
1540 0 : GNUNET_PQ_cleanup_result (rs);
1541 : }
1542 : }
1543 :
1544 :
1545 : /**
1546 : * Function called with purse_refunds table entries.
1547 : *
1548 : * @param cls closure
1549 : * @param result the postgres result
1550 : * @param num_results the number of results in @a result
1551 : */
1552 : static void
1553 0 : lrbt_cb_table_purse_refunds (void *cls,
1554 : PGresult *result,
1555 : unsigned int num_results)
1556 : {
1557 0 : struct LookupRecordsByTableContext *ctx = cls;
1558 0 : struct TALER_EXCHANGEDB_TableData td = {
1559 : .table = TALER_EXCHANGEDB_RT_PURSE_REFUNDS
1560 : };
1561 :
1562 0 : for (unsigned int i = 0; i<num_results; i++)
1563 : {
1564 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1565 0 : GNUNET_PQ_result_spec_uint64 (
1566 : "purse_refunds_serial_id",
1567 : &td.serial),
1568 0 : GNUNET_PQ_result_spec_auto_from_type (
1569 : "purse_pub",
1570 : &td.details.purse_refunds.purse_pub),
1571 : GNUNET_PQ_result_spec_end
1572 : };
1573 :
1574 0 : if (GNUNET_OK !=
1575 0 : GNUNET_PQ_extract_result (result,
1576 : rs,
1577 : i))
1578 : {
1579 0 : GNUNET_break (0);
1580 0 : ctx->error = true;
1581 0 : return;
1582 : }
1583 0 : ctx->cb (ctx->cb_cls,
1584 : &td);
1585 0 : GNUNET_PQ_cleanup_result (rs);
1586 : }
1587 : }
1588 :
1589 :
1590 : /**
1591 : * Function called with purse_merges table entries.
1592 : *
1593 : * @param cls closure
1594 : * @param result the postgres result
1595 : * @param num_results the number of results in @a result
1596 : */
1597 : static void
1598 0 : lrbt_cb_table_purse_merges (void *cls,
1599 : PGresult *result,
1600 : unsigned int num_results)
1601 : {
1602 0 : struct LookupRecordsByTableContext *ctx = cls;
1603 0 : struct TALER_EXCHANGEDB_TableData td = {
1604 : .table = TALER_EXCHANGEDB_RT_PURSE_MERGES
1605 : };
1606 :
1607 0 : for (unsigned int i = 0; i<num_results; i++)
1608 : {
1609 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1610 0 : GNUNET_PQ_result_spec_uint64 (
1611 : "purse_merge_request_serial_id",
1612 : &td.serial),
1613 0 : GNUNET_PQ_result_spec_uint64 (
1614 : "partner_serial_id",
1615 : &td.details.purse_merges.partner_serial_id),
1616 0 : GNUNET_PQ_result_spec_auto_from_type (
1617 : "reserve_pub",
1618 : &td.details.purse_merges.reserve_pub),
1619 0 : GNUNET_PQ_result_spec_auto_from_type (
1620 : "purse_pub",
1621 : &td.details.purse_merges.purse_pub),
1622 0 : GNUNET_PQ_result_spec_auto_from_type (
1623 : "merge_sig",
1624 : &td.details.purse_merges.merge_sig),
1625 0 : GNUNET_PQ_result_spec_timestamp (
1626 : "merge_timestamp",
1627 : &td.details.purse_merges.merge_timestamp),
1628 : GNUNET_PQ_result_spec_end
1629 : };
1630 :
1631 0 : if (GNUNET_OK !=
1632 0 : GNUNET_PQ_extract_result (result,
1633 : rs,
1634 : i))
1635 : {
1636 0 : GNUNET_break (0);
1637 0 : ctx->error = true;
1638 0 : return;
1639 : }
1640 0 : ctx->cb (ctx->cb_cls,
1641 : &td);
1642 0 : GNUNET_PQ_cleanup_result (rs);
1643 : }
1644 : }
1645 :
1646 :
1647 : /**
1648 : * Function called with purse_deposits table entries.
1649 : *
1650 : * @param cls closure
1651 : * @param result the postgres result
1652 : * @param num_results the number of results in @a result
1653 : */
1654 : static void
1655 0 : lrbt_cb_table_purse_deposits (void *cls,
1656 : PGresult *result,
1657 : unsigned int num_results)
1658 : {
1659 0 : struct LookupRecordsByTableContext *ctx = cls;
1660 0 : struct PostgresClosure *pg = ctx->pg;
1661 0 : struct TALER_EXCHANGEDB_TableData td = {
1662 : .table = TALER_EXCHANGEDB_RT_PURSE_DEPOSITS
1663 : };
1664 :
1665 0 : for (unsigned int i = 0; i<num_results; i++)
1666 : {
1667 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1668 0 : GNUNET_PQ_result_spec_uint64 (
1669 : "purse_deposit_serial_id",
1670 : &td.serial),
1671 0 : GNUNET_PQ_result_spec_uint64 (
1672 : "partner_serial_id",
1673 : &td.details.purse_deposits.partner_serial_id),
1674 0 : GNUNET_PQ_result_spec_auto_from_type (
1675 : "purse_pub",
1676 : &td.details.purse_deposits.purse_pub),
1677 0 : GNUNET_PQ_result_spec_auto_from_type (
1678 : "coin_pub",
1679 : &td.details.purse_deposits.coin_pub),
1680 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1681 : "amount_with_fee",
1682 : &td.details.purse_deposits.amount_with_fee),
1683 0 : GNUNET_PQ_result_spec_auto_from_type (
1684 : "coin_sig",
1685 : &td.details.purse_deposits.coin_sig),
1686 : GNUNET_PQ_result_spec_end
1687 : };
1688 :
1689 0 : if (GNUNET_OK !=
1690 0 : GNUNET_PQ_extract_result (result,
1691 : rs,
1692 : i))
1693 : {
1694 0 : GNUNET_break (0);
1695 0 : ctx->error = true;
1696 0 : return;
1697 : }
1698 0 : ctx->cb (ctx->cb_cls,
1699 : &td);
1700 0 : GNUNET_PQ_cleanup_result (rs);
1701 : }
1702 : }
1703 :
1704 :
1705 : /**
1706 : * Function called with account_merges table entries.
1707 : *
1708 : * @param cls closure
1709 : * @param result the postgres result
1710 : * @param num_results the number of results in @a result
1711 : */
1712 : static void
1713 0 : lrbt_cb_table_account_merges (void *cls,
1714 : PGresult *result,
1715 : unsigned int num_results)
1716 : {
1717 0 : struct LookupRecordsByTableContext *ctx = cls;
1718 0 : struct TALER_EXCHANGEDB_TableData td = {
1719 : .table = TALER_EXCHANGEDB_RT_ACCOUNT_MERGES
1720 : };
1721 :
1722 0 : for (unsigned int i = 0; i<num_results; i++)
1723 : {
1724 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1725 0 : GNUNET_PQ_result_spec_uint64 (
1726 : "account_merge_request_serial_id",
1727 : &td.serial),
1728 0 : GNUNET_PQ_result_spec_auto_from_type (
1729 : "reserve_pub",
1730 : &td.details.account_merges.reserve_pub),
1731 0 : GNUNET_PQ_result_spec_auto_from_type (
1732 : "reserve_sig",
1733 : &td.details.account_merges.reserve_sig),
1734 0 : GNUNET_PQ_result_spec_auto_from_type (
1735 : "purse_pub",
1736 : &td.details.account_merges.purse_pub),
1737 : GNUNET_PQ_result_spec_end
1738 : };
1739 :
1740 0 : if (GNUNET_OK !=
1741 0 : GNUNET_PQ_extract_result (result,
1742 : rs,
1743 : i))
1744 : {
1745 0 : GNUNET_break (0);
1746 0 : ctx->error = true;
1747 0 : return;
1748 : }
1749 0 : ctx->cb (ctx->cb_cls,
1750 : &td);
1751 0 : GNUNET_PQ_cleanup_result (rs);
1752 : }
1753 : }
1754 :
1755 :
1756 : /**
1757 : * Function called with history_requests table entries.
1758 : *
1759 : * @param cls closure
1760 : * @param result the postgres result
1761 : * @param num_results the number of results in @a result
1762 : */
1763 : static void
1764 0 : lrbt_cb_table_history_requests (void *cls,
1765 : PGresult *result,
1766 : unsigned int num_results)
1767 : {
1768 0 : struct LookupRecordsByTableContext *ctx = cls;
1769 0 : struct PostgresClosure *pg = ctx->pg;
1770 0 : struct TALER_EXCHANGEDB_TableData td = {
1771 : .table = TALER_EXCHANGEDB_RT_HISTORY_REQUESTS
1772 : };
1773 :
1774 0 : for (unsigned int i = 0; i<num_results; i++)
1775 : {
1776 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1777 0 : GNUNET_PQ_result_spec_uint64 (
1778 : "history_request_serial_id",
1779 : &td.serial),
1780 0 : GNUNET_PQ_result_spec_auto_from_type (
1781 : "reserve_pub",
1782 : &td.details.history_requests.reserve_pub),
1783 0 : GNUNET_PQ_result_spec_auto_from_type (
1784 : "reserve_sig",
1785 : &td.details.history_requests.reserve_sig),
1786 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1787 : "history_fee",
1788 : &td.details.history_requests.history_fee),
1789 : GNUNET_PQ_result_spec_end
1790 : };
1791 :
1792 0 : if (GNUNET_OK !=
1793 0 : GNUNET_PQ_extract_result (result,
1794 : rs,
1795 : i))
1796 : {
1797 0 : GNUNET_break (0);
1798 0 : ctx->error = true;
1799 0 : return;
1800 : }
1801 0 : ctx->cb (ctx->cb_cls,
1802 : &td);
1803 0 : GNUNET_PQ_cleanup_result (rs);
1804 : }
1805 : }
1806 :
1807 :
1808 : /**
1809 : * Function called with close_requests table entries.
1810 : *
1811 : * @param cls closure
1812 : * @param result the postgres result
1813 : * @param num_results the number of results in @a result
1814 : */
1815 : static void
1816 0 : lrbt_cb_table_close_requests (void *cls,
1817 : PGresult *result,
1818 : unsigned int num_results)
1819 : {
1820 0 : struct LookupRecordsByTableContext *ctx = cls;
1821 0 : struct PostgresClosure *pg = ctx->pg;
1822 0 : struct TALER_EXCHANGEDB_TableData td = {
1823 : .table = TALER_EXCHANGEDB_RT_CLOSE_REQUESTS
1824 : };
1825 :
1826 0 : for (unsigned int i = 0; i<num_results; i++)
1827 : {
1828 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1829 0 : GNUNET_PQ_result_spec_uint64 (
1830 : "close_request_serial_id",
1831 : &td.serial),
1832 0 : GNUNET_PQ_result_spec_auto_from_type (
1833 : "reserve_pub",
1834 : &td.details.close_requests.reserve_pub),
1835 0 : GNUNET_PQ_result_spec_auto_from_type (
1836 : "reserve_sig",
1837 : &td.details.close_requests.reserve_sig),
1838 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1839 : "close",
1840 : &td.details.close_requests.close),
1841 : GNUNET_PQ_result_spec_end
1842 : };
1843 :
1844 0 : if (GNUNET_OK !=
1845 0 : GNUNET_PQ_extract_result (result,
1846 : rs,
1847 : i))
1848 : {
1849 0 : GNUNET_break (0);
1850 0 : ctx->error = true;
1851 0 : return;
1852 : }
1853 0 : ctx->cb (ctx->cb_cls,
1854 : &td);
1855 0 : GNUNET_PQ_cleanup_result (rs);
1856 : }
1857 : }
1858 :
1859 :
1860 : /**
1861 : * Function called with wads_out table entries.
1862 : *
1863 : * @param cls closure
1864 : * @param result the postgres result
1865 : * @param num_results the number of results in @a result
1866 : */
1867 : static void
1868 0 : lrbt_cb_table_wads_out (void *cls,
1869 : PGresult *result,
1870 : unsigned int num_results)
1871 : {
1872 0 : struct LookupRecordsByTableContext *ctx = cls;
1873 0 : struct PostgresClosure *pg = ctx->pg;
1874 0 : struct TALER_EXCHANGEDB_TableData td = {
1875 : .table = TALER_EXCHANGEDB_RT_WADS_OUT
1876 : };
1877 :
1878 0 : for (unsigned int i = 0; i<num_results; i++)
1879 : {
1880 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1881 0 : GNUNET_PQ_result_spec_uint64 (
1882 : "wad_out_serial_id",
1883 : &td.serial),
1884 0 : GNUNET_PQ_result_spec_auto_from_type (
1885 : "wad_id",
1886 : &td.details.wads_out.wad_id),
1887 0 : GNUNET_PQ_result_spec_uint64 (
1888 : "partner_serial_id",
1889 : &td.details.wads_out.partner_serial_id),
1890 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1891 : "amount",
1892 : &td.details.wads_out.amount),
1893 0 : GNUNET_PQ_result_spec_timestamp (
1894 : "execution_time",
1895 : &td.details.wads_out.execution_time),
1896 : GNUNET_PQ_result_spec_end
1897 : };
1898 :
1899 0 : if (GNUNET_OK !=
1900 0 : GNUNET_PQ_extract_result (result,
1901 : rs,
1902 : i))
1903 : {
1904 0 : GNUNET_break (0);
1905 0 : ctx->error = true;
1906 0 : return;
1907 : }
1908 0 : ctx->cb (ctx->cb_cls,
1909 : &td);
1910 0 : GNUNET_PQ_cleanup_result (rs);
1911 : }
1912 : }
1913 :
1914 :
1915 : /**
1916 : * Function called with wads_out_entries table entries.
1917 : *
1918 : * @param cls closure
1919 : * @param result the postgres result
1920 : * @param num_results the number of results in @a result
1921 : */
1922 : static void
1923 0 : lrbt_cb_table_wads_out_entries (void *cls,
1924 : PGresult *result,
1925 : unsigned int num_results)
1926 : {
1927 0 : struct LookupRecordsByTableContext *ctx = cls;
1928 0 : struct PostgresClosure *pg = ctx->pg;
1929 0 : struct TALER_EXCHANGEDB_TableData td = {
1930 : .table = TALER_EXCHANGEDB_RT_WADS_OUT_ENTRIES
1931 : };
1932 :
1933 0 : for (unsigned int i = 0; i<num_results; i++)
1934 : {
1935 0 : struct GNUNET_PQ_ResultSpec rs[] = {
1936 0 : GNUNET_PQ_result_spec_uint64 (
1937 : "wad_out_entry_serial_id",
1938 : &td.serial),
1939 0 : GNUNET_PQ_result_spec_auto_from_type (
1940 : "reserve_pub",
1941 : &td.details.wads_out_entries.reserve_pub),
1942 0 : GNUNET_PQ_result_spec_auto_from_type (
1943 : "purse_pub",
1944 : &td.details.wads_out_entries.purse_pub),
1945 0 : GNUNET_PQ_result_spec_auto_from_type (
1946 : "h_contract",
1947 : &td.details.wads_out_entries.h_contract),
1948 0 : GNUNET_PQ_result_spec_timestamp (
1949 : "purse_expiration",
1950 : &td.details.wads_out_entries.purse_expiration),
1951 0 : GNUNET_PQ_result_spec_timestamp (
1952 : "merge_timestamp",
1953 : &td.details.wads_out_entries.merge_timestamp),
1954 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1955 : "amount_with_fee",
1956 : &td.details.wads_out_entries.amount_with_fee),
1957 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1958 : "wad_fee",
1959 : &td.details.wads_out_entries.wad_fee),
1960 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
1961 : "deposit_fees",
1962 : &td.details.wads_out_entries.deposit_fees),
1963 0 : GNUNET_PQ_result_spec_auto_from_type (
1964 : "reserve_sig",
1965 : &td.details.wads_out_entries.reserve_sig),
1966 0 : GNUNET_PQ_result_spec_auto_from_type (
1967 : "purse_sig",
1968 : &td.details.wads_out_entries.purse_sig),
1969 : GNUNET_PQ_result_spec_end
1970 : };
1971 :
1972 0 : if (GNUNET_OK !=
1973 0 : GNUNET_PQ_extract_result (result,
1974 : rs,
1975 : i))
1976 : {
1977 0 : GNUNET_break (0);
1978 0 : ctx->error = true;
1979 0 : return;
1980 : }
1981 0 : ctx->cb (ctx->cb_cls,
1982 : &td);
1983 0 : GNUNET_PQ_cleanup_result (rs);
1984 : }
1985 : }
1986 :
1987 :
1988 : /**
1989 : * Function called with wads_in table entries.
1990 : *
1991 : * @param cls closure
1992 : * @param result the postgres result
1993 : * @param num_results the number of results in @a result
1994 : */
1995 : static void
1996 0 : lrbt_cb_table_wads_in (void *cls,
1997 : PGresult *result,
1998 : unsigned int num_results)
1999 : {
2000 0 : struct LookupRecordsByTableContext *ctx = cls;
2001 0 : struct PostgresClosure *pg = ctx->pg;
2002 0 : struct TALER_EXCHANGEDB_TableData td = {
2003 : .table = TALER_EXCHANGEDB_RT_WADS_IN
2004 : };
2005 :
2006 0 : for (unsigned int i = 0; i<num_results; i++)
2007 : {
2008 0 : struct GNUNET_PQ_ResultSpec rs[] = {
2009 0 : GNUNET_PQ_result_spec_uint64 (
2010 : "wad_in_serial_id",
2011 : &td.serial),
2012 0 : GNUNET_PQ_result_spec_auto_from_type (
2013 : "wad_id",
2014 : &td.details.wads_in.wad_id),
2015 0 : GNUNET_PQ_result_spec_string (
2016 : "origin_exchange_url",
2017 : &td.details.wads_in.origin_exchange_url),
2018 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
2019 : "amount",
2020 : &td.details.wads_in.amount),
2021 0 : GNUNET_PQ_result_spec_timestamp (
2022 : "arrival_time",
2023 : &td.details.wads_in.arrival_time),
2024 : GNUNET_PQ_result_spec_end
2025 : };
2026 :
2027 0 : if (GNUNET_OK !=
2028 0 : GNUNET_PQ_extract_result (result,
2029 : rs,
2030 : i))
2031 : {
2032 0 : GNUNET_break (0);
2033 0 : ctx->error = true;
2034 0 : return;
2035 : }
2036 0 : ctx->cb (ctx->cb_cls,
2037 : &td);
2038 0 : GNUNET_PQ_cleanup_result (rs);
2039 : }
2040 : }
2041 :
2042 :
2043 : /**
2044 : * Function called with wads_in_entries table entries.
2045 : *
2046 : * @param cls closure
2047 : * @param result the postgres result
2048 : * @param num_results the number of results in @a result
2049 : */
2050 : static void
2051 0 : lrbt_cb_table_wads_in_entries (void *cls,
2052 : PGresult *result,
2053 : unsigned int num_results)
2054 : {
2055 0 : struct LookupRecordsByTableContext *ctx = cls;
2056 0 : struct PostgresClosure *pg = ctx->pg;
2057 0 : struct TALER_EXCHANGEDB_TableData td = {
2058 : .table = TALER_EXCHANGEDB_RT_WADS_IN_ENTRIES
2059 : };
2060 :
2061 0 : for (unsigned int i = 0; i<num_results; i++)
2062 : {
2063 0 : struct GNUNET_PQ_ResultSpec rs[] = {
2064 0 : GNUNET_PQ_result_spec_uint64 (
2065 : "wad_in_entry_serial_id",
2066 : &td.serial),
2067 0 : GNUNET_PQ_result_spec_auto_from_type (
2068 : "reserve_pub",
2069 : &td.details.wads_in_entries.reserve_pub),
2070 0 : GNUNET_PQ_result_spec_auto_from_type (
2071 : "purse_pub",
2072 : &td.details.wads_in_entries.purse_pub),
2073 0 : GNUNET_PQ_result_spec_auto_from_type (
2074 : "h_contract",
2075 : &td.details.wads_in_entries.h_contract),
2076 0 : GNUNET_PQ_result_spec_timestamp (
2077 : "purse_expiration",
2078 : &td.details.wads_in_entries.purse_expiration),
2079 0 : GNUNET_PQ_result_spec_timestamp (
2080 : "merge_timestamp",
2081 : &td.details.wads_in_entries.merge_timestamp),
2082 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
2083 : "amount_with_fee",
2084 : &td.details.wads_in_entries.amount_with_fee),
2085 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
2086 : "wad_fee",
2087 : &td.details.wads_in_entries.wad_fee),
2088 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
2089 : "deposit_fees",
2090 : &td.details.wads_in_entries.deposit_fees),
2091 0 : GNUNET_PQ_result_spec_auto_from_type (
2092 : "reserve_sig",
2093 : &td.details.wads_in_entries.reserve_sig),
2094 0 : GNUNET_PQ_result_spec_auto_from_type (
2095 : "purse_sig",
2096 : &td.details.wads_in_entries.purse_sig),
2097 : GNUNET_PQ_result_spec_end
2098 : };
2099 :
2100 0 : if (GNUNET_OK !=
2101 0 : GNUNET_PQ_extract_result (result,
2102 : rs,
2103 : i))
2104 : {
2105 0 : GNUNET_break (0);
2106 0 : ctx->error = true;
2107 0 : return;
2108 : }
2109 0 : ctx->cb (ctx->cb_cls,
2110 : &td);
2111 0 : GNUNET_PQ_cleanup_result (rs);
2112 : }
2113 : }
2114 :
2115 :
2116 : /**
2117 : * Function called with profit_drains table entries.
2118 : *
2119 : * @param cls closure
2120 : * @param result the postgres result
2121 : * @param num_results the number of results in @a result
2122 : */
2123 : static void
2124 0 : lrbt_cb_table_profit_drains (void *cls,
2125 : PGresult *result,
2126 : unsigned int num_results)
2127 : {
2128 0 : struct LookupRecordsByTableContext *ctx = cls;
2129 0 : struct PostgresClosure *pg = ctx->pg;
2130 0 : struct TALER_EXCHANGEDB_TableData td = {
2131 : .table = TALER_EXCHANGEDB_RT_PROFIT_DRAINS
2132 : };
2133 :
2134 0 : for (unsigned int i = 0; i<num_results; i++)
2135 : {
2136 0 : struct GNUNET_PQ_ResultSpec rs[] = {
2137 0 : GNUNET_PQ_result_spec_uint64 (
2138 : "profit_drain_serial_id",
2139 : &td.serial),
2140 0 : GNUNET_PQ_result_spec_auto_from_type (
2141 : "wtid",
2142 : &td.details.profit_drains.wtid),
2143 0 : GNUNET_PQ_result_spec_string (
2144 : "account_section",
2145 : &td.details.profit_drains.account_section),
2146 0 : GNUNET_PQ_result_spec_string (
2147 : "payto_uri",
2148 : &td.details.profit_drains.payto_uri),
2149 0 : GNUNET_PQ_result_spec_timestamp (
2150 : "trigger_date",
2151 : &td.details.profit_drains.trigger_date),
2152 0 : TALER_PQ_RESULT_SPEC_AMOUNT (
2153 : "amount",
2154 : &td.details.profit_drains.amount),
2155 0 : GNUNET_PQ_result_spec_auto_from_type (
2156 : "master_sig",
2157 : &td.details.profit_drains.master_sig),
2158 : GNUNET_PQ_result_spec_end
2159 : };
2160 :
2161 0 : if (GNUNET_OK !=
2162 0 : GNUNET_PQ_extract_result (result,
2163 : rs,
2164 : i))
2165 : {
2166 0 : GNUNET_break (0);
2167 0 : ctx->error = true;
2168 0 : return;
2169 : }
2170 0 : ctx->cb (ctx->cb_cls,
2171 : &td);
2172 0 : GNUNET_PQ_cleanup_result (rs);
2173 : }
2174 : }
2175 :
2176 :
2177 : /* end of lrbt_callbacks.c */
|