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