From 5e80154f430a5b24f8fcf5dbb68bfb9862f3b96a Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 10 Jan 2021 12:56:13 +0100 Subject: complete (untested) implementation of lrbt_callbacks --- src/exchangedb/lrbt_callbacks.c | 228 +++++++++++++++++++++++++++- src/exchangedb/plugin_exchangedb_postgres.c | 18 ++- 2 files changed, 231 insertions(+), 15 deletions(-) (limited to 'src/exchangedb') diff --git a/src/exchangedb/lrbt_callbacks.c b/src/exchangedb/lrbt_callbacks.c index e2dbe99a3..c840b1bd1 100644 --- a/src/exchangedb/lrbt_callbacks.c +++ b/src/exchangedb/lrbt_callbacks.c @@ -382,9 +382,20 @@ lrbt_cb_table_auditors (void *cls, for (unsigned int i = 0; ierror = true; return; } + td.details.auditors.is_active = (0 != is_active8); ctx->cb (ctx->cb_cls, &td); GNUNET_PQ_cleanup_result (rs); @@ -426,6 +438,12 @@ lrbt_cb_table_auditor_denom_sigs (void *cls, struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("serial", &td.serial), + GNUNET_PQ_result_spec_uint64 ("denominations_serial", + &td.details.auditor_denom_sigs. + denominations_serial), + GNUNET_PQ_result_spec_auto_from_type ("auditor_sig", + &td.details.auditor_denom_sigs. + auditor_sig), GNUNET_PQ_result_spec_end }; @@ -467,6 +485,21 @@ lrbt_cb_table_exchange_sign_keys (void *cls, struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("serial", &td.serial), + GNUNET_PQ_result_spec_auto_from_type ("exchange_pub", + &td.details.exchange_sign_keys. + exchange_pub), + GNUNET_PQ_result_spec_auto_from_type ("master_sig", + &td.details.exchange_sign_keys. + master_sig), + TALER_PQ_result_spec_absolute_time ("valid_from", + &td.details.exchange_sign_keys.meta. + start), + TALER_PQ_result_spec_absolute_time ("expire_sign", + &td.details.exchange_sign_keys.meta. + expire_sign), + TALER_PQ_result_spec_absolute_time ("expire_legal", + &td.details.exchange_sign_keys.meta. + expire_legal), GNUNET_PQ_result_spec_end }; @@ -508,6 +541,11 @@ lrbt_cb_table_signkey_revocations (void *cls, struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("serial", &td.serial), + GNUNET_PQ_result_spec_uint64 ("esk_serial", + &td.details.signkey_revocations.esk_serial), + GNUNET_PQ_result_spec_auto_from_type ("master_sig", + &td.details.signkey_revocations. + master_sig), GNUNET_PQ_result_spec_end }; @@ -549,6 +587,13 @@ lrbt_cb_table_known_coins (void *cls, struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("serial", &td.serial), + GNUNET_PQ_result_spec_auto_from_type ("coin_pub", + &td.details.known_coins.coin_pub), + GNUNET_PQ_result_spec_rsa_signature ( + "denom_sig", + &td.details.known_coins.denom_sig.rsa_signature), + GNUNET_PQ_result_spec_uint64 ("denominations_serial", + &td.details.known_coins.denominations_serial), GNUNET_PQ_result_spec_end }; @@ -581,6 +626,7 @@ lrbt_cb_table_refresh_commitments (void *cls, unsigned int num_results) { struct LookupRecordsByTableContext *ctx = cls; + struct PostgresClosure *pg = ctx->pg; struct TALER_EXCHANGEDB_TableData td = { .table = TALER_EXCHANGEDB_RT_REFRESH_COMMITMENTS }; @@ -588,8 +634,24 @@ lrbt_cb_table_refresh_commitments (void *cls, for (unsigned int i = 0; ierror = true; return; } + /* Both conditions should be identical, but we conservatively also guard against + unwarranted changes to the structure here. */ + if ( (tpriv_size != + sizeof (td.details.refresh_transfer_keys.tprivs)) || + (tpriv_size != + (TALER_CNC_KAPPA - 1) * sizeof (struct TALER_TransferPrivateKeyP)) ) + { + GNUNET_break (0); + GNUNET_PQ_cleanup_result (rs); + ctx->error = true; + return; + } + memcpy (&td.details.refresh_transfer_keys.tprivs[0], + tpriv, + tpriv_size); ctx->cb (ctx->cb_cls, &td); GNUNET_PQ_cleanup_result (rs); @@ -704,15 +811,55 @@ lrbt_cb_table_deposits (void *cls, unsigned int num_results) { struct LookupRecordsByTableContext *ctx = cls; + struct PostgresClosure *pg = ctx->pg; struct TALER_EXCHANGEDB_TableData td = { .table = TALER_EXCHANGEDB_RT_DEPOSITS }; for (unsigned int i = 0; ierror = true; return; } + td.details.deposits.tiny = (0 != tiny); + td.details.deposits.done = (0 != done); ctx->cb (ctx->cb_cls, &td); GNUNET_PQ_cleanup_result (rs); @@ -745,6 +894,7 @@ lrbt_cb_table_refunds (void *cls, unsigned int num_results) { struct LookupRecordsByTableContext *ctx = cls; + struct PostgresClosure *pg = ctx->pg; struct TALER_EXCHANGEDB_TableData td = { .table = TALER_EXCHANGEDB_RT_REFUNDS }; @@ -754,6 +904,14 @@ lrbt_cb_table_refunds (void *cls, struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("serial", &td.serial), + GNUNET_PQ_result_spec_auto_from_type ("merchant_sig", + &td.details.refunds.merchant_sig), + GNUNET_PQ_result_spec_uint64 ("rtransaction_id", + &td.details.refunds.rtransaction_id), + TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee", + &td.details.refunds.amount_with_fee), + GNUNET_PQ_result_spec_uint64 ("deposit_serial_id", + &td.details.refunds.deposit_serial_id), GNUNET_PQ_result_spec_end }; @@ -786,6 +944,7 @@ lrbt_cb_table_wire_out (void *cls, unsigned int num_results) { struct LookupRecordsByTableContext *ctx = cls; + struct PostgresClosure *pg = ctx->pg; struct TALER_EXCHANGEDB_TableData td = { .table = TALER_EXCHANGEDB_RT_WIRE_OUT }; @@ -793,8 +952,17 @@ lrbt_cb_table_wire_out (void *cls, for (unsigned int i = 0; ipg; struct TALER_EXCHANGEDB_TableData td = { .table = TALER_EXCHANGEDB_RT_WIRE_FEE }; @@ -877,6 +1052,16 @@ lrbt_cb_table_wire_fee (void *cls, struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("serial", &td.serial), + TALER_PQ_result_spec_absolute_time ("start_date", + &td.details.wire_fee.start_date), + TALER_PQ_result_spec_absolute_time ("end_date", + &td.details.wire_fee.end_date), + TALER_PQ_RESULT_SPEC_AMOUNT ("wire_fee", + &td.details.wire_fee.wire_fee), + TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee", + &td.details.wire_fee.closing_fee), + GNUNET_PQ_result_spec_auto_from_type ("master_sig", + &td.details.wire_fee.master_sig), GNUNET_PQ_result_spec_end }; @@ -909,6 +1094,7 @@ lrbt_cb_table_recoup (void *cls, unsigned int num_results) { struct LookupRecordsByTableContext *ctx = cls; + struct PostgresClosure *pg = ctx->pg; struct TALER_EXCHANGEDB_TableData td = { .table = TALER_EXCHANGEDB_RT_RECOUP }; @@ -918,6 +1104,18 @@ lrbt_cb_table_recoup (void *cls, struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("serial", &td.serial), + GNUNET_PQ_result_spec_auto_from_type ("coin_sig", + &td.details.recoup.coin_sig), + GNUNET_PQ_result_spec_auto_from_type ("coin_blind", + &td.details.recoup.coin_blind), + TALER_PQ_RESULT_SPEC_AMOUNT ("amount", + &td.details.recoup.amount), + TALER_PQ_result_spec_absolute_time ("timestamp", + &td.details.recoup.timestamp), + GNUNET_PQ_result_spec_uint64 ("known_coin_id", + &td.details.recoup.known_coin_id), + GNUNET_PQ_result_spec_uint64 ("reserve_out_serial_id", + &td.details.recoup.reserve_out_serial_id), GNUNET_PQ_result_spec_end }; @@ -950,6 +1148,7 @@ lrbt_cb_table_recoup_refresh (void *cls, unsigned int num_results) { struct LookupRecordsByTableContext *ctx = cls; + struct PostgresClosure *pg = ctx->pg; struct TALER_EXCHANGEDB_TableData td = { .table = TALER_EXCHANGEDB_RT_RECOUP_REFRESH }; @@ -959,6 +1158,19 @@ lrbt_cb_table_recoup_refresh (void *cls, struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("serial", &td.serial), + GNUNET_PQ_result_spec_auto_from_type ("coin_sig", + &td.details.recoup_refresh.coin_sig), + GNUNET_PQ_result_spec_auto_from_type ( + "coin_blind", + &td.details.recoup_refresh.coin_blind), + TALER_PQ_RESULT_SPEC_AMOUNT ("amount", + &td.details.recoup_refresh.amount), + TALER_PQ_result_spec_absolute_time ("timestamp", + &td.details.recoup_refresh.timestamp), + GNUNET_PQ_result_spec_uint64 ("known_coin_id", + &td.details.recoup_refresh.known_coin_id), + GNUNET_PQ_result_spec_uint64 ("rrc_serial", + &td.details.recoup_refresh.rrc_serial), GNUNET_PQ_result_spec_end }; diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index b81fb7c1b..a815c1b1a 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -3625,9 +3625,9 @@ add_recoup (void *cls, &recoup->timestamp), GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash", &recoup->coin.denom_pub_hash), - GNUNET_PQ_result_spec_rsa_signature ("denom_sig", - &recoup->coin.denom_sig. - rsa_signature), + GNUNET_PQ_result_spec_rsa_signature ( + "denom_sig", + &recoup->coin.denom_sig.rsa_signature), GNUNET_PQ_result_spec_end }; @@ -5976,10 +5976,14 @@ postgres_lookup_transfer_by_deposit ( struct TALER_Amount amount_with_fee; struct TALER_Amount deposit_fee; struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_auto_from_type ("wtid_raw", &wtid), - TALER_PQ_result_spec_absolute_time ("execution_date", &exec_time), - TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee", &amount_with_fee), - TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit", &deposit_fee), + GNUNET_PQ_result_spec_auto_from_type ("wtid_raw", + &wtid), + TALER_PQ_result_spec_absolute_time ("execution_date", + &exec_time), + TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee", + &amount_with_fee), + TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit", + &deposit_fee), GNUNET_PQ_result_spec_end }; -- cgit v1.2.3