Line data Source code
1 : /*
2 : This file is part of TALER
3 : (C) 2014--2025 Taler Systems SA
4 :
5 : TALER is free software; you can redistribute it and/or modify it under the
6 : terms of the GNU Lesser General Public License as published by the Free Software
7 : Foundation; either version 3, or (at your option) any later version.
8 :
9 : TALER is distributed in the hope that it will be useful, but WITHOUT ANY
10 : WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 : A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 :
13 : You should have received a copy of the GNU General Public License along with
14 : TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
15 : */
16 : /**
17 : * @file plugin_merchantdb_postgres.c
18 : * @brief database helper functions for postgres used by the merchant
19 : * @author Sree Harsha Totakura <sreeharsha@totakura.in>
20 : * @author Christian Grothoff
21 : * @author Marcello Stanisci
22 : * @author Priscilla Huang
23 : * @author Iván Ávalos
24 : */
25 : #include "platform.h"
26 : #include <gnunet/gnunet_util_lib.h>
27 : #include <gnunet/gnunet_pq_lib.h>
28 : #include <taler/taler_util.h>
29 : #include <taler/taler_pq_lib.h>
30 : #include <taler/taler_json_lib.h>
31 : #include <taler/taler_mhd_lib.h>
32 : #include "taler_merchantdb_plugin.h"
33 : #include "pg_helper.h"
34 : #include "pg_gc.h"
35 : #include "pg_insert_otp.h"
36 : #include "pg_get_kyc_status.h"
37 : #include "pg_get_kyc_limits.h"
38 : #include "pg_delete_otp.h"
39 : #include "pg_update_otp.h"
40 : #include "pg_account_kyc_set_failed.h"
41 : #include "pg_select_otp.h"
42 : #include "pg_select_otp_serial.h"
43 : #include "pg_insert_login_token.h"
44 : #include "pg_delete_login_token.h"
45 : #include "pg_select_login_token.h"
46 : #include "pg_lookup_login_tokens.h"
47 : #include "pg_insert_account.h"
48 : #include "pg_update_account.h"
49 : #include "pg_lookup_instances.h"
50 : #include "pg_lookup_transfers.h"
51 : #include "pg_lookup_pending_deposits.h"
52 : #include "pg_lookup_categories.h"
53 : #include "pg_lookup_units.h"
54 : #include "pg_select_category.h"
55 : #include "pg_update_category.h"
56 : #include "pg_insert_category.h"
57 : #include "pg_delete_category.h"
58 : #include "pg_select_unit.h"
59 : #include "pg_insert_unit.h"
60 : #include "pg_update_unit.h"
61 : #include "pg_delete_unit.h"
62 : #include "pg_insert_report.h"
63 : #include "pg_delete_report.h"
64 : #include "pg_update_report.h"
65 : #include "pg_select_reports.h"
66 : #include "pg_lookup_reports_pending.h"
67 : #include "pg_update_report_status.h"
68 : #include "pg_select_report.h"
69 : #include "pg_insert_product_group.h"
70 : #include "pg_delete_product_group.h"
71 : #include "pg_update_product_group.h"
72 : #include "pg_select_product_groups.h"
73 : #include "pg_insert_money_pot.h"
74 : #include "pg_delete_money_pot.h"
75 : #include "pg_update_money_pot.h"
76 : #include "pg_select_money_pots.h"
77 : #include "pg_select_money_pot.h"
78 : #include "pg_update_wirewatch_progress.h"
79 : #include "pg_select_wirewatch_accounts.h"
80 : #include "pg_select_open_transfers.h"
81 : #include "pg_delete_exchange_accounts.h"
82 : #include "pg_select_accounts_by_exchange.h"
83 : #include "pg_insert_exchange_account.h"
84 : #include "pg_lookup_instance_auth.h"
85 : #include "pg_lookup_otp_devices.h"
86 : #include "pg_update_transfer_status.h"
87 : #include "pg_lookup_mfa_challenge.h"
88 : #include "pg_solve_mfa_challenge.h"
89 : #include "pg_update_mfa_challenge.h"
90 : #include "pg_create_mfa_challenge.h"
91 : #include "pg_finalize_transfer_status.h"
92 : #include "pg_insert_instance.h"
93 : #include "pg_account_kyc_set_status.h"
94 : #include "pg_account_kyc_get_status.h"
95 : #include "pg_delete_instance_private_key.h"
96 : #include "pg_select_category_by_name.h"
97 : #include "pg_purge_instance.h"
98 : #include "pg_update_instance.h"
99 : #include "pg_update_instance_auth.h"
100 : #include "pg_inactivate_account.h"
101 : #include "pg_activate_account.h"
102 : #include "pg_lookup_products.h"
103 : #include "pg_lookup_all_products.h"
104 : #include "pg_lookup_product.h"
105 : #include "pg_lookup_product_image.h"
106 : #include "pg_delete_product.h"
107 : #include "pg_insert_product.h"
108 : #include "pg_update_product.h"
109 : #include "pg_lookup_token_family_keys.h"
110 : #include "pg_lock_product.h"
111 : #include "pg_expire_locks.h"
112 : #include "pg_delete_order.h"
113 : #include "pg_lookup_order.h"
114 : #include "pg_lookup_order_summary.h"
115 : #include "pg_lookup_orders.h"
116 : #include "pg_insert_order.h"
117 : #include "pg_insert_order_blinded_sigs.h"
118 : #include "pg_unlock_inventory.h"
119 : #include "pg_insert_order_lock.h"
120 : #include "pg_select_order_blinded_sigs.h"
121 : #include "pg_lookup_contract_terms3.h"
122 : #include "pg_lookup_contract_terms2.h"
123 : #include "pg_lookup_contract_terms.h"
124 : #include "pg_insert_contract_terms.h"
125 : #include "pg_update_contract_terms.h"
126 : #include "pg_delete_contract_terms.h"
127 : #include "pg_delete_template.h"
128 : #include "pg_insert_template.h"
129 : #include "pg_update_template.h"
130 : #include "pg_lookup_templates.h"
131 : #include "pg_lookup_template.h"
132 : #include "pg_lookup_deposits.h"
133 : #include "pg_insert_exchange_signkey.h"
134 : #include "pg_insert_deposit.h"
135 : #include "pg_insert_deposit_confirmation.h"
136 : #include "pg_lookup_refunds.h"
137 : #include "pg_mark_contract_paid.h"
138 : #include "pg_select_account_by_uri.h"
139 : #include "pg_refund_coin.h"
140 : #include "pg_lookup_order_status.h"
141 : #include "pg_lookup_order_status_by_serial.h"
142 : #include "pg_lookup_deposits_by_order.h"
143 : #include "pg_lookup_transfer_details_by_order.h"
144 : #include "pg_mark_order_wired.h"
145 : #include "pg_lookup_refunds_detailed.h"
146 : #include "pg_insert_refund_proof.h"
147 : #include "pg_lookup_refund_proof.h"
148 : #include "pg_lookup_order_by_fulfillment.h"
149 : #include "pg_delete_transfer.h"
150 : #include "pg_check_transfer_exists.h"
151 : #include "pg_lookup_account.h"
152 : #include "pg_lookup_expected_transfers.h"
153 : #include "pg_lookup_deposits_by_contract_and_coin.h"
154 : #include "pg_lookup_transfer_summary.h"
155 : #include "pg_lookup_transfer_details.h"
156 : #include "pg_lookup_webhooks.h"
157 : #include "pg_lookup_webhook.h"
158 : #include "pg_lookup_wire_fee.h"
159 : #include "pg_delete_webhook.h"
160 : #include "pg_insert_webhook.h"
161 : #include "pg_update_webhook.h"
162 : #include "pg_lookup_webhook_by_event.h"
163 : #include "pg_delete_pending_webhook.h"
164 : #include "pg_insert_pending_webhook.h"
165 : #include "pg_update_pending_webhook.h"
166 : #include "pg_lookup_pending_webhooks.h"
167 : #include "pg_update_deposit_confirmation_status.h"
168 : #include "pg_insert_exchange_keys.h"
169 : #include "pg_select_exchange_keys.h"
170 : #include "pg_insert_deposit_to_transfer.h"
171 : #include "pg_increase_refund.h"
172 : #include "pg_select_account.h"
173 : #include "pg_select_accounts.h"
174 : #include "pg_insert_transfer.h"
175 : #include "pg_insert_transfer_details.h"
176 : #include "pg_store_wire_fee_by_exchange.h"
177 : #include "pg_insert_token_family.h"
178 : #include "pg_lookup_token_family.h"
179 : #include "pg_lookup_token_families.h"
180 : #include "pg_delete_token_family.h"
181 : #include "pg_update_token_family.h"
182 : #include "pg_insert_token_family_key.h"
183 : #include "pg_lookup_token_family_key.h"
184 : #include "pg_insert_spent_token.h"
185 : #include "pg_insert_issued_token.h"
186 : #include "pg_lookup_spent_tokens_by_order.h"
187 : #include "pg_lookup_statistics_amount_by_bucket.h"
188 : #include "pg_lookup_statistics_amount_by_interval.h"
189 : #include "pg_lookup_statistics_counter_by_bucket.h"
190 : #include "pg_lookup_statistics_counter_by_interval.h"
191 : #include "pg_update_donau_instance_receipts_amount.h"
192 : #include "pg_delete_donau_instance.h"
193 : #include "pg_update_contract_session.h"
194 :
195 : #ifdef HAVE_DONAU_DONAU_SERVICE_H
196 : #include "donau/donau_service.h"
197 : #include "pg_insert_donau_instance.h"
198 : #include "pg_check_donau_instance.h"
199 : #include "pg_select_donau_instance_by_serial.h"
200 : #include "pg_select_all_donau_instances.h"
201 : #include "pg_select_donau_instances.h"
202 : #include "pg_select_donau_instances_filtered.h"
203 : #include "pg_lookup_donau_keys.h"
204 : #include "pg_lookup_order_charity.h"
205 : #include "pg_upsert_donau_keys.h"
206 : #include "pg_update_donau_instance.h"
207 : #endif
208 :
209 : /**
210 : * How often do we re-try if we run into a DB serialization error?
211 : */
212 : #define MAX_RETRIES 3
213 :
214 :
215 : /**
216 : * Drop all Taler tables. This should only be used by testcases.
217 : *
218 : * @param cls the `struct PostgresClosure` with the plugin-specific state
219 : * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
220 : */
221 : static enum GNUNET_GenericReturnValue
222 17 : postgres_drop_tables (void *cls)
223 : {
224 17 : struct PostgresClosure *pc = cls;
225 : struct GNUNET_PQ_Context *conn;
226 : enum GNUNET_GenericReturnValue ret;
227 :
228 17 : conn = GNUNET_PQ_connect_with_cfg (pc->cfg,
229 : "merchantdb-postgres",
230 : NULL,
231 : NULL,
232 : NULL);
233 17 : if (NULL == conn)
234 0 : return GNUNET_SYSERR;
235 17 : ret = GNUNET_PQ_exec_sql (conn,
236 : "drop");
237 17 : GNUNET_PQ_disconnect (conn);
238 17 : return ret;
239 : }
240 :
241 :
242 : /**
243 : * Initialize tables.
244 : *
245 : * @param cls the `struct PostgresClosure` with the plugin-specific state
246 : * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
247 : */
248 : static enum GNUNET_GenericReturnValue
249 16 : postgres_create_tables (void *cls)
250 : {
251 16 : struct PostgresClosure *pc = cls;
252 : struct GNUNET_PQ_Context *conn;
253 16 : struct GNUNET_PQ_ExecuteStatement es[] = {
254 16 : GNUNET_PQ_make_try_execute ("SET search_path TO merchant;"),
255 : GNUNET_PQ_EXECUTE_STATEMENT_END
256 : };
257 : enum GNUNET_GenericReturnValue ret;
258 :
259 16 : conn = GNUNET_PQ_connect_with_cfg (pc->cfg,
260 : "merchantdb-postgres",
261 : "merchant-",
262 : es,
263 : NULL);
264 16 : if (NULL == conn)
265 0 : return GNUNET_SYSERR;
266 16 : ret = GNUNET_PQ_exec_sql (conn,
267 : "procedures");
268 16 : GNUNET_PQ_disconnect (conn);
269 16 : return ret;
270 : }
271 :
272 :
273 : /**
274 : * Register callback to be invoked on events of type @a es.
275 : *
276 : * @param cls database context to use
277 : * @param es specification of the event to listen for
278 : * @param timeout how long to wait for the event
279 : * @param cb function to call when the event happens, possibly
280 : * multiple times (until cancel is invoked)
281 : * @param cb_cls closure for @a cb
282 : * @return handle useful to cancel the listener
283 : */
284 : static struct GNUNET_DB_EventHandler *
285 181 : postgres_event_listen (void *cls,
286 : const struct GNUNET_DB_EventHeaderP *es,
287 : struct GNUNET_TIME_Relative timeout,
288 : GNUNET_DB_EventCallback cb,
289 : void *cb_cls)
290 : {
291 181 : struct PostgresClosure *pg = cls;
292 :
293 181 : return GNUNET_PQ_event_listen (pg->conn,
294 : es,
295 : timeout,
296 : cb,
297 : cb_cls);
298 : }
299 :
300 :
301 : /**
302 : * Stop notifications.
303 : *
304 : * @param eh handle to unregister.
305 : */
306 : static void
307 181 : postgres_event_listen_cancel (struct GNUNET_DB_EventHandler *eh)
308 : {
309 181 : GNUNET_PQ_event_listen_cancel (eh);
310 181 : }
311 :
312 :
313 : /**
314 : * Notify all that listen on @a es of an event.
315 : *
316 : * @param cls database context to use
317 : * @param es specification of the event to generate
318 : * @param extra additional event data provided
319 : * @param extra_size number of bytes in @a extra
320 : */
321 : static void
322 386 : postgres_event_notify (void *cls,
323 : const struct GNUNET_DB_EventHeaderP *es,
324 : const void *extra,
325 : size_t extra_size)
326 : {
327 386 : struct PostgresClosure *pg = cls;
328 :
329 386 : return GNUNET_PQ_event_notify (pg->conn,
330 : es,
331 : extra,
332 : extra_size);
333 : }
334 :
335 :
336 : void
337 1612 : postgres_preflight (void *cls)
338 : {
339 1612 : struct PostgresClosure *pg = cls;
340 :
341 1612 : if (NULL == pg->transaction_name)
342 1612 : return; /* all good */
343 0 : GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
344 : "BUG: Preflight check detected running transaction `%s'!\n",
345 : pg->transaction_name);
346 0 : GNUNET_assert (0);
347 : }
348 :
349 :
350 : void
351 3481 : check_connection (struct PostgresClosure *pg)
352 : {
353 3481 : if (NULL != pg->transaction_name)
354 1224 : return;
355 2257 : GNUNET_PQ_reconnect_if_down (pg->conn);
356 : }
357 :
358 :
359 : /**
360 : * Establish connection to the database.
361 : *
362 : * @param cls plugin context
363 : * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure
364 : */
365 : static enum GNUNET_GenericReturnValue
366 88 : postgres_connect (void *cls)
367 : {
368 88 : struct PostgresClosure *pg = cls;
369 88 : struct GNUNET_PQ_ExecuteStatement es[] = {
370 88 : GNUNET_PQ_make_try_execute ("SET search_path TO merchant;"),
371 : GNUNET_PQ_EXECUTE_STATEMENT_END
372 : };
373 :
374 88 : pg->conn = GNUNET_PQ_connect_with_cfg2 (pg->cfg,
375 : "merchantdb-postgres",
376 : "merchant-",
377 : es,
378 : NULL, /* prepared statemetns */
379 : GNUNET_PQ_FLAG_CHECK_CURRENT);
380 88 : pg->prep_gen++;
381 88 : if (NULL == pg->conn)
382 0 : return GNUNET_SYSERR;
383 88 : return GNUNET_OK;
384 : };
385 :
386 :
387 : /**
388 : * Initialize Postgres database subsystem.
389 : *
390 : * @param cls a configuration instance
391 : * @return NULL on error, otherwise a `struct TALER_MERCHANTDB_Plugin`
392 : */
393 : void *
394 : libtaler_plugin_merchantdb_postgres_init (void *cls);
395 :
396 : /* declaration to avoid compiler warning */
397 : void *
398 103 : libtaler_plugin_merchantdb_postgres_init (void *cls)
399 : {
400 103 : const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
401 : struct PostgresClosure *pg;
402 : struct TALER_MERCHANTDB_Plugin *plugin;
403 :
404 103 : pg = GNUNET_new (struct PostgresClosure);
405 103 : pg->cfg = cfg;
406 103 : if (GNUNET_OK !=
407 103 : GNUNET_CONFIGURATION_get_value_filename (cfg,
408 : "merchantdb-postgres",
409 : "SQL_DIR",
410 : &pg->sql_dir))
411 : {
412 0 : GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
413 : "merchantdb-postgres",
414 : "SQL_DIR");
415 0 : GNUNET_free (pg);
416 0 : return NULL;
417 : }
418 103 : plugin = GNUNET_new (struct TALER_MERCHANTDB_Plugin);
419 103 : plugin->cls = pg;
420 103 : plugin->connect = &postgres_connect;
421 103 : plugin->create_tables = &postgres_create_tables;
422 103 : plugin->drop_tables = &postgres_drop_tables;
423 103 : plugin->event_listen = &postgres_event_listen;
424 103 : plugin->event_listen_cancel = &postgres_event_listen_cancel;
425 103 : plugin->event_notify = &postgres_event_notify;
426 103 : plugin->preflight = &postgres_preflight;
427 103 : plugin->start = &TMH_PG_start;
428 103 : plugin->start_read_committed = &TMH_PG_start_read_committed;
429 103 : plugin->rollback = &TMH_PG_rollback;
430 103 : plugin->commit = &TMH_PG_commit;
431 : plugin->insert_login_token
432 103 : = &TMH_PG_insert_login_token;
433 : plugin->delete_login_token
434 103 : = &TMH_PG_delete_login_token;
435 : plugin->delete_login_token_serial
436 103 : = &TMH_PG_delete_login_token_serial;
437 : plugin->select_login_token
438 103 : = &TMH_PG_select_login_token;
439 : plugin->lookup_login_tokens
440 103 : = &TMH_PG_lookup_login_tokens;
441 : plugin->select_account_by_uri
442 103 : = &TMH_PG_select_account_by_uri;
443 : plugin->lookup_instance_auth
444 103 : = &TMH_PG_lookup_instance_auth;
445 : plugin->insert_instance
446 103 : = &TMH_PG_insert_instance;
447 : plugin->insert_account
448 103 : = &TMH_PG_insert_account;
449 : plugin->lookup_otp_devices
450 103 : = &TMH_PG_lookup_otp_devices;
451 : plugin->delete_template
452 103 : = &TMH_PG_delete_template;
453 : plugin->insert_template
454 103 : = &TMH_PG_insert_template;
455 : plugin->update_template
456 103 : = &TMH_PG_update_template;
457 : plugin->lookup_templates
458 103 : = &TMH_PG_lookup_templates;
459 : plugin->lookup_template
460 103 : = &TMH_PG_lookup_template;
461 : plugin->update_account
462 103 : = &TMH_PG_update_account;
463 : plugin->account_kyc_set_status
464 103 : = &TMH_PG_account_kyc_set_status;
465 : plugin->account_kyc_get_status
466 103 : = &TMH_PG_account_kyc_get_status;
467 : plugin->delete_instance_private_key
468 103 : = &TMH_PG_delete_instance_private_key;
469 : plugin->purge_instance
470 103 : = &TMH_PG_purge_instance;
471 : plugin->update_instance
472 103 : = &TMH_PG_update_instance;
473 : plugin->update_instance_auth
474 103 : = &TMH_PG_update_instance_auth;
475 : plugin->activate_account
476 103 : = &TMH_PG_activate_account;
477 : plugin->inactivate_account
478 103 : = &TMH_PG_inactivate_account;
479 : plugin->update_transfer_status
480 103 : = &TMH_PG_update_transfer_status;
481 : plugin->finalize_transfer_status
482 103 : = &TMH_PG_finalize_transfer_status;
483 : plugin->lookup_products
484 103 : = &TMH_PG_lookup_products;
485 : plugin->lookup_all_products
486 103 : = &TMH_PG_lookup_all_products;
487 : plugin->lookup_product
488 103 : = &TMH_PG_lookup_product;
489 : plugin->lookup_product_image_by_hash
490 103 : = &TMH_PG_lookup_product_image_by_hash;
491 : plugin->delete_product
492 103 : = &TMH_PG_delete_product;
493 : plugin->insert_product
494 103 : = &TMH_PG_insert_product;
495 : plugin->update_product
496 103 : = &TMH_PG_update_product;
497 : plugin->insert_otp
498 103 : = &TMH_PG_insert_otp;
499 : plugin->delete_otp
500 103 : = &TMH_PG_delete_otp;
501 : plugin->update_otp
502 103 : = &TMH_PG_update_otp;
503 : plugin->select_otp
504 103 : = &TMH_PG_select_otp;
505 : plugin->select_otp_serial
506 103 : = &TMH_PG_select_otp_serial;
507 : plugin->lock_product
508 103 : = &TMH_PG_lock_product;
509 : plugin->expire_locks
510 103 : = &TMH_PG_expire_locks;
511 : plugin->delete_order
512 103 : = &TMH_PG_delete_order;
513 : plugin->lookup_order
514 103 : = &TMH_PG_lookup_order;
515 : plugin->lookup_order_summary
516 103 : = &TMH_PG_lookup_order_summary;
517 : plugin->lookup_orders
518 103 : = &TMH_PG_lookup_orders;
519 : plugin->insert_order
520 103 : = &TMH_PG_insert_order;
521 : plugin->insert_order_blinded_sigs
522 103 : = &TMH_PG_insert_order_blinded_sigs;
523 : plugin->unlock_inventory
524 103 : = &TMH_PG_unlock_inventory;
525 : plugin->insert_order_lock
526 103 : = &TMH_PG_insert_order_lock;
527 : plugin->select_order_blinded_sigs
528 103 : = &TMH_PG_select_order_blinded_sigs;
529 : plugin->lookup_contract_terms
530 103 : = &TMH_PG_lookup_contract_terms;
531 : plugin->lookup_contract_terms2
532 103 : = &TMH_PG_lookup_contract_terms2;
533 : plugin->lookup_contract_terms3
534 103 : = &TMH_PG_lookup_contract_terms3;
535 : plugin->insert_contract_terms
536 103 : = &TMH_PG_insert_contract_terms;
537 : plugin->update_contract_terms
538 103 : = &TMH_PG_update_contract_terms;
539 : plugin->delete_contract_terms
540 103 : = &TMH_PG_delete_contract_terms;
541 : plugin->lookup_deposits
542 103 : = &TMH_PG_lookup_deposits;
543 : plugin->insert_exchange_signkey
544 103 : = &TMH_PG_insert_exchange_signkey;
545 : plugin->insert_deposit_confirmation
546 103 : = &TMH_PG_insert_deposit_confirmation;
547 : plugin->insert_deposit
548 103 : = &TMH_PG_insert_deposit;
549 : plugin->lookup_refunds
550 103 : = &TMH_PG_lookup_refunds;
551 : plugin->mark_contract_paid
552 103 : = &TMH_PG_mark_contract_paid;
553 : plugin->refund_coin
554 103 : = &TMH_PG_refund_coin;
555 : plugin->lookup_order_status
556 103 : = &TMH_PG_lookup_order_status;
557 : plugin->lookup_order_status_by_serial
558 103 : = &TMH_PG_lookup_order_status_by_serial;
559 : plugin->lookup_deposits_by_order
560 103 : = &TMH_PG_lookup_deposits_by_order;
561 : plugin->lookup_transfer_details_by_order
562 103 : = &TMH_PG_lookup_transfer_details_by_order;
563 : plugin->mark_order_wired
564 103 : = &TMH_PG_mark_order_wired;
565 : plugin->increase_refund
566 103 : = &TMH_PG_increase_refund;
567 : plugin->lookup_refunds_detailed
568 103 : = &TMH_PG_lookup_refunds_detailed;
569 : plugin->insert_refund_proof
570 103 : = &TMH_PG_insert_refund_proof;
571 : plugin->lookup_refund_proof
572 103 : = &TMH_PG_lookup_refund_proof;
573 : plugin->lookup_order_by_fulfillment
574 103 : = &TMH_PG_lookup_order_by_fulfillment;
575 : plugin->delete_transfer
576 103 : = &TMH_PG_delete_transfer;
577 : plugin->check_transfer_exists
578 103 : = &TMH_PG_check_transfer_exists;
579 : plugin->lookup_account
580 103 : = &TMH_PG_lookup_account;
581 : plugin->lookup_wire_fee
582 103 : = &TMH_PG_lookup_wire_fee;
583 : plugin->lookup_deposits_by_contract_and_coin
584 103 : = &TMH_PG_lookup_deposits_by_contract_and_coin;
585 : plugin->lookup_transfer_summary
586 103 : = &TMH_PG_lookup_transfer_summary;
587 : plugin->lookup_transfer_details
588 103 : = &TMH_PG_lookup_transfer_details;
589 : plugin->lookup_instances
590 103 : = &TMH_PG_lookup_instances;
591 : plugin->lookup_instance
592 103 : = &TMH_PG_lookup_instance;
593 : plugin->lookup_transfers
594 103 : = &TMH_PG_lookup_transfers;
595 : plugin->update_wirewatch_progress
596 103 : = &TMH_PG_update_wirewatch_progress;
597 : plugin->select_wirewatch_accounts
598 103 : = &TMH_PG_select_wirewatch_accounts;
599 : plugin->select_account
600 103 : = &TMH_PG_select_account;
601 : plugin->select_accounts
602 103 : = &TMH_PG_select_accounts;
603 : plugin->select_open_transfers
604 103 : = &TMH_PG_select_open_transfers;
605 : plugin->insert_exchange_keys
606 103 : = &TMH_PG_insert_exchange_keys;
607 : plugin->select_exchange_keys
608 103 : = &TMH_PG_select_exchange_keys;
609 : plugin->insert_deposit_to_transfer
610 103 : = &TMH_PG_insert_deposit_to_transfer;
611 : plugin->insert_transfer
612 103 : = &TMH_PG_insert_transfer;
613 : plugin->lookup_token_family_keys
614 103 : = &TMH_PG_lookup_token_family_keys;
615 : plugin->insert_transfer_details
616 103 : = &TMH_PG_insert_transfer_details;
617 : plugin->store_wire_fee_by_exchange
618 103 : = &TMH_PG_store_wire_fee_by_exchange;
619 : plugin->lookup_webhooks
620 103 : = &TMH_PG_lookup_webhooks;
621 : plugin->lookup_webhook
622 103 : = &TMH_PG_lookup_webhook;
623 : plugin->delete_webhook
624 103 : = &TMH_PG_delete_webhook;
625 : plugin->insert_webhook
626 103 : = &TMH_PG_insert_webhook;
627 : plugin->update_webhook
628 103 : = &TMH_PG_update_webhook;
629 : plugin->lookup_pending_deposits
630 103 : = &TMH_PG_lookup_pending_deposits;
631 : plugin->lookup_webhook_by_event
632 103 : = &TMH_PG_lookup_webhook_by_event;
633 : plugin->lookup_all_webhooks
634 103 : = &TMH_PG_lookup_all_webhooks;
635 : plugin->lookup_future_webhook
636 103 : = &TMH_PG_lookup_future_webhook;
637 : plugin->lookup_pending_webhooks
638 103 : = &TMH_PG_lookup_pending_webhooks;
639 : plugin->delete_pending_webhook
640 103 : = &TMH_PG_delete_pending_webhook;
641 : plugin->insert_pending_webhook
642 103 : = &TMH_PG_insert_pending_webhook;
643 : plugin->update_pending_webhook
644 103 : = &TMH_PG_update_pending_webhook;
645 : plugin->lookup_categories
646 103 : = &TMH_PG_lookup_categories;
647 : plugin->lookup_units
648 103 : = &TMH_PG_lookup_units;
649 : plugin->select_category_by_name
650 103 : = &TMH_PG_select_category_by_name;
651 : plugin->get_kyc_status
652 103 : = &TMH_PG_get_kyc_status;
653 : plugin->account_kyc_set_failed
654 103 : = &TMH_PG_account_kyc_set_failed;
655 : plugin->get_kyc_limits
656 103 : = &TMH_PG_get_kyc_limits;
657 : plugin->select_category
658 103 : = &TMH_PG_select_category;
659 : plugin->select_unit
660 103 : = &TMH_PG_select_unit;
661 : plugin->update_category
662 103 : = &TMH_PG_update_category;
663 : plugin->update_unit
664 103 : = &TMH_PG_update_unit;
665 : plugin->insert_category
666 103 : = &TMH_PG_insert_category;
667 : plugin->insert_unit
668 103 : = &TMH_PG_insert_unit;
669 : plugin->delete_category
670 103 : = &TMH_PG_delete_category;
671 : plugin->delete_unit
672 103 : = &TMH_PG_delete_unit;
673 : plugin->delete_exchange_accounts
674 103 : = &TMH_PG_delete_exchange_accounts;
675 : plugin->select_accounts_by_exchange
676 103 : = &TMH_PG_select_accounts_by_exchange;
677 : plugin->insert_exchange_account
678 103 : = &TMH_PG_insert_exchange_account;
679 : plugin->insert_token_family
680 103 : = &TMH_PG_insert_token_family;
681 : plugin->lookup_expected_transfers
682 103 : = &TMH_PG_lookup_expected_transfers;
683 : plugin->lookup_token_family
684 103 : = &TMH_PG_lookup_token_family;
685 : plugin->lookup_token_families
686 103 : = &TMH_PG_lookup_token_families;
687 : plugin->delete_token_family
688 103 : = &TMH_PG_delete_token_family;
689 : plugin->update_token_family
690 103 : = &TMH_PG_update_token_family;
691 : plugin->insert_report
692 103 : = &TMH_PG_insert_report;
693 : plugin->delete_report
694 103 : = &TMH_PG_delete_report;
695 : plugin->update_report
696 103 : = &TMH_PG_update_report;
697 : plugin->select_reports
698 103 : = &TMH_PG_select_reports;
699 : plugin->lookup_reports_pending
700 103 : = &TMH_PG_lookup_reports_pending;
701 : plugin->update_report_status
702 103 : = &TMH_PG_update_report_status;
703 : plugin->select_report
704 103 : = &TMH_PG_select_report;
705 : plugin->insert_product_group
706 103 : = &TMH_PG_insert_product_group;
707 : plugin->delete_product_group
708 103 : = &TMH_PG_delete_product_group;
709 : plugin->update_product_group
710 103 : = &TMH_PG_update_product_group;
711 : plugin->select_product_groups
712 103 : = &TMH_PG_select_product_groups;
713 : plugin->insert_money_pot
714 103 : = &TMH_PG_insert_money_pot;
715 : plugin->delete_money_pot
716 103 : = &TMH_PG_delete_money_pot;
717 : plugin->update_money_pot
718 103 : = &TMH_PG_update_money_pot;
719 : plugin->select_money_pots
720 103 : = &TMH_PG_select_money_pots;
721 : plugin->select_money_pot
722 103 : = &TMH_PG_select_money_pot;
723 : plugin->insert_token_family_key
724 103 : = &TMH_PG_insert_token_family_key;
725 : plugin->update_contract_session
726 103 : = &TMH_PG_update_contract_session;
727 : plugin->lookup_token_family_key
728 103 : = &TMH_PG_lookup_token_family_key;
729 : plugin->update_deposit_confirmation_status
730 103 : = &TMH_PG_update_deposit_confirmation_status;
731 : plugin->update_donau_instance_receipts_amount
732 103 : = &TMH_PG_update_donau_instance_receipts_amount;
733 : plugin->insert_spent_token
734 103 : = &TMH_PG_insert_spent_token;
735 : plugin->insert_issued_token
736 103 : = &TMH_PG_insert_issued_token;
737 : plugin->lookup_spent_tokens_by_order
738 103 : = &TMH_PG_lookup_spent_tokens_by_order;
739 : plugin->lookup_statistics_amount_by_bucket
740 103 : = &TMH_PG_lookup_statistics_amount_by_bucket;
741 : plugin->lookup_statistics_counter_by_bucket
742 103 : = &TMH_PG_lookup_statistics_counter_by_bucket;
743 : plugin->lookup_statistics_counter_by_interval
744 103 : = &TMH_PG_lookup_statistics_counter_by_interval;
745 : plugin->lookup_statistics_amount_by_interval
746 103 : = &TMH_PG_lookup_statistics_amount_by_interval;
747 : plugin->lookup_mfa_challenge
748 103 : = &TMH_PG_lookup_mfa_challenge;
749 : plugin->solve_mfa_challenge
750 103 : = &TMH_PG_solve_mfa_challenge;
751 : plugin->update_mfa_challenge
752 103 : = &TMH_PG_update_mfa_challenge;
753 : plugin->create_mfa_challenge
754 103 : = &TMH_PG_create_mfa_challenge;
755 : plugin->gc
756 103 : = &TMH_PG_gc;
757 : #ifdef HAVE_DONAU_DONAU_SERVICE_H
758 : plugin->insert_donau_instance
759 : = &TMH_PG_insert_donau_instance;
760 : plugin->check_donau_instance
761 : = &TMH_PG_check_donau_instance;
762 : plugin->select_donau_instance_by_serial
763 : = &TMH_PG_select_donau_instance_by_serial;
764 : plugin->select_all_donau_instances
765 : = &TMH_PG_select_all_donau_instances;
766 : plugin->select_donau_instances
767 : = &TMH_PG_select_donau_instances;
768 : plugin->select_donau_instances_filtered
769 : = &TMH_PG_select_donau_instances_filtered;
770 : plugin->delete_donau_instance
771 : = &TMH_PG_delete_donau_instance;
772 : plugin->lookup_donau_keys
773 : = &TMH_PG_lookup_donau_keys;
774 : plugin->lookup_order_charity
775 : = &TMH_PG_lookup_order_charity;
776 : plugin->upsert_donau_keys
777 : = &TMH_PG_upsert_donau_keys;
778 : plugin->update_donau_instance
779 : = &TMH_PG_update_donau_instance;
780 : #endif
781 103 : return plugin;
782 : }
783 :
784 :
785 : /**
786 : * Shutdown Postgres database subsystem.
787 : *
788 : * @param cls a `struct TALER_MERCHANTDB_Plugin`
789 : * @return NULL (always)
790 : */
791 : void *
792 : libtaler_plugin_merchantdb_postgres_done (void *cls);
793 :
794 : /* declaration to avoid compiler warning */
795 : void *
796 103 : libtaler_plugin_merchantdb_postgres_done (void *cls)
797 : {
798 103 : struct TALER_MERCHANTDB_Plugin *plugin = cls;
799 103 : struct PostgresClosure *pg = plugin->cls;
800 :
801 103 : if (NULL != pg->conn)
802 : {
803 88 : GNUNET_PQ_disconnect (pg->conn);
804 88 : pg->conn = NULL;
805 : }
806 103 : GNUNET_free (pg->sql_dir);
807 103 : GNUNET_free (pg);
808 103 : GNUNET_free (plugin);
809 103 : return NULL;
810 : }
811 :
812 :
813 : /* end of plugin_merchantdb_postgres.c */
|