LCOV - code coverage report
Current view: top level - exchangedb - lrbt_callbacks.c (source / functions) Hit Total Coverage
Test: GNU Taler coverage report Lines: 239 408 58.6 %
Date: 2021-04-12 06:08:44 Functions: 14 21 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    This file is part of GNUnet
       3             :    Copyright (C) 2020 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/lrbt_callbacks.c
      22             :  * @brief callbacks used by postgres_lookup_records_by_table, to be
      23             :  *        inlined into the plugin
      24             :  * @author Christian Grothoff
      25             :  */
      26             : 
      27             : 
      28             : /**
      29             :  * Function called with denominations table entries.
      30             :  *
      31             :  * @param cls closure
      32             :  * @param result the postgres result
      33             :  * @param num_result the number of results in @a result
      34             :  */
      35             : static void
      36           1 : lrbt_cb_table_denominations (void *cls,
      37             :                              PGresult *result,
      38             :                              unsigned int num_results)
      39             : {
      40           1 :   struct LookupRecordsByTableContext *ctx = cls;
      41           1 :   struct PostgresClosure *pg = ctx->pg;
      42           1 :   struct TALER_EXCHANGEDB_TableData td = {
      43             :     .table = TALER_EXCHANGEDB_RT_DENOMINATIONS
      44             :   };
      45             : 
      46         425 :   for (unsigned int i = 0; i<num_results; i++)
      47             :   {
      48         424 :     struct GNUNET_PQ_ResultSpec rs[] = {
      49         424 :       GNUNET_PQ_result_spec_uint64 ("serial",
      50             :                                     &td.serial),
      51         424 :       GNUNET_PQ_result_spec_rsa_public_key (
      52             :         "denom_pub",
      53             :         &td.details.denominations.denom_pub.rsa_public_key),
      54         424 :       GNUNET_PQ_result_spec_auto_from_type ("master_sig",
      55             :                                             &td.details.denominations.master_sig),
      56         424 :       TALER_PQ_result_spec_absolute_time ("valid_from",
      57             :                                           &td.details.denominations.valid_from),
      58         424 :       TALER_PQ_result_spec_absolute_time ("expire_withdraw",
      59             :                                           &td.details.denominations.
      60             :                                           expire_withdraw),
      61         424 :       TALER_PQ_result_spec_absolute_time ("expire_deposit",
      62             :                                           &td.details.denominations.
      63             :                                           expire_deposit),
      64         424 :       TALER_PQ_result_spec_absolute_time ("expire_legal",
      65             :                                           &td.details.denominations.expire_legal),
      66         424 :       TALER_PQ_RESULT_SPEC_AMOUNT ("coin",
      67             :                                    &td.details.denominations.coin),
      68         424 :       TALER_PQ_RESULT_SPEC_AMOUNT ("fee_withdraw",
      69             :                                    &td.details.denominations.fee_withdraw),
      70         424 :       TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit",
      71             :                                    &td.details.denominations.fee_deposit),
      72         424 :       TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refresh",
      73             :                                    &td.details.denominations.fee_refresh),
      74         424 :       TALER_PQ_RESULT_SPEC_AMOUNT ("fee_refund",
      75             :                                    &td.details.denominations.fee_refund),
      76             :       GNUNET_PQ_result_spec_end
      77             :     };
      78             : 
      79         424 :     if (GNUNET_OK !=
      80         424 :         GNUNET_PQ_extract_result (result,
      81             :                                   rs,
      82             :                                   i))
      83             :     {
      84           0 :       GNUNET_break (0);
      85           0 :       ctx->error = true;
      86           0 :       return;
      87             :     }
      88         424 :     ctx->cb (ctx->cb_cls,
      89             :              &td);
      90         424 :     GNUNET_PQ_cleanup_result (rs);
      91             :   }
      92             : }
      93             : 
      94             : 
      95             : /**
      96             :  * Function called with denomination_revocations table entries.
      97             :  *
      98             :  * @param cls closure
      99             :  * @param result the postgres result
     100             :  * @param num_result the number of results in @a result
     101             :  */
     102             : static void
     103           0 : lrbt_cb_table_denomination_revocations (void *cls,
     104             :                                         PGresult *result,
     105             :                                         unsigned int num_results)
     106             : {
     107           0 :   struct LookupRecordsByTableContext *ctx = cls;
     108           0 :   struct TALER_EXCHANGEDB_TableData td = {
     109             :     .table = TALER_EXCHANGEDB_RT_DENOMINATION_REVOCATIONS
     110             :   };
     111             : 
     112           0 :   for (unsigned int i = 0; i<num_results; i++)
     113             :   {
     114           0 :     struct GNUNET_PQ_ResultSpec rs[] = {
     115           0 :       GNUNET_PQ_result_spec_uint64 ("serial",
     116             :                                     &td.serial),
     117           0 :       GNUNET_PQ_result_spec_uint64 (
     118             :         "denominations_serial",
     119             :         &td.details.denomination_revocations.denominations_serial),
     120           0 :       GNUNET_PQ_result_spec_auto_from_type (
     121             :         "master_sig",
     122             :         &td.details.denomination_revocations.master_sig),
     123             :       GNUNET_PQ_result_spec_end
     124             :     };
     125             : 
     126           0 :     if (GNUNET_OK !=
     127           0 :         GNUNET_PQ_extract_result (result,
     128             :                                   rs,
     129             :                                   i))
     130             :     {
     131           0 :       GNUNET_break (0);
     132           0 :       ctx->error = true;
     133           0 :       return;
     134             :     }
     135           0 :     ctx->cb (ctx->cb_cls,
     136             :              &td);
     137           0 :     GNUNET_PQ_cleanup_result (rs);
     138             :   }
     139             : }
     140             : 
     141             : 
     142             : /**
     143             :  * Function called with reserves table entries.
     144             :  *
     145             :  * @param cls closure
     146             :  * @param result the postgres result
     147             :  * @param num_result the number of results in @a result
     148             :  */
     149             : static void
     150           1 : lrbt_cb_table_reserves (void *cls,
     151             :                         PGresult *result,
     152             :                         unsigned int num_results)
     153             : {
     154           1 :   struct LookupRecordsByTableContext *ctx = cls;
     155           1 :   struct PostgresClosure *pg = ctx->pg;
     156           1 :   struct TALER_EXCHANGEDB_TableData td = {
     157             :     .table = TALER_EXCHANGEDB_RT_RESERVES
     158             :   };
     159             : 
     160           3 :   for (unsigned int i = 0; i<num_results; i++)
     161             :   {
     162           2 :     struct GNUNET_PQ_ResultSpec rs[] = {
     163           2 :       GNUNET_PQ_result_spec_uint64 ("serial",
     164             :                                     &td.serial),
     165           2 :       GNUNET_PQ_result_spec_auto_from_type ("reserve_pub",
     166             :                                             &td.details.reserves.reserve_pub),
     167           2 :       GNUNET_PQ_result_spec_string ("account_details",
     168             :                                     &td.details.reserves.account_details),
     169           2 :       TALER_PQ_RESULT_SPEC_AMOUNT ("current_balance",
     170             :                                    &td.details.reserves.current_balance),
     171           2 :       TALER_PQ_result_spec_absolute_time ("expiration_date",
     172             :                                           &td.details.reserves.expiration_date),
     173           2 :       TALER_PQ_result_spec_absolute_time ("gc_date",
     174             :                                           &td.details.reserves.gc_date),
     175             :       GNUNET_PQ_result_spec_end
     176             :     };
     177             : 
     178           2 :     if (GNUNET_OK !=
     179           2 :         GNUNET_PQ_extract_result (result,
     180             :                                   rs,
     181             :                                   i))
     182             :     {
     183           0 :       GNUNET_break (0);
     184           0 :       ctx->error = true;
     185           0 :       return;
     186             :     }
     187           2 :     ctx->cb (ctx->cb_cls,
     188             :              &td);
     189           2 :     GNUNET_PQ_cleanup_result (rs);
     190             :   }
     191             : }
     192             : 
     193             : 
     194             : /**
     195             :  * Function called with reserves_in table entries.
     196             :  *
     197             :  * @param cls closure
     198             :  * @param result the postgres result
     199             :  * @param num_result the number of results in @a result
     200             :  */
     201             : static void
     202           1 : lrbt_cb_table_reserves_in (void *cls,
     203             :                            PGresult *result,
     204             :                            unsigned int num_results)
     205             : {
     206           1 :   struct LookupRecordsByTableContext *ctx = cls;
     207           1 :   struct PostgresClosure *pg = ctx->pg;
     208           1 :   struct TALER_EXCHANGEDB_TableData td = {
     209             :     .table = TALER_EXCHANGEDB_RT_RESERVES_IN
     210             :   };
     211             : 
     212           3 :   for (unsigned int i = 0; i<num_results; i++)
     213             :   {
     214           2 :     struct GNUNET_PQ_ResultSpec rs[] = {
     215           2 :       GNUNET_PQ_result_spec_uint64 ("serial",
     216             :                                     &td.serial),
     217           2 :       GNUNET_PQ_result_spec_uint64 ("wire_reference",
     218             :                                     &td.details.reserves_in.wire_reference),
     219           2 :       TALER_PQ_RESULT_SPEC_AMOUNT ("credit",
     220             :                                    &td.details.reserves_in.credit),
     221           2 :       GNUNET_PQ_result_spec_string ("sender_account_details",
     222             :                                     &td.details.reserves_in.
     223             :                                     sender_account_details),
     224           2 :       GNUNET_PQ_result_spec_string ("exchange_account_section",
     225             :                                     &td.details.reserves_in.
     226             :                                     exchange_account_section),
     227           2 :       TALER_PQ_result_spec_absolute_time ("execution_date",
     228             :                                           &td.details.reserves_in.execution_date),
     229           2 :       GNUNET_PQ_result_spec_uint64 ("reserve_uuid",
     230             :                                     &td.details.reserves_in.reserve_uuid),
     231             :       GNUNET_PQ_result_spec_end
     232             :     };
     233             : 
     234           2 :     if (GNUNET_OK !=
     235           2 :         GNUNET_PQ_extract_result (result,
     236             :                                   rs,
     237             :                                   i))
     238             :     {
     239           0 :       GNUNET_break (0);
     240           0 :       ctx->error = true;
     241           0 :       return;
     242             :     }
     243           2 :     ctx->cb (ctx->cb_cls,
     244             :              &td);
     245           2 :     GNUNET_PQ_cleanup_result (rs);
     246             :   }
     247             : }
     248             : 
     249             : 
     250             : /**
     251             :  * Function called with reserves_close table entries.
     252             :  *
     253             :  * @param cls closure
     254             :  * @param result the postgres result
     255             :  * @param num_result the number of results in @a result
     256             :  */
     257             : static void
     258           0 : lrbt_cb_table_reserves_close (void *cls,
     259             :                               PGresult *result,
     260             :                               unsigned int num_results)
     261             : {
     262           0 :   struct LookupRecordsByTableContext *ctx = cls;
     263           0 :   struct PostgresClosure *pg = ctx->pg;
     264           0 :   struct TALER_EXCHANGEDB_TableData td = {
     265             :     .table = TALER_EXCHANGEDB_RT_RESERVES_CLOSE
     266             :   };
     267             : 
     268           0 :   for (unsigned int i = 0; i<num_results; i++)
     269             :   {
     270           0 :     struct GNUNET_PQ_ResultSpec rs[] = {
     271           0 :       GNUNET_PQ_result_spec_uint64 ("serial",
     272             :                                     &td.serial),
     273           0 :       TALER_PQ_result_spec_absolute_time (
     274             :         "execution_date",
     275             :         &td.details.reserves_close.execution_date),
     276           0 :       GNUNET_PQ_result_spec_auto_from_type ("wtid",
     277             :                                             &td.details.reserves_close.wtid),
     278           0 :       GNUNET_PQ_result_spec_string (
     279             :         "receiver_account",
     280             :         &td.details.reserves_close.receiver_account),
     281           0 :       TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
     282             :                                    &td.details.reserves_close.amount),
     283           0 :       TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee",
     284             :                                    &td.details.reserves_close.closing_fee),
     285           0 :       GNUNET_PQ_result_spec_uint64 ("reserve_uuid",
     286             :                                     &td.details.reserves_close.reserve_uuid),
     287             : 
     288             :       GNUNET_PQ_result_spec_end
     289             :     };
     290             : 
     291           0 :     if (GNUNET_OK !=
     292           0 :         GNUNET_PQ_extract_result (result,
     293             :                                   rs,
     294             :                                   i))
     295             :     {
     296           0 :       GNUNET_break (0);
     297           0 :       ctx->error = true;
     298           0 :       return;
     299             :     }
     300           0 :     ctx->cb (ctx->cb_cls,
     301             :              &td);
     302           0 :     GNUNET_PQ_cleanup_result (rs);
     303             :   }
     304             : }
     305             : 
     306             : 
     307             : /**
     308             :  * Function called with reserves_out table entries.
     309             :  *
     310             :  * @param cls closure
     311             :  * @param result the postgres result
     312             :  * @param num_result the number of results in @a result
     313             :  */
     314             : static void
     315           1 : lrbt_cb_table_reserves_out (void *cls,
     316             :                             PGresult *result,
     317             :                             unsigned int num_results)
     318             : {
     319           1 :   struct LookupRecordsByTableContext *ctx = cls;
     320           1 :   struct PostgresClosure *pg = ctx->pg;
     321           1 :   struct TALER_EXCHANGEDB_TableData td = {
     322             :     .table = TALER_EXCHANGEDB_RT_RESERVES_OUT
     323             :   };
     324             : 
     325          27 :   for (unsigned int i = 0; i<num_results; i++)
     326             :   {
     327          26 :     struct GNUNET_PQ_ResultSpec rs[] = {
     328          26 :       GNUNET_PQ_result_spec_uint64 ("serial",
     329             :                                     &td.serial),
     330          26 :       GNUNET_PQ_result_spec_auto_from_type ("h_blind_ev",
     331             :                                             &td.details.reserves_out.h_blind_ev),
     332          26 :       GNUNET_PQ_result_spec_rsa_signature (
     333             :         "denom_sig",
     334             :         &td.details.reserves_out.denom_sig.rsa_signature),
     335          26 :       GNUNET_PQ_result_spec_auto_from_type ("reserve_sig",
     336             :                                             &td.details.reserves_out.reserve_sig),
     337          26 :       TALER_PQ_result_spec_absolute_time (
     338             :         "execution_date",
     339             :         &td.details.reserves_out.execution_date),
     340          26 :       TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee",
     341             :                                    &td.details.reserves_out.amount_with_fee),
     342          26 :       GNUNET_PQ_result_spec_uint64 ("reserve_uuid",
     343             :                                     &td.details.reserves_out.reserve_uuid),
     344          26 :       GNUNET_PQ_result_spec_uint64 ("denominations_serial",
     345             :                                     &td.details.reserves_out.
     346             :                                     denominations_serial),
     347             :       GNUNET_PQ_result_spec_end
     348             :     };
     349             : 
     350          26 :     if (GNUNET_OK !=
     351          26 :         GNUNET_PQ_extract_result (result,
     352             :                                   rs,
     353             :                                   i))
     354             :     {
     355           0 :       GNUNET_break (0);
     356           0 :       ctx->error = true;
     357           0 :       return;
     358             :     }
     359          26 :     ctx->cb (ctx->cb_cls,
     360             :              &td);
     361          26 :     GNUNET_PQ_cleanup_result (rs);
     362             :   }
     363             : }
     364             : 
     365             : 
     366             : /**
     367             :  * Function called with auditors table entries.
     368             :  *
     369             :  * @param cls closure
     370             :  * @param result the postgres result
     371             :  * @param num_result the number of results in @a result
     372             :  */
     373             : static void
     374           1 : lrbt_cb_table_auditors (void *cls,
     375             :                         PGresult *result,
     376             :                         unsigned int num_results)
     377             : {
     378           1 :   struct LookupRecordsByTableContext *ctx = cls;
     379           1 :   struct TALER_EXCHANGEDB_TableData td = {
     380             :     .table = TALER_EXCHANGEDB_RT_AUDITORS
     381             :   };
     382             : 
     383           2 :   for (unsigned int i = 0; i<num_results; i++)
     384             :   {
     385           1 :     uint8_t is_active8 = 0;
     386           1 :     struct GNUNET_PQ_ResultSpec rs[] = {
     387           1 :       GNUNET_PQ_result_spec_uint64 ("serial",
     388             :                                     &td.serial),
     389           1 :       GNUNET_PQ_result_spec_auto_from_type ("auditor_pub",
     390             :                                             &td.details.auditors.auditor_pub),
     391           1 :       GNUNET_PQ_result_spec_string ("auditor_url",
     392             :                                     &td.details.auditors.auditor_url),
     393           1 :       GNUNET_PQ_result_spec_string ("auditor_name",
     394             :                                     &td.details.auditors.auditor_name),
     395           1 :       GNUNET_PQ_result_spec_auto_from_type ("is_active",
     396             :                                             &is_active8),
     397           1 :       TALER_PQ_result_spec_absolute_time ("last_change",
     398             :                                           &td.details.auditors.last_change),
     399             :       GNUNET_PQ_result_spec_end
     400             :     };
     401             : 
     402           1 :     if (GNUNET_OK !=
     403           1 :         GNUNET_PQ_extract_result (result,
     404             :                                   rs,
     405             :                                   i))
     406             :     {
     407           0 :       GNUNET_break (0);
     408           0 :       ctx->error = true;
     409           0 :       return;
     410             :     }
     411           1 :     td.details.auditors.is_active = (0 != is_active8);
     412           1 :     ctx->cb (ctx->cb_cls,
     413             :              &td);
     414           1 :     GNUNET_PQ_cleanup_result (rs);
     415             :   }
     416             : }
     417             : 
     418             : 
     419             : /**
     420             :  * Function called with auditor_denom_sigs table entries.
     421             :  *
     422             :  * @param cls closure
     423             :  * @param result the postgres result
     424             :  * @param num_result the number of results in @a result
     425             :  */
     426             : static void
     427           1 : lrbt_cb_table_auditor_denom_sigs (void *cls,
     428             :                                   PGresult *result,
     429             :                                   unsigned int num_results)
     430             : {
     431           1 :   struct LookupRecordsByTableContext *ctx = cls;
     432           1 :   struct TALER_EXCHANGEDB_TableData td = {
     433             :     .table = TALER_EXCHANGEDB_RT_AUDITOR_DENOM_SIGS
     434             :   };
     435             : 
     436         425 :   for (unsigned int i = 0; i<num_results; i++)
     437             :   {
     438         424 :     struct GNUNET_PQ_ResultSpec rs[] = {
     439         424 :       GNUNET_PQ_result_spec_uint64 (
     440             :         "serial",
     441             :         &td.serial),
     442         424 :       GNUNET_PQ_result_spec_uint64 (
     443             :         "auditor_uuid",
     444             :         &td.details.auditor_denom_sigs.auditor_uuid),
     445         424 :       GNUNET_PQ_result_spec_uint64 (
     446             :         "denominations_serial",
     447             :         &td.details.auditor_denom_sigs.denominations_serial),
     448         424 :       GNUNET_PQ_result_spec_auto_from_type (
     449             :         "auditor_sig",
     450             :         &td.details.auditor_denom_sigs.auditor_sig),
     451             :       GNUNET_PQ_result_spec_end
     452             :     };
     453             : 
     454         424 :     if (GNUNET_OK !=
     455         424 :         GNUNET_PQ_extract_result (result,
     456             :                                   rs,
     457             :                                   i))
     458             :     {
     459           0 :       GNUNET_break (0);
     460           0 :       ctx->error = true;
     461           0 :       return;
     462             :     }
     463         424 :     ctx->cb (ctx->cb_cls,
     464             :              &td);
     465         424 :     GNUNET_PQ_cleanup_result (rs);
     466             :   }
     467             : }
     468             : 
     469             : 
     470             : /**
     471             :  * Function called with exchange_sign_keys table entries.
     472             :  *
     473             :  * @param cls closure
     474             :  * @param result the postgres result
     475             :  * @param num_result the number of results in @a result
     476             :  */
     477             : static void
     478           1 : lrbt_cb_table_exchange_sign_keys (void *cls,
     479             :                                   PGresult *result,
     480             :                                   unsigned int num_results)
     481             : {
     482           1 :   struct LookupRecordsByTableContext *ctx = cls;
     483           1 :   struct TALER_EXCHANGEDB_TableData td = {
     484             :     .table = TALER_EXCHANGEDB_RT_EXCHANGE_SIGN_KEYS
     485             :   };
     486             : 
     487           6 :   for (unsigned int i = 0; i<num_results; i++)
     488             :   {
     489           5 :     struct GNUNET_PQ_ResultSpec rs[] = {
     490           5 :       GNUNET_PQ_result_spec_uint64 ("serial",
     491             :                                     &td.serial),
     492           5 :       GNUNET_PQ_result_spec_auto_from_type ("exchange_pub",
     493             :                                             &td.details.exchange_sign_keys.
     494             :                                             exchange_pub),
     495           5 :       GNUNET_PQ_result_spec_auto_from_type ("master_sig",
     496             :                                             &td.details.exchange_sign_keys.
     497             :                                             master_sig),
     498           5 :       TALER_PQ_result_spec_absolute_time ("valid_from",
     499             :                                           &td.details.exchange_sign_keys.meta.
     500             :                                           start),
     501           5 :       TALER_PQ_result_spec_absolute_time ("expire_sign",
     502             :                                           &td.details.exchange_sign_keys.meta.
     503             :                                           expire_sign),
     504           5 :       TALER_PQ_result_spec_absolute_time ("expire_legal",
     505             :                                           &td.details.exchange_sign_keys.meta.
     506             :                                           expire_legal),
     507             :       GNUNET_PQ_result_spec_end
     508             :     };
     509             : 
     510           5 :     if (GNUNET_OK !=
     511           5 :         GNUNET_PQ_extract_result (result,
     512             :                                   rs,
     513             :                                   i))
     514             :     {
     515           0 :       GNUNET_break (0);
     516           0 :       ctx->error = true;
     517           0 :       return;
     518             :     }
     519           5 :     ctx->cb (ctx->cb_cls,
     520             :              &td);
     521           5 :     GNUNET_PQ_cleanup_result (rs);
     522             :   }
     523             : }
     524             : 
     525             : 
     526             : /**
     527             :  * Function called with signkey_revocations table entries.
     528             :  *
     529             :  * @param cls closure
     530             :  * @param result the postgres result
     531             :  * @param num_result the number of results in @a result
     532             :  */
     533             : static void
     534           0 : lrbt_cb_table_signkey_revocations (void *cls,
     535             :                                    PGresult *result,
     536             :                                    unsigned int num_results)
     537             : {
     538           0 :   struct LookupRecordsByTableContext *ctx = cls;
     539           0 :   struct TALER_EXCHANGEDB_TableData td = {
     540             :     .table = TALER_EXCHANGEDB_RT_SIGNKEY_REVOCATIONS
     541             :   };
     542             : 
     543           0 :   for (unsigned int i = 0; i<num_results; i++)
     544             :   {
     545           0 :     struct GNUNET_PQ_ResultSpec rs[] = {
     546           0 :       GNUNET_PQ_result_spec_uint64 ("serial",
     547             :                                     &td.serial),
     548           0 :       GNUNET_PQ_result_spec_uint64 ("esk_serial",
     549             :                                     &td.details.signkey_revocations.esk_serial),
     550           0 :       GNUNET_PQ_result_spec_auto_from_type ("master_sig",
     551             :                                             &td.details.signkey_revocations.
     552             :                                             master_sig),
     553             :       GNUNET_PQ_result_spec_end
     554             :     };
     555             : 
     556           0 :     if (GNUNET_OK !=
     557           0 :         GNUNET_PQ_extract_result (result,
     558             :                                   rs,
     559             :                                   i))
     560             :     {
     561           0 :       GNUNET_break (0);
     562           0 :       ctx->error = true;
     563           0 :       return;
     564             :     }
     565           0 :     ctx->cb (ctx->cb_cls,
     566             :              &td);
     567           0 :     GNUNET_PQ_cleanup_result (rs);
     568             :   }
     569             : }
     570             : 
     571             : 
     572             : /**
     573             :  * Function called with known_coins table entries.
     574             :  *
     575             :  * @param cls closure
     576             :  * @param result the postgres result
     577             :  * @param num_result the number of results in @a result
     578             :  */
     579             : static void
     580           1 : lrbt_cb_table_known_coins (void *cls,
     581             :                            PGresult *result,
     582             :                            unsigned int num_results)
     583             : {
     584           1 :   struct LookupRecordsByTableContext *ctx = cls;
     585           1 :   struct TALER_EXCHANGEDB_TableData td = {
     586             :     .table = TALER_EXCHANGEDB_RT_KNOWN_COINS
     587             :   };
     588             : 
     589           4 :   for (unsigned int i = 0; i<num_results; i++)
     590             :   {
     591           3 :     struct GNUNET_PQ_ResultSpec rs[] = {
     592           3 :       GNUNET_PQ_result_spec_uint64 ("serial",
     593             :                                     &td.serial),
     594           3 :       GNUNET_PQ_result_spec_auto_from_type ("coin_pub",
     595             :                                             &td.details.known_coins.coin_pub),
     596           3 :       GNUNET_PQ_result_spec_rsa_signature (
     597             :         "denom_sig",
     598             :         &td.details.known_coins.denom_sig.rsa_signature),
     599           3 :       GNUNET_PQ_result_spec_uint64 ("denominations_serial",
     600             :                                     &td.details.known_coins.denominations_serial),
     601             :       GNUNET_PQ_result_spec_end
     602             :     };
     603             : 
     604           3 :     if (GNUNET_OK !=
     605           3 :         GNUNET_PQ_extract_result (result,
     606             :                                   rs,
     607             :                                   i))
     608             :     {
     609           0 :       GNUNET_break (0);
     610           0 :       ctx->error = true;
     611           0 :       return;
     612             :     }
     613           3 :     ctx->cb (ctx->cb_cls,
     614             :              &td);
     615           3 :     GNUNET_PQ_cleanup_result (rs);
     616             :   }
     617             : }
     618             : 
     619             : 
     620             : /**
     621             :  * Function called with refresh_commitments table entries.
     622             :  *
     623             :  * @param cls closure
     624             :  * @param result the postgres result
     625             :  * @param num_result the number of results in @a result
     626             :  */
     627             : static void
     628           1 : lrbt_cb_table_refresh_commitments (void *cls,
     629             :                                    PGresult *result,
     630             :                                    unsigned int num_results)
     631             : {
     632           1 :   struct LookupRecordsByTableContext *ctx = cls;
     633           1 :   struct PostgresClosure *pg = ctx->pg;
     634           1 :   struct TALER_EXCHANGEDB_TableData td = {
     635             :     .table = TALER_EXCHANGEDB_RT_REFRESH_COMMITMENTS
     636             :   };
     637             : 
     638           5 :   for (unsigned int i = 0; i<num_results; i++)
     639             :   {
     640           4 :     struct GNUNET_PQ_ResultSpec rs[] = {
     641           4 :       GNUNET_PQ_result_spec_uint64 (
     642             :         "serial",
     643             :         &td.serial),
     644           4 :       GNUNET_PQ_result_spec_auto_from_type (
     645             :         "rc",
     646             :         &td.details.refresh_commitments.rc),
     647           4 :       GNUNET_PQ_result_spec_auto_from_type (
     648             :         "old_coin_sig",
     649             :         &td.details.refresh_commitments.old_coin_sig),
     650           4 :       TALER_PQ_RESULT_SPEC_AMOUNT (
     651             :         "amount_with_fee",
     652             :         &td.details.refresh_commitments.amount_with_fee),
     653           4 :       GNUNET_PQ_result_spec_uint32 (
     654             :         "noreveal_index",
     655             :         &td.details.refresh_commitments.noreveal_index),
     656           4 :       GNUNET_PQ_result_spec_uint64 (
     657             :         "old_known_coin_id",
     658             :         &td.details.refresh_commitments.old_known_coin_id),
     659             :       GNUNET_PQ_result_spec_end
     660             :     };
     661             : 
     662           4 :     if (GNUNET_OK !=
     663           4 :         GNUNET_PQ_extract_result (result,
     664             :                                   rs,
     665             :                                   i))
     666             :     {
     667           0 :       GNUNET_break (0);
     668           0 :       ctx->error = true;
     669           0 :       return;
     670             :     }
     671           4 :     ctx->cb (ctx->cb_cls,
     672             :              &td);
     673           4 :     GNUNET_PQ_cleanup_result (rs);
     674             :   }
     675             : }
     676             : 
     677             : 
     678             : /**
     679             :  * Function called with refresh_revealed_coins table entries.
     680             :  *
     681             :  * @param cls closure
     682             :  * @param result the postgres result
     683             :  * @param num_result the number of results in @a result
     684             :  */
     685             : static void
     686           1 : lrbt_cb_table_refresh_revealed_coins (void *cls,
     687             :                                       PGresult *result,
     688             :                                       unsigned int num_results)
     689             : {
     690           1 :   struct LookupRecordsByTableContext *ctx = cls;
     691           1 :   struct TALER_EXCHANGEDB_TableData td = {
     692             :     .table = TALER_EXCHANGEDB_RT_REFRESH_REVEALED_COINS
     693             :   };
     694             : 
     695          49 :   for (unsigned int i = 0; i<num_results; i++)
     696             :   {
     697          48 :     struct GNUNET_PQ_ResultSpec rs[] = {
     698          48 :       GNUNET_PQ_result_spec_uint64 (
     699             :         "serial",
     700             :         &td.serial),
     701          48 :       GNUNET_PQ_result_spec_uint32 (
     702             :         "freshcoin_index",
     703             :         &td.details.refresh_revealed_coins.freshcoin_index),
     704          48 :       GNUNET_PQ_result_spec_auto_from_type (
     705             :         "link_sig",
     706             :         &td.details.refresh_revealed_coins.link_sig),
     707          48 :       GNUNET_PQ_result_spec_variable_size (
     708             :         "coin_ev",
     709             :         (void **) &td.details.refresh_revealed_coins.coin_ev,
     710             :         &td.details.refresh_revealed_coins.coin_ev_size),
     711          48 :       GNUNET_PQ_result_spec_rsa_signature (
     712             :         "ev_sig",
     713             :         &td.details.refresh_revealed_coins.ev_sig.rsa_signature),
     714          48 :       GNUNET_PQ_result_spec_uint64 (
     715             :         "denominations_serial",
     716             :         &td.details.refresh_revealed_coins.denominations_serial),
     717          48 :       GNUNET_PQ_result_spec_uint64 (
     718             :         "melt_serial_id",
     719             :         &td.details.refresh_revealed_coins.melt_serial_id),
     720             :       GNUNET_PQ_result_spec_end
     721             :     };
     722             : 
     723          48 :     if (GNUNET_OK !=
     724          48 :         GNUNET_PQ_extract_result (result,
     725             :                                   rs,
     726             :                                   i))
     727             :     {
     728           0 :       GNUNET_break (0);
     729           0 :       ctx->error = true;
     730           0 :       return;
     731             :     }
     732          48 :     ctx->cb (ctx->cb_cls,
     733             :              &td);
     734          48 :     GNUNET_PQ_cleanup_result (rs);
     735             :   }
     736             : }
     737             : 
     738             : 
     739             : /**
     740             :  * Function called with refresh_transfer_keys table entries.
     741             :  *
     742             :  * @param cls closure
     743             :  * @param result the postgres result
     744             :  * @param num_result the number of results in @a result
     745             :  */
     746             : static void
     747           1 : lrbt_cb_table_refresh_transfer_keys (void *cls,
     748             :                                      PGresult *result,
     749             :                                      unsigned int num_results)
     750             : {
     751           1 :   struct LookupRecordsByTableContext *ctx = cls;
     752           1 :   struct TALER_EXCHANGEDB_TableData td = {
     753             :     .table = TALER_EXCHANGEDB_RT_REFRESH_TRANSFER_KEYS
     754             :   };
     755             : 
     756           5 :   for (unsigned int i = 0; i<num_results; i++)
     757             :   {
     758             :     void *tpriv;
     759             :     size_t tpriv_size;
     760           4 :     struct GNUNET_PQ_ResultSpec rs[] = {
     761           4 :       GNUNET_PQ_result_spec_uint64 ("serial",
     762             :                                     &td.serial),
     763           4 :       GNUNET_PQ_result_spec_auto_from_type ("transfer_pub",
     764             :                                             &td.details.refresh_transfer_keys.tp),
     765           4 :       GNUNET_PQ_result_spec_variable_size ("transfer_privs",
     766             :                                            &tpriv,
     767             :                                            &tpriv_size),
     768           4 :       GNUNET_PQ_result_spec_uint64 ("melt_serial_id",
     769             :                                     &td.details.refresh_transfer_keys.
     770             :                                     melt_serial_id),
     771             :       GNUNET_PQ_result_spec_end
     772             :     };
     773             : 
     774           4 :     if (GNUNET_OK !=
     775           4 :         GNUNET_PQ_extract_result (result,
     776             :                                   rs,
     777             :                                   i))
     778             :     {
     779           0 :       GNUNET_break (0);
     780           0 :       ctx->error = true;
     781           0 :       return;
     782             :     }
     783             :     /* Both conditions should be identical, but we conservatively also guard against
     784             :        unwarranted changes to the structure here. */
     785           4 :     if ( (tpriv_size !=
     786           4 :           sizeof (td.details.refresh_transfer_keys.tprivs)) ||
     787           4 :          (tpriv_size !=
     788             :           (TALER_CNC_KAPPA - 1) * sizeof (struct TALER_TransferPrivateKeyP)) )
     789             :     {
     790           0 :       GNUNET_break (0);
     791           0 :       GNUNET_PQ_cleanup_result (rs);
     792           0 :       ctx->error = true;
     793           0 :       return;
     794             :     }
     795           4 :     memcpy (&td.details.refresh_transfer_keys.tprivs[0],
     796             :             tpriv,
     797             :             tpriv_size);
     798           4 :     ctx->cb (ctx->cb_cls,
     799             :              &td);
     800           4 :     GNUNET_PQ_cleanup_result (rs);
     801             :   }
     802             : }
     803             : 
     804             : 
     805             : /**
     806             :  * Function called with deposits table entries.
     807             :  *
     808             :  * @param cls closure
     809             :  * @param result the postgres result
     810             :  * @param num_result the number of results in @a result
     811             :  */
     812             : static void
     813           1 : lrbt_cb_table_deposits (void *cls,
     814             :                         PGresult *result,
     815             :                         unsigned int num_results)
     816             : {
     817           1 :   struct LookupRecordsByTableContext *ctx = cls;
     818           1 :   struct PostgresClosure *pg = ctx->pg;
     819           1 :   struct TALER_EXCHANGEDB_TableData td = {
     820             :     .table = TALER_EXCHANGEDB_RT_DEPOSITS
     821             :   };
     822             : 
     823           4 :   for (unsigned int i = 0; i<num_results; i++)
     824             :   {
     825           3 :     uint8_t tiny = 0; /* initialized to make compiler happy */
     826           3 :     uint8_t done = 0; /* initialized to make compiler happy */
     827           3 :     struct GNUNET_PQ_ResultSpec rs[] = {
     828           3 :       GNUNET_PQ_result_spec_uint64 (
     829             :         "serial",
     830             :         &td.serial),
     831           3 :       TALER_PQ_RESULT_SPEC_AMOUNT (
     832             :         "amount_with_fee",
     833             :         &td.details.deposits.amount_with_fee),
     834           3 :       TALER_PQ_result_spec_absolute_time (
     835             :         "wallet_timestamp",
     836             :         &td.details.deposits.wallet_timestamp),
     837           3 :       TALER_PQ_result_spec_absolute_time (
     838             :         "exchange_timestamp",
     839             :         &td.details.deposits.exchange_timestamp),
     840           3 :       TALER_PQ_result_spec_absolute_time (
     841             :         "refund_deadline",
     842             :         &td.details.deposits.refund_deadline),
     843           3 :       TALER_PQ_result_spec_absolute_time (
     844             :         "wire_deadline",
     845             :         &td.details.deposits.wire_deadline),
     846           3 :       GNUNET_PQ_result_spec_auto_from_type (
     847             :         "merchant_pub",
     848             :         &td.details.deposits.merchant_pub),
     849           3 :       GNUNET_PQ_result_spec_auto_from_type (
     850             :         "h_contract_terms",
     851             :         &td.details.deposits.h_contract_terms),
     852           3 :       GNUNET_PQ_result_spec_auto_from_type (
     853             :         "coin_sig",
     854             :         &td.details.deposits.coin_sig),
     855           3 :       TALER_PQ_result_spec_json (
     856             :         "wire",
     857             :         &td.details.deposits.wire),
     858           3 :       GNUNET_PQ_result_spec_auto_from_type (
     859             :         "tiny",
     860             :         &td.details.deposits.tiny),
     861           3 :       GNUNET_PQ_result_spec_auto_from_type (
     862             :         "done",
     863             :         &td.details.deposits.done),
     864           3 :       GNUNET_PQ_result_spec_uint64 (
     865             :         "known_coin_id",
     866             :         &td.details.deposits.known_coin_id),
     867             :       GNUNET_PQ_result_spec_end
     868             :     };
     869             : 
     870           3 :     if (GNUNET_OK !=
     871           3 :         GNUNET_PQ_extract_result (result,
     872             :                                   rs,
     873             :                                   i))
     874             :     {
     875           0 :       GNUNET_break (0);
     876           0 :       ctx->error = true;
     877           0 :       return;
     878             :     }
     879           3 :     td.details.deposits.tiny = (0 != tiny);
     880           3 :     td.details.deposits.done = (0 != done);
     881           3 :     ctx->cb (ctx->cb_cls,
     882             :              &td);
     883           3 :     GNUNET_PQ_cleanup_result (rs);
     884             :   }
     885             : }
     886             : 
     887             : 
     888             : /**
     889             :  * Function called with refunds table entries.
     890             :  *
     891             :  * @param cls closure
     892             :  * @param result the postgres result
     893             :  * @param num_result the number of results in @a result
     894             :  */
     895             : static void
     896           1 : lrbt_cb_table_refunds (void *cls,
     897             :                        PGresult *result,
     898             :                        unsigned int num_results)
     899             : {
     900           1 :   struct LookupRecordsByTableContext *ctx = cls;
     901           1 :   struct PostgresClosure *pg = ctx->pg;
     902           1 :   struct TALER_EXCHANGEDB_TableData td = {
     903             :     .table = TALER_EXCHANGEDB_RT_REFUNDS
     904             :   };
     905             : 
     906           2 :   for (unsigned int i = 0; i<num_results; i++)
     907             :   {
     908           1 :     struct GNUNET_PQ_ResultSpec rs[] = {
     909           1 :       GNUNET_PQ_result_spec_uint64 ("serial",
     910             :                                     &td.serial),
     911           1 :       GNUNET_PQ_result_spec_auto_from_type ("merchant_sig",
     912             :                                             &td.details.refunds.merchant_sig),
     913           1 :       GNUNET_PQ_result_spec_uint64 ("rtransaction_id",
     914             :                                     &td.details.refunds.rtransaction_id),
     915           1 :       TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee",
     916             :                                    &td.details.refunds.amount_with_fee),
     917           1 :       GNUNET_PQ_result_spec_uint64 ("deposit_serial_id",
     918             :                                     &td.details.refunds.deposit_serial_id),
     919             :       GNUNET_PQ_result_spec_end
     920             :     };
     921             : 
     922           1 :     if (GNUNET_OK !=
     923           1 :         GNUNET_PQ_extract_result (result,
     924             :                                   rs,
     925             :                                   i))
     926             :     {
     927           0 :       GNUNET_break (0);
     928           0 :       ctx->error = true;
     929           0 :       return;
     930             :     }
     931           1 :     ctx->cb (ctx->cb_cls,
     932             :              &td);
     933           1 :     GNUNET_PQ_cleanup_result (rs);
     934             :   }
     935             : }
     936             : 
     937             : 
     938             : /**
     939             :  * Function called with wire_out table entries.
     940             :  *
     941             :  * @param cls closure
     942             :  * @param result the postgres result
     943             :  * @param num_result the number of results in @a result
     944             :  */
     945             : static void
     946           0 : lrbt_cb_table_wire_out (void *cls,
     947             :                         PGresult *result,
     948             :                         unsigned int num_results)
     949             : {
     950           0 :   struct LookupRecordsByTableContext *ctx = cls;
     951           0 :   struct PostgresClosure *pg = ctx->pg;
     952           0 :   struct TALER_EXCHANGEDB_TableData td = {
     953             :     .table = TALER_EXCHANGEDB_RT_WIRE_OUT
     954             :   };
     955             : 
     956           0 :   for (unsigned int i = 0; i<num_results; i++)
     957             :   {
     958           0 :     struct GNUNET_PQ_ResultSpec rs[] = {
     959           0 :       TALER_PQ_result_spec_absolute_time ("execution_date",
     960             :                                           &td.details.wire_out.execution_date),
     961           0 :       GNUNET_PQ_result_spec_auto_from_type ("wtid_raw",
     962             :                                             &td.details.wire_out.wtid_raw),
     963           0 :       TALER_PQ_result_spec_json ("wire_target",
     964             :                                  &td.details.wire_out.wire_target),
     965           0 :       GNUNET_PQ_result_spec_string (
     966             :         "exchnage_account_section",
     967             :         &td.details.wire_out.exchange_account_section),
     968           0 :       TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
     969             :                                    &td.details.wire_out.amount),
     970             :       GNUNET_PQ_result_spec_end
     971             :     };
     972             : 
     973           0 :     if (GNUNET_OK !=
     974           0 :         GNUNET_PQ_extract_result (result,
     975             :                                   rs,
     976             :                                   i))
     977             :     {
     978           0 :       GNUNET_break (0);
     979           0 :       ctx->error = true;
     980           0 :       return;
     981             :     }
     982           0 :     ctx->cb (ctx->cb_cls,
     983             :              &td);
     984           0 :     GNUNET_PQ_cleanup_result (rs);
     985             :   }
     986             : }
     987             : 
     988             : 
     989             : /**
     990             :  * Function called with aggregation_tracking table entries.
     991             :  *
     992             :  * @param cls closure
     993             :  * @param result the postgres result
     994             :  * @param num_result the number of results in @a result
     995             :  */
     996             : static void
     997           0 : lrbt_cb_table_aggregation_tracking (void *cls,
     998             :                                     PGresult *result,
     999             :                                     unsigned int num_results)
    1000             : {
    1001           0 :   struct LookupRecordsByTableContext *ctx = cls;
    1002           0 :   struct TALER_EXCHANGEDB_TableData td = {
    1003             :     .table = TALER_EXCHANGEDB_RT_AGGREGATION_TRACKING
    1004             :   };
    1005             : 
    1006           0 :   for (unsigned int i = 0; i<num_results; i++)
    1007             :   {
    1008           0 :     struct GNUNET_PQ_ResultSpec rs[] = {
    1009           0 :       GNUNET_PQ_result_spec_uint64 ("serial",
    1010             :                                     &td.serial),
    1011           0 :       GNUNET_PQ_result_spec_uint64 (
    1012             :         "deposit_serial_id",
    1013             :         &td.details.aggregation_tracking.deposit_serial_id),
    1014           0 :       GNUNET_PQ_result_spec_auto_from_type (
    1015             :         "wtid_raw",
    1016             :         &td.details.aggregation_tracking.wtid_raw),
    1017             :       GNUNET_PQ_result_spec_end
    1018             :     };
    1019             : 
    1020           0 :     if (GNUNET_OK !=
    1021           0 :         GNUNET_PQ_extract_result (result,
    1022             :                                   rs,
    1023             :                                   i))
    1024             :     {
    1025           0 :       GNUNET_break (0);
    1026           0 :       ctx->error = true;
    1027           0 :       return;
    1028             :     }
    1029           0 :     ctx->cb (ctx->cb_cls,
    1030             :              &td);
    1031           0 :     GNUNET_PQ_cleanup_result (rs);
    1032             :   }
    1033             : }
    1034             : 
    1035             : 
    1036             : /**
    1037             :  * Function called with wire_fee table entries.
    1038             :  *
    1039             :  * @param cls closure
    1040             :  * @param result the postgres result
    1041             :  * @param num_result the number of results in @a result
    1042             :  */
    1043             : static void
    1044           1 : lrbt_cb_table_wire_fee (void *cls,
    1045             :                         PGresult *result,
    1046             :                         unsigned int num_results)
    1047             : {
    1048           1 :   struct LookupRecordsByTableContext *ctx = cls;
    1049           1 :   struct PostgresClosure *pg = ctx->pg;
    1050           1 :   struct TALER_EXCHANGEDB_TableData td = {
    1051             :     .table = TALER_EXCHANGEDB_RT_WIRE_FEE
    1052             :   };
    1053             : 
    1054           2 :   for (unsigned int i = 0; i<num_results; i++)
    1055             :   {
    1056           1 :     struct GNUNET_PQ_ResultSpec rs[] = {
    1057           1 :       GNUNET_PQ_result_spec_uint64 ("serial",
    1058             :                                     &td.serial),
    1059           1 :       GNUNET_PQ_result_spec_string ("wire_method",
    1060             :                                     &td.details.wire_fee.wire_method),
    1061           1 :       TALER_PQ_result_spec_absolute_time ("start_date",
    1062             :                                           &td.details.wire_fee.start_date),
    1063           1 :       TALER_PQ_result_spec_absolute_time ("end_date",
    1064             :                                           &td.details.wire_fee.end_date),
    1065           1 :       TALER_PQ_RESULT_SPEC_AMOUNT ("wire_fee",
    1066             :                                    &td.details.wire_fee.wire_fee),
    1067           1 :       TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee",
    1068             :                                    &td.details.wire_fee.closing_fee),
    1069           1 :       GNUNET_PQ_result_spec_auto_from_type ("master_sig",
    1070             :                                             &td.details.wire_fee.master_sig),
    1071             :       GNUNET_PQ_result_spec_end
    1072             :     };
    1073             : 
    1074           1 :     if (GNUNET_OK !=
    1075           1 :         GNUNET_PQ_extract_result (result,
    1076             :                                   rs,
    1077             :                                   i))
    1078             :     {
    1079           0 :       GNUNET_break (0);
    1080           0 :       ctx->error = true;
    1081           0 :       return;
    1082             :     }
    1083           1 :     ctx->cb (ctx->cb_cls,
    1084             :              &td);
    1085           1 :     GNUNET_PQ_cleanup_result (rs);
    1086             :   }
    1087             : }
    1088             : 
    1089             : 
    1090             : /**
    1091             :  * Function called with recoup table entries.
    1092             :  *
    1093             :  * @param cls closure
    1094             :  * @param result the postgres result
    1095             :  * @param num_result the number of results in @a result
    1096             :  */
    1097             : static void
    1098           0 : lrbt_cb_table_recoup (void *cls,
    1099             :                       PGresult *result,
    1100             :                       unsigned int num_results)
    1101             : {
    1102           0 :   struct LookupRecordsByTableContext *ctx = cls;
    1103           0 :   struct PostgresClosure *pg = ctx->pg;
    1104           0 :   struct TALER_EXCHANGEDB_TableData td = {
    1105             :     .table = TALER_EXCHANGEDB_RT_RECOUP
    1106             :   };
    1107             : 
    1108           0 :   for (unsigned int i = 0; i<num_results; i++)
    1109             :   {
    1110           0 :     struct GNUNET_PQ_ResultSpec rs[] = {
    1111           0 :       GNUNET_PQ_result_spec_uint64 ("serial",
    1112             :                                     &td.serial),
    1113           0 :       GNUNET_PQ_result_spec_auto_from_type ("coin_sig",
    1114             :                                             &td.details.recoup.coin_sig),
    1115           0 :       GNUNET_PQ_result_spec_auto_from_type ("coin_blind",
    1116             :                                             &td.details.recoup.coin_blind),
    1117           0 :       TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
    1118             :                                    &td.details.recoup.amount),
    1119           0 :       TALER_PQ_result_spec_absolute_time ("timestamp",
    1120             :                                           &td.details.recoup.timestamp),
    1121           0 :       GNUNET_PQ_result_spec_uint64 ("known_coin_id",
    1122             :                                     &td.details.recoup.known_coin_id),
    1123           0 :       GNUNET_PQ_result_spec_uint64 ("reserve_out_serial_id",
    1124             :                                     &td.details.recoup.reserve_out_serial_id),
    1125             :       GNUNET_PQ_result_spec_end
    1126             :     };
    1127             : 
    1128           0 :     if (GNUNET_OK !=
    1129           0 :         GNUNET_PQ_extract_result (result,
    1130             :                                   rs,
    1131             :                                   i))
    1132             :     {
    1133           0 :       GNUNET_break (0);
    1134           0 :       ctx->error = true;
    1135           0 :       return;
    1136             :     }
    1137           0 :     ctx->cb (ctx->cb_cls,
    1138             :              &td);
    1139           0 :     GNUNET_PQ_cleanup_result (rs);
    1140             :   }
    1141             : }
    1142             : 
    1143             : 
    1144             : /**
    1145             :  * Function called with recoup_refresh table entries.
    1146             :  *
    1147             :  * @param cls closure
    1148             :  * @param result the postgres result
    1149             :  * @param num_result the number of results in @a result
    1150             :  */
    1151             : static void
    1152           0 : lrbt_cb_table_recoup_refresh (void *cls,
    1153             :                               PGresult *result,
    1154             :                               unsigned int num_results)
    1155             : {
    1156           0 :   struct LookupRecordsByTableContext *ctx = cls;
    1157           0 :   struct PostgresClosure *pg = ctx->pg;
    1158           0 :   struct TALER_EXCHANGEDB_TableData td = {
    1159             :     .table = TALER_EXCHANGEDB_RT_RECOUP_REFRESH
    1160             :   };
    1161             : 
    1162           0 :   for (unsigned int i = 0; i<num_results; i++)
    1163             :   {
    1164           0 :     struct GNUNET_PQ_ResultSpec rs[] = {
    1165           0 :       GNUNET_PQ_result_spec_uint64 ("serial",
    1166             :                                     &td.serial),
    1167           0 :       GNUNET_PQ_result_spec_auto_from_type ("coin_sig",
    1168             :                                             &td.details.recoup_refresh.coin_sig),
    1169           0 :       GNUNET_PQ_result_spec_auto_from_type (
    1170             :         "coin_blind",
    1171             :         &td.details.recoup_refresh.coin_blind),
    1172           0 :       TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
    1173             :                                    &td.details.recoup_refresh.amount),
    1174           0 :       TALER_PQ_result_spec_absolute_time ("timestamp",
    1175             :                                           &td.details.recoup_refresh.timestamp),
    1176           0 :       GNUNET_PQ_result_spec_uint64 ("known_coin_id",
    1177             :                                     &td.details.recoup_refresh.known_coin_id),
    1178           0 :       GNUNET_PQ_result_spec_uint64 ("rrc_serial",
    1179             :                                     &td.details.recoup_refresh.rrc_serial),
    1180             :       GNUNET_PQ_result_spec_end
    1181             :     };
    1182             : 
    1183           0 :     if (GNUNET_OK !=
    1184           0 :         GNUNET_PQ_extract_result (result,
    1185             :                                   rs,
    1186             :                                   i))
    1187             :     {
    1188           0 :       GNUNET_break (0);
    1189           0 :       ctx->error = true;
    1190           0 :       return;
    1191             :     }
    1192           0 :     ctx->cb (ctx->cb_cls,
    1193             :              &td);
    1194           0 :     GNUNET_PQ_cleanup_result (rs);
    1195             :   }
    1196             : }
    1197             : 
    1198             : 
    1199             : /* end of lrbt_callbacks.c */

Generated by: LCOV version 1.14