Line data Source code
1 : /* 2 : This file is part of TALER 3 : Copyright (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 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 : /** 18 : * @file plugin_exchangedb_postgres.c 19 : * @brief Low-level (statement-level) Postgres database access for the exchange 20 : * @author Florian Dold 21 : * @author Christian Grothoff 22 : * @author Sree Harsha Totakura 23 : * @author Marcello Stanisci 24 : * @author Özgür Kesim 25 : */ 26 : #include "platform.h" 27 : #include <poll.h> 28 : #include <pthread.h> 29 : #include <libpq-fe.h> 30 : #include "pg_abort_shard.h" 31 : #include "pg_activate_signing_key.h" 32 : #include "pg_add_denomination_key.h" 33 : #include "pg_add_policy_fulfillment_proof.h" 34 : #include "pg_aggregate.h" 35 : #include "pg_batch_ensure_coin_known.h" 36 : #include "pg_begin_revolving_shard.h" 37 : #include "pg_begin_shard.h" 38 : #include "pg_clear_aml_lock.h" 39 : #include "pg_commit.h" 40 : #include "pg_complete_shard.h" 41 : #include "pg_compute_shard.h" 42 : #include "pg_count_known_coins.h" 43 : #include "pg_create_aggregation_transient.h" 44 : #include "pg_create_tables.h" 45 : #include "pg_delete_aggregation_transient.h" 46 : #include "pg_delete_shard_locks.h" 47 : #include "pg_disable_rules.h" 48 : #include "pg_do_withdraw.h" 49 : #include "pg_do_check_deposit_idempotent.h" 50 : #include "pg_do_deposit.h" 51 : #include "pg_do_melt.h" 52 : #include "pg_do_purse_delete.h" 53 : #include "pg_do_purse_deposit.h" 54 : #include "pg_do_purse_merge.h" 55 : #include "pg_do_recoup.h" 56 : #include "pg_do_recoup_refresh.h" 57 : #include "pg_do_refresh.h" 58 : #include "pg_do_refund.h" 59 : #include "pg_do_reserve_open.h" 60 : #include "pg_do_reserve_purse.h" 61 : #include "pg_drain_kyc_alert.h" 62 : #include "pg_drop_tables.h" 63 : #include "pg_enable_rules.h" 64 : #include "pg_ensure_coin_known.h" 65 : #include "pg_event_listen.h" 66 : #include "pg_event_listen_cancel.h" 67 : #include "pg_event_notify.h" 68 : #include "pg_expire_purse.h" 69 : #include "pg_find_aggregation_transient.h" 70 : #include "pg_gc.h" 71 : #include "pg_get_withdraw.h" 72 : #include "pg_get_coin_denomination.h" 73 : #include "pg_get_coin_transactions.h" 74 : #include "pg_get_denomination_info.h" 75 : #include "pg_get_denomination_by_serial.h" 76 : #include "pg_get_denomination_revocation.h" 77 : #include "pg_get_drain_profit.h" 78 : #include "pg_get_expired_reserves.h" 79 : #include "pg_get_extension_manifest.h" 80 : #include "pg_get_global_fee.h" 81 : #include "pg_get_global_fees.h" 82 : #include "pg_get_known_coin.h" 83 : #include "pg_get_kyc_rules.h" 84 : #include "pg_get_old_coin_by_h_blind.h" 85 : #include "pg_get_pending_kyc_requirement_process.h" 86 : #include "pg_get_policy_details.h" 87 : #include "pg_get_purse_deposit.h" 88 : #include "pg_get_purse_request.h" 89 : #include "pg_get_ready_deposit.h" 90 : #include "pg_get_refresh.h" 91 : #include "pg_get_refresh_reveal.h" 92 : #include "pg_get_reserve_balance.h" 93 : #include "pg_get_reserve_by_h_planchets.h" 94 : #include "pg_get_reserve_history.h" 95 : #include "pg_get_signature_for_known_coin.h" 96 : #include "pg_get_unfinished_close_requests.h" 97 : #include "pg_get_wire_accounts.h" 98 : #include "pg_get_wire_fee.h" 99 : #include "pg_get_wire_fees.h" 100 : #include "pg_get_wire_hash_for_contract.h" 101 : #include "pg_have_deposit2.h" 102 : #include "pg_helper.h" 103 : #include "pg_inject_auditor_triggers.h" 104 : #include "pg_insert_active_legitimization_measure.h" 105 : #include "pg_insert_aml_decision.h" 106 : #include "pg_insert_aml_officer.h" 107 : #include "pg_insert_aml_program_failure.h" 108 : #include "pg_insert_auditor.h" 109 : #include "pg_insert_auditor_denom_sig.h" 110 : #include "pg_insert_close_request.h" 111 : #include "pg_insert_contract.h" 112 : #include "pg_insert_denomination_info.h" 113 : #include "pg_insert_denomination_revocation.h" 114 : #include "pg_insert_drain_profit.h" 115 : #include "pg_insert_global_fee.h" 116 : #include "pg_insert_kyc_failure.h" 117 : #include "pg_insert_kyc_requirement_process.h" 118 : #include "pg_insert_partner.h" 119 : #include "pg_insert_purse_request.h" 120 : #include "pg_insert_records_by_table.h" 121 : #include "pg_insert_refund.h" 122 : #include "pg_insert_reserve_closed.h" 123 : #include "pg_insert_reserve_open_deposit.h" 124 : #include "pg_insert_sanction_list_hit.h" 125 : #include "pg_insert_signkey_revocation.h" 126 : #include "pg_insert_successor_measure.h" 127 : #include "pg_insert_wire.h" 128 : #include "pg_insert_wire_fee.h" 129 : #include "pg_iterate_active_auditors.h" 130 : #include "pg_iterate_active_signkeys.h" 131 : #include "pg_iterate_auditor_denominations.h" 132 : #include "pg_iterate_denomination_info.h" 133 : #include "pg_iterate_denominations.h" 134 : #include "pg_iterate_kyc_reference.h" 135 : #include "pg_iterate_reserve_close_info.h" 136 : #include "pg_kyc_provider_account_lookup.h" 137 : #include "pg_kycauth_in_insert.h" 138 : #include "pg_lookup_active_legitimization.h" 139 : #include "pg_lookup_aml_history.h" 140 : #include "pg_lookup_aml_officer.h" 141 : #include "pg_lookup_auditor_status.h" 142 : #include "pg_lookup_auditor_timestamp.h" 143 : #include "pg_lookup_completed_legitimization.h" 144 : #include "pg_lookup_denomination_key.h" 145 : #include "pg_lookup_global_fee_by_time.h" 146 : #include "pg_lookup_h_payto_by_access_token.h" 147 : #include "pg_lookup_kyc_history.h" 148 : #include "pg_lookup_kyc_process_by_account.h" 149 : #include "pg_lookup_kyc_requirement_by_row.h" 150 : #include "pg_lookup_kyc_status_by_token.h" 151 : #include "pg_lookup_pending_legitimization.h" 152 : #include "pg_lookup_records_by_table.h" 153 : #include "pg_lookup_rules_by_access_token.h" 154 : #include "pg_lookup_serial_by_table.h" 155 : #include "pg_lookup_signing_key.h" 156 : #include "pg_lookup_signkey_revocation.h" 157 : #include "pg_lookup_transfer_by_deposit.h" 158 : #include "pg_lookup_wire_fee_by_time.h" 159 : #include "pg_lookup_wire_timestamp.h" 160 : #include "pg_lookup_wire_transfer.h" 161 : #include "pg_persist_kyc_attributes.h" 162 : #include "pg_persist_policy_details.h" 163 : #include "pg_preflight.h" 164 : #include "pg_profit_drains_get_pending.h" 165 : #include "pg_profit_drains_set_finished.h" 166 : #include "pg_release_revolving_shard.h" 167 : #include "pg_reserves_get.h" 168 : #include "pg_reserves_get_origin.h" 169 : #include "pg_reserves_in_insert.h" 170 : #include "pg_reserves_update.h" 171 : #include "pg_rollback.h" 172 : #include "pg_select_account_merges_above_serial_id.h" 173 : #include "pg_select_aggregation_amounts_for_kyc_check.h" 174 : #include "pg_select_aggregation_transient.h" 175 : #include "pg_select_aggregations_above_serial.h" 176 : #include "pg_select_all_kyc_attributes.h" 177 : #include "pg_select_all_purse_decisions_above_serial_id.h" 178 : #include "pg_select_all_purse_deletions_above_serial_id.h" 179 : #include "pg_select_aml_attributes.h" 180 : #include "pg_select_aml_decisions.h" 181 : #include "pg_select_aml_measures.h" 182 : #include "pg_select_aml_statistics.h" 183 : #include "pg_select_auditor_denom_sig.h" 184 : #include "pg_select_batch_deposits_missing_wire.h" 185 : #include "pg_select_coin_deposits_above_serial_id.h" 186 : #include "pg_select_contract.h" 187 : #include "pg_select_contract_by_purse.h" 188 : #include "pg_select_deposit_amounts_for_kyc_check.h" 189 : #include "pg_select_exchange_credit_transfers.h" 190 : #include "pg_select_exchange_debit_transfers.h" 191 : #include "pg_select_kyc_attributes.h" 192 : #include "pg_select_merge_amounts_for_kyc_check.h" 193 : #include "pg_select_purse.h" 194 : #include "pg_select_purse_by_merge_pub.h" 195 : #include "pg_select_purse_decisions_above_serial_id.h" 196 : #include "pg_select_purse_deposits_above_serial_id.h" 197 : #include "pg_select_purse_deposits_by_purse.h" 198 : #include "pg_select_purse_merge.h" 199 : #include "pg_select_purse_merges_above_serial_id.h" 200 : #include "pg_select_purse_requests_above_serial_id.h" 201 : #include "pg_select_recoup_above_serial_id.h" 202 : #include "pg_select_recoup_refresh_above_serial_id.h" 203 : #include "pg_select_refreshes_above_serial_id.h" 204 : #include "pg_select_refunds_above_serial_id.h" 205 : #include "pg_select_refunds_by_coin.h" 206 : #include "pg_select_reserve_close_info.h" 207 : #include "pg_select_reserve_closed_above_serial_id.h" 208 : #include "pg_select_reserve_open_above_serial_id.h" 209 : #include "pg_select_reserves_in_above_serial_id.h" 210 : #include "pg_select_reserves_in_above_serial_id_by_account.h" 211 : #include "pg_select_wire_out_above_serial_id.h" 212 : #include "pg_select_wire_out_above_serial_id_by_account.h" 213 : #include "pg_select_withdraw_amounts_for_kyc_check.h" 214 : #include "pg_select_withdrawals_above_serial_id.h" 215 : #include "pg_set_aml_lock.h" 216 : #include "pg_set_extension_manifest.h" 217 : #include "pg_set_purse_balance.h" 218 : #include "pg_start.h" 219 : #include "pg_start_deferred_wire_out.h" 220 : #include "pg_start_read_committed.h" 221 : #include "pg_start_read_only.h" 222 : #include "pg_store_wire_transfer_out.h" 223 : #include "pg_test_aml_officer.h" 224 : #include "pg_trigger_kyc_rule_for_account.h" 225 : #include "pg_update_aggregation_transient.h" 226 : #include "pg_update_auditor.h" 227 : #include "pg_update_kyc_process_by_row.h" 228 : #include "pg_update_wire.h" 229 : #include "pg_wad_in_insert.h" 230 : #include "pg_wire_prepare_data_get.h" 231 : #include "pg_wire_prepare_data_insert.h" 232 : #include "pg_wire_prepare_data_mark_failed.h" 233 : #include "pg_wire_prepare_data_mark_finished.h" 234 : #include "plugin_exchangedb_common.h" 235 : #include "plugin_exchangedb_postgres.h" 236 : #include "taler_dbevents.h" 237 : #include "taler_error_codes.h" 238 : #include "taler_exchangedb_plugin.h" 239 : #include "taler_json_lib.h" 240 : #include "taler_pq_lib.h" 241 : #include "taler_util.h" 242 : 243 : /** 244 : * Set to 1 to enable Postgres auto_explain module. This will 245 : * slow down things a _lot_, but also provide extensive logging 246 : * in the Postgres database logger for performance analysis. 247 : */ 248 : #define AUTO_EXPLAIN 0 249 : 250 : 251 : /** 252 : * Log a really unexpected PQ error with all the details we can get hold of. 253 : * 254 : * @param result PQ result object of the PQ operation that failed 255 : * @param conn SQL connection that was used 256 : */ 257 : #define BREAK_DB_ERR(result,conn) do { \ 258 : GNUNET_break (0); \ 259 : GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ 260 : "Database failure: %s/%s/%s/%s/%s", \ 261 : PQresultErrorField (result, PG_DIAG_MESSAGE_PRIMARY), \ 262 : PQresultErrorField (result, PG_DIAG_MESSAGE_DETAIL), \ 263 : PQresultErrorMessage (result), \ 264 : PQresStatus (PQresultStatus (result)), \ 265 : PQerrorMessage (conn)); \ 266 : } while (0) 267 : 268 : 269 : /** 270 : * Initialize Postgres database subsystem. 271 : * 272 : * @param cls a configuration instance 273 : * @return NULL on error, otherwise a `struct 274 : * TALER_EXCHANGEDB_Plugin` 275 : */ 276 : void * 277 : libtaler_plugin_exchangedb_postgres_init (void *cls); 278 : 279 : /* Declaration used to squash compiler warning */ 280 : void * 281 895 : libtaler_plugin_exchangedb_postgres_init (void *cls) 282 : { 283 895 : const struct GNUNET_CONFIGURATION_Handle *cfg = cls; 284 : struct PostgresClosure *pg; 285 : struct TALER_EXCHANGEDB_Plugin *plugin; 286 : unsigned long long dpl; 287 : 288 895 : pg = GNUNET_new (struct PostgresClosure); 289 895 : plugin = GNUNET_new (struct TALER_EXCHANGEDB_Plugin); 290 895 : pg->cfg = cfg; 291 895 : if (GNUNET_OK != 292 895 : GNUNET_CONFIGURATION_get_value_filename (cfg, 293 : "exchangedb-postgres", 294 : "SQL_DIR", 295 : &pg->sql_dir)) 296 : { 297 0 : GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, 298 : "exchangedb-postgres", 299 : "SQL_DIR"); 300 0 : goto fail; 301 : } 302 895 : if (GNUNET_OK != 303 895 : GNUNET_CONFIGURATION_get_value_string (cfg, 304 : "exchange", 305 : "BASE_URL", 306 : &pg->exchange_url)) 307 : { 308 0 : GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, 309 : "exchange", 310 : "BASE_URL"); 311 0 : goto fail; 312 : } 313 895 : if (GNUNET_OK != 314 895 : GNUNET_CONFIGURATION_get_value_time (cfg, 315 : "exchangedb", 316 : "IDLE_RESERVE_EXPIRATION_TIME", 317 : &pg->idle_reserve_expiration_time)) 318 : { 319 0 : GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, 320 : "exchangedb", 321 : "IDLE_RESERVE_EXPIRATION_TIME"); 322 0 : goto fail; 323 : } 324 895 : if (GNUNET_OK != 325 895 : GNUNET_CONFIGURATION_get_value_time (cfg, 326 : "exchangedb", 327 : "MAX_AML_PROGRAM_RUNTIME", 328 : &plugin->max_aml_program_runtime)) 329 : { 330 0 : GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, 331 : "exchangedb", 332 : "MAX_AML_PROGRAM_RUNTIME"); 333 0 : goto fail; 334 : } 335 895 : if (GNUNET_OK != 336 895 : GNUNET_CONFIGURATION_get_value_time (cfg, 337 : "exchangedb", 338 : "LEGAL_RESERVE_EXPIRATION_TIME", 339 : &pg->legal_reserve_expiration_time)) 340 : { 341 0 : GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, 342 : "exchangedb", 343 : "LEGAL_RESERVE_EXPIRATION_TIME"); 344 0 : goto fail; 345 : } 346 895 : if (GNUNET_OK != 347 895 : GNUNET_CONFIGURATION_get_value_time (cfg, 348 : "exchangedb", 349 : "AGGREGATOR_SHIFT", 350 : &pg->aggregator_shift)) 351 : { 352 0 : GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING, 353 : "exchangedb", 354 : "AGGREGATOR_SHIFT"); 355 : } 356 895 : if (GNUNET_OK != 357 895 : GNUNET_CONFIGURATION_get_value_number (cfg, 358 : "exchangedb", 359 : "DEFAULT_PURSE_LIMIT", 360 : &dpl)) 361 : { 362 0 : GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING, 363 : "exchangedb", 364 : "DEFAULT_PURSE_LIMIT"); 365 0 : pg->def_purse_limit = 1; 366 : } 367 : else 368 : { 369 895 : pg->def_purse_limit = (uint32_t) dpl; 370 : } 371 : 372 895 : if (GNUNET_OK != 373 895 : TALER_config_get_currency (cfg, 374 : "exchange", 375 : &pg->currency)) 376 : { 377 0 : goto fail; 378 : } 379 895 : plugin->cls = pg; 380 : plugin->do_reserve_open 381 895 : = &TEH_PG_do_reserve_open; 382 : plugin->drop_tables 383 895 : = &TEH_PG_drop_tables; 384 : plugin->free_coin_transaction_list 385 895 : = &TEH_COMMON_free_coin_transaction_list; 386 : plugin->free_reserve_history 387 895 : = &TEH_COMMON_free_reserve_history; 388 : plugin->get_coin_transactions 389 895 : = &TEH_PG_get_coin_transactions; 390 : plugin->get_expired_reserves 391 895 : = &TEH_PG_get_expired_reserves; 392 : plugin->get_purse_request 393 895 : = &TEH_PG_get_purse_request; 394 : plugin->get_reserve_history 395 895 : = &TEH_PG_get_reserve_history; 396 : plugin->get_unfinished_close_requests 397 895 : = &TEH_PG_get_unfinished_close_requests; 398 : plugin->insert_records_by_table 399 895 : = &TEH_PG_insert_records_by_table; 400 : plugin->insert_reserve_open_deposit 401 895 : = &TEH_PG_insert_reserve_open_deposit; 402 : plugin->insert_close_request 403 895 : = &TEH_PG_insert_close_request; 404 : plugin->delete_aggregation_transient 405 895 : = &TEH_PG_delete_aggregation_transient; 406 : plugin->iterate_reserve_close_info 407 895 : = &TEH_PG_iterate_reserve_close_info; 408 : plugin->iterate_kyc_reference 409 895 : = &TEH_PG_iterate_kyc_reference; 410 : plugin->lookup_records_by_table 411 895 : = &TEH_PG_lookup_records_by_table; 412 : plugin->lookup_serial_by_table 413 895 : = &TEH_PG_lookup_serial_by_table; 414 : plugin->select_account_merges_above_serial_id 415 895 : = &TEH_PG_select_account_merges_above_serial_id; 416 : plugin->select_all_purse_decisions_above_serial_id 417 895 : = &TEH_PG_select_all_purse_decisions_above_serial_id; 418 : plugin->select_all_purse_deletions_above_serial_id 419 895 : = &TEH_PG_select_all_purse_deletions_above_serial_id; 420 : plugin->select_purse 421 895 : = &TEH_PG_select_purse; 422 : plugin->select_purse_deposits_above_serial_id 423 895 : = &TEH_PG_select_purse_deposits_above_serial_id; 424 : plugin->select_purse_merges_above_serial_id 425 895 : = &TEH_PG_select_purse_merges_above_serial_id; 426 : plugin->select_purse_requests_above_serial_id 427 895 : = &TEH_PG_select_purse_requests_above_serial_id; 428 : plugin->select_reserve_close_info 429 895 : = &TEH_PG_select_reserve_close_info; 430 : plugin->select_reserve_closed_above_serial_id 431 895 : = &TEH_PG_select_reserve_closed_above_serial_id; 432 : plugin->select_reserve_open_above_serial_id 433 895 : = &TEH_PG_select_reserve_open_above_serial_id; 434 : plugin->insert_purse_request 435 895 : = &TEH_PG_insert_purse_request; 436 : plugin->iterate_active_signkeys 437 895 : = &TEH_PG_iterate_active_signkeys; 438 : plugin->commit 439 895 : = &TEH_PG_commit; 440 : plugin->preflight 441 895 : = &TEH_PG_preflight; 442 : plugin->select_aggregation_amounts_for_kyc_check 443 895 : = &TEH_PG_select_aggregation_amounts_for_kyc_check; 444 : plugin->get_kyc_rules 445 895 : = &TEH_PG_get_kyc_rules; 446 : plugin->get_kyc_rules2 447 895 : = &TEH_PG_get_kyc_rules2; 448 : plugin->kyc_provider_account_lookup 449 895 : = &TEH_PG_kyc_provider_account_lookup; 450 : plugin->lookup_kyc_process_by_account 451 895 : = &TEH_PG_lookup_kyc_process_by_account; 452 : plugin->update_kyc_process_by_row 453 895 : = &TEH_PG_update_kyc_process_by_row; 454 : plugin->insert_kyc_requirement_process 455 895 : = &TEH_PG_insert_kyc_requirement_process; 456 : plugin->select_withdraw_amounts_for_kyc_check 457 895 : = &TEH_PG_select_withdraw_amounts_for_kyc_check; 458 : plugin->select_merge_amounts_for_kyc_check 459 895 : = &TEH_PG_select_merge_amounts_for_kyc_check; 460 : plugin->profit_drains_set_finished 461 895 : = &TEH_PG_profit_drains_set_finished; 462 : plugin->profit_drains_get_pending 463 895 : = &TEH_PG_profit_drains_get_pending; 464 : plugin->get_drain_profit 465 895 : = &TEH_PG_get_drain_profit; 466 : plugin->get_purse_deposit 467 895 : = &TEH_PG_get_purse_deposit; 468 : plugin->insert_contract 469 895 : = &TEH_PG_insert_contract; 470 : plugin->select_contract 471 895 : = &TEH_PG_select_contract; 472 : plugin->select_purse_merge 473 895 : = &TEH_PG_select_purse_merge; 474 : plugin->select_contract_by_purse 475 895 : = &TEH_PG_select_contract_by_purse; 476 : plugin->insert_drain_profit 477 895 : = &TEH_PG_insert_drain_profit; 478 : plugin->do_reserve_purse 479 895 : = &TEH_PG_do_reserve_purse; 480 : plugin->lookup_global_fee_by_time 481 895 : = &TEH_PG_lookup_global_fee_by_time; 482 : plugin->do_purse_deposit 483 895 : = &TEH_PG_do_purse_deposit; 484 : plugin->activate_signing_key 485 895 : = &TEH_PG_activate_signing_key; 486 : plugin->update_auditor 487 895 : = &TEH_PG_update_auditor; 488 : plugin->begin_revolving_shard 489 895 : = &TEH_PG_begin_revolving_shard; 490 : plugin->get_extension_manifest 491 895 : = &TEH_PG_get_extension_manifest; 492 : plugin->do_purse_merge 493 895 : = &TEH_PG_do_purse_merge; 494 : plugin->do_purse_delete 495 895 : = &TEH_PG_do_purse_delete; 496 : plugin->start_read_committed 497 895 : = &TEH_PG_start_read_committed; 498 : plugin->start_read_only 499 895 : = &TEH_PG_start_read_only; 500 : plugin->insert_denomination_info 501 895 : = &TEH_PG_insert_denomination_info; 502 : plugin->lookup_wire_fee_by_time 503 895 : = &TEH_PG_lookup_wire_fee_by_time; 504 : plugin->start 505 895 : = &TEH_PG_start; 506 : plugin->rollback 507 895 : = &TEH_PG_rollback; 508 : plugin->create_tables 509 895 : = &TEH_PG_create_tables; 510 : plugin->event_listen 511 895 : = &TEH_PG_event_listen; 512 : plugin->event_listen_cancel 513 895 : = &TEH_PG_event_listen_cancel; 514 : plugin->event_notify 515 895 : = &TEH_PG_event_notify; 516 : plugin->get_denomination_info 517 895 : = &TEH_PG_get_denomination_info; 518 : plugin->get_denomination_by_serial 519 895 : = &TEH_PG_get_denomination_by_serial; 520 : plugin->iterate_denomination_info 521 895 : = &TEH_PG_iterate_denomination_info; 522 : plugin->iterate_denominations 523 895 : = &TEH_PG_iterate_denominations; 524 : plugin->iterate_active_auditors 525 895 : = &TEH_PG_iterate_active_auditors; 526 : plugin->iterate_auditor_denominations 527 895 : = &TEH_PG_iterate_auditor_denominations; 528 : plugin->lookup_rules_by_access_token 529 895 : = &TEH_PG_lookup_rules_by_access_token; 530 : plugin->reserves_get 531 895 : = &TEH_PG_reserves_get; 532 : plugin->reserves_get_origin 533 895 : = &TEH_PG_reserves_get_origin; 534 : plugin->drain_kyc_alert 535 895 : = &TEH_PG_drain_kyc_alert; 536 : plugin->reserves_in_insert 537 895 : = &TEH_PG_reserves_in_insert; 538 : plugin->do_withdraw 539 895 : = &TEH_PG_do_withdraw; 540 : plugin->get_withdraw 541 895 : = &TEH_PG_get_withdraw; 542 : plugin->wad_in_insert 543 895 : = &TEH_PG_wad_in_insert; 544 : plugin->kycauth_in_insert 545 895 : = &TEH_PG_kycauth_in_insert; 546 : plugin->get_policy_details 547 895 : = &TEH_PG_get_policy_details; 548 : plugin->persist_policy_details 549 895 : = &TEH_PG_persist_policy_details; 550 : plugin->do_deposit 551 895 : = &TEH_PG_do_deposit; 552 : plugin->get_wire_hash_for_contract 553 895 : = &TEH_PG_get_wire_hash_for_contract; 554 : plugin->add_policy_fulfillment_proof 555 895 : = &TEH_PG_add_policy_fulfillment_proof; 556 : plugin->do_refresh 557 895 : = &TEH_PG_do_refresh; 558 : plugin->do_refund 559 895 : = &TEH_PG_do_refund; 560 : plugin->do_recoup 561 895 : = &TEH_PG_do_recoup; 562 : plugin->do_recoup_refresh 563 895 : = &TEH_PG_do_recoup_refresh; 564 : plugin->get_reserve_balance 565 895 : = &TEH_PG_get_reserve_balance; 566 : plugin->count_known_coins 567 895 : = &TEH_PG_count_known_coins; 568 : plugin->ensure_coin_known 569 895 : = &TEH_PG_ensure_coin_known; 570 : plugin->get_known_coin 571 895 : = &TEH_PG_get_known_coin; 572 : plugin->get_signature_for_known_coin 573 895 : = &TEH_PG_get_signature_for_known_coin; 574 : plugin->get_coin_denomination 575 895 : = &TEH_PG_get_coin_denomination; 576 : plugin->have_deposit2 577 895 : = &TEH_PG_have_deposit2; 578 : plugin->aggregate 579 895 : = &TEH_PG_aggregate; 580 : plugin->create_aggregation_transient 581 895 : = &TEH_PG_create_aggregation_transient; 582 : plugin->select_aggregation_transient 583 895 : = &TEH_PG_select_aggregation_transient; 584 : plugin->find_aggregation_transient 585 895 : = &TEH_PG_find_aggregation_transient; 586 : plugin->update_aggregation_transient 587 895 : = &TEH_PG_update_aggregation_transient; 588 : plugin->get_ready_deposit 589 895 : = &TEH_PG_get_ready_deposit; 590 : plugin->insert_refund 591 895 : = &TEH_PG_insert_refund; 592 : plugin->select_refunds_by_coin 593 895 : = &TEH_PG_select_refunds_by_coin; 594 : plugin->select_aml_measures 595 895 : = &TEH_PG_select_aml_measures; 596 : plugin->get_refresh 597 895 : = &TEH_PG_get_refresh; 598 : plugin->lookup_wire_transfer 599 895 : = &TEH_PG_lookup_wire_transfer; 600 : plugin->lookup_transfer_by_deposit 601 895 : = &TEH_PG_lookup_transfer_by_deposit; 602 : plugin->insert_wire_fee 603 895 : = &TEH_PG_insert_wire_fee; 604 : plugin->insert_global_fee 605 895 : = &TEH_PG_insert_global_fee; 606 : plugin->get_wire_fee 607 895 : = &TEH_PG_get_wire_fee; 608 : plugin->get_global_fee 609 895 : = &TEH_PG_get_global_fee; 610 : plugin->get_global_fees 611 895 : = &TEH_PG_get_global_fees; 612 : plugin->insert_reserve_closed 613 895 : = &TEH_PG_insert_reserve_closed; 614 : plugin->wire_prepare_data_insert 615 895 : = &TEH_PG_wire_prepare_data_insert; 616 : plugin->wire_prepare_data_mark_finished 617 895 : = &TEH_PG_wire_prepare_data_mark_finished; 618 : plugin->wire_prepare_data_mark_failed 619 895 : = &TEH_PG_wire_prepare_data_mark_failed; 620 : plugin->wire_prepare_data_get 621 895 : = &TEH_PG_wire_prepare_data_get; 622 : plugin->start_deferred_wire_out 623 895 : = &TEH_PG_start_deferred_wire_out; 624 : plugin->store_wire_transfer_out 625 895 : = &TEH_PG_store_wire_transfer_out; 626 : plugin->gc 627 895 : = &TEH_PG_gc; 628 : plugin->select_coin_deposits_above_serial_id 629 895 : = &TEH_PG_select_coin_deposits_above_serial_id; 630 : plugin->lookup_aml_history 631 895 : = &TEH_PG_lookup_aml_history; 632 : plugin->lookup_kyc_history 633 895 : = &TEH_PG_lookup_kyc_history; 634 : plugin->select_purse_decisions_above_serial_id 635 895 : = &TEH_PG_select_purse_decisions_above_serial_id; 636 : plugin->select_purse_deposits_by_purse 637 895 : = &TEH_PG_select_purse_deposits_by_purse; 638 : plugin->select_refreshes_above_serial_id 639 895 : = &TEH_PG_select_refreshes_above_serial_id; 640 : plugin->select_refunds_above_serial_id 641 895 : = &TEH_PG_select_refunds_above_serial_id; 642 : plugin->select_reserves_in_above_serial_id 643 895 : = &TEH_PG_select_reserves_in_above_serial_id; 644 : plugin->select_reserves_in_above_serial_id_by_account 645 895 : = &TEH_PG_select_reserves_in_above_serial_id_by_account; 646 : plugin->select_withdrawals_above_serial_id 647 895 : = &TEH_PG_select_withdrawals_above_serial_id; 648 : plugin->select_wire_out_above_serial_id 649 895 : = &TEH_PG_select_wire_out_above_serial_id; 650 : plugin->select_wire_out_above_serial_id_by_account 651 895 : = &TEH_PG_select_wire_out_above_serial_id_by_account; 652 : plugin->select_recoup_above_serial_id 653 895 : = &TEH_PG_select_recoup_above_serial_id; 654 : plugin->select_recoup_refresh_above_serial_id 655 895 : = &TEH_PG_select_recoup_refresh_above_serial_id; 656 : plugin->get_reserve_by_h_planchets 657 895 : = &TEH_PG_get_reserve_by_h_planchets; 658 : plugin->get_old_coin_by_h_blind 659 895 : = &TEH_PG_get_old_coin_by_h_blind; 660 : plugin->insert_denomination_revocation 661 895 : = &TEH_PG_insert_denomination_revocation; 662 : plugin->get_denomination_revocation 663 895 : = &TEH_PG_get_denomination_revocation; 664 : plugin->select_batch_deposits_missing_wire 665 895 : = &TEH_PG_select_batch_deposits_missing_wire; 666 : plugin->select_aggregations_above_serial 667 895 : = &TEH_PG_select_aggregations_above_serial; 668 : plugin->lookup_auditor_timestamp 669 895 : = &TEH_PG_lookup_auditor_timestamp; 670 : plugin->lookup_auditor_status 671 895 : = &TEH_PG_lookup_auditor_status; 672 : plugin->insert_auditor 673 895 : = &TEH_PG_insert_auditor; 674 : plugin->lookup_wire_timestamp 675 895 : = &TEH_PG_lookup_wire_timestamp; 676 : plugin->insert_wire 677 895 : = &TEH_PG_insert_wire; 678 : plugin->update_wire 679 895 : = &TEH_PG_update_wire; 680 : plugin->get_wire_accounts 681 895 : = &TEH_PG_get_wire_accounts; 682 : plugin->get_wire_fees 683 895 : = &TEH_PG_get_wire_fees; 684 : plugin->select_aml_decisions 685 895 : = &TEH_PG_select_aml_decisions; 686 : plugin->select_deposit_amounts_for_kyc_check 687 895 : = &TEH_PG_select_deposit_amounts_for_kyc_check; 688 : plugin->do_check_deposit_idempotent 689 895 : = &TEH_PG_do_check_deposit_idempotent; 690 : plugin->insert_signkey_revocation 691 895 : = &TEH_PG_insert_signkey_revocation; 692 : plugin->select_aml_attributes 693 895 : = &TEH_PG_select_aml_attributes; 694 : plugin->select_aml_statistics 695 895 : = &TEH_PG_select_aml_statistics; 696 : plugin->lookup_signkey_revocation 697 895 : = &TEH_PG_lookup_signkey_revocation; 698 : plugin->lookup_denomination_key 699 895 : = &TEH_PG_lookup_denomination_key; 700 : plugin->lookup_completed_legitimization 701 895 : = &TEH_PG_lookup_completed_legitimization; 702 : plugin->lookup_pending_legitimization 703 895 : = &TEH_PG_lookup_pending_legitimization; 704 : plugin->lookup_active_legitimization 705 895 : = &TEH_PG_lookup_active_legitimization; 706 : plugin->insert_auditor_denom_sig 707 895 : = &TEH_PG_insert_auditor_denom_sig; 708 : plugin->select_auditor_denom_sig 709 895 : = &TEH_PG_select_auditor_denom_sig; 710 : plugin->add_denomination_key 711 895 : = &TEH_PG_add_denomination_key; 712 : plugin->lookup_signing_key 713 895 : = &TEH_PG_lookup_signing_key; 714 : plugin->lookup_h_payto_by_access_token 715 895 : = &TEH_PG_lookup_h_payto_by_access_token; 716 : plugin->insert_sanction_list_hit 717 895 : = &TEH_PG_insert_sanction_list_hit; 718 : plugin->select_exchange_debit_transfers 719 895 : = &TEH_PG_select_exchange_debit_transfers; 720 : plugin->select_exchange_credit_transfers 721 895 : = &TEH_PG_select_exchange_credit_transfers; 722 : plugin->select_all_kyc_attributes 723 895 : = &TEH_PG_select_all_kyc_attributes; 724 : plugin->begin_shard 725 895 : = &TEH_PG_begin_shard; 726 : plugin->abort_shard 727 895 : = &TEH_PG_abort_shard; 728 : plugin->insert_kyc_failure 729 895 : = &TEH_PG_insert_kyc_failure; 730 : plugin->complete_shard 731 895 : = &TEH_PG_complete_shard; 732 : plugin->release_revolving_shard 733 895 : = &TEH_PG_release_revolving_shard; 734 : plugin->delete_shard_locks 735 895 : = &TEH_PG_delete_shard_locks; 736 : plugin->set_extension_manifest 737 895 : = &TEH_PG_set_extension_manifest; 738 : plugin->insert_partner 739 895 : = &TEH_PG_insert_partner; 740 : plugin->expire_purse 741 895 : = &TEH_PG_expire_purse; 742 : plugin->select_purse_by_merge_pub 743 895 : = &TEH_PG_select_purse_by_merge_pub; 744 : plugin->set_purse_balance 745 895 : = &TEH_PG_set_purse_balance; 746 : plugin->get_pending_kyc_requirement_process 747 895 : = &TEH_PG_get_pending_kyc_requirement_process; 748 : plugin->select_kyc_attributes 749 895 : = &TEH_PG_select_kyc_attributes; 750 : plugin->insert_aml_officer 751 895 : = &TEH_PG_insert_aml_officer; 752 : plugin->enable_rules 753 895 : = &TEH_PG_enable_rules; 754 : plugin->disable_rules 755 895 : = &TEH_PG_disable_rules; 756 : plugin->test_aml_officer 757 895 : = &TEH_PG_test_aml_officer; 758 : plugin->lookup_aml_officer 759 895 : = &TEH_PG_lookup_aml_officer; 760 : plugin->insert_active_legitimization_measure 761 895 : = &TEH_PG_insert_active_legitimization_measure; 762 : plugin->insert_aml_decision 763 895 : = &TEH_PG_insert_aml_decision; 764 : plugin->lookup_kyc_requirement_by_row 765 895 : = &TEH_PG_lookup_kyc_requirement_by_row; 766 : plugin->trigger_kyc_rule_for_account 767 895 : = &TEH_PG_trigger_kyc_rule_for_account; 768 : plugin->lookup_kyc_status_by_token 769 895 : = &TEH_PG_lookup_kyc_status_by_token; 770 : plugin->batch_ensure_coin_known 771 895 : = &TEH_PG_batch_ensure_coin_known; 772 : plugin->inject_auditor_triggers 773 895 : = &TEH_PG_inject_auditor_triggers; 774 : plugin->insert_successor_measure 775 895 : = &TEH_PG_insert_successor_measure; 776 : plugin->insert_aml_program_failure 777 895 : = &TEH_PG_insert_aml_program_failure; 778 : plugin->persist_kyc_attributes 779 895 : = &TEH_PG_persist_kyc_attributes; 780 : plugin->clear_aml_lock 781 895 : = &TEH_PG_clear_aml_lock; 782 : plugin->set_aml_lock 783 895 : = &TEH_PG_set_aml_lock; 784 : 785 895 : return plugin; 786 : 787 0 : fail: 788 0 : GNUNET_free (pg->exchange_url); 789 0 : GNUNET_free (pg->sql_dir); 790 0 : GNUNET_free (pg); 791 0 : GNUNET_free (plugin); 792 0 : return NULL; 793 : } 794 : 795 : 796 : /** 797 : * Shutdown Postgres database subsystem. 798 : * 799 : * @param cls a `struct TALER_EXCHANGEDB_Plugin` 800 : * @return NULL (always) 801 : */ 802 : void * 803 : libtaler_plugin_exchangedb_postgres_done (void *cls); 804 : 805 : /* Declaration used to squash compiler warning */ 806 : void * 807 895 : libtaler_plugin_exchangedb_postgres_done (void *cls) 808 : { 809 895 : struct TALER_EXCHANGEDB_Plugin *plugin = cls; 810 895 : struct PostgresClosure *pg = plugin->cls; 811 : 812 895 : if (NULL != pg->conn) 813 : { 814 871 : GNUNET_PQ_disconnect (pg->conn); 815 871 : pg->conn = NULL; 816 : } 817 895 : GNUNET_free (pg->exchange_url); 818 895 : GNUNET_free (pg->sql_dir); 819 895 : GNUNET_free (pg->currency); 820 895 : GNUNET_free (pg); 821 895 : GNUNET_free (plugin); 822 895 : return NULL; 823 : } 824 : 825 : 826 : /* end of plugin_exchangedb_postgres.c */