LCOV - code coverage report
Current view: top level - exchangedb - insert_records_by_table.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 745 0
Test Date: 2026-06-14 14:19:22 Functions: 0.0 % 47 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/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/taler_error_codes.h"
      27              : #include "taler/taler_dbevents.h"
      28              : #include "taler/taler_pq_lib.h"
      29              : #include "exchange-database/insert_records_by_table.h"
      30              : #include "helper.h"
      31              : #include <gnunet/gnunet_pq_lib.h>
      32              : 
      33              : 
      34              : /**
      35              :  * Signature of helper functions of #TALER_EXCHANGEDB_insert_records_by_table().
      36              :  *
      37              :  * @param pg plugin context
      38              :  * @param td record to insert
      39              :  * @return transaction status code
      40              :  */
      41              : typedef enum GNUNET_DB_QueryStatus
      42              : (*InsertRecordCallback)(struct TALER_EXCHANGEDB_PostgresContext *pg,
      43              :                         const struct TALER_EXCHANGEDB_TableData *td);
      44              : 
      45              : 
      46              : /**
      47              :  * Function called with denominations records to insert into table.
      48              :  *
      49              :  * @param pg plugin context
      50              :  * @param td record to insert
      51              :  */
      52              : static enum GNUNET_DB_QueryStatus
      53            0 : irbt_cb_table_denominations (struct TALER_EXCHANGEDB_PostgresContext *pg,
      54              :                              const struct TALER_EXCHANGEDB_TableData *td)
      55              : {
      56              :   struct TALER_DenominationHashP denom_hash;
      57            0 :   struct GNUNET_PQ_QueryParam params[] = {
      58            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
      59            0 :     GNUNET_PQ_query_param_auto_from_type (&denom_hash),
      60            0 :     GNUNET_PQ_query_param_uint32 (
      61              :       &td->details.denominations.denom_type),
      62            0 :     GNUNET_PQ_query_param_uint32 (
      63              :       &td->details.denominations.age_mask),
      64            0 :     TALER_PQ_query_param_denom_pub (
      65              :       &td->details.denominations.denom_pub),
      66            0 :     GNUNET_PQ_query_param_auto_from_type (
      67              :       &td->details.denominations.master_sig),
      68            0 :     GNUNET_PQ_query_param_timestamp (
      69              :       &td->details.denominations.valid_from),
      70            0 :     GNUNET_PQ_query_param_timestamp (
      71              :       &td->details.denominations.expire_withdraw),
      72            0 :     GNUNET_PQ_query_param_timestamp (
      73              :       &td->details.denominations.expire_deposit),
      74            0 :     GNUNET_PQ_query_param_timestamp (
      75              :       &td->details.denominations.expire_legal),
      76            0 :     TALER_PQ_query_param_amount (
      77            0 :       pg->conn,
      78              :       &td->details.denominations.coin),
      79            0 :     TALER_PQ_query_param_amount (
      80            0 :       pg->conn,
      81              :       &td->details.denominations.fees.withdraw),
      82            0 :     TALER_PQ_query_param_amount (
      83            0 :       pg->conn,
      84              :       &td->details.denominations.fees.deposit),
      85            0 :     TALER_PQ_query_param_amount (
      86            0 :       pg->conn,
      87              :       &td->details.denominations.fees.refresh),
      88            0 :     TALER_PQ_query_param_amount (
      89            0 :       pg->conn,
      90              :       &td->details.denominations.fees.refund),
      91              :     GNUNET_PQ_query_param_end
      92              :   };
      93              : 
      94            0 :   PREPARE (pg,
      95              :            "insert_into_table_denominations",
      96              :            "INSERT INTO denominations"
      97              :            "(denominations_serial"
      98              :            ",denom_pub_hash"
      99              :            ",denom_type"
     100              :            ",age_mask"
     101              :            ",denom_pub"
     102              :            ",master_sig"
     103              :            ",valid_from"
     104              :            ",expire_withdraw"
     105              :            ",expire_deposit"
     106              :            ",expire_legal"
     107              :            ",coin"
     108              :            ",fee_withdraw"
     109              :            ",fee_deposit"
     110              :            ",fee_refresh"
     111              :            ",fee_refund"
     112              :            ") VALUES "
     113              :            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10,"
     114              :            " $11, $12, $13, $14, $15);");
     115              : 
     116            0 :   TALER_denom_pub_hash (
     117              :     &td->details.denominations.denom_pub,
     118              :     &denom_hash);
     119              : 
     120            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     121              :                                              "insert_into_table_denominations",
     122              :                                              params);
     123              : }
     124              : 
     125              : 
     126              : /**
     127              :  * Function called with denomination_revocations records to insert into table.
     128              :  *
     129              :  * @param pg plugin context
     130              :  * @param td record to insert
     131              :  */
     132              : static enum GNUNET_DB_QueryStatus
     133            0 : irbt_cb_table_denomination_revocations (
     134              :   struct TALER_EXCHANGEDB_PostgresContext *pg,
     135              :   const struct TALER_EXCHANGEDB_TableData *td)
     136              : {
     137            0 :   struct GNUNET_PQ_QueryParam params[] = {
     138            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     139            0 :     GNUNET_PQ_query_param_auto_from_type (
     140              :       &td->details.denomination_revocations.master_sig),
     141            0 :     GNUNET_PQ_query_param_uint64 (
     142              :       &td->details.denomination_revocations.denominations_serial),
     143              :     GNUNET_PQ_query_param_end
     144              :   };
     145              : 
     146            0 :   PREPARE (pg,
     147              :            "insert_into_table_denomination_revocations",
     148              :            "INSERT INTO denomination_revocations"
     149              :            "(denom_revocations_serial_id"
     150              :            ",master_sig"
     151              :            ",denominations_serial"
     152              :            ") VALUES "
     153              :            "($1, $2, $3);");
     154            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     155              :                                              "insert_into_table_denomination_revocations",
     156              :                                              params);
     157              : }
     158              : 
     159              : 
     160              : /**
     161              :  * Function called with wire target records to insert into table.
     162              :  *
     163              :  * @param pg plugin context
     164              :  * @param td record to insert
     165              :  */
     166              : static enum GNUNET_DB_QueryStatus
     167            0 : irbt_cb_table_wire_targets (struct TALER_EXCHANGEDB_PostgresContext *pg,
     168              :                             const struct TALER_EXCHANGEDB_TableData *td)
     169              : {
     170              :   struct TALER_NormalizedPaytoHashP normalized_payto_hash;
     171              :   struct TALER_FullPaytoHashP full_payto_hash;
     172            0 :   struct GNUNET_PQ_QueryParam params[] = {
     173            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     174            0 :     GNUNET_PQ_query_param_auto_from_type (&full_payto_hash),
     175            0 :     GNUNET_PQ_query_param_auto_from_type (&normalized_payto_hash),
     176            0 :     GNUNET_PQ_query_param_string (
     177            0 :       td->details.wire_targets.full_payto_uri.full_payto),
     178              :     GNUNET_PQ_query_param_end
     179              :   };
     180              : 
     181            0 :   TALER_full_payto_hash (
     182              :     td->details.wire_targets.full_payto_uri,
     183              :     &full_payto_hash);
     184            0 :   TALER_full_payto_normalize_and_hash (
     185              :     td->details.wire_targets.full_payto_uri,
     186              :     &normalized_payto_hash);
     187            0 :   PREPARE (pg,
     188              :            "insert_into_table_wire_targets",
     189              :            "INSERT INTO wire_targets"
     190              :            "(wire_target_serial_id"
     191              :            ",wire_target_h_payto"
     192              :            ",h_normalized_payto"
     193              :            ",payto_uri"
     194              :            ") VALUES "
     195              :            "($1, $2, $3, $4);");
     196            0 :   return GNUNET_PQ_eval_prepared_non_select (
     197              :     pg->conn,
     198              :     "insert_into_table_wire_targets",
     199              :     params);
     200              : }
     201              : 
     202              : 
     203              : /**
     204              :  * Function called with kyc target records to insert into table.
     205              :  *
     206              :  * @param pg plugin context
     207              :  * @param td record to insert
     208              :  */
     209              : static enum GNUNET_DB_QueryStatus
     210            0 : irbt_cb_table_kyc_targets (struct TALER_EXCHANGEDB_PostgresContext *pg,
     211              :                            const struct TALER_EXCHANGEDB_TableData *td)
     212              : {
     213            0 :   struct GNUNET_PQ_QueryParam params[] = {
     214            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     215            0 :     GNUNET_PQ_query_param_auto_from_type (
     216              :       &td->details.kyc_targets.h_normalized_payto),
     217            0 :     GNUNET_PQ_query_param_auto_from_type (
     218              :       &td->details.kyc_targets.access_token),
     219            0 :     td->details.kyc_targets.no_account
     220            0 :     ? GNUNET_PQ_query_param_null ()
     221            0 :     : GNUNET_PQ_query_param_auto_from_type (
     222              :       &td->details.kyc_targets.target_pub),
     223            0 :     GNUNET_PQ_query_param_bool (
     224            0 :       td->details.kyc_targets.is_wallet),
     225              :     GNUNET_PQ_query_param_end
     226              :   };
     227              : 
     228            0 :   PREPARE (pg,
     229              :            "insert_into_table_kyc_targets",
     230              :            "INSERT INTO kyc_targets"
     231              :            "(kyc_target_serial_id"
     232              :            ",h_normalized_payto"
     233              :            ",access_token"
     234              :            ",target_pub"
     235              :            ",is_wallet"
     236              :            ") VALUES "
     237              :            "($1, $2, $3, $4, $5);");
     238            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     239              :                                              "insert_into_table_kyc_targets",
     240              :                                              params);
     241              : }
     242              : 
     243              : 
     244              : /**
     245              :  * Function called with records to insert into table.
     246              :  *
     247              :  * @param pg plugin context
     248              :  * @param td record to insert
     249              :  */
     250              : static enum GNUNET_DB_QueryStatus
     251            0 : irbt_cb_table_legitimization_measures (
     252              :   struct TALER_EXCHANGEDB_PostgresContext *pg,
     253              :   const struct TALER_EXCHANGEDB_TableData *td)
     254              : {
     255            0 :   struct GNUNET_PQ_QueryParam params[] = {
     256            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     257            0 :     GNUNET_PQ_query_param_auto_from_type (
     258              :       &td->details.legitimization_measures.target_token),
     259            0 :     GNUNET_PQ_query_param_timestamp (
     260              :       &td->details.legitimization_measures.start_time),
     261            0 :     TALER_PQ_query_param_json (
     262            0 :       td->details.legitimization_measures.measures),
     263            0 :     GNUNET_PQ_query_param_uint32 (
     264              :       &td->details.legitimization_measures.display_priority),
     265              :     GNUNET_PQ_query_param_end
     266              :   };
     267              : 
     268            0 :   PREPARE (pg,
     269              :            "insert_into_table_legitimization_measures",
     270              :            "INSERT INTO legitimization_measures"
     271              :            "(legitimization_measure_serial_id"
     272              :            ",access_token"
     273              :            ",start_time"
     274              :            ",jmeasures"
     275              :            ",display_priority"
     276              :            ") VALUES "
     277              :            "($1, $2, $3, $4::TEXT::JSONB, $5);");
     278            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     279              :                                              "insert_into_table_legitimization_measures",
     280              :                                              params);
     281              : }
     282              : 
     283              : 
     284              : /**
     285              :  * Function called with records to insert into table.
     286              :  *
     287              :  * @param pg plugin context
     288              :  * @param td record to insert
     289              :  */
     290              : static enum GNUNET_DB_QueryStatus
     291            0 : irbt_cb_table_legitimization_outcomes (
     292              :   struct TALER_EXCHANGEDB_PostgresContext *pg,
     293              :   const struct TALER_EXCHANGEDB_TableData *td)
     294              : {
     295            0 :   struct GNUNET_PQ_QueryParam params[] = {
     296            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     297            0 :     GNUNET_PQ_query_param_auto_from_type (
     298              :       &td->details.legitimization_outcomes.h_payto),
     299            0 :     GNUNET_PQ_query_param_timestamp (
     300              :       &td->details.legitimization_outcomes.decision_time),
     301            0 :     GNUNET_PQ_query_param_timestamp (
     302              :       &td->details.legitimization_outcomes.expiration_time),
     303            0 :     TALER_PQ_query_param_json (
     304            0 :       td->details.legitimization_outcomes.properties),
     305            0 :     GNUNET_PQ_query_param_bool (
     306            0 :       td->details.legitimization_outcomes.to_investigate),
     307            0 :     TALER_PQ_query_param_json (
     308            0 :       td->details.legitimization_outcomes.new_rules),
     309              :     GNUNET_PQ_query_param_end
     310              :   };
     311              : 
     312            0 :   PREPARE (pg,
     313              :            "insert_into_table_legitimization_outcomes",
     314              :            "INSERT INTO legitimization_outcomes"
     315              :            "(outcome_serial_id"
     316              :            ",h_payto"
     317              :            ",decision_time"
     318              :            ",expiration_time"
     319              :            ",jproperties"
     320              :            ",to_investigate"
     321              :            ",jnew_rules"
     322              :            ") VALUES "
     323              :            "($1, $2, $3, $4, $5::TEXT::JSONB, $6, $7::TEXT::JSONB);");
     324            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     325              :                                              "insert_into_table_legitimization_outcomes",
     326              :                                              params);
     327              : }
     328              : 
     329              : 
     330              : /**
     331              :  * Function called with records to insert into table.
     332              :  *
     333              :  * @param pg plugin context
     334              :  * @param td record to insert
     335              :  */
     336              : static enum GNUNET_DB_QueryStatus
     337            0 : irbt_cb_table_legitimization_processes (
     338              :   struct TALER_EXCHANGEDB_PostgresContext *pg,
     339              :   const struct TALER_EXCHANGEDB_TableData *td)
     340              : {
     341            0 :   struct GNUNET_PQ_QueryParam params[] = {
     342            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     343            0 :     GNUNET_PQ_query_param_auto_from_type (
     344              :       &td->details.legitimization_processes.h_payto),
     345            0 :     GNUNET_PQ_query_param_timestamp (
     346              :       &td->details.legitimization_processes.start_time),
     347            0 :     GNUNET_PQ_query_param_timestamp (
     348              :       &td->details.legitimization_processes.expiration_time),
     349            0 :     GNUNET_PQ_query_param_uint64 (
     350              :       &td->details.legitimization_processes.legitimization_measure_serial_id),
     351            0 :     GNUNET_PQ_query_param_uint32 (
     352              :       &td->details.legitimization_processes.measure_index),
     353            0 :     GNUNET_PQ_query_param_string (
     354            0 :       td->details.legitimization_processes.provider_name),
     355            0 :     GNUNET_PQ_query_param_string (
     356            0 :       td->details.legitimization_processes.provider_user_id),
     357            0 :     GNUNET_PQ_query_param_string (
     358            0 :       td->details.legitimization_processes.provider_legitimization_id),
     359            0 :     GNUNET_PQ_query_param_string (
     360            0 :       td->details.legitimization_processes.redirect_url),
     361              :     GNUNET_PQ_query_param_end
     362              :   };
     363              : 
     364            0 :   PREPARE (pg,
     365              :            "insert_into_table_legitimization_processes",
     366              :            "INSERT INTO legitimization_processes"
     367              :            "(legitimization_process_serial_id"
     368              :            ",h_payto"
     369              :            ",start_time"
     370              :            ",expiration_time"
     371              :            ",legitimization_measure_serial_id"
     372              :            ",measure_index"
     373              :            ",provider_name"
     374              :            ",provider_user_id"
     375              :            ",provider_legitimization_id"
     376              :            ",redirect_url"
     377              :            ") VALUES "
     378              :            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10);");
     379            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     380              :                                              "insert_into_table_legitimization_processes",
     381              :                                              params);
     382              : }
     383              : 
     384              : 
     385              : /**
     386              :  * Function called with reserves records to insert into table.
     387              :  *
     388              :  * @param pg plugin context
     389              :  * @param td record to insert
     390              :  */
     391              : static enum GNUNET_DB_QueryStatus
     392            0 : irbt_cb_table_reserves (struct TALER_EXCHANGEDB_PostgresContext *pg,
     393              :                         const struct TALER_EXCHANGEDB_TableData *td)
     394              : {
     395            0 :   struct GNUNET_PQ_QueryParam params[] = {
     396            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     397            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.reserves.reserve_pub),
     398            0 :     GNUNET_PQ_query_param_timestamp (&td->details.reserves.expiration_date),
     399            0 :     GNUNET_PQ_query_param_timestamp (&td->details.reserves.gc_date),
     400              :     GNUNET_PQ_query_param_end
     401              :   };
     402              : 
     403            0 :   PREPARE (pg,
     404              :            "insert_into_table_reserves",
     405              :            "INSERT INTO reserves"
     406              :            "(reserve_uuid"
     407              :            ",reserve_pub"
     408              :            ",expiration_date"
     409              :            ",gc_date"
     410              :            ") VALUES "
     411              :            "($1, $2, $3, $4);");
     412            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     413              :                                              "insert_into_table_reserves",
     414              :                                              params);
     415              : }
     416              : 
     417              : 
     418              : /**
     419              :  * Function called with reserves_in records to insert into table.
     420              :  *
     421              :  * @param pg plugin context
     422              :  * @param td record to insert
     423              :  */
     424              : static enum GNUNET_DB_QueryStatus
     425            0 : irbt_cb_table_reserves_in (struct TALER_EXCHANGEDB_PostgresContext *pg,
     426              :                            const struct TALER_EXCHANGEDB_TableData *td)
     427              : {
     428            0 :   struct GNUNET_PQ_QueryParam params[] = {
     429            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     430            0 :     GNUNET_PQ_query_param_uint64 (&td->details.reserves_in.wire_reference),
     431            0 :     TALER_PQ_query_param_amount (
     432            0 :       pg->conn,
     433              :       &td->details.reserves_in.credit),
     434            0 :     GNUNET_PQ_query_param_auto_from_type (
     435              :       &td->details.reserves_in.sender_account_h_payto),
     436            0 :     GNUNET_PQ_query_param_string (
     437            0 :       td->details.reserves_in.exchange_account_section),
     438            0 :     GNUNET_PQ_query_param_timestamp (
     439              :       &td->details.reserves_in.execution_date),
     440            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.reserves_in.reserve_pub),
     441              :     GNUNET_PQ_query_param_end
     442              :   };
     443              : 
     444            0 :   PREPARE (pg,
     445              :            "insert_into_table_reserves_in",
     446              :            "INSERT INTO reserves_in"
     447              :            "(reserve_in_serial_id"
     448              :            ",wire_reference"
     449              :            ",credit"
     450              :            ",wire_source_h_payto"
     451              :            ",exchange_account_section"
     452              :            ",execution_date"
     453              :            ",reserve_pub"
     454              :            ") VALUES "
     455              :            "($1, $2, $3, $4, $5, $6, $7);");
     456            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     457              :                                              "insert_into_table_reserves_in",
     458              :                                              params);
     459              : }
     460              : 
     461              : 
     462              : /**
     463              :  * Function called with kycauth_in records to insert into table.
     464              :  *
     465              :  * @param pg plugin context
     466              :  * @param td record to insert
     467              :  */
     468              : static enum GNUNET_DB_QueryStatus
     469            0 : irbt_cb_table_kycauths_in (struct TALER_EXCHANGEDB_PostgresContext *pg,
     470              :                            const struct TALER_EXCHANGEDB_TableData *td)
     471              : {
     472            0 :   struct GNUNET_PQ_QueryParam params[] = {
     473            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     474            0 :     GNUNET_PQ_query_param_uint64 (&td->details.kycauth_in.wire_reference),
     475            0 :     TALER_PQ_query_param_amount (
     476            0 :       pg->conn,
     477              :       &td->details.reserves_in.credit),
     478            0 :     GNUNET_PQ_query_param_auto_from_type (
     479              :       &td->details.reserves_in.sender_account_h_payto),
     480            0 :     GNUNET_PQ_query_param_string (
     481            0 :       td->details.reserves_in.exchange_account_section),
     482            0 :     GNUNET_PQ_query_param_timestamp (
     483              :       &td->details.reserves_in.execution_date),
     484            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.kycauth_in.account_pub),
     485              :     GNUNET_PQ_query_param_end
     486              :   };
     487              : 
     488            0 :   PREPARE (pg,
     489              :            "insert_into_table_kycauth_in",
     490              :            "INSERT INTO kycauths_in"
     491              :            "(kycauth_in_serial_id"
     492              :            ",wire_reference"
     493              :            ",credit"
     494              :            ",wire_source_h_payto"
     495              :            ",exchange_account_section"
     496              :            ",execution_date"
     497              :            ",account_pub"
     498              :            ") VALUES "
     499              :            "($1, $2, $3, $4, $5, $6, $7);");
     500            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     501              :                                              "insert_into_table_kycauth_in",
     502              :                                              params);
     503              : }
     504              : 
     505              : 
     506              : /**
     507              :  * Function called with reserves_open_requests records to insert into table.
     508              :  *
     509              :  * @param pg plugin context
     510              :  * @param td record to insert
     511              :  */
     512              : static enum GNUNET_DB_QueryStatus
     513            0 : irbt_cb_table_reserves_open_requests (struct TALER_EXCHANGEDB_PostgresContext *
     514              :                                       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 TALER_EXCHANGEDB_PostgresContext *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 TALER_EXCHANGEDB_PostgresContext *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 TALER_EXCHANGEDB_PostgresContext *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 TALER_EXCHANGEDB_PostgresContext *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 TALER_EXCHANGEDB_PostgresContext *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 TALER_EXCHANGEDB_PostgresContext *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 TALER_EXCHANGEDB_PostgresContext *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 TALER_EXCHANGEDB_PostgresContext *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 TALER_EXCHANGEDB_PostgresContext *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 :     TALER_PQ_query_param_amount (
     934            0 :       pg->conn,
     935              :       &td->details.batch_deposits.total_amount),
     936            0 :     TALER_PQ_query_param_amount (
     937            0 :       pg->conn,
     938              :       &td->details.batch_deposits.total_without_fee),
     939            0 :     GNUNET_PQ_query_param_auto_from_type (
     940              :       &td->details.batch_deposits.merchant_sig),
     941            0 :     GNUNET_PQ_query_param_bool (td->details.batch_deposits.done),
     942              :     GNUNET_PQ_query_param_end
     943              :   };
     944              : 
     945            0 :   PREPARE (pg,
     946              :            "insert_into_table_batch_deposits",
     947              :            "INSERT INTO batch_deposits"
     948              :            "(batch_deposit_serial_id"
     949              :            ",shard"
     950              :            ",merchant_pub"
     951              :            ",wallet_timestamp"
     952              :            ",exchange_timestamp"
     953              :            ",refund_deadline"
     954              :            ",wire_deadline"
     955              :            ",h_contract_terms"
     956              :            ",wallet_data_hash"
     957              :            ",wire_salt"
     958              :            ",wire_target_h_payto"
     959              :            ",total_amount"
     960              :            ",total_without_fee"
     961              :            ",merchant_sig"
     962              :            ",done"
     963              :            ") VALUES "
     964              :            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10,"
     965              :            " $11, $12, $13, $14, $15);");
     966            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
     967              :                                              "insert_into_table_batch_deposits",
     968              :                                              params);
     969              : }
     970              : 
     971              : 
     972              : /**
     973              :  * Function called with deposits records to insert into table.
     974              :  *
     975              :  * @param pg plugin context
     976              :  * @param td record to insert
     977              :  */
     978              : static enum GNUNET_DB_QueryStatus
     979            0 : irbt_cb_table_coin_deposits (struct TALER_EXCHANGEDB_PostgresContext *pg,
     980              :                              const struct TALER_EXCHANGEDB_TableData *td)
     981              : {
     982            0 :   struct GNUNET_PQ_QueryParam params[] = {
     983            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
     984            0 :     GNUNET_PQ_query_param_uint64 (
     985              :       &td->details.coin_deposits.batch_deposit_serial_id),
     986            0 :     GNUNET_PQ_query_param_auto_from_type (
     987              :       &td->details.coin_deposits.coin_pub),
     988            0 :     GNUNET_PQ_query_param_auto_from_type (
     989              :       &td->details.coin_deposits.coin_sig),
     990            0 :     TALER_PQ_query_param_amount (
     991            0 :       pg->conn,
     992              :       &td->details.coin_deposits.amount_with_fee),
     993              :     GNUNET_PQ_query_param_end
     994              :   };
     995              : 
     996            0 :   PREPARE (pg,
     997              :            "insert_into_table_coin_deposits",
     998              :            "INSERT INTO coin_deposits"
     999              :            "(coin_deposit_serial_id"
    1000              :            ",batch_deposit_serial_id"
    1001              :            ",coin_pub"
    1002              :            ",coin_sig"
    1003              :            ",amount_with_fee"
    1004              :            ") VALUES "
    1005              :            "($1, $2, $3, $4, $5);");
    1006            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1007              :                                              "insert_into_table_coin_deposits",
    1008              :                                              params);
    1009              : }
    1010              : 
    1011              : 
    1012              : /**
    1013              :  * Function called with refunds records to insert into table.
    1014              :  *
    1015              :  * @param pg plugin context
    1016              :  * @param td record to insert
    1017              :  */
    1018              : static enum GNUNET_DB_QueryStatus
    1019            0 : irbt_cb_table_refunds (struct TALER_EXCHANGEDB_PostgresContext *pg,
    1020              :                        const struct TALER_EXCHANGEDB_TableData *td)
    1021              : {
    1022            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1023            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1024            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.refunds.coin_pub),
    1025            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.refunds.merchant_sig),
    1026            0 :     GNUNET_PQ_query_param_uint64 (&td->details.refunds.rtransaction_id),
    1027            0 :     TALER_PQ_query_param_amount (
    1028            0 :       pg->conn,
    1029              :       &td->details.refunds.amount_with_fee),
    1030            0 :     GNUNET_PQ_query_param_uint64 (
    1031              :       &td->details.refunds.batch_deposit_serial_id),
    1032              :     GNUNET_PQ_query_param_end
    1033              :   };
    1034              : 
    1035            0 :   PREPARE (pg,
    1036              :            "insert_into_table_refunds",
    1037              :            "INSERT INTO refunds"
    1038              :            "(refund_serial_id"
    1039              :            ",coin_pub"
    1040              :            ",merchant_sig"
    1041              :            ",rtransaction_id"
    1042              :            ",amount_with_fee"
    1043              :            ",batch_deposit_serial_id"
    1044              :            ") VALUES "
    1045              :            "($1, $2, $3, $4, $5, $6);");
    1046            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1047              :                                              "insert_into_table_refunds",
    1048              :                                              params);
    1049              : }
    1050              : 
    1051              : 
    1052              : /**
    1053              :  * Function called with wire_out records to insert into table.
    1054              :  *
    1055              :  * @param pg plugin context
    1056              :  * @param td record to insert
    1057              :  */
    1058              : static enum GNUNET_DB_QueryStatus
    1059            0 : irbt_cb_table_wire_out (struct TALER_EXCHANGEDB_PostgresContext *pg,
    1060              :                         const struct TALER_EXCHANGEDB_TableData *td)
    1061              : {
    1062            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1063            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1064            0 :     GNUNET_PQ_query_param_timestamp (&td->details.wire_out.execution_date),
    1065            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.wire_out.wtid_raw),
    1066            0 :     GNUNET_PQ_query_param_auto_from_type (
    1067              :       &td->details.wire_out.wire_target_h_payto),
    1068            0 :     GNUNET_PQ_query_param_string (
    1069            0 :       td->details.wire_out.exchange_account_section),
    1070            0 :     TALER_PQ_query_param_amount (
    1071            0 :       pg->conn,
    1072              :       &td->details.wire_out.amount),
    1073              :     GNUNET_PQ_query_param_end
    1074              :   };
    1075              : 
    1076            0 :   PREPARE (pg,
    1077              :            "insert_into_table_wire_out",
    1078              :            "INSERT INTO wire_out"
    1079              :            "(wireout_uuid"
    1080              :            ",execution_date"
    1081              :            ",wtid_raw"
    1082              :            ",wire_target_h_payto"
    1083              :            ",exchange_account_section"
    1084              :            ",amount"
    1085              :            ") VALUES "
    1086              :            "($1, $2, $3, $4, $5, $6);");
    1087            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1088              :                                              "insert_into_table_wire_out",
    1089              :                                              params);
    1090              : }
    1091              : 
    1092              : 
    1093              : /**
    1094              :  * Function called with aggregation_tracking records to insert into table.
    1095              :  *
    1096              :  * @param pg plugin context
    1097              :  * @param td record to insert
    1098              :  */
    1099              : static enum GNUNET_DB_QueryStatus
    1100            0 : irbt_cb_table_aggregation_tracking (struct TALER_EXCHANGEDB_PostgresContext *pg,
    1101              :                                     const struct TALER_EXCHANGEDB_TableData *td)
    1102              : {
    1103            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1104            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1105            0 :     GNUNET_PQ_query_param_uint64 (
    1106              :       &td->details.aggregation_tracking.batch_deposit_serial_id),
    1107            0 :     GNUNET_PQ_query_param_auto_from_type (
    1108              :       &td->details.aggregation_tracking.wtid_raw),
    1109              :     GNUNET_PQ_query_param_end
    1110              :   };
    1111              : 
    1112            0 :   PREPARE (pg,
    1113              :            "insert_into_table_aggregation_tracking",
    1114              :            "INSERT INTO aggregation_tracking"
    1115              :            "(aggregation_serial_id"
    1116              :            ",batch_deposit_serial_id"
    1117              :            ",wtid_raw"
    1118              :            ") VALUES "
    1119              :            "($1, $2, $3);");
    1120            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1121              :                                              "insert_into_table_aggregation_tracking",
    1122              :                                              params);
    1123              : }
    1124              : 
    1125              : 
    1126              : /**
    1127              :  * Function called with wire_fee records to insert into table.
    1128              :  *
    1129              :  * @param pg plugin context
    1130              :  * @param td record to insert
    1131              :  */
    1132              : static enum GNUNET_DB_QueryStatus
    1133            0 : irbt_cb_table_wire_fee (struct TALER_EXCHANGEDB_PostgresContext *pg,
    1134              :                         const struct TALER_EXCHANGEDB_TableData *td)
    1135              : {
    1136            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1137            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1138            0 :     GNUNET_PQ_query_param_string (td->details.wire_fee.wire_method),
    1139            0 :     GNUNET_PQ_query_param_timestamp (&td->details.wire_fee.start_date),
    1140            0 :     GNUNET_PQ_query_param_timestamp (&td->details.wire_fee.end_date),
    1141            0 :     TALER_PQ_query_param_amount (
    1142            0 :       pg->conn,
    1143              :       &td->details.wire_fee.fees.wire),
    1144            0 :     TALER_PQ_query_param_amount (
    1145            0 :       pg->conn,
    1146              :       &td->details.wire_fee.fees.closing),
    1147            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.wire_fee.master_sig),
    1148              :     GNUNET_PQ_query_param_end
    1149              :   };
    1150              : 
    1151            0 :   PREPARE (pg,
    1152              :            "insert_into_table_wire_fee",
    1153              :            "INSERT INTO wire_fee"
    1154              :            "(wire_fee_serial"
    1155              :            ",wire_method"
    1156              :            ",start_date"
    1157              :            ",end_date"
    1158              :            ",wire_fee"
    1159              :            ",closing_fee"
    1160              :            ",master_sig"
    1161              :            ") VALUES "
    1162              :            "($1, $2, $3, $4, $5, $6, $7);");
    1163            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1164              :                                              "insert_into_table_wire_fee",
    1165              :                                              params);
    1166              : }
    1167              : 
    1168              : 
    1169              : /**
    1170              :  * Function called with wire_fee records to insert into table.
    1171              :  *
    1172              :  * @param pg plugin context
    1173              :  * @param td record to insert
    1174              :  */
    1175              : static enum GNUNET_DB_QueryStatus
    1176            0 : irbt_cb_table_global_fee (struct TALER_EXCHANGEDB_PostgresContext *pg,
    1177              :                           const struct TALER_EXCHANGEDB_TableData *td)
    1178              : {
    1179            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1180            0 :     GNUNET_PQ_query_param_uint64 (
    1181              :       &td->serial),
    1182            0 :     GNUNET_PQ_query_param_timestamp (
    1183              :       &td->details.global_fee.start_date),
    1184            0 :     GNUNET_PQ_query_param_timestamp (
    1185              :       &td->details.global_fee.end_date),
    1186            0 :     TALER_PQ_query_param_amount (
    1187            0 :       pg->conn,
    1188              :       &td->details.global_fee.fees.history),
    1189            0 :     TALER_PQ_query_param_amount (
    1190            0 :       pg->conn,
    1191              :       &td->details.global_fee.fees.account),
    1192            0 :     TALER_PQ_query_param_amount (
    1193            0 :       pg->conn,
    1194              :       &td->details.global_fee.fees.purse),
    1195            0 :     GNUNET_PQ_query_param_relative_time (
    1196              :       &td->details.global_fee.purse_timeout),
    1197            0 :     GNUNET_PQ_query_param_relative_time (
    1198              :       &td->details.global_fee.history_expiration),
    1199            0 :     GNUNET_PQ_query_param_uint32 (
    1200              :       &td->details.global_fee.purse_account_limit),
    1201            0 :     GNUNET_PQ_query_param_auto_from_type (
    1202              :       &td->details.global_fee.master_sig),
    1203              :     GNUNET_PQ_query_param_end
    1204              :   };
    1205              : 
    1206            0 :   PREPARE (pg,
    1207              :            "insert_into_table_global_fee",
    1208              :            "INSERT INTO global_fee"
    1209              :            "(global_fee_serial"
    1210              :            ",start_date"
    1211              :            ",end_date"
    1212              :            ",history_fee"
    1213              :            ",account_fee"
    1214              :            ",purse_fee"
    1215              :            ",purse_timeout"
    1216              :            ",history_expiration"
    1217              :            ",purse_account_limit"
    1218              :            ",master_sig"
    1219              :            ") VALUES "
    1220              :            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10);");
    1221            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1222              :                                              "insert_into_table_global_fee",
    1223              :                                              params);
    1224              : }
    1225              : 
    1226              : 
    1227              : /**
    1228              :  * Function called with recoup records to insert into table.
    1229              :  *
    1230              :  * @param pg plugin context
    1231              :  * @param td record to insert
    1232              :  */
    1233              : static enum GNUNET_DB_QueryStatus
    1234            0 : irbt_cb_table_recoup (struct TALER_EXCHANGEDB_PostgresContext *pg,
    1235              :                       const struct TALER_EXCHANGEDB_TableData *td)
    1236              : {
    1237            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1238            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1239            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.recoup.coin_sig),
    1240            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.recoup.coin_blind),
    1241            0 :     TALER_PQ_query_param_amount (
    1242            0 :       pg->conn,
    1243              :       &td->details.recoup.amount),
    1244            0 :     GNUNET_PQ_query_param_timestamp (&td->details.recoup.timestamp),
    1245            0 :     GNUNET_PQ_query_param_auto_from_type (
    1246              :       &td->details.recoup.coin_pub),
    1247            0 :     GNUNET_PQ_query_param_uint64 (&td->details.recoup.withdraw_serial_id),
    1248              :     GNUNET_PQ_query_param_end
    1249              :   };
    1250              : 
    1251            0 :   PREPARE (pg,
    1252              :            "insert_into_table_recoup",
    1253              :            "INSERT INTO recoup"
    1254              :            "(recoup_uuid"
    1255              :            ",coin_sig"
    1256              :            ",coin_blind"
    1257              :            ",amount"
    1258              :            ",recoup_timestamp"
    1259              :            ",coin_pub"
    1260              :            ",withdraw_serial_id"
    1261              :            ") VALUES "
    1262              :            "($1, $2, $3, $4, $5, $6, $7);");
    1263            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1264              :                                              "insert_into_table_recoup",
    1265              :                                              params);
    1266              : }
    1267              : 
    1268              : 
    1269              : /**
    1270              :  * Function called with recoup_refresh records to insert into table.
    1271              :  *
    1272              :  * @param pg plugin context
    1273              :  * @param td record to insert
    1274              :  */
    1275              : static enum GNUNET_DB_QueryStatus
    1276            0 : irbt_cb_table_recoup_refresh (struct TALER_EXCHANGEDB_PostgresContext *pg,
    1277              :                               const struct TALER_EXCHANGEDB_TableData *td)
    1278              : {
    1279            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1280            0 :     GNUNET_PQ_query_param_uint64 (
    1281              :       &td->serial),
    1282            0 :     GNUNET_PQ_query_param_auto_from_type (
    1283              :       &td->details.recoup_refresh.coin_sig),
    1284            0 :     GNUNET_PQ_query_param_auto_from_type (
    1285              :       &td->details.recoup_refresh.coin_blind),
    1286            0 :     TALER_PQ_query_param_amount (
    1287            0 :       pg->conn,
    1288              :       &td->details.recoup_refresh.amount),
    1289            0 :     GNUNET_PQ_query_param_timestamp (
    1290              :       &td->details.recoup_refresh.recoup_timestamp),
    1291            0 :     GNUNET_PQ_query_param_uint64 (
    1292              :       &td->details.recoup_refresh.known_coin_id),
    1293            0 :     GNUNET_PQ_query_param_auto_from_type (
    1294              :       &td->details.recoup_refresh.coin_pub),
    1295            0 :     GNUNET_PQ_query_param_uint64 (
    1296              :       &td->details.recoup_refresh.refresh_id),
    1297              :     GNUNET_PQ_query_param_end
    1298              :   };
    1299              : 
    1300            0 :   PREPARE (pg,
    1301              :            "insert_into_table_recoup_refresh",
    1302              :            "INSERT INTO recoup_refresh"
    1303              :            "(recoup_refresh_uuid"
    1304              :            ",coin_sig"
    1305              :            ",coin_blind"
    1306              :            ",amount"
    1307              :            ",recoup_timestamp"
    1308              :            ",known_coin_id"
    1309              :            ",coin_pub"
    1310              :            ",refresh_id"
    1311              :            ") VALUES "
    1312              :            "($1, $2, $3, $4, $5, $6, $7, $8);");
    1313            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1314              :                                              "insert_into_table_recoup_refresh",
    1315              :                                              params);
    1316              : }
    1317              : 
    1318              : 
    1319              : /**
    1320              :  * Function called with purse_requests records to insert into table.
    1321              :  *
    1322              :  * @param pg plugin context
    1323              :  * @param td record to insert
    1324              :  */
    1325              : static enum GNUNET_DB_QueryStatus
    1326            0 : irbt_cb_table_purse_requests (struct TALER_EXCHANGEDB_PostgresContext *pg,
    1327              :                               const struct TALER_EXCHANGEDB_TableData *td)
    1328              : {
    1329            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1330            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1331            0 :     GNUNET_PQ_query_param_auto_from_type (
    1332              :       &td->details.purse_requests.purse_pub),
    1333            0 :     GNUNET_PQ_query_param_auto_from_type (
    1334              :       &td->details.purse_requests.merge_pub),
    1335            0 :     GNUNET_PQ_query_param_timestamp (
    1336              :       &td->details.purse_requests.purse_creation),
    1337            0 :     GNUNET_PQ_query_param_timestamp (
    1338              :       &td->details.purse_requests.purse_expiration),
    1339            0 :     GNUNET_PQ_query_param_auto_from_type (
    1340              :       &td->details.purse_requests.h_contract_terms),
    1341            0 :     GNUNET_PQ_query_param_uint32 (&td->details.purse_requests.age_limit),
    1342            0 :     GNUNET_PQ_query_param_uint32 (&td->details.purse_requests.flags),
    1343            0 :     TALER_PQ_query_param_amount (
    1344            0 :       pg->conn,
    1345              :       &td->details.purse_requests.amount_with_fee),
    1346            0 :     TALER_PQ_query_param_amount (
    1347            0 :       pg->conn,
    1348              :       &td->details.purse_requests.purse_fee),
    1349            0 :     GNUNET_PQ_query_param_auto_from_type (
    1350              :       &td->details.purse_requests.purse_sig),
    1351              :     GNUNET_PQ_query_param_end
    1352              :   };
    1353              : 
    1354            0 :   PREPARE (pg,
    1355              :            "insert_into_table_purse_requests",
    1356              :            "INSERT INTO purse_requests"
    1357              :            "(purse_requests_serial_id"
    1358              :            ",purse_pub"
    1359              :            ",merge_pub"
    1360              :            ",purse_creation"
    1361              :            ",purse_expiration"
    1362              :            ",h_contract_terms"
    1363              :            ",age_limit"
    1364              :            ",flags"
    1365              :            ",amount_with_fee"
    1366              :            ",purse_fee"
    1367              :            ",purse_sig"
    1368              :            ") VALUES "
    1369              :            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11);");
    1370            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1371              :                                              "insert_into_table_purse_requests",
    1372              :                                              params);
    1373              : }
    1374              : 
    1375              : 
    1376              : /**
    1377              :  * Function called with purse_decision records to insert into table.
    1378              :  *
    1379              :  * @param pg plugin context
    1380              :  * @param td record to insert
    1381              :  */
    1382              : static enum GNUNET_DB_QueryStatus
    1383            0 : irbt_cb_table_purse_decision (struct TALER_EXCHANGEDB_PostgresContext *pg,
    1384              :                               const struct TALER_EXCHANGEDB_TableData *td)
    1385              : {
    1386            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1387            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1388            0 :     GNUNET_PQ_query_param_auto_from_type (
    1389              :       &td->details.purse_decision.purse_pub),
    1390            0 :     GNUNET_PQ_query_param_timestamp (
    1391              :       &td->details.purse_decision.action_timestamp),
    1392            0 :     GNUNET_PQ_query_param_bool (
    1393            0 :       td->details.purse_decision.refunded),
    1394              :     GNUNET_PQ_query_param_end
    1395              :   };
    1396              : 
    1397            0 :   PREPARE (pg,
    1398              :            "insert_into_table_purse_refunds",
    1399              :            "INSERT INTO purse_refunds"
    1400              :            "(purse_refunds_serial_id"
    1401              :            ",purse_pub"
    1402              :            ",action_timestamp"
    1403              :            ",refunded"
    1404              :            ") VALUES "
    1405              :            "($1, $2, $3, $4);");
    1406            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1407              :                                              "insert_into_table_purse_decision",
    1408              :                                              params);
    1409              : }
    1410              : 
    1411              : 
    1412              : /**
    1413              :  * Function called with purse_merges records to insert into table.
    1414              :  *
    1415              :  * @param pg plugin context
    1416              :  * @param td record to insert
    1417              :  */
    1418              : static enum GNUNET_DB_QueryStatus
    1419            0 : irbt_cb_table_purse_merges (struct TALER_EXCHANGEDB_PostgresContext *pg,
    1420              :                             const struct TALER_EXCHANGEDB_TableData *td)
    1421              : {
    1422            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1423            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1424            0 :     GNUNET_PQ_query_param_uint64 (&td->details.purse_merges.partner_serial_id),
    1425            0 :     GNUNET_PQ_query_param_auto_from_type (
    1426              :       &td->details.purse_merges.reserve_pub),
    1427            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.purse_merges.purse_pub),
    1428            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.purse_merges.merge_sig),
    1429            0 :     GNUNET_PQ_query_param_timestamp (&td->details.purse_merges.merge_timestamp),
    1430              :     GNUNET_PQ_query_param_end
    1431              :   };
    1432              : 
    1433            0 :   PREPARE (pg,
    1434              :            "insert_into_table_purse_merges",
    1435              :            "INSERT INTO purse_merges"
    1436              :            "(purse_merge_request_serial_id"
    1437              :            ",partner_serial_id"
    1438              :            ",reserve_pub"
    1439              :            ",purse_pub"
    1440              :            ",merge_sig"
    1441              :            ",merge_timestamp"
    1442              :            ") VALUES "
    1443              :            "($1, $2, $3, $4, $5, $6);");
    1444            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1445              :                                              "insert_into_table_purse_merges",
    1446              :                                              params);
    1447              : }
    1448              : 
    1449              : 
    1450              : /**
    1451              :  * Function called with purse_deposits records to insert into table.
    1452              :  *
    1453              :  * @param pg plugin context
    1454              :  * @param td record to insert
    1455              :  */
    1456              : static enum GNUNET_DB_QueryStatus
    1457            0 : irbt_cb_table_purse_deposits (struct TALER_EXCHANGEDB_PostgresContext *pg,
    1458              :                               const struct TALER_EXCHANGEDB_TableData *td)
    1459              : {
    1460            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1461            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1462            0 :     GNUNET_PQ_query_param_uint64 (
    1463              :       &td->details.purse_deposits.partner_serial_id),
    1464            0 :     GNUNET_PQ_query_param_auto_from_type (
    1465              :       &td->details.purse_deposits.purse_pub),
    1466            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.purse_deposits.coin_pub),
    1467            0 :     TALER_PQ_query_param_amount (
    1468            0 :       pg->conn,
    1469              :       &td->details.purse_deposits.amount_with_fee),
    1470            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.purse_deposits.coin_sig),
    1471              :     GNUNET_PQ_query_param_end
    1472              :   };
    1473              : 
    1474            0 :   PREPARE (pg,
    1475              :            "insert_into_table_purse_deposits",
    1476              :            "INSERT INTO purse_deposits"
    1477              :            "(purse_deposit_serial_id"
    1478              :            ",partner_serial_id"
    1479              :            ",purse_pub"
    1480              :            ",coin_pub"
    1481              :            ",amount_with_fee"
    1482              :            ",coin_sig"
    1483              :            ") VALUES "
    1484              :            "($1, $2, $3, $4, $5, $6);");
    1485            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1486              :                                              "insert_into_table_purse_deposits",
    1487              :                                              params);
    1488              : }
    1489              : 
    1490              : 
    1491              : /**
    1492              : x * Function called with account_mergers records to insert into table.
    1493              :  *
    1494              :  * @param pg plugin context
    1495              :  * @param td record to insert
    1496              :  */
    1497              : static enum GNUNET_DB_QueryStatus
    1498            0 : irbt_cb_table_account_mergers (struct TALER_EXCHANGEDB_PostgresContext *pg,
    1499              :                                const struct TALER_EXCHANGEDB_TableData *td)
    1500              : {
    1501            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1502            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1503            0 :     GNUNET_PQ_query_param_auto_from_type (
    1504              :       &td->details.account_merges.reserve_pub),
    1505            0 :     GNUNET_PQ_query_param_auto_from_type (
    1506              :       &td->details.account_merges.reserve_sig),
    1507            0 :     GNUNET_PQ_query_param_auto_from_type (
    1508              :       &td->details.account_merges.purse_pub),
    1509            0 :     GNUNET_PQ_query_param_auto_from_type (
    1510              :       &td->details.account_merges.wallet_h_payto),
    1511              :     GNUNET_PQ_query_param_end
    1512              :   };
    1513              : 
    1514            0 :   PREPARE (pg,
    1515              :            "insert_into_table_account_merges",
    1516              :            "INSERT INTO account_merges"
    1517              :            "(account_merge_request_serial_id"
    1518              :            ",reserve_pub"
    1519              :            ",reserve_sig"
    1520              :            ",purse_pub"
    1521              :            ",wallet_h_payto"
    1522              :            ") VALUES "
    1523              :            "($1, $2, $3, $4, $5);");
    1524            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1525              :                                              "insert_into_table_account_merges",
    1526              :                                              params);
    1527              : }
    1528              : 
    1529              : 
    1530              : /**
    1531              :  * Function called with history_requests records to insert into table.
    1532              :  *
    1533              :  * @param pg plugin context
    1534              :  * @param td record to insert
    1535              :  */
    1536              : static enum GNUNET_DB_QueryStatus
    1537            0 : irbt_cb_table_history_requests (struct TALER_EXCHANGEDB_PostgresContext *pg,
    1538              :                                 const struct TALER_EXCHANGEDB_TableData *td)
    1539              : {
    1540            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1541            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1542            0 :     GNUNET_PQ_query_param_auto_from_type (
    1543              :       &td->details.history_requests.reserve_pub),
    1544            0 :     GNUNET_PQ_query_param_timestamp (
    1545              :       &td->details.history_requests.request_timestamp),
    1546            0 :     GNUNET_PQ_query_param_auto_from_type (
    1547              :       &td->details.history_requests.reserve_sig),
    1548            0 :     TALER_PQ_query_param_amount (
    1549            0 :       pg->conn,
    1550              :       &td->details.history_requests.history_fee),
    1551              :     GNUNET_PQ_query_param_end
    1552              :   };
    1553              : 
    1554            0 :   PREPARE (pg,
    1555              :            "insert_into_table_history_requests",
    1556              :            "INSERT INTO history_requests"
    1557              :            "(history_request_serial_id"
    1558              :            ",reserve_pub"
    1559              :            ",request_timestamp"
    1560              :            ",reserve_sig"
    1561              :            ",history_fee"
    1562              :            ") VALUES "
    1563              :            "($1, $2, $3, $4, $5);");
    1564            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1565              :                                              "insert_into_table_history_requests",
    1566              :                                              params);
    1567              : }
    1568              : 
    1569              : 
    1570              : /**
    1571              :  * Function called with close_requests records to insert into table.
    1572              :  *
    1573              :  * @param pg plugin context
    1574              :  * @param td record to insert
    1575              :  */
    1576              : static enum GNUNET_DB_QueryStatus
    1577            0 : irbt_cb_table_close_requests (struct TALER_EXCHANGEDB_PostgresContext *pg,
    1578              :                               const struct TALER_EXCHANGEDB_TableData *td)
    1579              : {
    1580            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1581            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1582            0 :     GNUNET_PQ_query_param_auto_from_type (
    1583              :       &td->details.close_requests.reserve_pub),
    1584            0 :     GNUNET_PQ_query_param_timestamp (
    1585              :       &td->details.close_requests.close_timestamp),
    1586            0 :     GNUNET_PQ_query_param_auto_from_type (
    1587              :       &td->details.close_requests.reserve_sig),
    1588            0 :     TALER_PQ_query_param_amount (
    1589            0 :       pg->conn,
    1590              :       &td->details.close_requests.close),
    1591            0 :     TALER_PQ_query_param_amount (
    1592            0 :       pg->conn,
    1593              :       &td->details.close_requests.close_fee),
    1594            0 :     GNUNET_PQ_query_param_string (
    1595            0 :       td->details.close_requests.payto_uri.full_payto),
    1596              :     GNUNET_PQ_query_param_end
    1597              :   };
    1598              : 
    1599            0 :   PREPARE (pg,
    1600              :            "insert_into_table_close_requests",
    1601              :            "INSERT INTO close_requests"
    1602              :            "(close_request_serial_id"
    1603              :            ",reserve_pub"
    1604              :            ",close_timestamp"
    1605              :            ",reserve_sig"
    1606              :            ",close"
    1607              :            ",close_fee"
    1608              :            ",payto_uri"
    1609              :            ") VALUES "
    1610              :            "($1, $2, $3, $4, $5, $6, $7);");
    1611            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1612              :                                              "insert_into_table_close_requests",
    1613              :                                              params);
    1614              : }
    1615              : 
    1616              : 
    1617              : /**
    1618              :  * Function called with wads_out records to insert into table.
    1619              :  *
    1620              :  * @param pg plugin context
    1621              :  * @param td record to insert
    1622              :  */
    1623              : static enum GNUNET_DB_QueryStatus
    1624            0 : irbt_cb_table_wads_out (struct TALER_EXCHANGEDB_PostgresContext *pg,
    1625              :                         const struct TALER_EXCHANGEDB_TableData *td)
    1626              : {
    1627            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1628            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1629            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.wads_out.wad_id),
    1630            0 :     GNUNET_PQ_query_param_uint64 (&td->details.wads_out.partner_serial_id),
    1631            0 :     TALER_PQ_query_param_amount (
    1632            0 :       pg->conn,
    1633              :       &td->details.wads_out.amount),
    1634            0 :     GNUNET_PQ_query_param_timestamp (&td->details.wads_out.execution_time),
    1635              :     GNUNET_PQ_query_param_end
    1636              :   };
    1637              : 
    1638            0 :   PREPARE (pg,
    1639              :            "insert_into_table_wads_out",
    1640              :            "INSERT INTO wads_out"
    1641              :            "(wad_out_serial_id"
    1642              :            ",wad_id"
    1643              :            ",partner_serial_id"
    1644              :            ",amount"
    1645              :            ",execution_time"
    1646              :            ") VALUES "
    1647              :            "($1, $2, $3, $4, $5);");
    1648            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1649              :                                              "insert_into_table_wads_out",
    1650              :                                              params);
    1651              : }
    1652              : 
    1653              : 
    1654              : /**
    1655              :  * Function called with wads_out_entries records to insert into table.
    1656              :  *
    1657              :  * @param pg plugin context
    1658              :  * @param td record to insert
    1659              :  */
    1660              : static enum GNUNET_DB_QueryStatus
    1661            0 : irbt_cb_table_wads_out_entries (struct TALER_EXCHANGEDB_PostgresContext *pg,
    1662              :                                 const struct TALER_EXCHANGEDB_TableData *td)
    1663              : {
    1664            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1665            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1666            0 :     GNUNET_PQ_query_param_uint64 (
    1667              :       &td->details.wads_out_entries.wad_out_serial_id),
    1668            0 :     GNUNET_PQ_query_param_auto_from_type (
    1669              :       &td->details.wads_out_entries.reserve_pub),
    1670            0 :     GNUNET_PQ_query_param_auto_from_type (
    1671              :       &td->details.wads_out_entries.purse_pub),
    1672            0 :     GNUNET_PQ_query_param_auto_from_type (
    1673              :       &td->details.wads_out_entries.h_contract),
    1674            0 :     GNUNET_PQ_query_param_timestamp (
    1675              :       &td->details.wads_out_entries.purse_expiration),
    1676            0 :     GNUNET_PQ_query_param_timestamp (
    1677              :       &td->details.wads_out_entries.merge_timestamp),
    1678            0 :     TALER_PQ_query_param_amount (
    1679            0 :       pg->conn,
    1680              :       &td->details.wads_out_entries.amount_with_fee),
    1681            0 :     TALER_PQ_query_param_amount (
    1682            0 :       pg->conn,
    1683              :       &td->details.wads_out_entries.wad_fee),
    1684            0 :     TALER_PQ_query_param_amount (
    1685            0 :       pg->conn,
    1686              :       &td->details.wads_out_entries.deposit_fees),
    1687            0 :     GNUNET_PQ_query_param_auto_from_type (
    1688              :       &td->details.wads_out_entries.reserve_sig),
    1689            0 :     GNUNET_PQ_query_param_auto_from_type (
    1690              :       &td->details.wads_out_entries.purse_sig),
    1691              :     GNUNET_PQ_query_param_end
    1692              :   };
    1693              : 
    1694            0 :   PREPARE (pg,
    1695              :            "insert_into_table_wad_out_entries",
    1696              :            "INSERT INTO wad_out_entries"
    1697              :            "(wad_out_entry_serial_id"
    1698              :            ",wad_out_serial_id"
    1699              :            ",reserve_pub"
    1700              :            ",purse_pub"
    1701              :            ",h_contract"
    1702              :            ",purse_expiration"
    1703              :            ",merge_timestamp"
    1704              :            ",amount_with_fee"
    1705              :            ",wad_fee"
    1706              :            ",deposit_fees"
    1707              :            ",reserve_sig"
    1708              :            ",purse_sig"
    1709              :            ") VALUES "
    1710              :            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);");
    1711            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1712              :                                              "insert_into_table_wads_out_entries",
    1713              :                                              params);
    1714              : }
    1715              : 
    1716              : 
    1717              : /**
    1718              :  * Function called with wads_in records to insert into table.
    1719              :  *
    1720              :  * @param pg plugin context
    1721              :  * @param td record to insert
    1722              :  */
    1723              : static enum GNUNET_DB_QueryStatus
    1724            0 : irbt_cb_table_wads_in (struct TALER_EXCHANGEDB_PostgresContext *pg,
    1725              :                        const struct TALER_EXCHANGEDB_TableData *td)
    1726              : {
    1727            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1728            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1729            0 :     GNUNET_PQ_query_param_auto_from_type (&td->details.wads_in.wad_id),
    1730            0 :     GNUNET_PQ_query_param_string (td->details.wads_in.origin_exchange_url),
    1731            0 :     TALER_PQ_query_param_amount (
    1732            0 :       pg->conn,
    1733              :       &td->details.wads_in.amount),
    1734            0 :     GNUNET_PQ_query_param_timestamp (&td->details.wads_in.arrival_time),
    1735              :     GNUNET_PQ_query_param_end
    1736              :   };
    1737              : 
    1738            0 :   PREPARE (pg,
    1739              :            "insert_into_table_wads_in",
    1740              :            "INSERT INTO wads_in"
    1741              :            "(wad_in_serial_id"
    1742              :            ",wad_id"
    1743              :            ",origin_exchange_url"
    1744              :            ",amount"
    1745              :            ",arrival_time"
    1746              :            ") VALUES "
    1747              :            "($1, $2, $3, $4, $5);");
    1748            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1749              :                                              "insert_into_table_wads_in",
    1750              :                                              params);
    1751              : }
    1752              : 
    1753              : 
    1754              : /**
    1755              :  * Function called with wads_in_entries records to insert into table.
    1756              :  *
    1757              :  * @param pg plugin context
    1758              :  * @param td record to insert
    1759              :  */
    1760              : static enum GNUNET_DB_QueryStatus
    1761            0 : irbt_cb_table_wads_in_entries (struct TALER_EXCHANGEDB_PostgresContext *pg,
    1762              :                                const struct TALER_EXCHANGEDB_TableData *td)
    1763              : {
    1764            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1765            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1766            0 :     GNUNET_PQ_query_param_auto_from_type (
    1767              :       &td->details.wads_in_entries.reserve_pub),
    1768            0 :     GNUNET_PQ_query_param_auto_from_type (
    1769              :       &td->details.wads_in_entries.purse_pub),
    1770            0 :     GNUNET_PQ_query_param_auto_from_type (
    1771              :       &td->details.wads_in_entries.h_contract),
    1772            0 :     GNUNET_PQ_query_param_timestamp (
    1773              :       &td->details.wads_in_entries.purse_expiration),
    1774            0 :     GNUNET_PQ_query_param_timestamp (
    1775              :       &td->details.wads_in_entries.merge_timestamp),
    1776            0 :     TALER_PQ_query_param_amount (
    1777            0 :       pg->conn,
    1778              :       &td->details.wads_in_entries.amount_with_fee),
    1779            0 :     TALER_PQ_query_param_amount (
    1780            0 :       pg->conn,
    1781              :       &td->details.wads_in_entries.wad_fee),
    1782            0 :     TALER_PQ_query_param_amount (
    1783            0 :       pg->conn,
    1784              :       &td->details.wads_in_entries.deposit_fees),
    1785            0 :     GNUNET_PQ_query_param_auto_from_type (
    1786              :       &td->details.wads_in_entries.reserve_sig),
    1787            0 :     GNUNET_PQ_query_param_auto_from_type (
    1788              :       &td->details.wads_in_entries.purse_sig),
    1789              :     GNUNET_PQ_query_param_end
    1790              :   };
    1791              : 
    1792            0 :   PREPARE (pg,
    1793              :            "insert_into_table_wad_in_entries",
    1794              :            "INSERT INTO wad_in_entries"
    1795              :            "(wad_in_entry_serial_id"
    1796              :            ",wad_in_serial_id"
    1797              :            ",reserve_pub"
    1798              :            ",purse_pub"
    1799              :            ",h_contract"
    1800              :            ",purse_expiration"
    1801              :            ",merge_timestamp"
    1802              :            ",amount_with_fee"
    1803              :            ",wad_fee"
    1804              :            ",deposit_fees"
    1805              :            ",reserve_sig"
    1806              :            ",purse_sig"
    1807              :            ") VALUES "
    1808              :            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);");
    1809            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1810              :                                              "insert_into_table_wads_in_entries",
    1811              :                                              params);
    1812              : }
    1813              : 
    1814              : 
    1815              : /**
    1816              :  * Function called with profit_drains records to insert into table.
    1817              :  *
    1818              :  * @param pg plugin context
    1819              :  * @param td record to insert
    1820              :  */
    1821              : static enum GNUNET_DB_QueryStatus
    1822            0 : irbt_cb_table_profit_drains (struct TALER_EXCHANGEDB_PostgresContext *pg,
    1823              :                              const struct TALER_EXCHANGEDB_TableData *td)
    1824              : {
    1825            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1826            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1827            0 :     GNUNET_PQ_query_param_auto_from_type (
    1828              :       &td->details.profit_drains.wtid),
    1829            0 :     GNUNET_PQ_query_param_string (
    1830            0 :       td->details.profit_drains.account_section),
    1831            0 :     GNUNET_PQ_query_param_string (
    1832            0 :       td->details.profit_drains.payto_uri.full_payto),
    1833            0 :     GNUNET_PQ_query_param_timestamp (
    1834              :       &td->details.profit_drains.trigger_date),
    1835            0 :     TALER_PQ_query_param_amount (
    1836            0 :       pg->conn,
    1837              :       &td->details.profit_drains.amount),
    1838            0 :     GNUNET_PQ_query_param_auto_from_type (
    1839              :       &td->details.profit_drains.master_sig),
    1840              :     GNUNET_PQ_query_param_end
    1841              :   };
    1842              : 
    1843            0 :   PREPARE (pg,
    1844              :            "insert_into_table_profit_drains",
    1845              :            "INSERT INTO profit_drains"
    1846              :            "(profit_drain_serial_id"
    1847              :            ",wtid"
    1848              :            ",account_section"
    1849              :            ",payto_uri"
    1850              :            ",trigger_date"
    1851              :            ",amount"
    1852              :            ",master_sig"
    1853              :            ") VALUES "
    1854              :            "($1, $2, $3, $4, $5, $6, $7);");
    1855            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1856              :                                              "insert_into_table_profit_drains",
    1857              :                                              params);
    1858              : }
    1859              : 
    1860              : 
    1861              : /**
    1862              :  * Function called with aml_staff records to insert into table.
    1863              :  *
    1864              :  * @param pg plugin context
    1865              :  * @param td record to insert
    1866              :  */
    1867              : static enum GNUNET_DB_QueryStatus
    1868            0 : irbt_cb_table_aml_staff (struct TALER_EXCHANGEDB_PostgresContext *pg,
    1869              :                          const struct TALER_EXCHANGEDB_TableData *td)
    1870              : {
    1871            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1872            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1873            0 :     GNUNET_PQ_query_param_auto_from_type (
    1874              :       &td->details.aml_staff.decider_pub),
    1875            0 :     GNUNET_PQ_query_param_auto_from_type (
    1876              :       &td->details.aml_staff.master_sig),
    1877            0 :     GNUNET_PQ_query_param_string (
    1878            0 :       td->details.aml_staff.decider_name),
    1879            0 :     GNUNET_PQ_query_param_bool (
    1880            0 :       td->details.aml_staff.is_active),
    1881            0 :     GNUNET_PQ_query_param_bool (
    1882            0 :       td->details.aml_staff.read_only),
    1883            0 :     GNUNET_PQ_query_param_timestamp (
    1884              :       &td->details.aml_staff.last_change),
    1885              :     GNUNET_PQ_query_param_end
    1886              :   };
    1887              : 
    1888            0 :   PREPARE (pg,
    1889              :            "insert_into_table_aml_staff",
    1890              :            "INSERT INTO aml_staff"
    1891              :            "(aml_staff_uuid"
    1892              :            ",decider_pub"
    1893              :            ",master_sig"
    1894              :            ",decider_name"
    1895              :            ",is_active"
    1896              :            ",read_only"
    1897              :            ",last_change"
    1898              :            ") VALUES "
    1899              :            "($1, $2, $3, $4, $5, $6, $7);");
    1900            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1901              :                                              "insert_into_table_aml_staff",
    1902              :                                              params);
    1903              : }
    1904              : 
    1905              : 
    1906              : /**
    1907              :  * Function called with kyc_attributes records to insert into table.
    1908              :  *
    1909              :  * @param pg plugin context
    1910              :  * @param td record to insert
    1911              :  */
    1912              : static enum GNUNET_DB_QueryStatus
    1913            0 : irbt_cb_table_kyc_attributes (struct TALER_EXCHANGEDB_PostgresContext *pg,
    1914              :                               const struct TALER_EXCHANGEDB_TableData *td)
    1915              : {
    1916            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1917            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1918            0 :     GNUNET_PQ_query_param_auto_from_type (
    1919              :       &td->details.kyc_attributes.h_payto),
    1920            0 :     GNUNET_PQ_query_param_uint64 (
    1921              :       &td->details.kyc_attributes.legitimization_serial),
    1922            0 :     GNUNET_PQ_query_param_timestamp (
    1923              :       &td->details.kyc_attributes.collection_time),
    1924            0 :     GNUNET_PQ_query_param_timestamp (
    1925              :       &td->details.kyc_attributes.expiration_time),
    1926            0 :     GNUNET_PQ_query_param_uint64 (
    1927              :       &td->details.kyc_attributes.trigger_outcome_serial),
    1928            0 :     GNUNET_PQ_query_param_fixed_size (
    1929            0 :       &td->details.kyc_attributes.encrypted_attributes,
    1930            0 :       td->details.kyc_attributes.encrypted_attributes_size),
    1931              :     GNUNET_PQ_query_param_end
    1932              :   };
    1933              : 
    1934            0 :   PREPARE (pg,
    1935              :            "insert_into_table_kyc_attributes",
    1936              :            "INSERT INTO kyc_attributes"
    1937              :            "(kyc_attributes_serial_id"
    1938              :            ",h_payto"
    1939              :            ",legitimization_serial"
    1940              :            ",collection_time"
    1941              :            ",expiration_time"
    1942              :            ",trigger_outcome_serial"
    1943              :            ",encrypted_attributes"
    1944              :            ") VALUES "
    1945              :            "($1, $2, $3, $4, $5, $6, $7);");
    1946            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1947              :                                              "insert_into_table_kyc_attributes",
    1948              :                                              params);
    1949              : }
    1950              : 
    1951              : 
    1952              : /**
    1953              :  * Function called with aml_history records to insert into table.
    1954              :  *
    1955              :  * @param pg plugin context
    1956              :  * @param td record to insert
    1957              :  */
    1958              : static enum GNUNET_DB_QueryStatus
    1959            0 : irbt_cb_table_aml_history (struct TALER_EXCHANGEDB_PostgresContext *pg,
    1960              :                            const struct TALER_EXCHANGEDB_TableData *td)
    1961              : {
    1962            0 :   struct GNUNET_PQ_QueryParam params[] = {
    1963            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    1964            0 :     GNUNET_PQ_query_param_auto_from_type (
    1965              :       &td->details.aml_history.h_payto),
    1966            0 :     GNUNET_PQ_query_param_uint64 (
    1967              :       &td->details.aml_history.outcome_serial_id),
    1968            0 :     GNUNET_PQ_query_param_string (
    1969            0 :       td->details.aml_history.justification),
    1970            0 :     GNUNET_PQ_query_param_auto_from_type (
    1971              :       &td->details.aml_history.decider_pub),
    1972            0 :     GNUNET_PQ_query_param_auto_from_type (
    1973              :       &td->details.aml_history.decider_sig),
    1974              :     GNUNET_PQ_query_param_end
    1975              :   };
    1976              : 
    1977            0 :   PREPARE (pg,
    1978              :            "insert_into_table_aml_history",
    1979              :            "INSERT INTO aml_history"
    1980              :            "(aml_history_serial_id"
    1981              :            ",h_payto"
    1982              :            ",outcome_serial_id"
    1983              :            ",justification"
    1984              :            ",decider_pub"
    1985              :            ",decider_sig"
    1986              :            ") VALUES "
    1987              :            "($1, $2, $3, $4, $5, $6);");
    1988            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    1989              :                                              "insert_into_table_aml_history",
    1990              :                                              params);
    1991              : }
    1992              : 
    1993              : 
    1994              : /**
    1995              :  * Function called with kyc_event records to insert into table.
    1996              :  *
    1997              :  * @param pg plugin context
    1998              :  * @param td record to insert
    1999              :  */
    2000              : static enum GNUNET_DB_QueryStatus
    2001            0 : irbt_cb_table_kyc_events (struct TALER_EXCHANGEDB_PostgresContext *pg,
    2002              :                           const struct TALER_EXCHANGEDB_TableData *td)
    2003              : {
    2004            0 :   struct GNUNET_PQ_QueryParam params[] = {
    2005            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    2006            0 :     GNUNET_PQ_query_param_timestamp (
    2007              :       &td->details.kyc_events.event_timestamp),
    2008            0 :     GNUNET_PQ_query_param_string (
    2009            0 :       td->details.kyc_events.event_type),
    2010              :     GNUNET_PQ_query_param_end
    2011              :   };
    2012              : 
    2013            0 :   PREPARE (pg,
    2014              :            "insert_into_table_kyc_events",
    2015              :            "INSERT INTO kyc_events"
    2016              :            "(kyc_event_serial_id"
    2017              :            ",event_timestamp"
    2018              :            ",event_type"
    2019              :            ") VALUES "
    2020              :            "($1, $2, $3);");
    2021            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    2022              :                                              "insert_into_table_kyc_events",
    2023              :                                              params);
    2024              : }
    2025              : 
    2026              : 
    2027              : /**
    2028              :  * Function called with purse_deletion records to insert into table.
    2029              :  *
    2030              :  * @param pg plugin context
    2031              :  * @param td record to insert
    2032              :  */
    2033              : static enum GNUNET_DB_QueryStatus
    2034            0 : irbt_cb_table_purse_deletion (struct TALER_EXCHANGEDB_PostgresContext *pg,
    2035              :                               const struct TALER_EXCHANGEDB_TableData *td)
    2036              : {
    2037            0 :   struct GNUNET_PQ_QueryParam params[] = {
    2038            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    2039            0 :     GNUNET_PQ_query_param_auto_from_type (
    2040              :       &td->details.purse_deletion.purse_pub),
    2041            0 :     GNUNET_PQ_query_param_auto_from_type (
    2042              :       &td->details.purse_deletion.purse_sig),
    2043              :     GNUNET_PQ_query_param_end
    2044              :   };
    2045              : 
    2046            0 :   PREPARE (pg,
    2047              :            "insert_into_table_purse_deletion",
    2048              :            "INSERT INTO purse_deletion"
    2049              :            "(purse_deletion_serial_id"
    2050              :            ",purse_pub"
    2051              :            ",purse_sig"
    2052              :            ") VALUES "
    2053              :            "($1, $2, $3);");
    2054            0 :   return GNUNET_PQ_eval_prepared_non_select (pg->conn,
    2055              :                                              "insert_into_table_purse_deletion",
    2056              :                                              params);
    2057              : }
    2058              : 
    2059              : 
    2060              : /**
    2061              :  * Function called with withdraw records to insert into table.
    2062              :  *
    2063              :  * @param pg plugin context
    2064              :  * @param td record to insert
    2065              :  */
    2066              : static enum GNUNET_DB_QueryStatus
    2067            0 : irbt_cb_table_withdraw (
    2068              :   struct TALER_EXCHANGEDB_PostgresContext *pg,
    2069              :   const struct TALER_EXCHANGEDB_TableData *td)
    2070              : {
    2071            0 :   struct GNUNET_PQ_QueryParam params[] = {
    2072            0 :     GNUNET_PQ_query_param_uint64 (&td->serial),
    2073            0 :     GNUNET_PQ_query_param_auto_from_type (
    2074              :       &td->details.withdraw.planchets_h),
    2075            0 :     GNUNET_PQ_query_param_timestamp (
    2076              :       &td->details.withdraw.execution_date),
    2077            0 :     TALER_PQ_query_param_amount (
    2078            0 :       pg->conn,
    2079              :       &td->details.withdraw.amount_with_fee),
    2080            0 :     GNUNET_PQ_query_param_auto_from_type (
    2081              :       &td->details.withdraw.reserve_pub),
    2082            0 :     GNUNET_PQ_query_param_auto_from_type (
    2083              :       &td->details.withdraw.reserve_sig),
    2084            0 :     td->details.withdraw.age_proof_required
    2085            0 :     ? GNUNET_PQ_query_param_uint16 (
    2086              :       &td->details.withdraw.max_age)
    2087            0 :     : GNUNET_PQ_query_param_null (),
    2088            0 :     td->details.withdraw.age_proof_required
    2089            0 :     ? GNUNET_PQ_query_param_uint16 (
    2090              :       &td->details.withdraw.noreveal_index)
    2091            0 :     : GNUNET_PQ_query_param_null (),
    2092            0 :     td->details.withdraw.age_proof_required
    2093            0 :     ? GNUNET_PQ_query_param_auto_from_type (
    2094              :       &td->details.withdraw.selected_h)
    2095            0 :     : GNUNET_PQ_query_param_null (),
    2096            0 :     td->details.withdraw.no_blinding_seed
    2097            0 :     ? GNUNET_PQ_query_param_null ()
    2098            0 :     : GNUNET_PQ_query_param_auto_from_type (
    2099              :       &td->details.withdraw.blinding_seed),
    2100            0 :     (0 < td->details.withdraw.num_cs_r_values)
    2101            0 :     ? TALER_PQ_query_param_array_cs_r_pub (
    2102            0 :       td->details.withdraw.num_cs_r_values,
    2103            0 :       td->details.withdraw.cs_r_values,
    2104              :       pg->conn)
    2105            0 :     : GNUNET_PQ_query_param_null (),
    2106            0 :     (0 < td->details.withdraw.num_cs_r_values)
    2107            0 :     ? GNUNET_PQ_query_param_uint64 (
    2108              :       &td->details.withdraw.cs_r_choices)
    2109            0 :     : GNUNET_PQ_query_param_null (),
    2110            0 :     GNUNET_PQ_query_param_array_uint64 (
    2111            0 :       td->details.withdraw.num_coins,
    2112            0 :       td->details.withdraw.denom_serials,
    2113              :       pg->conn),
    2114            0 :     TALER_PQ_query_param_array_blinded_denom_sig (
    2115            0 :       td->details.withdraw.num_coins,
    2116            0 :       td->details.withdraw.denom_sigs,
    2117              :       pg->conn),
    2118              :     GNUNET_PQ_query_param_end
    2119              :   };
    2120              :   enum GNUNET_DB_QueryStatus qs;
    2121              : 
    2122            0 :   PREPARE (pg,
    2123              :            "insert_into_table_withdraw",
    2124              :            "INSERT INTO withdraw"
    2125              :            "(withdraw_id"
    2126              :            ",planchets_h"
    2127              :            ",execution_date"
    2128              :            ",amount_with_fee"
    2129              :            ",reserve_pub"
    2130              :            ",reserve_sig"
    2131              :            ",max_age"
    2132              :            ",noreveal_index"
    2133              :            ",selected_h"
    2134              :            ",blinding_seed"
    2135              :            ",cs_r_values"
    2136              :            ",cs_r_choices"
    2137              :            ",denom_serials"
    2138              :            ",denom_sigs"
    2139              :            ") VALUES "
    2140              :            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14);");
    2141            0 :   qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
    2142              :                                            "insert_into_table_withdraw",
    2143              :                                            params);
    2144            0 :   GNUNET_PQ_cleanup_query_params_closures (params);
    2145            0 :   return qs;
    2146              : }
    2147              : 
    2148              : 
    2149              : enum GNUNET_DB_QueryStatus
    2150            0 : TALER_EXCHANGEDB_insert_records_by_table (struct
    2151              :                                           TALER_EXCHANGEDB_PostgresContext *pg,
    2152              :                                           const struct
    2153              :                                           TALER_EXCHANGEDB_TableData *td)
    2154              : {
    2155            0 :   InsertRecordCallback rh = NULL;
    2156              : 
    2157            0 :   switch (td->table)
    2158              :   {
    2159            0 :   case TALER_EXCHANGEDB_RT_DENOMINATIONS:
    2160            0 :     rh = &irbt_cb_table_denominations;
    2161            0 :     break;
    2162            0 :   case TALER_EXCHANGEDB_RT_DENOMINATION_REVOCATIONS:
    2163            0 :     rh = &irbt_cb_table_denomination_revocations;
    2164            0 :     break;
    2165            0 :   case TALER_EXCHANGEDB_RT_WIRE_TARGETS:
    2166            0 :     rh = &irbt_cb_table_wire_targets;
    2167            0 :     break;
    2168            0 :   case TALER_EXCHANGEDB_RT_KYC_TARGETS:
    2169            0 :     rh = &irbt_cb_table_kyc_targets;
    2170            0 :     break;
    2171            0 :   case TALER_EXCHANGEDB_RT_RESERVES:
    2172            0 :     rh = &irbt_cb_table_reserves;
    2173            0 :     break;
    2174            0 :   case TALER_EXCHANGEDB_RT_RESERVES_IN:
    2175            0 :     rh = &irbt_cb_table_reserves_in;
    2176            0 :     break;
    2177            0 :   case TALER_EXCHANGEDB_RT_KYCAUTHS_IN:
    2178            0 :     rh = &irbt_cb_table_kycauths_in;
    2179            0 :     break;
    2180            0 :   case TALER_EXCHANGEDB_RT_RESERVES_CLOSE:
    2181            0 :     rh = &irbt_cb_table_reserves_close;
    2182            0 :     break;
    2183            0 :   case TALER_EXCHANGEDB_RT_RESERVES_OPEN_REQUESTS:
    2184            0 :     rh = &irbt_cb_table_reserves_open_requests;
    2185            0 :     break;
    2186            0 :   case TALER_EXCHANGEDB_RT_RESERVES_OPEN_DEPOSITS:
    2187            0 :     rh = &irbt_cb_table_reserves_open_deposits;
    2188            0 :     break;
    2189            0 :   case TALER_EXCHANGEDB_RT_AUDITORS:
    2190            0 :     rh = &irbt_cb_table_auditors;
    2191            0 :     break;
    2192            0 :   case TALER_EXCHANGEDB_RT_AUDITOR_DENOM_SIGS:
    2193            0 :     rh = &irbt_cb_table_auditor_denom_sigs;
    2194            0 :     break;
    2195            0 :   case TALER_EXCHANGEDB_RT_EXCHANGE_SIGN_KEYS:
    2196            0 :     rh = &irbt_cb_table_exchange_sign_keys;
    2197            0 :     break;
    2198            0 :   case TALER_EXCHANGEDB_RT_SIGNKEY_REVOCATIONS:
    2199            0 :     rh = &irbt_cb_table_signkey_revocations;
    2200            0 :     break;
    2201            0 :   case TALER_EXCHANGEDB_RT_KNOWN_COINS:
    2202            0 :     rh = &irbt_cb_table_known_coins;
    2203            0 :     break;
    2204            0 :   case TALER_EXCHANGEDB_RT_REFRESH:
    2205            0 :     rh = &irbt_cb_table_refresh;
    2206            0 :     break;
    2207            0 :   case TALER_EXCHANGEDB_RT_BATCH_DEPOSITS:
    2208            0 :     rh = &irbt_cb_table_batch_deposits;
    2209            0 :     break;
    2210            0 :   case TALER_EXCHANGEDB_RT_COIN_DEPOSITS:
    2211            0 :     rh = &irbt_cb_table_coin_deposits;
    2212            0 :     break;
    2213            0 :   case TALER_EXCHANGEDB_RT_REFUNDS:
    2214            0 :     rh = &irbt_cb_table_refunds;
    2215            0 :     break;
    2216            0 :   case TALER_EXCHANGEDB_RT_WIRE_OUT:
    2217            0 :     rh = &irbt_cb_table_wire_out;
    2218            0 :     break;
    2219            0 :   case TALER_EXCHANGEDB_RT_AGGREGATION_TRACKING:
    2220            0 :     rh = &irbt_cb_table_aggregation_tracking;
    2221            0 :     break;
    2222            0 :   case TALER_EXCHANGEDB_RT_WIRE_FEE:
    2223            0 :     rh = &irbt_cb_table_wire_fee;
    2224            0 :     break;
    2225            0 :   case TALER_EXCHANGEDB_RT_GLOBAL_FEE:
    2226            0 :     rh = &irbt_cb_table_global_fee;
    2227            0 :     break;
    2228            0 :   case TALER_EXCHANGEDB_RT_RECOUP:
    2229            0 :     rh = &irbt_cb_table_recoup;
    2230            0 :     break;
    2231            0 :   case TALER_EXCHANGEDB_RT_RECOUP_REFRESH:
    2232            0 :     rh = &irbt_cb_table_recoup_refresh;
    2233            0 :     break;
    2234            0 :   case TALER_EXCHANGEDB_RT_PURSE_REQUESTS:
    2235            0 :     rh = &irbt_cb_table_purse_requests;
    2236            0 :     break;
    2237            0 :   case TALER_EXCHANGEDB_RT_PURSE_DECISION:
    2238            0 :     rh = &irbt_cb_table_purse_decision;
    2239            0 :     break;
    2240            0 :   case TALER_EXCHANGEDB_RT_PURSE_MERGES:
    2241            0 :     rh = &irbt_cb_table_purse_merges;
    2242            0 :     break;
    2243            0 :   case TALER_EXCHANGEDB_RT_PURSE_DEPOSITS:
    2244            0 :     rh = &irbt_cb_table_purse_deposits;
    2245            0 :     break;
    2246            0 :   case TALER_EXCHANGEDB_RT_ACCOUNT_MERGES:
    2247            0 :     rh = &irbt_cb_table_account_mergers;
    2248            0 :     break;
    2249            0 :   case TALER_EXCHANGEDB_RT_HISTORY_REQUESTS:
    2250            0 :     rh = &irbt_cb_table_history_requests;
    2251            0 :     break;
    2252            0 :   case TALER_EXCHANGEDB_RT_CLOSE_REQUESTS:
    2253            0 :     rh = &irbt_cb_table_close_requests;
    2254            0 :     break;
    2255            0 :   case TALER_EXCHANGEDB_RT_WADS_OUT:
    2256            0 :     rh = &irbt_cb_table_wads_out;
    2257            0 :     break;
    2258            0 :   case TALER_EXCHANGEDB_RT_WADS_OUT_ENTRIES:
    2259            0 :     rh = &irbt_cb_table_wads_out_entries;
    2260            0 :     break;
    2261            0 :   case TALER_EXCHANGEDB_RT_WADS_IN:
    2262            0 :     rh = &irbt_cb_table_wads_in;
    2263            0 :     break;
    2264            0 :   case TALER_EXCHANGEDB_RT_WADS_IN_ENTRIES:
    2265            0 :     rh = &irbt_cb_table_wads_in_entries;
    2266            0 :     break;
    2267            0 :   case TALER_EXCHANGEDB_RT_PROFIT_DRAINS:
    2268            0 :     rh = &irbt_cb_table_profit_drains;
    2269            0 :     break;
    2270            0 :   case TALER_EXCHANGEDB_RT_AML_STAFF:
    2271            0 :     rh = &irbt_cb_table_aml_staff;
    2272            0 :     break;
    2273            0 :   case TALER_EXCHANGEDB_RT_PURSE_DELETION:
    2274            0 :     rh = &irbt_cb_table_purse_deletion;
    2275            0 :     break;
    2276            0 :   case TALER_EXCHANGEDB_RT_WITHDRAW:
    2277            0 :     rh = &irbt_cb_table_withdraw;
    2278            0 :     break;
    2279            0 :   case TALER_EXCHANGEDB_RT_LEGITIMIZATION_MEASURES:
    2280            0 :     rh = &irbt_cb_table_legitimization_measures;
    2281            0 :     break;
    2282            0 :   case TALER_EXCHANGEDB_RT_LEGITIMIZATION_OUTCOMES:
    2283            0 :     rh = &irbt_cb_table_legitimization_outcomes;
    2284            0 :     break;
    2285            0 :   case TALER_EXCHANGEDB_RT_LEGITIMIZATION_PROCESSES:
    2286            0 :     rh = &irbt_cb_table_legitimization_processes;
    2287            0 :     break;
    2288            0 :   case TALER_EXCHANGEDB_RT_KYC_ATTRIBUTES:
    2289            0 :     rh = &irbt_cb_table_kyc_attributes;
    2290            0 :     break;
    2291            0 :   case TALER_EXCHANGEDB_RT_AML_HISTORY:
    2292            0 :     rh = &irbt_cb_table_aml_history;
    2293            0 :     break;
    2294            0 :   case TALER_EXCHANGEDB_RT_KYC_EVENTS:
    2295            0 :     rh = &irbt_cb_table_kyc_events;
    2296            0 :     break;
    2297              :   }
    2298            0 :   if (NULL == rh)
    2299              :   {
    2300            0 :     GNUNET_break (0);
    2301            0 :     return GNUNET_DB_STATUS_HARD_ERROR;
    2302              :   }
    2303            0 :   return rh (pg,
    2304              :              td);
    2305              : }
    2306              : 
    2307              : 
    2308              : /* end of insert_records_by_table.c */
        

Generated by: LCOV version 2.0-1