LCOV - code coverage report
Current view: top level - exchangedb - pg_insert_records_by_table.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 801 0
Test Date: 2025-12-28 14:06:02 Functions: 0.0 % 50 0

            Line data    Source code
       1              : /*
       2              :    This file is part of GNUnet
       3              :    Copyright (C) 2020-2025 Taler Systems SA
       4              : 
       5              :    GNUnet is free software: you can redistribute it and/or modify it
       6              :    under the terms of the GNU Affero General Public License as published
       7              :    by the Free Software Foundation, either version 3 of the License,
       8              :    or (at your option) any later version.
       9              : 
      10              :    GNUnet is distributed in the hope that it will be useful, but
      11              :    WITHOUT ANY WARRANTY; without even the implied warranty of
      12              :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13              :    Affero General Public License for more details.
      14              : 
      15              :    You should have received a copy of the GNU Affero General Public License
      16              :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      17              : 
      18              :      SPDX-License-Identifier: AGPL3.0-or-later
      19              :  */
      20              : /**
      21              :  * @file exchangedb/pg_insert_records_by_table.c
      22              :  * @brief replicate_records_by_table implementation
      23              :  * @author Christian Grothoff
      24              :  * @author Özgür Kesim
      25              :  */
      26              : #include "taler/platform.h"
      27              : #include "taler/taler_error_codes.h"
      28              : #include "taler/taler_dbevents.h"
      29              : #include "taler/taler_pq_lib.h"
      30              : #include "pg_insert_records_by_table.h"
      31              : #include "pg_helper.h"
      32              : #include <gnunet/gnunet_pq_lib.h>
      33              : 
      34              : 
      35              : /**
      36              :  * Signature of helper functions of #TEH_PG_insert_records_by_table().
      37              :  *
      38              :  * @param pg plugin context
      39              :  * @param td record to insert
      40              :  * @return transaction status code
      41              :  */
      42              : typedef enum GNUNET_DB_QueryStatus
      43              : (*InsertRecordCallback)(struct PostgresClosure *pg,
      44              :                         const struct TALER_EXCHANGEDB_TableData *td);
      45              : 
      46              : 
      47              : /**
      48              :  * Function called with denominations records to insert into table.
      49              :  *
      50              :  * @param pg plugin context
      51              :  * @param td record to insert
      52              :  */
      53              : static enum GNUNET_DB_QueryStatus
      54            0 : irbt_cb_table_denominations (struct PostgresClosure *pg,
      55              :                              const struct TALER_EXCHANGEDB_TableData *td)
      56              : {
      57              :   struct TALER_DenominationHashP denom_hash;
      58            0 :   struct GNUNET_PQ_QueryParam params[] = {
      59            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
      60            0 :     GNUNET_PQ_query_param_auto_from_type (&denom_hash),
      61            0 :     GNUNET_PQ_query_param_uint32 (
      62              :       &td->details.denominations.denom_type),
      63            0 :     GNUNET_PQ_query_param_uint32 (
      64              :       &td->details.denominations.age_mask),
      65            0 :     TALER_PQ_query_param_denom_pub (
      66              :       &td->details.denominations.denom_pub),
      67            0 :     GNUNET_PQ_query_param_auto_from_type (
      68              :       &td->details.denominations.master_sig),
      69            0 :     GNUNET_PQ_query_param_timestamp (
      70              :       &td->details.denominations.valid_from),
      71            0 :     GNUNET_PQ_query_param_timestamp (
      72              :       &td->details.denominations.expire_withdraw),
      73            0 :     GNUNET_PQ_query_param_timestamp (
      74              :       &td->details.denominations.expire_deposit),
      75            0 :     GNUNET_PQ_query_param_timestamp (
      76              :       &td->details.denominations.expire_legal),
      77            0 :     TALER_PQ_query_param_amount (
      78            0 :       pg->conn,
      79              :       &td->details.denominations.coin),
      80            0 :     TALER_PQ_query_param_amount (
      81            0 :       pg->conn,
      82              :       &td->details.denominations.fees.withdraw),
      83            0 :     TALER_PQ_query_param_amount (
      84            0 :       pg->conn,
      85              :       &td->details.denominations.fees.deposit),
      86            0 :     TALER_PQ_query_param_amount (
      87            0 :       pg->conn,
      88              :       &td->details.denominations.fees.refresh),
      89            0 :     TALER_PQ_query_param_amount (
      90            0 :       pg->conn,
      91              :       &td->details.denominations.fees.refund),
      92              :     GNUNET_PQ_query_param_end
      93              :   };
      94              : 
      95            0 :   PREPARE (pg,
      96              :            "insert_into_table_denominations",
      97              :            "INSERT INTO denominations"
      98              :            "(denominations_serial"
      99              :            ",denom_pub_hash"
     100              :            ",denom_type"
     101              :            ",age_mask"
     102              :            ",denom_pub"
     103              :            ",master_sig"
     104              :            ",valid_from"
     105              :            ",expire_withdraw"
     106              :            ",expire_deposit"
     107              :            ",expire_legal"
     108              :            ",coin"
     109              :            ",fee_withdraw"
     110              :            ",fee_deposit"
     111              :            ",fee_refresh"
     112              :            ",fee_refund"
     113              :            ") VALUES "
     114              :            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10,"
     115              :            " $11, $12, $13, $14, $15);");
     116              : 
     117            0 :   TALER_denom_pub_hash (
     118              :     &td->details.denominations.denom_pub,
     119              :     &denom_hash);
     120              : 
     121            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     122              :                                              "insert_into_table_denominations",
     123              :                                              params);
     124              : }
     125              : 
     126              : 
     127              : /**
     128              :  * Function called with denomination_revocations records to insert into table.
     129              :  *
     130              :  * @param pg plugin context
     131              :  * @param td record to insert
     132              :  */
     133              : static enum GNUNET_DB_QueryStatus
     134            0 : irbt_cb_table_denomination_revocations (
     135              :   struct PostgresClosure *pg,
     136              :   const struct TALER_EXCHANGEDB_TableData *td)
     137              : {
     138            0 :   struct GNUNET_PQ_QueryParam params[] = {
     139            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     140            0 :     GNUNET_PQ_query_param_auto_from_type (
     141              :       &td->details.denomination_revocations.master_sig),
     142            0 :     GNUNET_PQ_query_param_uint64 (
     143              :       &td->details.denomination_revocations.denominations_serial),
     144              :     GNUNET_PQ_query_param_end
     145              :   };
     146              : 
     147            0 :   PREPARE (pg,
     148              :            "insert_into_table_denomination_revocations",
     149              :            "INSERT INTO denomination_revocations"
     150              :            "(denom_revocations_serial_id"
     151              :            ",master_sig"
     152              :            ",denominations_serial"
     153              :            ") VALUES "
     154              :            "($1, $2, $3);");
     155            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     156              :                                              "insert_into_table_denomination_revocations",
     157              :                                              params);
     158              : }
     159              : 
     160              : 
     161              : /**
     162              :  * Function called with wire target records to insert into table.
     163              :  *
     164              :  * @param pg plugin context
     165              :  * @param td record to insert
     166              :  */
     167              : static enum GNUNET_DB_QueryStatus
     168            0 : irbt_cb_table_wire_targets (struct PostgresClosure *pg,
     169              :                             const struct TALER_EXCHANGEDB_TableData *td)
     170              : {
     171              :   struct TALER_NormalizedPaytoHashP normalized_payto_hash;
     172              :   struct TALER_FullPaytoHashP full_payto_hash;
     173            0 :   struct GNUNET_PQ_QueryParam params[] = {
     174            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     175            0 :     GNUNET_PQ_query_param_auto_from_type (&full_payto_hash),
     176            0 :     GNUNET_PQ_query_param_auto_from_type (&normalized_payto_hash),
     177            0 :     GNUNET_PQ_query_param_string (
     178            0 :       td->details.wire_targets.full_payto_uri.full_payto),
     179              :     GNUNET_PQ_query_param_end
     180              :   };
     181              : 
     182            0 :   TALER_full_payto_hash (
     183              :     td->details.wire_targets.full_payto_uri,
     184              :     &full_payto_hash);
     185            0 :   TALER_full_payto_normalize_and_hash (
     186              :     td->details.wire_targets.full_payto_uri,
     187              :     &normalized_payto_hash);
     188            0 :   PREPARE (pg,
     189              :            "insert_into_table_wire_targets",
     190              :            "INSERT INTO wire_targets"
     191              :            "(wire_target_serial_id"
     192              :            ",wire_target_h_payto"
     193              :            ",h_normalized_payto"
     194              :            ",payto_uri"
     195              :            ") VALUES "
     196              :            "($1, $2, $3, $4);");
     197            0 :   return GNUNET_PQ_eval_prepared_non_select (
     198              :     pg->conn,
     199              :     "insert_into_table_wire_targets",
     200              :     params);
     201              : }
     202              : 
     203              : 
     204              : /**
     205              :  * Function called with kyc target records to insert into table.
     206              :  *
     207              :  * @param pg plugin context
     208              :  * @param td record to insert
     209              :  */
     210              : static enum GNUNET_DB_QueryStatus
     211            0 : irbt_cb_table_kyc_targets (struct PostgresClosure *pg,
     212              :                            const struct TALER_EXCHANGEDB_TableData *td)
     213              : {
     214            0 :   struct GNUNET_PQ_QueryParam params[] = {
     215            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     216            0 :     GNUNET_PQ_query_param_auto_from_type (
     217              :       &td->details.kyc_targets.h_normalized_payto),
     218            0 :     GNUNET_PQ_query_param_auto_from_type (
     219              :       &td->details.kyc_targets.access_token),
     220            0 :     td->details.kyc_targets.no_account
     221            0 :     ? GNUNET_PQ_query_param_null ()
     222            0 :     : GNUNET_PQ_query_param_auto_from_type (
     223              :       &td->details.kyc_targets.target_pub),
     224            0 :     GNUNET_PQ_query_param_bool (
     225            0 :       td->details.kyc_targets.is_wallet),
     226              :     GNUNET_PQ_query_param_end
     227              :   };
     228              : 
     229            0 :   PREPARE (pg,
     230              :            "insert_into_table_kyc_targets",
     231              :            "INSERT INTO kyc_targets"
     232              :            "(kyc_target_serial_id"
     233              :            ",h_normalized_payto"
     234              :            ",access_token"
     235              :            ",target_pub"
     236              :            ",is_wallet"
     237              :            ") VALUES "
     238              :            "($1, $2, $3, $4, $5);");
     239            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     240              :                                              "insert_into_table_kyc_targets",
     241              :                                              params);
     242              : }
     243              : 
     244              : 
     245              : /**
     246              :  * Function called with records to insert into table.
     247              :  *
     248              :  * @param pg plugin context
     249              :  * @param td record to insert
     250              :  */
     251              : static enum GNUNET_DB_QueryStatus
     252            0 : irbt_cb_table_legitimization_measures (
     253              :   struct PostgresClosure *pg,
     254              :   const struct TALER_EXCHANGEDB_TableData *td)
     255              : {
     256            0 :   struct GNUNET_PQ_QueryParam params[] = {
     257            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     258            0 :     GNUNET_PQ_query_param_auto_from_type (
     259              :       &td->details.legitimization_measures.target_token),
     260            0 :     GNUNET_PQ_query_param_timestamp (
     261              :       &td->details.legitimization_measures.start_time),
     262            0 :     TALER_PQ_query_param_json (
     263            0 :       td->details.legitimization_measures.measures),
     264            0 :     GNUNET_PQ_query_param_uint32 (
     265              :       &td->details.legitimization_measures.display_priority),
     266              :     GNUNET_PQ_query_param_end
     267              :   };
     268              : 
     269            0 :   PREPARE (pg,
     270              :            "insert_into_table_legitimization_measures",
     271              :            "INSERT INTO legitimization_measures"
     272              :            "(legitimization_measure_serial_id"
     273              :            ",access_token"
     274              :            ",start_time"
     275              :            ",jmeasures"
     276              :            ",display_priority"
     277              :            ") VALUES "
     278              :            "($1, $2, $3, $4::TEXT::JSONB, $5);");
     279            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     280              :                                              "insert_into_table_legitimization_measures",
     281              :                                              params);
     282              : }
     283              : 
     284              : 
     285              : /**
     286              :  * Function called with records to insert into table.
     287              :  *
     288              :  * @param pg plugin context
     289              :  * @param td record to insert
     290              :  */
     291              : static enum GNUNET_DB_QueryStatus
     292            0 : irbt_cb_table_legitimization_outcomes (
     293              :   struct PostgresClosure *pg,
     294              :   const struct TALER_EXCHANGEDB_TableData *td)
     295              : {
     296            0 :   struct GNUNET_PQ_QueryParam params[] = {
     297            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     298            0 :     GNUNET_PQ_query_param_auto_from_type (
     299              :       &td->details.legitimization_outcomes.h_payto),
     300            0 :     GNUNET_PQ_query_param_timestamp (
     301              :       &td->details.legitimization_outcomes.decision_time),
     302            0 :     GNUNET_PQ_query_param_timestamp (
     303              :       &td->details.legitimization_outcomes.expiration_time),
     304            0 :     TALER_PQ_query_param_json (
     305            0 :       td->details.legitimization_outcomes.properties),
     306            0 :     GNUNET_PQ_query_param_bool (
     307            0 :       td->details.legitimization_outcomes.to_investigate),
     308            0 :     TALER_PQ_query_param_json (
     309            0 :       td->details.legitimization_outcomes.new_rules),
     310              :     GNUNET_PQ_query_param_end
     311              :   };
     312              : 
     313            0 :   PREPARE (pg,
     314              :            "insert_into_table_legitimization_outcomes",
     315              :            "INSERT INTO legitimization_outcomes"
     316              :            "(outcome_serial_id"
     317              :            ",h_payto"
     318              :            ",decision_time"
     319              :            ",expiration_time"
     320              :            ",jproperties"
     321              :            ",to_investigate"
     322              :            ",jnew_rules"
     323              :            ") VALUES "
     324              :            "($1, $2, $3, $4, $5::TEXT::JSONB, $6, $7::TEXT::JSONB);");
     325            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     326              :                                              "insert_into_table_legitimization_outcomes",
     327              :                                              params);
     328              : }
     329              : 
     330              : 
     331              : /**
     332              :  * Function called with records to insert into table.
     333              :  *
     334              :  * @param pg plugin context
     335              :  * @param td record to insert
     336              :  */
     337              : static enum GNUNET_DB_QueryStatus
     338            0 : irbt_cb_table_legitimization_processes (
     339              :   struct PostgresClosure *pg,
     340              :   const struct TALER_EXCHANGEDB_TableData *td)
     341              : {
     342            0 :   struct GNUNET_PQ_QueryParam params[] = {
     343            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     344            0 :     GNUNET_PQ_query_param_auto_from_type (
     345              :       &td->details.legitimization_processes.h_payto),
     346            0 :     GNUNET_PQ_query_param_timestamp (
     347              :       &td->details.legitimization_processes.start_time),
     348            0 :     GNUNET_PQ_query_param_timestamp (
     349              :       &td->details.legitimization_processes.expiration_time),
     350            0 :     GNUNET_PQ_query_param_uint64 (
     351              :       &td->details.legitimization_processes.legitimization_measure_serial_id),
     352            0 :     GNUNET_PQ_query_param_uint32 (
     353              :       &td->details.legitimization_processes.measure_index),
     354            0 :     GNUNET_PQ_query_param_string (
     355            0 :       td->details.legitimization_processes.provider_name),
     356            0 :     GNUNET_PQ_query_param_string (
     357            0 :       td->details.legitimization_processes.provider_user_id),
     358            0 :     GNUNET_PQ_query_param_string (
     359            0 :       td->details.legitimization_processes.provider_legitimization_id),
     360            0 :     GNUNET_PQ_query_param_string (
     361            0 :       td->details.legitimization_processes.redirect_url),
     362              :     GNUNET_PQ_query_param_end
     363              :   };
     364              : 
     365            0 :   PREPARE (pg,
     366              :            "insert_into_table_legitimization_processes",
     367              :            "INSERT INTO legitimization_processes"
     368              :            "(legitimization_process_serial_id"
     369              :            ",h_payto"
     370              :            ",start_time"
     371              :            ",expiration_time"
     372              :            ",legitimization_measure_serial_id"
     373              :            ",measure_index"
     374              :            ",provider_name"
     375              :            ",provider_user_id"
     376              :            ",provider_legitimization_id"
     377              :            ",redirect_url"
     378              :            ") VALUES "
     379              :            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10);");
     380            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     381              :                                              "insert_into_table_legitimization_processes",
     382              :                                              params);
     383              : }
     384              : 
     385              : 
     386              : /**
     387              :  * Function called with reserves records to insert into table.
     388              :  *
     389              :  * @param pg plugin context
     390              :  * @param td record to insert
     391              :  */
     392              : static enum GNUNET_DB_QueryStatus
     393            0 : irbt_cb_table_reserves (struct PostgresClosure *pg,
     394              :                         const struct TALER_EXCHANGEDB_TableData *td)
     395              : {
     396            0 :   struct GNUNET_PQ_QueryParam params[] = {
     397            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     398            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.reserves.reserve_pub),
     399            0 :     GNUNET_PQ_query_param_timestamp (&td->details.reserves.expiration_date),
     400            0 :     GNUNET_PQ_query_param_timestamp (&td->details.reserves.gc_date),
     401              :     GNUNET_PQ_query_param_end
     402              :   };
     403              : 
     404            0 :   PREPARE (pg,
     405              :            "insert_into_table_reserves",
     406              :            "INSERT INTO reserves"
     407              :            "(reserve_uuid"
     408              :            ",reserve_pub"
     409              :            ",expiration_date"
     410              :            ",gc_date"
     411              :            ") VALUES "
     412              :            "($1, $2, $3, $4);");
     413            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     414              :                                              "insert_into_table_reserves",
     415              :                                              params);
     416              : }
     417              : 
     418              : 
     419              : /**
     420              :  * Function called with reserves_in records to insert into table.
     421              :  *
     422              :  * @param pg plugin context
     423              :  * @param td record to insert
     424              :  */
     425              : static enum GNUNET_DB_QueryStatus
     426            0 : irbt_cb_table_reserves_in (struct PostgresClosure *pg,
     427              :                            const struct TALER_EXCHANGEDB_TableData *td)
     428              : {
     429            0 :   struct GNUNET_PQ_QueryParam params[] = {
     430            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     431            0 :     GNUNET_PQ_query_param_uint64 (&td->details.reserves_in.wire_reference),
     432            0 :     TALER_PQ_query_param_amount (
     433            0 :       pg->conn,
     434              :       &td->details.reserves_in.credit),
     435            0 :     GNUNET_PQ_query_param_auto_from_type (
     436              :       &td->details.reserves_in.sender_account_h_payto),
     437            0 :     GNUNET_PQ_query_param_string (
     438            0 :       td->details.reserves_in.exchange_account_section),
     439            0 :     GNUNET_PQ_query_param_timestamp (
     440              :       &td->details.reserves_in.execution_date),
     441            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.reserves_in.reserve_pub),
     442              :     GNUNET_PQ_query_param_end
     443              :   };
     444              : 
     445            0 :   PREPARE (pg,
     446              :            "insert_into_table_reserves_in",
     447              :            "INSERT INTO reserves_in"
     448              :            "(reserve_in_serial_id"
     449              :            ",wire_reference"
     450              :            ",credit"
     451              :            ",wire_source_h_payto"
     452              :            ",exchange_account_section"
     453              :            ",execution_date"
     454              :            ",reserve_pub"
     455              :            ") VALUES "
     456              :            "($1, $2, $3, $4, $5, $6, $7);");
     457            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     458              :                                              "insert_into_table_reserves_in",
     459              :                                              params);
     460              : }
     461              : 
     462              : 
     463              : /**
     464              :  * Function called with kycauth_in records to insert into table.
     465              :  *
     466              :  * @param pg plugin context
     467              :  * @param td record to insert
     468              :  */
     469              : static enum GNUNET_DB_QueryStatus
     470            0 : irbt_cb_table_kycauths_in (struct PostgresClosure *pg,
     471              :                            const struct TALER_EXCHANGEDB_TableData *td)
     472              : {
     473            0 :   struct GNUNET_PQ_QueryParam params[] = {
     474            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     475            0 :     GNUNET_PQ_query_param_uint64 (&td->details.kycauth_in.wire_reference),
     476            0 :     TALER_PQ_query_param_amount (
     477            0 :       pg->conn,
     478              :       &td->details.reserves_in.credit),
     479            0 :     GNUNET_PQ_query_param_auto_from_type (
     480              :       &td->details.reserves_in.sender_account_h_payto),
     481            0 :     GNUNET_PQ_query_param_string (
     482            0 :       td->details.reserves_in.exchange_account_section),
     483            0 :     GNUNET_PQ_query_param_timestamp (
     484              :       &td->details.reserves_in.execution_date),
     485            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.kycauth_in.account_pub),
     486              :     GNUNET_PQ_query_param_end
     487              :   };
     488              : 
     489            0 :   PREPARE (pg,
     490              :            "insert_into_table_kycauth_in",
     491              :            "INSERT INTO kycauths_in"
     492              :            "(kycauth_in_serial_id"
     493              :            ",wire_reference"
     494              :            ",credit"
     495              :            ",wire_source_h_payto"
     496              :            ",exchange_account_section"
     497              :            ",execution_date"
     498              :            ",account_pub"
     499              :            ") VALUES "
     500              :            "($1, $2, $3, $4, $5, $6, $7);");
     501            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     502              :                                              "insert_into_table_kycauth_in",
     503              :                                              params);
     504              : }
     505              : 
     506              : 
     507              : /**
     508              :  * Function called with reserves_open_requests records to insert into table.
     509              :  *
     510              :  * @param pg plugin context
     511              :  * @param td record to insert
     512              :  */
     513              : static enum GNUNET_DB_QueryStatus
     514            0 : irbt_cb_table_reserves_open_requests (struct PostgresClosure *pg,
     515              :                                       const struct
     516              :                                       TALER_EXCHANGEDB_TableData *td)
     517              : {
     518            0 :   struct GNUNET_PQ_QueryParam params[] = {
     519            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     520            0 :     GNUNET_PQ_query_param_timestamp (
     521              :       &td->details.reserves_open_requests.expiration_date),
     522            0 :     GNUNET_PQ_query_param_auto_from_type (
     523              :       &td->details.reserves_open_requests.reserve_sig),
     524            0 :     TALER_PQ_query_param_amount (
     525            0 :       pg->conn,
     526              :       &td->details.reserves_open_requests.reserve_payment),
     527            0 :     GNUNET_PQ_query_param_uint32 (
     528              :       &td->details.reserves_open_requests.requested_purse_limit),
     529              :     GNUNET_PQ_query_param_end
     530              :   };
     531              : 
     532            0 :   PREPARE (pg,
     533              :            "insert_into_table_reserves_open_requests",
     534              :            "INSERT INTO reserves_open_requests"
     535              :            "(open_request_uuid"
     536              :            ",reserve_pub"
     537              :            ",request_timestamp"
     538              :            ",expiration_date"
     539              :            ",reserve_sig"
     540              :            ",reserve_payment"
     541              :            ",requested_purse_limit"
     542              :            ") VALUES "
     543              :            "($1, $2, $3, $4, $5, $6, $7);");
     544            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     545              :                                              "insert_into_table_reserves_open_requests",
     546              :                                              params);
     547              : }
     548              : 
     549              : 
     550              : /**
     551              :  * Function called with reserves_open_requests records to insert into table.
     552              :  *
     553              :  * @param pg plugin context
     554              :  * @param td record to insert
     555              :  */
     556              : static enum GNUNET_DB_QueryStatus
     557            0 : irbt_cb_table_reserves_open_deposits (
     558              :   struct PostgresClosure *pg,
     559              :   const struct TALER_EXCHANGEDB_TableData *td)
     560              : {
     561            0 :   struct GNUNET_PQ_QueryParam params[] = {
     562            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     563            0 :     GNUNET_PQ_query_param_auto_from_type (
     564              :       &td->details.reserves_open_deposits.coin_pub),
     565            0 :     GNUNET_PQ_query_param_auto_from_type (
     566              :       &td->details.reserves_open_deposits.coin_sig),
     567            0 :     GNUNET_PQ_query_param_auto_from_type (
     568              :       &td->details.reserves_open_deposits.reserve_sig),
     569            0 :     TALER_PQ_query_param_amount (
     570            0 :       pg->conn,
     571              :       &td->details.reserves_open_deposits.contribution),
     572              :     GNUNET_PQ_query_param_end
     573              :   };
     574              : 
     575            0 :   PREPARE (pg,
     576              :            "insert_into_table_reserves_open_deposits",
     577              :            "INSERT INTO reserves_open_deposits"
     578              :            "(reserve_open_deposit_uuid"
     579              :            ",reserve_sig"
     580              :            ",reserve_pub"
     581              :            ",coin_pub"
     582              :            ",coin_sig"
     583              :            ",contribution"
     584              :            ") VALUES "
     585              :            "($1, $2, $3, $4, $5, $6);");
     586            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     587              :                                              "insert_into_table_reserves_open_deposits",
     588              :                                              params);
     589              : }
     590              : 
     591              : 
     592              : /**
     593              :  * Function called with reserves_close records to insert into table.
     594              :  *
     595              :  * @param pg plugin context
     596              :  * @param td record to insert
     597              :  */
     598              : static enum GNUNET_DB_QueryStatus
     599            0 : irbt_cb_table_reserves_close (struct PostgresClosure *pg,
     600              :                               const struct TALER_EXCHANGEDB_TableData *td)
     601              : {
     602            0 :   struct GNUNET_PQ_QueryParam params[] = {
     603            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     604            0 :     GNUNET_PQ_query_param_timestamp (
     605              :       &td->details.reserves_close.execution_date),
     606            0 :     GNUNET_PQ_query_param_auto_from_type (
     607              :       &td->details.reserves_close.wtid),
     608            0 :     GNUNET_PQ_query_param_auto_from_type (
     609              :       &td->details.reserves_close.sender_account_h_payto),
     610            0 :     TALER_PQ_query_param_amount (
     611            0 :       pg->conn,
     612              :       &td->details.reserves_close.amount),
     613            0 :     TALER_PQ_query_param_amount (
     614            0 :       pg->conn,
     615              :       &td->details.reserves_close.closing_fee),
     616            0 :     GNUNET_PQ_query_param_auto_from_type (
     617              :       &td->details.reserves_close.reserve_pub),
     618              :     GNUNET_PQ_query_param_end
     619              :   };
     620              : 
     621            0 :   PREPARE (pg,
     622              :            "insert_into_table_reserves_close",
     623              :            "INSERT INTO reserves_close"
     624              :            "(close_uuid"
     625              :            ",execution_date"
     626              :            ",wtid"
     627              :            ",wire_target_h_payto"
     628              :            ",amount"
     629              :            ",closing_fee"
     630              :            ",reserve_pub"
     631              :            ") VALUES "
     632              :            "($1, $2, $3, $4, $5, $6, $7);");
     633            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     634              :                                              "insert_into_table_reserves_close",
     635              :                                              params);
     636              : }
     637              : 
     638              : 
     639              : /**
     640              :  * Function called with auditors records to insert into table.
     641              :  *
     642              :  * @param pg plugin context
     643              :  * @param td record to insert
     644              :  */
     645              : static enum GNUNET_DB_QueryStatus
     646            0 : irbt_cb_table_auditors (struct PostgresClosure *pg,
     647              :                         const struct TALER_EXCHANGEDB_TableData *td)
     648              : {
     649            0 :   struct GNUNET_PQ_QueryParam params[] = {
     650            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     651            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.auditors.auditor_pub),
     652            0 :     GNUNET_PQ_query_param_string (td->details.auditors.auditor_name),
     653            0 :     GNUNET_PQ_query_param_string (td->details.auditors.auditor_url),
     654            0 :     GNUNET_PQ_query_param_bool (td->details.auditors.is_active),
     655            0 :     GNUNET_PQ_query_param_timestamp (&td->details.auditors.last_change),
     656              :     GNUNET_PQ_query_param_end
     657              :   };
     658              : 
     659            0 :   PREPARE (pg,
     660              :            "insert_into_table_auditors",
     661              :            "INSERT INTO auditors"
     662              :            "(auditor_uuid"
     663              :            ",auditor_pub"
     664              :            ",auditor_name"
     665              :            ",auditor_url"
     666              :            ",is_active"
     667              :            ",last_change"
     668              :            ") VALUES "
     669              :            "($1, $2, $3, $4, $5, $6);");
     670            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     671              :                                              "insert_into_table_auditors",
     672              :                                              params);
     673              : }
     674              : 
     675              : 
     676              : /**
     677              :  * Function called with auditor_denom_sigs records to insert into table.
     678              :  *
     679              :  * @param pg plugin context
     680              :  * @param td record to insert
     681              :  */
     682              : static enum GNUNET_DB_QueryStatus
     683            0 : irbt_cb_table_auditor_denom_sigs (struct PostgresClosure *pg,
     684              :                                   const struct TALER_EXCHANGEDB_TableData *td)
     685              : {
     686            0 :   struct GNUNET_PQ_QueryParam params[] = {
     687            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     688            0 :     GNUNET_PQ_query_param_uint64 (&td->details.auditor_denom_sigs.auditor_uuid),
     689            0 :     GNUNET_PQ_query_param_uint64 (
     690              :       &td->details.auditor_denom_sigs.denominations_serial),
     691            0 :     GNUNET_PQ_query_param_auto_from_type (
     692              :       &td->details.auditor_denom_sigs.auditor_sig),
     693              :     GNUNET_PQ_query_param_end
     694              :   };
     695              : 
     696            0 :   PREPARE (pg,
     697              :            "insert_into_table_auditor_denom_sigs",
     698              :            "INSERT INTO auditor_denom_sigs"
     699              :            "(auditor_denom_serial"
     700              :            ",auditor_uuid"
     701              :            ",denominations_serial"
     702              :            ",auditor_sig"
     703              :            ") VALUES "
     704              :            "($1, $2, $3, $4);");
     705            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     706              :                                              "insert_into_table_auditor_denom_sigs",
     707              :                                              params);
     708              : }
     709              : 
     710              : 
     711              : /**
     712              :  * Function called with exchange_sign_keys records to insert into table.
     713              :  *
     714              :  * @param pg plugin context
     715              :  * @param td record to insert
     716              :  */
     717              : static enum GNUNET_DB_QueryStatus
     718            0 : irbt_cb_table_exchange_sign_keys (struct PostgresClosure *pg,
     719              :                                   const struct TALER_EXCHANGEDB_TableData *td)
     720              : {
     721            0 :   struct GNUNET_PQ_QueryParam params[] = {
     722            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     723            0 :     GNUNET_PQ_query_param_auto_from_type (
     724              :       &td->details.exchange_sign_keys.exchange_pub),
     725            0 :     GNUNET_PQ_query_param_auto_from_type (
     726              :       &td->details.exchange_sign_keys.master_sig),
     727            0 :     GNUNET_PQ_query_param_timestamp (
     728              :       &td->details.exchange_sign_keys.meta.start),
     729            0 :     GNUNET_PQ_query_param_timestamp (
     730              :       &td->details.exchange_sign_keys.meta.expire_sign),
     731            0 :     GNUNET_PQ_query_param_timestamp (
     732              :       &td->details.exchange_sign_keys.meta.expire_legal),
     733              :     GNUNET_PQ_query_param_end
     734              :   };
     735              : 
     736            0 :   PREPARE (pg,
     737              :            "insert_into_table_exchange_sign_keys",
     738              :            "INSERT INTO exchange_sign_keys"
     739              :            "(esk_serial"
     740              :            ",exchange_pub"
     741              :            ",master_sig"
     742              :            ",valid_from"
     743              :            ",expire_sign"
     744              :            ",expire_legal"
     745              :            ") VALUES "
     746              :            "($1, $2, $3, $4, $5, $6);");
     747            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     748              :                                              "insert_into_table_exchange_sign_keys",
     749              :                                              params);
     750              : }
     751              : 
     752              : 
     753              : /**
     754              :  * Function called with signkey_revocations records to insert into table.
     755              :  *
     756              :  * @param pg plugin context
     757              :  * @param td record to insert
     758              :  */
     759              : static enum GNUNET_DB_QueryStatus
     760            0 : irbt_cb_table_signkey_revocations (struct PostgresClosure *pg,
     761              :                                    const struct TALER_EXCHANGEDB_TableData *td)
     762              : {
     763            0 :   struct GNUNET_PQ_QueryParam params[] = {
     764            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     765            0 :     GNUNET_PQ_query_param_uint64 (&td->details.signkey_revocations.esk_serial),
     766            0 :     GNUNET_PQ_query_param_auto_from_type (
     767              :       &td->details.signkey_revocations.master_sig),
     768              :     GNUNET_PQ_query_param_end
     769              :   };
     770              : 
     771            0 :   PREPARE (pg,
     772              :            "insert_into_table_signkey_revocations",
     773              :            "INSERT INTO signkey_revocations"
     774              :            "(signkey_revocations_serial_id"
     775              :            ",esk_serial"
     776              :            ",master_sig"
     777              :            ") VALUES "
     778              :            "($1, $2, $3);");
     779            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     780              :                                              "insert_into_table_signkey_revocations",
     781              :                                              params);
     782              : }
     783              : 
     784              : 
     785              : /**
     786              :  * Function called with known_coins records to insert into table.
     787              :  *
     788              :  * @param pg plugin context
     789              :  * @param td record to insert
     790              :  */
     791              : static enum GNUNET_DB_QueryStatus
     792            0 : irbt_cb_table_known_coins (struct PostgresClosure *pg,
     793              :                            const struct TALER_EXCHANGEDB_TableData *td)
     794              : {
     795            0 :   struct GNUNET_PQ_QueryParam params[] = {
     796            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     797            0 :     GNUNET_PQ_query_param_auto_from_type (
     798              :       &td->details.known_coins.coin_pub),
     799            0 :     TALER_PQ_query_param_denom_sig (
     800              :       &td->details.known_coins.denom_sig),
     801            0 :     GNUNET_PQ_query_param_uint64 (
     802              :       &td->details.known_coins.denominations_serial),
     803              :     GNUNET_PQ_query_param_end
     804              :   };
     805              : 
     806            0 :   PREPARE (pg,
     807              :            "insert_into_table_known_coins",
     808              :            "INSERT INTO known_coins"
     809              :            "(known_coin_id"
     810              :            ",coin_pub"
     811              :            ",denom_sig"
     812              :            ",denominations_serial"
     813              :            ") VALUES "
     814              :            "($1, $2, $3, $4);");
     815            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     816              :                                              "insert_into_table_known_coins",
     817              :                                              params);
     818              : }
     819              : 
     820              : 
     821              : /**
     822              :  * Function called with refresh records to insert into table.
     823              :  *
     824              :  * @param pg plugin context
     825              :  * @param td record to insert
     826              :  */
     827              : static enum GNUNET_DB_QueryStatus
     828            0 : irbt_cb_table_refresh (struct PostgresClosure *pg,
     829              :                        const struct TALER_EXCHANGEDB_TableData *td)
     830              : {
     831            0 :   struct GNUNET_PQ_QueryParam params[] = {
     832            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     833            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.refresh.rc),
     834            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.refresh.execution_date),
     835            0 :     TALER_PQ_query_param_amount (
     836            0 :       pg->conn,
     837              :       &td->details.refresh.amount_with_fee),
     838            0 :     GNUNET_PQ_query_param_auto_from_type (
     839              :       &td->details.refresh.old_coin_pub),
     840            0 :     GNUNET_PQ_query_param_auto_from_type (
     841              :       &td->details.refresh.old_coin_sig),
     842            0 :     GNUNET_PQ_query_param_auto_from_type (
     843              :       &td->details.refresh.refresh_seed),
     844            0 :     GNUNET_PQ_query_param_uint32 (
     845              :       &td->details.refresh.noreveal_index),
     846            0 :     GNUNET_PQ_query_param_auto_from_type (
     847              :       &td->details.refresh.planchets_h),
     848            0 :     GNUNET_PQ_query_param_auto_from_type (
     849              :       &td->details.refresh.selected_h),
     850            0 :     td->details.refresh.no_blinding_seed
     851            0 :        ? GNUNET_PQ_query_param_null ()
     852            0 :        : GNUNET_PQ_query_param_auto_from_type (
     853              :       &td->details.refresh.blinding_seed),
     854            0 :     td->details.refresh.no_blinding_seed
     855            0 :        ? GNUNET_PQ_query_param_null ()
     856            0 :        : TALER_PQ_query_param_array_cs_r_pub (
     857            0 :       td->details.refresh.num_cs_r_values,
     858            0 :       td->details.refresh.cs_r_values,
     859              :       pg->conn),
     860            0 :     td->details.refresh.no_blinding_seed
     861            0 :        ? GNUNET_PQ_query_param_null ()
     862            0 :        : GNUNET_PQ_query_param_uint64 (
     863              :       &td->details.refresh.cs_r_choices),
     864            0 :     GNUNET_PQ_query_param_array_uint64 (
     865            0 :       td->details.refresh.num_coins,
     866            0 :       td->details.refresh.denom_serials,
     867              :       pg->conn),
     868            0 :     TALER_PQ_query_param_array_blinded_denom_sig (
     869            0 :       td->details.refresh.num_coins,
     870            0 :       td->details.refresh.denom_sigs,
     871              :       pg->conn),
     872              :     GNUNET_PQ_query_param_end
     873              :   };
     874              : 
     875            0 :   PREPARE (pg,
     876              :            "insert_into_table_refresh",
     877              :            "INSERT INTO refresh"
     878              :            "(refresh_id"
     879              :            ",rc"
     880              :            ",execution_date"
     881              :            ",amount_with_fee"
     882              :            ",old_coin_pub"
     883              :            ",old_coin_sig"
     884              :            ",refresh_seed"
     885              :            ",noreveal_index"
     886              :            ",planchets_h"
     887              :            ",selected_h"
     888              :            ",blinding_seed"
     889              :            ",cs_r_values"
     890              :            ",cs_r_choices"
     891              :            ",denom_serials"
     892              :            ",denom_sigs"
     893              :            ") VALUES "
     894              :            "($1, $2, $3, $4, $5, $6,$7,$8,$9,$10,$11,$12,$13,$14,$15);");
     895            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     896              :                                              "insert_into_table_refresh",
     897              :                                              params);
     898              : }
     899              : 
     900              : 
     901              : /**
     902              :  * Function called with batch deposits records to insert into table.
     903              :  *
     904              :  * @param pg plugin context
     905              :  * @param td record to insert
     906              :  */
     907              : static enum GNUNET_DB_QueryStatus
     908            0 : irbt_cb_table_batch_deposits (struct PostgresClosure *pg,
     909              :                               const struct TALER_EXCHANGEDB_TableData *td)
     910              : {
     911            0 :   struct GNUNET_PQ_QueryParam params[] = {
     912            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     913            0 :     GNUNET_PQ_query_param_uint64 (&td->details.batch_deposits.shard),
     914            0 :     GNUNET_PQ_query_param_auto_from_type (
     915              :       &td->details.batch_deposits.merchant_pub),
     916            0 :     GNUNET_PQ_query_param_timestamp (
     917              :       &td->details.batch_deposits.wallet_timestamp),
     918            0 :     GNUNET_PQ_query_param_timestamp (
     919              :       &td->details.batch_deposits.exchange_timestamp),
     920            0 :     GNUNET_PQ_query_param_timestamp (
     921              :       &td->details.batch_deposits.refund_deadline),
     922            0 :     GNUNET_PQ_query_param_timestamp (&td->details.batch_deposits.wire_deadline),
     923            0 :     GNUNET_PQ_query_param_auto_from_type (
     924              :       &td->details.batch_deposits.h_contract_terms),
     925            0 :     td->details.batch_deposits.no_wallet_data_hash
     926            0 :     ? GNUNET_PQ_query_param_null ()
     927            0 :     : GNUNET_PQ_query_param_auto_from_type (
     928              :       &td->details.batch_deposits.wallet_data_hash),
     929            0 :     GNUNET_PQ_query_param_auto_from_type (
     930              :       &td->details.batch_deposits.wire_salt),
     931            0 :     GNUNET_PQ_query_param_auto_from_type (
     932              :       &td->details.batch_deposits.wire_target_h_payto),
     933            0 :     td->details.batch_deposits.no_policy_details
     934            0 :     ? GNUNET_PQ_query_param_null ()
     935            0 :     : GNUNET_PQ_query_param_uint64 (
     936              :       &td->details.batch_deposits.policy_details_serial_id),
     937            0 :     GNUNET_PQ_query_param_bool (td->details.batch_deposits.policy_blocked),
     938            0 :     TALER_PQ_query_param_amount (
     939            0 :       pg->conn,
     940              :       &td->details.batch_deposits.total_amount),
     941            0 :     GNUNET_PQ_query_param_auto_from_type (
     942              :       &td->details.batch_deposits.merchant_sig),
     943            0 :     GNUNET_PQ_query_param_bool (td->details.batch_deposits.done),
     944              :     GNUNET_PQ_query_param_end
     945              :   };
     946              : 
     947            0 :   PREPARE (pg,
     948              :            "insert_into_table_batch_deposits",
     949              :            "INSERT INTO batch_deposits"
     950              :            "(batch_deposit_serial_id"
     951              :            ",shard"
     952              :            ",merchant_pub"
     953              :            ",wallet_timestamp"
     954              :            ",exchange_timestamp"
     955              :            ",refund_deadline"
     956              :            ",wire_deadline"
     957              :            ",h_contract_terms"
     958              :            ",wallet_data_hash"
     959              :            ",wire_salt"
     960              :            ",wire_target_h_payto"
     961              :            ",policy_details_serial_id"
     962              :            ",policy_blocked"
     963              :            ",total_amount"
     964              :            ",merchant_sig"
     965              :            ",done"
     966              :            ") VALUES "
     967              :            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10,"
     968              :            " $11, $12, $13, $14, $15, $16);");
     969            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     970              :                                              "insert_into_table_batch_deposits",
     971              :                                              params);
     972              : }
     973              : 
     974              : 
     975              : /**
     976              :  * Function called with deposits records to insert into table.
     977              :  *
     978              :  * @param pg plugin context
     979              :  * @param td record to insert
     980              :  */
     981              : static enum GNUNET_DB_QueryStatus
     982            0 : irbt_cb_table_coin_deposits (struct PostgresClosure *pg,
     983              :                              const struct TALER_EXCHANGEDB_TableData *td)
     984              : {
     985            0 :   struct GNUNET_PQ_QueryParam params[] = {
     986            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     987            0 :     GNUNET_PQ_query_param_uint64 (
     988              :       &td->details.coin_deposits.batch_deposit_serial_id),
     989            0 :     GNUNET_PQ_query_param_auto_from_type (
     990              :       &td->details.coin_deposits.coin_pub),
     991            0 :     GNUNET_PQ_query_param_auto_from_type (
     992              :       &td->details.coin_deposits.coin_sig),
     993            0 :     TALER_PQ_query_param_amount (
     994            0 :       pg->conn,
     995              :       &td->details.coin_deposits.amount_with_fee),
     996              :     GNUNET_PQ_query_param_end
     997              :   };
     998              : 
     999            0 :   PREPARE (pg,
    1000              :            "insert_into_table_coin_deposits",
    1001              :            "INSERT INTO coin_deposits"
    1002              :            "(coin_deposit_serial_id"
    1003              :            ",batch_deposit_serial_id"
    1004              :            ",coin_pub"
    1005              :            ",coin_sig"
    1006              :            ",amount_with_fee"
    1007              :            ") VALUES "
    1008              :            "($1, $2, $3, $4, $5);");
    1009            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1010              :                                              "insert_into_table_coin_deposits",
    1011              :                                              params);
    1012              : }
    1013              : 
    1014              : 
    1015              : /**
    1016              :  * Function called with refunds records to insert into table.
    1017              :  *
    1018              :  * @param pg plugin context
    1019              :  * @param td record to insert
    1020              :  */
    1021              : static enum GNUNET_DB_QueryStatus
    1022            0 : irbt_cb_table_refunds (struct PostgresClosure *pg,
    1023              :                        const struct TALER_EXCHANGEDB_TableData *td)
    1024              : {
    1025            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1026            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1027            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.refunds.coin_pub),
    1028            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.refunds.merchant_sig),
    1029            0 :     GNUNET_PQ_query_param_uint64 (&td->details.refunds.rtransaction_id),
    1030            0 :     TALER_PQ_query_param_amount (
    1031            0 :       pg->conn,
    1032              :       &td->details.refunds.amount_with_fee),
    1033            0 :     GNUNET_PQ_query_param_uint64 (
    1034              :       &td->details.refunds.batch_deposit_serial_id),
    1035              :     GNUNET_PQ_query_param_end
    1036              :   };
    1037              : 
    1038            0 :   PREPARE (pg,
    1039              :            "insert_into_table_refunds",
    1040              :            "INSERT INTO refunds"
    1041              :            "(refund_serial_id"
    1042              :            ",coin_pub"
    1043              :            ",merchant_sig"
    1044              :            ",rtransaction_id"
    1045              :            ",amount_with_fee"
    1046              :            ",batch_deposit_serial_id"
    1047              :            ") VALUES "
    1048              :            "($1, $2, $3, $4, $5, $6);");
    1049            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1050              :                                              "insert_into_table_refunds",
    1051              :                                              params);
    1052              : }
    1053              : 
    1054              : 
    1055              : /**
    1056              :  * Function called with wire_out records to insert into table.
    1057              :  *
    1058              :  * @param pg plugin context
    1059              :  * @param td record to insert
    1060              :  */
    1061              : static enum GNUNET_DB_QueryStatus
    1062            0 : irbt_cb_table_wire_out (struct PostgresClosure *pg,
    1063              :                         const struct TALER_EXCHANGEDB_TableData *td)
    1064              : {
    1065            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1066            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1067            0 :     GNUNET_PQ_query_param_timestamp (&td->details.wire_out.execution_date),
    1068            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.wire_out.wtid_raw),
    1069            0 :     GNUNET_PQ_query_param_auto_from_type (
    1070              :       &td->details.wire_out.wire_target_h_payto),
    1071            0 :     GNUNET_PQ_query_param_string (
    1072            0 :       td->details.wire_out.exchange_account_section),
    1073            0 :     TALER_PQ_query_param_amount (
    1074            0 :       pg->conn,
    1075              :       &td->details.wire_out.amount),
    1076              :     GNUNET_PQ_query_param_end
    1077              :   };
    1078              : 
    1079            0 :   PREPARE (pg,
    1080              :            "insert_into_table_wire_out",
    1081              :            "INSERT INTO wire_out"
    1082              :            "(wireout_uuid"
    1083              :            ",execution_date"
    1084              :            ",wtid_raw"
    1085              :            ",wire_target_h_payto"
    1086              :            ",exchange_account_section"
    1087              :            ",amount"
    1088              :            ") VALUES "
    1089              :            "($1, $2, $3, $4, $5, $6);");
    1090            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1091              :                                              "insert_into_table_wire_out",
    1092              :                                              params);
    1093              : }
    1094              : 
    1095              : 
    1096              : /**
    1097              :  * Function called with aggregation_tracking records to insert into table.
    1098              :  *
    1099              :  * @param pg plugin context
    1100              :  * @param td record to insert
    1101              :  */
    1102              : static enum GNUNET_DB_QueryStatus
    1103            0 : irbt_cb_table_aggregation_tracking (struct PostgresClosure *pg,
    1104              :                                     const struct TALER_EXCHANGEDB_TableData *td)
    1105              : {
    1106            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1107            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1108            0 :     GNUNET_PQ_query_param_uint64 (
    1109              :       &td->details.aggregation_tracking.batch_deposit_serial_id),
    1110            0 :     GNUNET_PQ_query_param_auto_from_type (
    1111              :       &td->details.aggregation_tracking.wtid_raw),
    1112              :     GNUNET_PQ_query_param_end
    1113              :   };
    1114              : 
    1115            0 :   PREPARE (pg,
    1116              :            "insert_into_table_aggregation_tracking",
    1117              :            "INSERT INTO aggregation_tracking"
    1118              :            "(aggregation_serial_id"
    1119              :            ",batch_deposit_serial_id"
    1120              :            ",wtid_raw"
    1121              :            ") VALUES "
    1122              :            "($1, $2, $3);");
    1123            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1124              :                                              "insert_into_table_aggregation_tracking",
    1125              :                                              params);
    1126              : }
    1127              : 
    1128              : 
    1129              : /**
    1130              :  * Function called with wire_fee records to insert into table.
    1131              :  *
    1132              :  * @param pg plugin context
    1133              :  * @param td record to insert
    1134              :  */
    1135              : static enum GNUNET_DB_QueryStatus
    1136            0 : irbt_cb_table_wire_fee (struct PostgresClosure *pg,
    1137              :                         const struct TALER_EXCHANGEDB_TableData *td)
    1138              : {
    1139            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1140            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1141            0 :     GNUNET_PQ_query_param_string (td->details.wire_fee.wire_method),
    1142            0 :     GNUNET_PQ_query_param_timestamp (&td->details.wire_fee.start_date),
    1143            0 :     GNUNET_PQ_query_param_timestamp (&td->details.wire_fee.end_date),
    1144            0 :     TALER_PQ_query_param_amount (
    1145            0 :       pg->conn,
    1146              :       &td->details.wire_fee.fees.wire),
    1147            0 :     TALER_PQ_query_param_amount (
    1148            0 :       pg->conn,
    1149              :       &td->details.wire_fee.fees.closing),
    1150            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.wire_fee.master_sig),
    1151              :     GNUNET_PQ_query_param_end
    1152              :   };
    1153              : 
    1154            0 :   PREPARE (pg,
    1155              :            "insert_into_table_wire_fee",
    1156              :            "INSERT INTO wire_fee"
    1157              :            "(wire_fee_serial"
    1158              :            ",wire_method"
    1159              :            ",start_date"
    1160              :            ",end_date"
    1161              :            ",wire_fee"
    1162              :            ",closing_fee"
    1163              :            ",master_sig"
    1164              :            ") VALUES "
    1165              :            "($1, $2, $3, $4, $5, $6, $7);");
    1166            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1167              :                                              "insert_into_table_wire_fee",
    1168              :                                              params);
    1169              : }
    1170              : 
    1171              : 
    1172              : /**
    1173              :  * Function called with wire_fee records to insert into table.
    1174              :  *
    1175              :  * @param pg plugin context
    1176              :  * @param td record to insert
    1177              :  */
    1178              : static enum GNUNET_DB_QueryStatus
    1179            0 : irbt_cb_table_global_fee (struct PostgresClosure *pg,
    1180              :                           const struct TALER_EXCHANGEDB_TableData *td)
    1181              : {
    1182            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1183            0 :     GNUNET_PQ_query_param_uint64 (
    1184              :       &td->serial),
    1185            0 :     GNUNET_PQ_query_param_timestamp (
    1186              :       &td->details.global_fee.start_date),
    1187            0 :     GNUNET_PQ_query_param_timestamp (
    1188              :       &td->details.global_fee.end_date),
    1189            0 :     TALER_PQ_query_param_amount (
    1190            0 :       pg->conn,
    1191              :       &td->details.global_fee.fees.history),
    1192            0 :     TALER_PQ_query_param_amount (
    1193            0 :       pg->conn,
    1194              :       &td->details.global_fee.fees.account),
    1195            0 :     TALER_PQ_query_param_amount (
    1196            0 :       pg->conn,
    1197              :       &td->details.global_fee.fees.purse),
    1198            0 :     GNUNET_PQ_query_param_relative_time (
    1199              :       &td->details.global_fee.purse_timeout),
    1200            0 :     GNUNET_PQ_query_param_relative_time (
    1201              :       &td->details.global_fee.history_expiration),
    1202            0 :     GNUNET_PQ_query_param_uint32 (
    1203              :       &td->details.global_fee.purse_account_limit),
    1204            0 :     GNUNET_PQ_query_param_auto_from_type (
    1205              :       &td->details.global_fee.master_sig),
    1206              :     GNUNET_PQ_query_param_end
    1207              :   };
    1208              : 
    1209            0 :   PREPARE (pg,
    1210              :            "insert_into_table_global_fee",
    1211              :            "INSERT INTO global_fee"
    1212              :            "(global_fee_serial"
    1213              :            ",start_date"
    1214              :            ",end_date"
    1215              :            ",history_fee"
    1216              :            ",account_fee"
    1217              :            ",purse_fee"
    1218              :            ",purse_timeout"
    1219              :            ",history_expiration"
    1220              :            ",purse_account_limit"
    1221              :            ",master_sig"
    1222              :            ") VALUES "
    1223              :            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10);");
    1224            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1225              :                                              "insert_into_table_global_fee",
    1226              :                                              params);
    1227              : }
    1228              : 
    1229              : 
    1230              : /**
    1231              :  * Function called with recoup records to insert into table.
    1232              :  *
    1233              :  * @param pg plugin context
    1234              :  * @param td record to insert
    1235              :  */
    1236              : static enum GNUNET_DB_QueryStatus
    1237            0 : irbt_cb_table_recoup (struct PostgresClosure *pg,
    1238              :                       const struct TALER_EXCHANGEDB_TableData *td)
    1239              : {
    1240            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1241            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1242            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.recoup.coin_sig),
    1243            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.recoup.coin_blind),
    1244            0 :     TALER_PQ_query_param_amount (
    1245            0 :       pg->conn,
    1246              :       &td->details.recoup.amount),
    1247            0 :     GNUNET_PQ_query_param_timestamp (&td->details.recoup.timestamp),
    1248            0 :     GNUNET_PQ_query_param_auto_from_type (
    1249              :       &td->details.recoup.coin_pub),
    1250            0 :     GNUNET_PQ_query_param_uint64 (&td->details.recoup.withdraw_serial_id),
    1251              :     GNUNET_PQ_query_param_end
    1252              :   };
    1253              : 
    1254            0 :   PREPARE (pg,
    1255              :            "insert_into_table_recoup",
    1256              :            "INSERT INTO recoup"
    1257              :            "(recoup_uuid"
    1258              :            ",coin_sig"
    1259              :            ",coin_blind"
    1260              :            ",amount"
    1261              :            ",recoup_timestamp"
    1262              :            ",coin_pub"
    1263              :            ",withdraw_serial_id"
    1264              :            ") VALUES "
    1265              :            "($1, $2, $3, $4, $5, $6, $7);");
    1266            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1267              :                                              "insert_into_table_recoup",
    1268              :                                              params);
    1269              : }
    1270              : 
    1271              : 
    1272              : /**
    1273              :  * Function called with recoup_refresh records to insert into table.
    1274              :  *
    1275              :  * @param pg plugin context
    1276              :  * @param td record to insert
    1277              :  */
    1278              : static enum GNUNET_DB_QueryStatus
    1279            0 : irbt_cb_table_recoup_refresh (struct PostgresClosure *pg,
    1280              :                               const struct TALER_EXCHANGEDB_TableData *td)
    1281              : {
    1282            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1283            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1284            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.recoup_refresh.coin_sig),
    1285            0 :     GNUNET_PQ_query_param_auto_from_type (
    1286              :       &td->details.recoup_refresh.coin_blind),
    1287            0 :     TALER_PQ_query_param_amount (
    1288            0 :       pg->conn,
    1289              :       &td->details.recoup_refresh.amount),
    1290            0 :     GNUNET_PQ_query_param_timestamp (&td->details.recoup_refresh.timestamp),
    1291            0 :     GNUNET_PQ_query_param_uint64 (&td->details.recoup_refresh.known_coin_id),
    1292            0 :     GNUNET_PQ_query_param_auto_from_type (
    1293              :       &td->details.recoup.coin_pub),
    1294            0 :     GNUNET_PQ_query_param_uint64 (&td->details.recoup_refresh.rrc_serial),
    1295              :     GNUNET_PQ_query_param_end
    1296              :   };
    1297              : 
    1298            0 :   PREPARE (pg,
    1299              :            "insert_into_table_recoup_refresh",
    1300              :            "INSERT INTO recoup_refresh"
    1301              :            "(recoup_refresh_uuid"
    1302              :            ",coin_sig"
    1303              :            ",coin_blind"
    1304              :            ",amount"
    1305              :            ",recoup_timestamp"
    1306              :            ",known_coin_id"
    1307              :            ",coin_pub"
    1308              :            ",rrc_serial"
    1309              :            ") VALUES "
    1310              :            "($1, $2, $3, $4, $5, $6, $7, $8);");
    1311            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1312              :                                              "insert_into_table_recoup_refresh",
    1313              :                                              params);
    1314              : }
    1315              : 
    1316              : 
    1317              : /**
    1318              :  * Function called with extensions records to insert into table.
    1319              :  *
    1320              :  * @param pg plugin context
    1321              :  * @param td record to insert
    1322              :  */
    1323              : static enum GNUNET_DB_QueryStatus
    1324            0 : irbt_cb_table_extensions (struct PostgresClosure *pg,
    1325              :                           const struct TALER_EXCHANGEDB_TableData *td)
    1326              : {
    1327            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1328            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1329            0 :     GNUNET_PQ_query_param_string (td->details.extensions.name),
    1330            0 :     NULL == td->details.extensions.manifest ?
    1331            0 :     GNUNET_PQ_query_param_null () :
    1332            0 :     GNUNET_PQ_query_param_string (td->details.extensions.manifest),
    1333              :     GNUNET_PQ_query_param_end
    1334              :   };
    1335              : 
    1336            0 :   PREPARE (pg,
    1337              :            "insert_into_table_extensions",
    1338              :            "INSERT INTO extensions"
    1339              :            "(extension_id"
    1340              :            ",name"
    1341              :            ",manifest"
    1342              :            ") VALUES "
    1343              :            "($1, $2, $3);");
    1344            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1345              :                                              "insert_into_table_extensions",
    1346              :                                              params);
    1347              : }
    1348              : 
    1349              : 
    1350              : /**
    1351              :  * Function called with policy_details records to insert into table.
    1352              :  *
    1353              :  * @param pg plugin context
    1354              :  * @param td record to insert
    1355              :  */
    1356              : static enum GNUNET_DB_QueryStatus
    1357            0 : irbt_cb_table_policy_details (struct PostgresClosure *pg,
    1358              :                               const struct TALER_EXCHANGEDB_TableData *td)
    1359              : {
    1360            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1361            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1362            0 :     GNUNET_PQ_query_param_auto_from_type (
    1363              :       &td->details.policy_details.hash_code),
    1364            0 :     (td->details.policy_details.no_policy_json)
    1365            0 :       ? GNUNET_PQ_query_param_null ()
    1366            0 :       : TALER_PQ_query_param_json (td->details.policy_details.policy_json),
    1367            0 :     TALER_PQ_query_param_amount (
    1368            0 :       pg->conn,
    1369              :       &td->details.policy_details.commitment),
    1370            0 :     TALER_PQ_query_param_amount (
    1371            0 :       pg->conn,
    1372              :       &td->details.policy_details.accumulated_total),
    1373            0 :     TALER_PQ_query_param_amount (
    1374            0 :       pg->conn,
    1375              :       &td->details.policy_details.fee),
    1376            0 :     TALER_PQ_query_param_amount (pg->conn,
    1377              :                                  &td->details.policy_details.transferable),
    1378            0 :     GNUNET_PQ_query_param_timestamp (&td->details.policy_details.deadline),
    1379            0 :     GNUNET_PQ_query_param_uint16 (
    1380              :       &td->details.policy_details.fulfillment_state),
    1381            0 :     (td->details.policy_details.no_fulfillment_id)
    1382            0 :       ? GNUNET_PQ_query_param_null ()
    1383            0 :       : GNUNET_PQ_query_param_uint64 (
    1384              :       &td->details.policy_details.fulfillment_id),
    1385              :     GNUNET_PQ_query_param_end
    1386              :   };
    1387              : 
    1388            0 :   PREPARE (pg,
    1389              :            "insert_into_table_policy_details",
    1390              :            "INSERT INTO policy_details"
    1391              :            "(policy_details_serial_id"
    1392              :            ",policy_hash_code"
    1393              :            ",policy_json"
    1394              :            ",deadline"
    1395              :            ",commitment"
    1396              :            ",accumulated_total"
    1397              :            ",fee"
    1398              :            ",transferable"
    1399              :            ",fulfillment_state"
    1400              :            ",fulfillment_id"
    1401              :            ") VALUES "
    1402              :            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10);");
    1403            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1404              :                                              "insert_into_table_policy_details",
    1405              :                                              params);
    1406              : }
    1407              : 
    1408              : 
    1409              : /**
    1410              :  * Function called with policy_fulfillment records to insert into table.
    1411              :  *
    1412              :  * @param pg plugin context
    1413              :  * @param td record to insert
    1414              :  */
    1415              : static enum GNUNET_DB_QueryStatus
    1416            0 : irbt_cb_table_policy_fulfillments (struct PostgresClosure *pg,
    1417              :                                    const struct TALER_EXCHANGEDB_TableData *td)
    1418              : {
    1419            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1420            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1421            0 :     GNUNET_PQ_query_param_timestamp (
    1422              :       &td->details.policy_fulfillments.fulfillment_timestamp),
    1423            0 :     (NULL == td->details.policy_fulfillments.fulfillment_proof)
    1424            0 :       ? GNUNET_PQ_query_param_null ()
    1425            0 :       : GNUNET_PQ_query_param_string (
    1426            0 :       td->details.policy_fulfillments.fulfillment_proof),
    1427            0 :     GNUNET_PQ_query_param_auto_from_type (
    1428              :       &td->details.policy_fulfillments.h_fulfillment_proof),
    1429            0 :     GNUNET_PQ_query_param_fixed_size (
    1430            0 :       td->details.policy_fulfillments.policy_hash_codes,
    1431            0 :       td->details.policy_fulfillments.policy_hash_codes_count),
    1432              :     GNUNET_PQ_query_param_end
    1433              :   };
    1434              : 
    1435            0 :   PREPARE (pg,
    1436              :            "insert_into_table_policy_fulfillments",
    1437              :            "INSERT INTO policy_fulfillments "
    1438              :            "(fulfillment_id"
    1439              :            ",fulfillment_timestamp"
    1440              :            ",fulfillment_proof"
    1441              :            ",h_fulfillment_proof"
    1442              :            ",policy_hash_codes"
    1443              :            ") VALUES "
    1444              :            "($1, $2, $3::TEXT::JSONB, $4, $5);");
    1445            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1446              :                                              "insert_into_table_policy_fulfillments",
    1447              :                                              params);
    1448              : }
    1449              : 
    1450              : 
    1451              : /**
    1452              :  * Function called with purse_requests records to insert into table.
    1453              :  *
    1454              :  * @param pg plugin context
    1455              :  * @param td record to insert
    1456              :  */
    1457              : static enum GNUNET_DB_QueryStatus
    1458            0 : irbt_cb_table_purse_requests (struct PostgresClosure *pg,
    1459              :                               const struct TALER_EXCHANGEDB_TableData *td)
    1460              : {
    1461            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1462            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1463            0 :     GNUNET_PQ_query_param_auto_from_type (
    1464              :       &td->details.purse_requests.purse_pub),
    1465            0 :     GNUNET_PQ_query_param_auto_from_type (
    1466              :       &td->details.purse_requests.merge_pub),
    1467            0 :     GNUNET_PQ_query_param_timestamp (
    1468              :       &td->details.purse_requests.purse_creation),
    1469            0 :     GNUNET_PQ_query_param_timestamp (
    1470              :       &td->details.purse_requests.purse_expiration),
    1471            0 :     GNUNET_PQ_query_param_auto_from_type (
    1472              :       &td->details.purse_requests.h_contract_terms),
    1473            0 :     GNUNET_PQ_query_param_uint32 (&td->details.purse_requests.age_limit),
    1474            0 :     GNUNET_PQ_query_param_uint32 (&td->details.purse_requests.flags),
    1475            0 :     TALER_PQ_query_param_amount (
    1476            0 :       pg->conn,
    1477              :       &td->details.purse_requests.amount_with_fee),
    1478            0 :     TALER_PQ_query_param_amount (
    1479            0 :       pg->conn,
    1480              :       &td->details.purse_requests.purse_fee),
    1481            0 :     GNUNET_PQ_query_param_auto_from_type (
    1482              :       &td->details.purse_requests.purse_sig),
    1483              :     GNUNET_PQ_query_param_end
    1484              :   };
    1485              : 
    1486            0 :   PREPARE (pg,
    1487              :            "insert_into_table_purse_requests",
    1488              :            "INSERT INTO purse_requests"
    1489              :            "(purse_requests_serial_id"
    1490              :            ",purse_pub"
    1491              :            ",merge_pub"
    1492              :            ",purse_creation"
    1493              :            ",purse_expiration"
    1494              :            ",h_contract_terms"
    1495              :            ",age_limit"
    1496              :            ",flags"
    1497              :            ",amount_with_fee"
    1498              :            ",purse_fee"
    1499              :            ",purse_sig"
    1500              :            ") VALUES "
    1501              :            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11);");
    1502            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1503              :                                              "insert_into_table_purse_requests",
    1504              :                                              params);
    1505              : }
    1506              : 
    1507              : 
    1508              : /**
    1509              :  * Function called with purse_decision records to insert into table.
    1510              :  *
    1511              :  * @param pg plugin context
    1512              :  * @param td record to insert
    1513              :  */
    1514              : static enum GNUNET_DB_QueryStatus
    1515            0 : irbt_cb_table_purse_decision (struct PostgresClosure *pg,
    1516              :                               const struct TALER_EXCHANGEDB_TableData *td)
    1517              : {
    1518            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1519            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1520            0 :     GNUNET_PQ_query_param_auto_from_type (
    1521              :       &td->details.purse_decision.purse_pub),
    1522            0 :     GNUNET_PQ_query_param_timestamp (
    1523              :       &td->details.purse_decision.action_timestamp),
    1524            0 :     GNUNET_PQ_query_param_bool (
    1525            0 :       td->details.purse_decision.refunded),
    1526              :     GNUNET_PQ_query_param_end
    1527              :   };
    1528              : 
    1529            0 :   PREPARE (pg,
    1530              :            "insert_into_table_purse_refunds",
    1531              :            "INSERT INTO purse_refunds"
    1532              :            "(purse_refunds_serial_id"
    1533              :            ",purse_pub"
    1534              :            ",action_timestamp"
    1535              :            ",refunded"
    1536              :            ") VALUES "
    1537              :            "($1, $2, $3, $4);");
    1538            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1539              :                                              "insert_into_table_purse_decision",
    1540              :                                              params);
    1541              : }
    1542              : 
    1543              : 
    1544              : /**
    1545              :  * Function called with purse_merges records to insert into table.
    1546              :  *
    1547              :  * @param pg plugin context
    1548              :  * @param td record to insert
    1549              :  */
    1550              : static enum GNUNET_DB_QueryStatus
    1551            0 : irbt_cb_table_purse_merges (struct PostgresClosure *pg,
    1552              :                             const struct TALER_EXCHANGEDB_TableData *td)
    1553              : {
    1554            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1555            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1556            0 :     GNUNET_PQ_query_param_uint64 (&td->details.purse_merges.partner_serial_id),
    1557            0 :     GNUNET_PQ_query_param_auto_from_type (
    1558              :       &td->details.purse_merges.reserve_pub),
    1559            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.purse_merges.purse_pub),
    1560            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.purse_merges.merge_sig),
    1561            0 :     GNUNET_PQ_query_param_timestamp (&td->details.purse_merges.merge_timestamp),
    1562              :     GNUNET_PQ_query_param_end
    1563              :   };
    1564              : 
    1565            0 :   PREPARE (pg,
    1566              :            "insert_into_table_purse_merges",
    1567              :            "INSERT INTO purse_merges"
    1568              :            "(purse_merge_request_serial_id"
    1569              :            ",partner_serial_id"
    1570              :            ",reserve_pub"
    1571              :            ",purse_pub"
    1572              :            ",merge_sig"
    1573              :            ",merge_timestamp"
    1574              :            ") VALUES "
    1575              :            "($1, $2, $3, $4, $5, $6);");
    1576            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1577              :                                              "insert_into_table_purse_merges",
    1578              :                                              params);
    1579              : }
    1580              : 
    1581              : 
    1582              : /**
    1583              :  * Function called with purse_deposits records to insert into table.
    1584              :  *
    1585              :  * @param pg plugin context
    1586              :  * @param td record to insert
    1587              :  */
    1588              : static enum GNUNET_DB_QueryStatus
    1589            0 : irbt_cb_table_purse_deposits (struct PostgresClosure *pg,
    1590              :                               const struct TALER_EXCHANGEDB_TableData *td)
    1591              : {
    1592            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1593            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1594            0 :     GNUNET_PQ_query_param_uint64 (
    1595              :       &td->details.purse_deposits.partner_serial_id),
    1596            0 :     GNUNET_PQ_query_param_auto_from_type (
    1597              :       &td->details.purse_deposits.purse_pub),
    1598            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.purse_deposits.coin_pub),
    1599            0 :     TALER_PQ_query_param_amount (
    1600            0 :       pg->conn,
    1601              :       &td->details.purse_deposits.amount_with_fee),
    1602            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.purse_deposits.coin_sig),
    1603              :     GNUNET_PQ_query_param_end
    1604              :   };
    1605              : 
    1606            0 :   PREPARE (pg,
    1607              :            "insert_into_table_purse_deposits",
    1608              :            "INSERT INTO purse_deposits"
    1609              :            "(purse_deposit_serial_id"
    1610              :            ",partner_serial_id"
    1611              :            ",purse_pub"
    1612              :            ",coin_pub"
    1613              :            ",amount_with_fee"
    1614              :            ",coin_sig"
    1615              :            ") VALUES "
    1616              :            "($1, $2, $3, $4, $5, $6);");
    1617            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1618              :                                              "insert_into_table_purse_deposits",
    1619              :                                              params);
    1620              : }
    1621              : 
    1622              : 
    1623              : /**
    1624              : x * Function called with account_mergers records to insert into table.
    1625              :  *
    1626              :  * @param pg plugin context
    1627              :  * @param td record to insert
    1628              :  */
    1629              : static enum GNUNET_DB_QueryStatus
    1630            0 : irbt_cb_table_account_mergers (struct PostgresClosure *pg,
    1631              :                                const struct TALER_EXCHANGEDB_TableData *td)
    1632              : {
    1633            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1634            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1635            0 :     GNUNET_PQ_query_param_auto_from_type (
    1636              :       &td->details.account_merges.reserve_pub),
    1637            0 :     GNUNET_PQ_query_param_auto_from_type (
    1638              :       &td->details.account_merges.reserve_sig),
    1639            0 :     GNUNET_PQ_query_param_auto_from_type (
    1640              :       &td->details.account_merges.purse_pub),
    1641            0 :     GNUNET_PQ_query_param_auto_from_type (
    1642              :       &td->details.account_merges.wallet_h_payto),
    1643              :     GNUNET_PQ_query_param_end
    1644              :   };
    1645              : 
    1646            0 :   PREPARE (pg,
    1647              :            "insert_into_table_account_merges",
    1648              :            "INSERT INTO account_merges"
    1649              :            "(account_merge_request_serial_id"
    1650              :            ",reserve_pub"
    1651              :            ",reserve_sig"
    1652              :            ",purse_pub"
    1653              :            ",wallet_h_payto"
    1654              :            ") VALUES "
    1655              :            "($1, $2, $3, $4, $5);");
    1656            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1657              :                                              "insert_into_table_account_merges",
    1658              :                                              params);
    1659              : }
    1660              : 
    1661              : 
    1662              : /**
    1663              :  * Function called with history_requests records to insert into table.
    1664              :  *
    1665              :  * @param pg plugin context
    1666              :  * @param td record to insert
    1667              :  */
    1668              : static enum GNUNET_DB_QueryStatus
    1669            0 : irbt_cb_table_history_requests (struct PostgresClosure *pg,
    1670              :                                 const struct TALER_EXCHANGEDB_TableData *td)
    1671              : {
    1672            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1673            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1674            0 :     GNUNET_PQ_query_param_auto_from_type (
    1675              :       &td->details.history_requests.reserve_pub),
    1676            0 :     GNUNET_PQ_query_param_timestamp (
    1677              :       &td->details.history_requests.request_timestamp),
    1678            0 :     GNUNET_PQ_query_param_auto_from_type (
    1679              :       &td->details.history_requests.reserve_sig),
    1680            0 :     TALER_PQ_query_param_amount (
    1681            0 :       pg->conn,
    1682              :       &td->details.history_requests.history_fee),
    1683              :     GNUNET_PQ_query_param_end
    1684              :   };
    1685              : 
    1686            0 :   PREPARE (pg,
    1687              :            "insert_into_table_history_requests",
    1688              :            "INSERT INTO history_requests"
    1689              :            "(history_request_serial_id"
    1690              :            ",reserve_pub"
    1691              :            ",request_timestamp"
    1692              :            ",reserve_sig"
    1693              :            ",history_fee"
    1694              :            ") VALUES "
    1695              :            "($1, $2, $3, $4, $5);");
    1696            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1697              :                                              "insert_into_table_history_requests",
    1698              :                                              params);
    1699              : }
    1700              : 
    1701              : 
    1702              : /**
    1703              :  * Function called with close_requests records to insert into table.
    1704              :  *
    1705              :  * @param pg plugin context
    1706              :  * @param td record to insert
    1707              :  */
    1708              : static enum GNUNET_DB_QueryStatus
    1709            0 : irbt_cb_table_close_requests (struct PostgresClosure *pg,
    1710              :                               const struct TALER_EXCHANGEDB_TableData *td)
    1711              : {
    1712            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1713            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1714            0 :     GNUNET_PQ_query_param_auto_from_type (
    1715              :       &td->details.close_requests.reserve_pub),
    1716            0 :     GNUNET_PQ_query_param_timestamp (
    1717              :       &td->details.close_requests.close_timestamp),
    1718            0 :     GNUNET_PQ_query_param_auto_from_type (
    1719              :       &td->details.close_requests.reserve_sig),
    1720            0 :     TALER_PQ_query_param_amount (
    1721            0 :       pg->conn,
    1722              :       &td->details.close_requests.close),
    1723            0 :     TALER_PQ_query_param_amount (
    1724            0 :       pg->conn,
    1725              :       &td->details.close_requests.close_fee),
    1726            0 :     GNUNET_PQ_query_param_string (
    1727            0 :       td->details.close_requests.payto_uri.full_payto),
    1728              :     GNUNET_PQ_query_param_end
    1729              :   };
    1730              : 
    1731            0 :   PREPARE (pg,
    1732              :            "insert_into_table_close_requests",
    1733              :            "INSERT INTO close_requests"
    1734              :            "(close_request_serial_id"
    1735              :            ",reserve_pub"
    1736              :            ",close_timestamp"
    1737              :            ",reserve_sig"
    1738              :            ",close"
    1739              :            ",close_fee"
    1740              :            ",payto_uri"
    1741              :            ") VALUES "
    1742              :            "($1, $2, $3, $4, $5, $6, $7);");
    1743            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1744              :                                              "insert_into_table_close_requests",
    1745              :                                              params);
    1746              : }
    1747              : 
    1748              : 
    1749              : /**
    1750              :  * Function called with wads_out records to insert into table.
    1751              :  *
    1752              :  * @param pg plugin context
    1753              :  * @param td record to insert
    1754              :  */
    1755              : static enum GNUNET_DB_QueryStatus
    1756            0 : irbt_cb_table_wads_out (struct PostgresClosure *pg,
    1757              :                         const struct TALER_EXCHANGEDB_TableData *td)
    1758              : {
    1759            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1760            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1761            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.wads_out.wad_id),
    1762            0 :     GNUNET_PQ_query_param_uint64 (&td->details.wads_out.partner_serial_id),
    1763            0 :     TALER_PQ_query_param_amount (
    1764            0 :       pg->conn,
    1765              :       &td->details.wads_out.amount),
    1766            0 :     GNUNET_PQ_query_param_timestamp (&td->details.wads_out.execution_time),
    1767              :     GNUNET_PQ_query_param_end
    1768              :   };
    1769              : 
    1770            0 :   PREPARE (pg,
    1771              :            "insert_into_table_wads_out",
    1772              :            "INSERT INTO wads_out"
    1773              :            "(wad_out_serial_id"
    1774              :            ",wad_id"
    1775              :            ",partner_serial_id"
    1776              :            ",amount"
    1777              :            ",execution_time"
    1778              :            ") VALUES "
    1779              :            "($1, $2, $3, $4, $5);");
    1780            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1781              :                                              "insert_into_table_wads_out",
    1782              :                                              params);
    1783              : }
    1784              : 
    1785              : 
    1786              : /**
    1787              :  * Function called with wads_out_entries records to insert into table.
    1788              :  *
    1789              :  * @param pg plugin context
    1790              :  * @param td record to insert
    1791              :  */
    1792              : static enum GNUNET_DB_QueryStatus
    1793            0 : irbt_cb_table_wads_out_entries (struct PostgresClosure *pg,
    1794              :                                 const struct TALER_EXCHANGEDB_TableData *td)
    1795              : {
    1796            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1797            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1798            0 :     GNUNET_PQ_query_param_uint64 (
    1799              :       &td->details.wads_out_entries.wad_out_serial_id),
    1800            0 :     GNUNET_PQ_query_param_auto_from_type (
    1801              :       &td->details.wads_out_entries.reserve_pub),
    1802            0 :     GNUNET_PQ_query_param_auto_from_type (
    1803              :       &td->details.wads_out_entries.purse_pub),
    1804            0 :     GNUNET_PQ_query_param_auto_from_type (
    1805              :       &td->details.wads_out_entries.h_contract),
    1806            0 :     GNUNET_PQ_query_param_timestamp (
    1807              :       &td->details.wads_out_entries.purse_expiration),
    1808            0 :     GNUNET_PQ_query_param_timestamp (
    1809              :       &td->details.wads_out_entries.merge_timestamp),
    1810            0 :     TALER_PQ_query_param_amount (
    1811            0 :       pg->conn,
    1812              :       &td->details.wads_out_entries.amount_with_fee),
    1813            0 :     TALER_PQ_query_param_amount (
    1814            0 :       pg->conn,
    1815              :       &td->details.wads_out_entries.wad_fee),
    1816            0 :     TALER_PQ_query_param_amount (
    1817            0 :       pg->conn,
    1818              :       &td->details.wads_out_entries.deposit_fees),
    1819            0 :     GNUNET_PQ_query_param_auto_from_type (
    1820              :       &td->details.wads_out_entries.reserve_sig),
    1821            0 :     GNUNET_PQ_query_param_auto_from_type (
    1822              :       &td->details.wads_out_entries.purse_sig),
    1823              :     GNUNET_PQ_query_param_end
    1824              :   };
    1825              : 
    1826            0 :   PREPARE (pg,
    1827              :            "insert_into_table_wad_out_entries",
    1828              :            "INSERT INTO wad_out_entries"
    1829              :            "(wad_out_entry_serial_id"
    1830              :            ",wad_out_serial_id"
    1831              :            ",reserve_pub"
    1832              :            ",purse_pub"
    1833              :            ",h_contract"
    1834              :            ",purse_expiration"
    1835              :            ",merge_timestamp"
    1836              :            ",amount_with_fee"
    1837              :            ",wad_fee"
    1838              :            ",deposit_fees"
    1839              :            ",reserve_sig"
    1840              :            ",purse_sig"
    1841              :            ") VALUES "
    1842              :            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);");
    1843            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1844              :                                              "insert_into_table_wads_out_entries",
    1845              :                                              params);
    1846              : }
    1847              : 
    1848              : 
    1849              : /**
    1850              :  * Function called with wads_in records to insert into table.
    1851              :  *
    1852              :  * @param pg plugin context
    1853              :  * @param td record to insert
    1854              :  */
    1855              : static enum GNUNET_DB_QueryStatus
    1856            0 : irbt_cb_table_wads_in (struct PostgresClosure *pg,
    1857              :                        const struct TALER_EXCHANGEDB_TableData *td)
    1858              : {
    1859            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1860            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1861            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.wads_in.wad_id),
    1862            0 :     GNUNET_PQ_query_param_string (td->details.wads_in.origin_exchange_url),
    1863            0 :     TALER_PQ_query_param_amount (
    1864            0 :       pg->conn,
    1865              :       &td->details.wads_in.amount),
    1866            0 :     GNUNET_PQ_query_param_timestamp (&td->details.wads_in.arrival_time),
    1867              :     GNUNET_PQ_query_param_end
    1868              :   };
    1869              : 
    1870            0 :   PREPARE (pg,
    1871              :            "insert_into_table_wads_in",
    1872              :            "INSERT INTO wads_in"
    1873              :            "(wad_in_serial_id"
    1874              :            ",wad_id"
    1875              :            ",origin_exchange_url"
    1876              :            ",amount"
    1877              :            ",arrival_time"
    1878              :            ") VALUES "
    1879              :            "($1, $2, $3, $4, $5);");
    1880            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1881              :                                              "insert_into_table_wads_in",
    1882              :                                              params);
    1883              : }
    1884              : 
    1885              : 
    1886              : /**
    1887              :  * Function called with wads_in_entries records to insert into table.
    1888              :  *
    1889              :  * @param pg plugin context
    1890              :  * @param td record to insert
    1891              :  */
    1892              : static enum GNUNET_DB_QueryStatus
    1893            0 : irbt_cb_table_wads_in_entries (struct PostgresClosure *pg,
    1894              :                                const struct TALER_EXCHANGEDB_TableData *td)
    1895              : {
    1896            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1897            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1898            0 :     GNUNET_PQ_query_param_auto_from_type (
    1899              :       &td->details.wads_in_entries.reserve_pub),
    1900            0 :     GNUNET_PQ_query_param_auto_from_type (
    1901              :       &td->details.wads_in_entries.purse_pub),
    1902            0 :     GNUNET_PQ_query_param_auto_from_type (
    1903              :       &td->details.wads_in_entries.h_contract),
    1904            0 :     GNUNET_PQ_query_param_timestamp (
    1905              :       &td->details.wads_in_entries.purse_expiration),
    1906            0 :     GNUNET_PQ_query_param_timestamp (
    1907              :       &td->details.wads_in_entries.merge_timestamp),
    1908            0 :     TALER_PQ_query_param_amount (
    1909            0 :       pg->conn,
    1910              :       &td->details.wads_in_entries.amount_with_fee),
    1911            0 :     TALER_PQ_query_param_amount (
    1912            0 :       pg->conn,
    1913              :       &td->details.wads_in_entries.wad_fee),
    1914            0 :     TALER_PQ_query_param_amount (
    1915            0 :       pg->conn,
    1916              :       &td->details.wads_in_entries.deposit_fees),
    1917            0 :     GNUNET_PQ_query_param_auto_from_type (
    1918              :       &td->details.wads_in_entries.reserve_sig),
    1919            0 :     GNUNET_PQ_query_param_auto_from_type (
    1920              :       &td->details.wads_in_entries.purse_sig),
    1921              :     GNUNET_PQ_query_param_end
    1922              :   };
    1923              : 
    1924            0 :   PREPARE (pg,
    1925              :            "insert_into_table_wad_in_entries",
    1926              :            "INSERT INTO wad_in_entries"
    1927              :            "(wad_in_entry_serial_id"
    1928              :            ",wad_in_serial_id"
    1929              :            ",reserve_pub"
    1930              :            ",purse_pub"
    1931              :            ",h_contract"
    1932              :            ",purse_expiration"
    1933              :            ",merge_timestamp"
    1934              :            ",amount_with_fee"
    1935              :            ",wad_fee"
    1936              :            ",deposit_fees"
    1937              :            ",reserve_sig"
    1938              :            ",purse_sig"
    1939              :            ") VALUES "
    1940              :            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);");
    1941            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1942              :                                              "insert_into_table_wads_in_entries",
    1943              :                                              params);
    1944              : }
    1945              : 
    1946              : 
    1947              : /**
    1948              :  * Function called with profit_drains records to insert into table.
    1949              :  *
    1950              :  * @param pg plugin context
    1951              :  * @param td record to insert
    1952              :  */
    1953              : static enum GNUNET_DB_QueryStatus
    1954            0 : irbt_cb_table_profit_drains (struct PostgresClosure *pg,
    1955              :                              const struct TALER_EXCHANGEDB_TableData *td)
    1956              : {
    1957            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1958            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1959            0 :     GNUNET_PQ_query_param_auto_from_type (
    1960              :       &td->details.profit_drains.wtid),
    1961            0 :     GNUNET_PQ_query_param_string (
    1962            0 :       td->details.profit_drains.account_section),
    1963            0 :     GNUNET_PQ_query_param_string (
    1964            0 :       td->details.profit_drains.payto_uri.full_payto),
    1965            0 :     GNUNET_PQ_query_param_timestamp (
    1966              :       &td->details.profit_drains.trigger_date),
    1967            0 :     TALER_PQ_query_param_amount (
    1968            0 :       pg->conn,
    1969              :       &td->details.profit_drains.amount),
    1970            0 :     GNUNET_PQ_query_param_auto_from_type (
    1971              :       &td->details.profit_drains.master_sig),
    1972              :     GNUNET_PQ_query_param_end
    1973              :   };
    1974              : 
    1975            0 :   PREPARE (pg,
    1976              :            "insert_into_table_profit_drains",
    1977              :            "INSERT INTO profit_drains"
    1978              :            "(profit_drain_serial_id"
    1979              :            ",wtid"
    1980              :            ",account_section"
    1981              :            ",payto_uri"
    1982              :            ",trigger_date"
    1983              :            ",amount"
    1984              :            ",master_sig"
    1985              :            ") VALUES "
    1986              :            "($1, $2, $3, $4, $5, $6, $7);");
    1987            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1988              :                                              "insert_into_table_profit_drains",
    1989              :                                              params);
    1990              : }
    1991              : 
    1992              : 
    1993              : /**
    1994              :  * Function called with aml_staff records to insert into table.
    1995              :  *
    1996              :  * @param pg plugin context
    1997              :  * @param td record to insert
    1998              :  */
    1999              : static enum GNUNET_DB_QueryStatus
    2000            0 : irbt_cb_table_aml_staff (struct PostgresClosure *pg,
    2001              :                          const struct TALER_EXCHANGEDB_TableData *td)
    2002              : {
    2003            0 :   struct GNUNET_PQ_QueryParam params[] = {
    2004            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    2005            0 :     GNUNET_PQ_query_param_auto_from_type (
    2006              :       &td->details.aml_staff.decider_pub),
    2007            0 :     GNUNET_PQ_query_param_auto_from_type (
    2008              :       &td->details.aml_staff.master_sig),
    2009            0 :     GNUNET_PQ_query_param_string (
    2010            0 :       td->details.aml_staff.decider_name),
    2011            0 :     GNUNET_PQ_query_param_bool (
    2012            0 :       td->details.aml_staff.is_active),
    2013            0 :     GNUNET_PQ_query_param_bool (
    2014            0 :       td->details.aml_staff.read_only),
    2015            0 :     GNUNET_PQ_query_param_timestamp (
    2016              :       &td->details.aml_staff.last_change),
    2017              :     GNUNET_PQ_query_param_end
    2018              :   };
    2019              : 
    2020            0 :   PREPARE (pg,
    2021              :            "insert_into_table_aml_staff",
    2022              :            "INSERT INTO aml_staff"
    2023              :            "(aml_staff_uuid"
    2024              :            ",decider_pub"
    2025              :            ",master_sig"
    2026              :            ",decider_name"
    2027              :            ",is_active"
    2028              :            ",read_only"
    2029              :            ",last_change"
    2030              :            ") VALUES "
    2031              :            "($1, $2, $3, $4, $5, $6, $7);");
    2032            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    2033              :                                              "insert_into_table_aml_staff",
    2034              :                                              params);
    2035              : }
    2036              : 
    2037              : 
    2038              : /**
    2039              :  * Function called with kyc_attributes records to insert into table.
    2040              :  *
    2041              :  * @param pg plugin context
    2042              :  * @param td record to insert
    2043              :  */
    2044              : static enum GNUNET_DB_QueryStatus
    2045            0 : irbt_cb_table_kyc_attributes (struct PostgresClosure *pg,
    2046              :                               const struct TALER_EXCHANGEDB_TableData *td)
    2047              : {
    2048            0 :   struct GNUNET_PQ_QueryParam params[] = {
    2049            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    2050            0 :     GNUNET_PQ_query_param_auto_from_type (
    2051              :       &td->details.kyc_attributes.h_payto),
    2052            0 :     GNUNET_PQ_query_param_uint64 (
    2053              :       &td->details.kyc_attributes.legitimization_serial),
    2054            0 :     GNUNET_PQ_query_param_timestamp (
    2055              :       &td->details.kyc_attributes.collection_time),
    2056            0 :     GNUNET_PQ_query_param_timestamp (
    2057              :       &td->details.kyc_attributes.expiration_time),
    2058            0 :     GNUNET_PQ_query_param_uint64 (
    2059              :       &td->details.kyc_attributes.trigger_outcome_serial),
    2060            0 :     GNUNET_PQ_query_param_fixed_size (
    2061            0 :       &td->details.kyc_attributes.encrypted_attributes,
    2062            0 :       td->details.kyc_attributes.encrypted_attributes_size),
    2063              :     GNUNET_PQ_query_param_end
    2064              :   };
    2065              : 
    2066            0 :   PREPARE (pg,
    2067              :            "insert_into_table_kyc_attributes",
    2068              :            "INSERT INTO kyc_attributes"
    2069              :            "(kyc_attributes_serial_id"
    2070              :            ",h_payto"
    2071              :            ",legitimization_serial"
    2072              :            ",collection_time"
    2073              :            ",expiration_time"
    2074              :            ",trigger_outcome_serial"
    2075              :            ",encrypted_attributes"
    2076              :            ") VALUES "
    2077              :            "($1, $2, $3, $4, $5, $6, $7);");
    2078            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    2079              :                                              "insert_into_table_kyc_attributes",
    2080              :                                              params);
    2081              : }
    2082              : 
    2083              : 
    2084              : /**
    2085              :  * Function called with aml_history records to insert into table.
    2086              :  *
    2087              :  * @param pg plugin context
    2088              :  * @param td record to insert
    2089              :  */
    2090              : static enum GNUNET_DB_QueryStatus
    2091            0 : irbt_cb_table_aml_history (struct PostgresClosure *pg,
    2092              :                            const struct TALER_EXCHANGEDB_TableData *td)
    2093              : {
    2094            0 :   struct GNUNET_PQ_QueryParam params[] = {
    2095            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    2096            0 :     GNUNET_PQ_query_param_auto_from_type (
    2097              :       &td->details.aml_history.h_payto),
    2098            0 :     GNUNET_PQ_query_param_uint64 (
    2099              :       &td->details.aml_history.outcome_serial_id),
    2100            0 :     GNUNET_PQ_query_param_string (
    2101            0 :       td->details.aml_history.justification),
    2102            0 :     GNUNET_PQ_query_param_auto_from_type (
    2103              :       &td->details.aml_history.decider_pub),
    2104            0 :     GNUNET_PQ_query_param_auto_from_type (
    2105              :       &td->details.aml_history.decider_sig),
    2106              :     GNUNET_PQ_query_param_end
    2107              :   };
    2108              : 
    2109            0 :   PREPARE (pg,
    2110              :            "insert_into_table_aml_history",
    2111              :            "INSERT INTO aml_history"
    2112              :            "(aml_history_serial_id"
    2113              :            ",h_payto"
    2114              :            ",outcome_serial_id"
    2115              :            ",justification"
    2116              :            ",decider_pub"
    2117              :            ",decider_sig"
    2118              :            ") VALUES "
    2119              :            "($1, $2, $3, $4, $5, $6);");
    2120            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    2121              :                                              "insert_into_table_aml_history",
    2122              :                                              params);
    2123              : }
    2124              : 
    2125              : 
    2126              : /**
    2127              :  * Function called with kyc_event records to insert into table.
    2128              :  *
    2129              :  * @param pg plugin context
    2130              :  * @param td record to insert
    2131              :  */
    2132              : static enum GNUNET_DB_QueryStatus
    2133            0 : irbt_cb_table_kyc_events (struct PostgresClosure *pg,
    2134              :                           const struct TALER_EXCHANGEDB_TableData *td)
    2135              : {
    2136            0 :   struct GNUNET_PQ_QueryParam params[] = {
    2137            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    2138            0 :     GNUNET_PQ_query_param_timestamp (
    2139              :       &td->details.kyc_events.event_timestamp),
    2140            0 :     GNUNET_PQ_query_param_string (
    2141            0 :       td->details.kyc_events.event_type),
    2142              :     GNUNET_PQ_query_param_end
    2143              :   };
    2144              : 
    2145            0 :   PREPARE (pg,
    2146              :            "insert_into_table_kyc_events",
    2147              :            "INSERT INTO kyc_events"
    2148              :            "(kyc_event_serial_id"
    2149              :            ",event_timestamp"
    2150              :            ",event_type"
    2151              :            ") VALUES "
    2152              :            "($1, $2, $3);");
    2153            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    2154              :                                              "insert_into_table_kyc_events",
    2155              :                                              params);
    2156              : }
    2157              : 
    2158              : 
    2159              : /**
    2160              :  * Function called with purse_deletion records to insert into table.
    2161              :  *
    2162              :  * @param pg plugin context
    2163              :  * @param td record to insert
    2164              :  */
    2165              : static enum GNUNET_DB_QueryStatus
    2166            0 : irbt_cb_table_purse_deletion (struct PostgresClosure *pg,
    2167              :                               const struct TALER_EXCHANGEDB_TableData *td)
    2168              : {
    2169            0 :   struct GNUNET_PQ_QueryParam params[] = {
    2170            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    2171            0 :     GNUNET_PQ_query_param_auto_from_type (
    2172              :       &td->details.purse_deletion.purse_pub),
    2173            0 :     GNUNET_PQ_query_param_auto_from_type (
    2174              :       &td->details.purse_deletion.purse_sig),
    2175              :     GNUNET_PQ_query_param_end
    2176              :   };
    2177              : 
    2178            0 :   PREPARE (pg,
    2179              :            "insert_into_table_purse_deletion",
    2180              :            "INSERT INTO purse_deletion"
    2181              :            "(purse_deletion_serial_id"
    2182              :            ",purse_pub"
    2183              :            ",purse_sig"
    2184              :            ") VALUES "
    2185              :            "($1, $2, $3);");
    2186            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    2187              :                                              "insert_into_table_purse_deletion",
    2188              :                                              params);
    2189              : }
    2190              : 
    2191              : 
    2192              : /**
    2193              :  * Function called with withdraw records to insert into table.
    2194              :  *
    2195              :  * @param pg plugin context
    2196              :  * @param td record to insert
    2197              :  */
    2198              : static enum GNUNET_DB_QueryStatus
    2199            0 : irbt_cb_table_withdraw (
    2200              :   struct PostgresClosure *pg,
    2201              :   const struct TALER_EXCHANGEDB_TableData *td)
    2202              : {
    2203            0 :   struct GNUNET_PQ_QueryParam params[] = {
    2204            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    2205            0 :     GNUNET_PQ_query_param_auto_from_type (
    2206              :       &td->details.withdraw.planchets_h),
    2207            0 :     GNUNET_PQ_query_param_timestamp (
    2208              :       &td->details.withdraw.execution_date),
    2209            0 :     TALER_PQ_query_param_amount (
    2210            0 :       pg->conn,
    2211              :       &td->details.withdraw.amount_with_fee),
    2212            0 :     GNUNET_PQ_query_param_auto_from_type (
    2213              :       &td->details.withdraw.reserve_pub),
    2214            0 :     GNUNET_PQ_query_param_auto_from_type (
    2215              :       &td->details.withdraw.reserve_sig),
    2216            0 :     td->details.withdraw.age_proof_required
    2217            0 :     ? GNUNET_PQ_query_param_uint16 (
    2218              :       &td->details.withdraw.max_age)
    2219            0 :     : GNUNET_PQ_query_param_null (),
    2220            0 :     td->details.withdraw.age_proof_required
    2221            0 :     ? GNUNET_PQ_query_param_uint16 (
    2222              :       &td->details.withdraw.noreveal_index)
    2223            0 :     : GNUNET_PQ_query_param_null (),
    2224            0 :     td->details.withdraw.age_proof_required
    2225            0 :     ? GNUNET_PQ_query_param_auto_from_type (
    2226              :       &td->details.withdraw.selected_h)
    2227            0 :     : GNUNET_PQ_query_param_null (),
    2228            0 :     td->details.withdraw.no_blinding_seed
    2229            0 :     ? GNUNET_PQ_query_param_null ()
    2230            0 :     : GNUNET_PQ_query_param_auto_from_type (
    2231              :       &td->details.withdraw.blinding_seed),
    2232            0 :     (0 < td->details.withdraw.num_cs_r_values)
    2233            0 :     ? TALER_PQ_query_param_array_cs_r_pub (
    2234            0 :       td->details.withdraw.num_cs_r_values,
    2235            0 :       td->details.withdraw.cs_r_values,
    2236              :       pg->conn)
    2237            0 :     : GNUNET_PQ_query_param_null (),
    2238            0 :     (0 < td->details.withdraw.num_cs_r_values)
    2239            0 :     ? GNUNET_PQ_query_param_uint64 (
    2240              :       &td->details.withdraw.cs_r_choices)
    2241            0 :     : GNUNET_PQ_query_param_null (),
    2242            0 :     GNUNET_PQ_query_param_array_uint64 (
    2243            0 :       td->details.withdraw.num_coins,
    2244            0 :       td->details.withdraw.denom_serials,
    2245              :       pg->conn),
    2246            0 :     TALER_PQ_query_param_array_blinded_denom_sig (
    2247            0 :       td->details.withdraw.num_coins,
    2248            0 :       td->details.withdraw.denom_sigs,
    2249              :       pg->conn),
    2250              :     GNUNET_PQ_query_param_end
    2251              :   };
    2252              :   enum GNUNET_DB_QueryStatus qs;
    2253              : 
    2254            0 :   PREPARE (pg,
    2255              :            "insert_into_table_withdraw",
    2256              :            "INSERT INTO withdraw"
    2257              :            "(withdraw_id"
    2258              :            ",planchets_h"
    2259              :            ",execution_date"
    2260              :            ",amount_with_fee"
    2261              :            ",reserve_pub"
    2262              :            ",reserve_sig"
    2263              :            ",max_age"
    2264              :            ",noreveal_index"
    2265              :            ",selected_h"
    2266              :            ",blinding_seed"
    2267              :            ",cs_r_values"
    2268              :            ",cs_r_choices"
    2269              :            ",denom_serials"
    2270              :            ",denom_sigs"
    2271              :            ") VALUES "
    2272              :            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14);");
    2273            0 :   qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
    2274              :                                            "insert_into_table_withdraw",
    2275              :                                            params);
    2276            0 :   GNUNET_PQ_cleanup_query_params_closures (params);
    2277            0 :   return qs;
    2278              : }
    2279              : 
    2280              : 
    2281              : enum GNUNET_DB_QueryStatus
    2282            0 : TEH_PG_insert_records_by_table (void *cls,
    2283              :                                 const struct TALER_EXCHANGEDB_TableData *td)
    2284              : {
    2285            0 :   struct PostgresClosure *pg = cls;
    2286            0 :   InsertRecordCallback rh = NULL;
    2287              : 
    2288            0 :   switch (td->table)
    2289              :   {
    2290            0 :   case TALER_EXCHANGEDB_RT_DENOMINATIONS:
    2291            0 :     rh = &irbt_cb_table_denominations;
    2292            0 :     break;
    2293            0 :   case TALER_EXCHANGEDB_RT_DENOMINATION_REVOCATIONS:
    2294            0 :     rh = &irbt_cb_table_denomination_revocations;
    2295            0 :     break;
    2296            0 :   case TALER_EXCHANGEDB_RT_WIRE_TARGETS:
    2297            0 :     rh = &irbt_cb_table_wire_targets;
    2298            0 :     break;
    2299            0 :   case TALER_EXCHANGEDB_RT_KYC_TARGETS:
    2300            0 :     rh = &irbt_cb_table_kyc_targets;
    2301            0 :     break;
    2302            0 :   case TALER_EXCHANGEDB_RT_RESERVES:
    2303            0 :     rh = &irbt_cb_table_reserves;
    2304            0 :     break;
    2305            0 :   case TALER_EXCHANGEDB_RT_RESERVES_IN:
    2306            0 :     rh = &irbt_cb_table_reserves_in;
    2307            0 :     break;
    2308            0 :   case TALER_EXCHANGEDB_RT_KYCAUTHS_IN:
    2309            0 :     rh = &irbt_cb_table_kycauths_in;
    2310            0 :     break;
    2311            0 :   case TALER_EXCHANGEDB_RT_RESERVES_CLOSE:
    2312            0 :     rh = &irbt_cb_table_reserves_close;
    2313            0 :     break;
    2314            0 :   case TALER_EXCHANGEDB_RT_RESERVES_OPEN_REQUESTS:
    2315            0 :     rh = &irbt_cb_table_reserves_open_requests;
    2316            0 :     break;
    2317            0 :   case TALER_EXCHANGEDB_RT_RESERVES_OPEN_DEPOSITS:
    2318            0 :     rh = &irbt_cb_table_reserves_open_deposits;
    2319            0 :     break;
    2320            0 :   case TALER_EXCHANGEDB_RT_AUDITORS:
    2321            0 :     rh = &irbt_cb_table_auditors;
    2322            0 :     break;
    2323            0 :   case TALER_EXCHANGEDB_RT_AUDITOR_DENOM_SIGS:
    2324            0 :     rh = &irbt_cb_table_auditor_denom_sigs;
    2325            0 :     break;
    2326            0 :   case TALER_EXCHANGEDB_RT_EXCHANGE_SIGN_KEYS:
    2327            0 :     rh = &irbt_cb_table_exchange_sign_keys;
    2328            0 :     break;
    2329            0 :   case TALER_EXCHANGEDB_RT_SIGNKEY_REVOCATIONS:
    2330            0 :     rh = &irbt_cb_table_signkey_revocations;
    2331            0 :     break;
    2332            0 :   case TALER_EXCHANGEDB_RT_KNOWN_COINS:
    2333            0 :     rh = &irbt_cb_table_known_coins;
    2334            0 :     break;
    2335            0 :   case TALER_EXCHANGEDB_RT_REFRESH:
    2336            0 :     rh = &irbt_cb_table_refresh;
    2337            0 :     break;
    2338            0 :   case TALER_EXCHANGEDB_RT_BATCH_DEPOSITS:
    2339            0 :     rh = &irbt_cb_table_batch_deposits;
    2340            0 :     break;
    2341            0 :   case TALER_EXCHANGEDB_RT_COIN_DEPOSITS:
    2342            0 :     rh = &irbt_cb_table_coin_deposits;
    2343            0 :     break;
    2344            0 :   case TALER_EXCHANGEDB_RT_REFUNDS:
    2345            0 :     rh = &irbt_cb_table_refunds;
    2346            0 :     break;
    2347            0 :   case TALER_EXCHANGEDB_RT_WIRE_OUT:
    2348            0 :     rh = &irbt_cb_table_wire_out;
    2349            0 :     break;
    2350            0 :   case TALER_EXCHANGEDB_RT_AGGREGATION_TRACKING:
    2351            0 :     rh = &irbt_cb_table_aggregation_tracking;
    2352            0 :     break;
    2353            0 :   case TALER_EXCHANGEDB_RT_WIRE_FEE:
    2354            0 :     rh = &irbt_cb_table_wire_fee;
    2355            0 :     break;
    2356            0 :   case TALER_EXCHANGEDB_RT_GLOBAL_FEE:
    2357            0 :     rh = &irbt_cb_table_global_fee;
    2358            0 :     break;
    2359            0 :   case TALER_EXCHANGEDB_RT_RECOUP:
    2360            0 :     rh = &irbt_cb_table_recoup;
    2361            0 :     break;
    2362            0 :   case TALER_EXCHANGEDB_RT_RECOUP_REFRESH:
    2363            0 :     rh = &irbt_cb_table_recoup_refresh;
    2364            0 :     break;
    2365            0 :   case TALER_EXCHANGEDB_RT_EXTENSIONS:
    2366            0 :     rh = &irbt_cb_table_extensions;
    2367            0 :     break;
    2368            0 :   case TALER_EXCHANGEDB_RT_POLICY_DETAILS:
    2369            0 :     rh = &irbt_cb_table_policy_details;
    2370            0 :     break;
    2371            0 :   case TALER_EXCHANGEDB_RT_POLICY_FULFILLMENTS:
    2372            0 :     rh = &irbt_cb_table_policy_fulfillments;
    2373            0 :     break;
    2374            0 :   case TALER_EXCHANGEDB_RT_PURSE_REQUESTS:
    2375            0 :     rh = &irbt_cb_table_purse_requests;
    2376            0 :     break;
    2377            0 :   case TALER_EXCHANGEDB_RT_PURSE_DECISION:
    2378            0 :     rh = &irbt_cb_table_purse_decision;
    2379            0 :     break;
    2380            0 :   case TALER_EXCHANGEDB_RT_PURSE_MERGES:
    2381            0 :     rh = &irbt_cb_table_purse_merges;
    2382            0 :     break;
    2383            0 :   case TALER_EXCHANGEDB_RT_PURSE_DEPOSITS:
    2384            0 :     rh = &irbt_cb_table_purse_deposits;
    2385            0 :     break;
    2386            0 :   case TALER_EXCHANGEDB_RT_ACCOUNT_MERGES:
    2387            0 :     rh = &irbt_cb_table_account_mergers;
    2388            0 :     break;
    2389            0 :   case TALER_EXCHANGEDB_RT_HISTORY_REQUESTS:
    2390            0 :     rh = &irbt_cb_table_history_requests;
    2391            0 :     break;
    2392            0 :   case TALER_EXCHANGEDB_RT_CLOSE_REQUESTS:
    2393            0 :     rh = &irbt_cb_table_close_requests;
    2394            0 :     break;
    2395            0 :   case TALER_EXCHANGEDB_RT_WADS_OUT:
    2396            0 :     rh = &irbt_cb_table_wads_out;
    2397            0 :     break;
    2398            0 :   case TALER_EXCHANGEDB_RT_WADS_OUT_ENTRIES:
    2399            0 :     rh = &irbt_cb_table_wads_out_entries;
    2400            0 :     break;
    2401            0 :   case TALER_EXCHANGEDB_RT_WADS_IN:
    2402            0 :     rh = &irbt_cb_table_wads_in;
    2403            0 :     break;
    2404            0 :   case TALER_EXCHANGEDB_RT_WADS_IN_ENTRIES:
    2405            0 :     rh = &irbt_cb_table_wads_in_entries;
    2406            0 :     break;
    2407            0 :   case TALER_EXCHANGEDB_RT_PROFIT_DRAINS:
    2408            0 :     rh = &irbt_cb_table_profit_drains;
    2409            0 :     break;
    2410            0 :   case TALER_EXCHANGEDB_RT_AML_STAFF:
    2411            0 :     rh = &irbt_cb_table_aml_staff;
    2412            0 :     break;
    2413            0 :   case TALER_EXCHANGEDB_RT_PURSE_DELETION:
    2414            0 :     rh = &irbt_cb_table_purse_deletion;
    2415            0 :     break;
    2416            0 :   case TALER_EXCHANGEDB_RT_WITHDRAW:
    2417            0 :     rh = &irbt_cb_table_withdraw;
    2418            0 :     break;
    2419            0 :   case TALER_EXCHANGEDB_RT_LEGITIMIZATION_MEASURES:
    2420            0 :     rh = &irbt_cb_table_legitimization_measures;
    2421            0 :     break;
    2422            0 :   case TALER_EXCHANGEDB_RT_LEGITIMIZATION_OUTCOMES:
    2423            0 :     rh = &irbt_cb_table_legitimization_outcomes;
    2424            0 :     break;
    2425            0 :   case TALER_EXCHANGEDB_RT_LEGITIMIZATION_PROCESSES:
    2426            0 :     rh = &irbt_cb_table_legitimization_processes;
    2427            0 :     break;
    2428            0 :   case TALER_EXCHANGEDB_RT_KYC_ATTRIBUTES:
    2429            0 :     rh = &irbt_cb_table_kyc_attributes;
    2430            0 :     break;
    2431            0 :   case TALER_EXCHANGEDB_RT_AML_HISTORY:
    2432            0 :     rh = &irbt_cb_table_aml_history;
    2433            0 :     break;
    2434            0 :   case TALER_EXCHANGEDB_RT_KYC_EVENTS:
    2435            0 :     rh = &irbt_cb_table_kyc_events;
    2436            0 :     break;
    2437              :   }
    2438            0 :   if (NULL == rh)
    2439              :   {
    2440            0 :     GNUNET_break (0);
    2441            0 :     return GNUNET_DB_STATUS_HARD_ERROR;
    2442              :   }
    2443            0 :   return rh (pg,
    2444              :              td);
    2445              : }
    2446              : 
    2447              : 
    2448              : /* end of pg_insert_records_by_table.c */
        

Generated by: LCOV version 2.0-1