diff options
Diffstat (limited to 'src/exchangedb/pg_lookup_records_by_table.c')
-rw-r--r-- | src/exchangedb/pg_lookup_records_by_table.c | 939 |
1 files changed, 815 insertions, 124 deletions
diff --git a/src/exchangedb/pg_lookup_records_by_table.c b/src/exchangedb/pg_lookup_records_by_table.c index 806896e78..fc4af32a8 100644 --- a/src/exchangedb/pg_lookup_records_by_table.c +++ b/src/exchangedb/pg_lookup_records_by_table.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet - Copyright (C) 2020, 2021, 2022 Taler Systems SA + Copyright (C) 2020-2023 Taler Systems SA GNUnet is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published @@ -21,6 +21,7 @@ * @file exchangedb/pg_lookup_records_by_table.c * @brief implementation of lookup_records_by_table * @author Christian Grothoff + * @author Özgür Kesim */ #include "platform.h" #include "taler_error_codes.h" @@ -28,6 +29,7 @@ #include "taler_pq_lib.h" #include "pg_lookup_records_by_table.h" #include "pg_helper.h" +#include <gnunet/gnunet_pq_lib.h> /** @@ -232,6 +234,114 @@ lrbt_cb_table_wire_targets (void *cls, /** + * Function called with legitimization_processes table entries. + * + * @param cls closure + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +lrbt_cb_table_legitimization_processes (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct LookupRecordsByTableContext *ctx = cls; + struct TALER_EXCHANGEDB_TableData td = { + .table = TALER_EXCHANGEDB_RT_LEGITIMIZATION_PROCESSES + }; + + for (unsigned int i = 0; i<num_results; i++) + { + struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), + GNUNET_PQ_result_spec_auto_from_type ( + "h_payto", + &td.details.legitimization_processes.h_payto), + GNUNET_PQ_result_spec_timestamp ( + "expiration_time", + &td.details.legitimization_processes.expiration_time), + GNUNET_PQ_result_spec_string ( + "provider_section", + &td.details.legitimization_processes.provider_section), + GNUNET_PQ_result_spec_string ( + "provider_user_id", + &td.details.legitimization_processes.provider_user_id), + GNUNET_PQ_result_spec_string ( + "provider_legitimization_id", + &td.details.legitimization_processes.provider_legitimization_id), + GNUNET_PQ_result_spec_end + }; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + ctx->error = true; + return; + } + ctx->cb (ctx->cb_cls, + &td); + GNUNET_PQ_cleanup_result (rs); + } +} + + +/** + * Function called with legitimization_requirements table entries. + * + * @param cls closure + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +lrbt_cb_table_legitimization_requirements (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct LookupRecordsByTableContext *ctx = cls; + struct TALER_EXCHANGEDB_TableData td = { + .table = TALER_EXCHANGEDB_RT_LEGITIMIZATION_REQUIREMENTS + }; + + for (unsigned int i = 0; i<num_results; i++) + { + struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), + GNUNET_PQ_result_spec_auto_from_type ( + "h_payto", + &td.details.legitimization_requirements.h_payto), + GNUNET_PQ_result_spec_allow_null ( + GNUNET_PQ_result_spec_auto_from_type ( + "reserve_pub", + &td.details.legitimization_requirements.reserve_pub), + &td.details.legitimization_requirements.no_reserve_pub), + GNUNET_PQ_result_spec_string ( + "required_checks", + &td.details.legitimization_requirements.required_checks), + GNUNET_PQ_result_spec_end + }; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + ctx->error = true; + return; + } + ctx->cb (ctx->cb_cls, + &td); + GNUNET_PQ_cleanup_result (rs); + } +} + + +/** * Function called with reserves table entries. * * @param cls closure @@ -401,6 +511,123 @@ lrbt_cb_table_reserves_close (void *cls, /** + * Function called with reserves_open_requests table entries. + * + * @param cls closure + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +lrbt_cb_table_reserves_open_requests (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct LookupRecordsByTableContext *ctx = cls; + struct PostgresClosure *pg = ctx->pg; + struct TALER_EXCHANGEDB_TableData td = { + .table = TALER_EXCHANGEDB_RT_RESERVES_OPEN_REQUESTS + }; + + for (unsigned int i = 0; i<num_results; i++) + { + struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), + GNUNET_PQ_result_spec_auto_from_type ( + "reserve_pub", + &td.details.reserves_open_requests.reserve_pub), + GNUNET_PQ_result_spec_timestamp ( + "request_timestamp", + &td.details.reserves_open_requests.request_timestamp), + GNUNET_PQ_result_spec_timestamp ( + "expiration_date", + &td.details.reserves_open_requests.expiration_date), + GNUNET_PQ_result_spec_auto_from_type ( + "reserve_sig", + &td.details.reserves_open_requests.reserve_sig), + TALER_PQ_RESULT_SPEC_AMOUNT ( + "reserve_payment", + &td.details.reserves_open_requests.reserve_payment), + GNUNET_PQ_result_spec_uint32 ( + "requested_purse_limit", + &td.details.reserves_open_requests.requested_purse_limit), + GNUNET_PQ_result_spec_end + }; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + ctx->error = true; + return; + } + ctx->cb (ctx->cb_cls, + &td); + GNUNET_PQ_cleanup_result (rs); + } +} + + +/** + * Function called with reserves_open_deposits table entries. + * + * @param cls closure + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +lrbt_cb_table_reserves_open_deposits (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct LookupRecordsByTableContext *ctx = cls; + struct PostgresClosure *pg = ctx->pg; + struct TALER_EXCHANGEDB_TableData td = { + .table = TALER_EXCHANGEDB_RT_RESERVES_OPEN_DEPOSITS + }; + + for (unsigned int i = 0; i<num_results; i++) + { + struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ("serial", + &td.serial), + GNUNET_PQ_result_spec_auto_from_type ( + "reserve_sig", + &td.details.reserves_open_deposits.reserve_sig), + GNUNET_PQ_result_spec_auto_from_type ( + "reserve_pub", + &td.details.reserves_open_deposits.reserve_pub), + GNUNET_PQ_result_spec_auto_from_type ( + "coin_pub", + &td.details.reserves_open_deposits.coin_pub), + GNUNET_PQ_result_spec_auto_from_type ( + "coin_sig", + &td.details.reserves_open_deposits.coin_sig), + TALER_PQ_RESULT_SPEC_AMOUNT ( + "contribution", + &td.details.reserves_open_deposits.contribution), + GNUNET_PQ_result_spec_end + }; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + ctx->error = true; + return; + } + ctx->cb (ctx->cb_cls, + &td); + GNUNET_PQ_cleanup_result (rs); + } +} + + +/** * Function called with reserves_out table entries. * * @param cls closure @@ -897,9 +1124,9 @@ lrbt_cb_table_refresh_transfer_keys (void *cls, ctx->error = true; return; } - memcpy (&td.details.refresh_transfer_keys.tprivs[0], - tpriv, - tpriv_size); + GNUNET_memcpy (&td.details.refresh_transfer_keys.tprivs[0], + tpriv, + tpriv_size); ctx->cb (ctx->cb_cls, &td); GNUNET_PQ_cleanup_result (rs); @@ -908,77 +1135,124 @@ lrbt_cb_table_refresh_transfer_keys (void *cls, /** - * Function called with deposits table entries. + * Function called with batch deposits table entries. * * @param cls closure * @param result the postgres result * @param num_results the number of results in @a result */ static void -lrbt_cb_table_deposits (void *cls, - PGresult *result, - unsigned int num_results) +lrbt_cb_table_batch_deposits (void *cls, + PGresult *result, + unsigned int num_results) { struct LookupRecordsByTableContext *ctx = cls; - struct PostgresClosure *pg = ctx->pg; struct TALER_EXCHANGEDB_TableData td = { - .table = TALER_EXCHANGEDB_RT_DEPOSITS + .table = TALER_EXCHANGEDB_RT_BATCH_DEPOSITS }; for (unsigned int i = 0; i<num_results; i++) { - bool no_policy; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ( "serial", &td.serial), GNUNET_PQ_result_spec_uint64 ( "shard", - &td.details.deposits.shard), - GNUNET_PQ_result_spec_uint64 ( - "known_coin_id", - &td.details.deposits.known_coin_id), + &td.details.batch_deposits.shard), GNUNET_PQ_result_spec_auto_from_type ( - "coin_pub", - &td.details.deposits.coin_pub), - TALER_PQ_RESULT_SPEC_AMOUNT ( - "amount_with_fee", - &td.details.deposits.amount_with_fee), + "merchant_pub", + &td.details.batch_deposits.merchant_pub), GNUNET_PQ_result_spec_timestamp ( "wallet_timestamp", - &td.details.deposits.wallet_timestamp), + &td.details.batch_deposits.wallet_timestamp), GNUNET_PQ_result_spec_timestamp ( "exchange_timestamp", - &td.details.deposits.exchange_timestamp), + &td.details.batch_deposits.exchange_timestamp), GNUNET_PQ_result_spec_timestamp ( "refund_deadline", - &td.details.deposits.refund_deadline), + &td.details.batch_deposits.refund_deadline), GNUNET_PQ_result_spec_timestamp ( "wire_deadline", - &td.details.deposits.wire_deadline), - GNUNET_PQ_result_spec_auto_from_type ( - "merchant_pub", - &td.details.deposits.merchant_pub), + &td.details.batch_deposits.wire_deadline), GNUNET_PQ_result_spec_auto_from_type ( "h_contract_terms", - &td.details.deposits.h_contract_terms), - GNUNET_PQ_result_spec_auto_from_type ( - "coin_sig", - &td.details.deposits.coin_sig), + &td.details.batch_deposits.h_contract_terms), + GNUNET_PQ_result_spec_allow_null ( + GNUNET_PQ_result_spec_auto_from_type ( + "wallet_data_hash", + &td.details.batch_deposits.wallet_data_hash), + &td.details.batch_deposits.no_wallet_data_hash), GNUNET_PQ_result_spec_auto_from_type ( "wire_salt", - &td.details.deposits.wire_salt), + &td.details.batch_deposits.wire_salt), GNUNET_PQ_result_spec_auto_from_type ( "wire_target_h_payto", - &td.details.deposits.wire_target_h_payto), + &td.details.batch_deposits.wire_target_h_payto), GNUNET_PQ_result_spec_auto_from_type ( "policy_blocked", - &td.details.deposits.policy_blocked), + &td.details.batch_deposits.policy_blocked), GNUNET_PQ_result_spec_allow_null ( GNUNET_PQ_result_spec_uint64 ( "policy_details_serial_id", - &td.details.deposits.policy_details_serial_id), - &no_policy), + &td.details.batch_deposits.policy_details_serial_id), + &td.details.batch_deposits.no_policy_details), + GNUNET_PQ_result_spec_end + }; + + td.details.batch_deposits.policy_details_serial_id = 0; + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + ctx->error = true; + return; + } + ctx->cb (ctx->cb_cls, + &td); + GNUNET_PQ_cleanup_result (rs); + } +} + + +/** + * Function called with coin deposits table entries. + * + * @param cls closure + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +lrbt_cb_table_coin_deposits (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct LookupRecordsByTableContext *ctx = cls; + struct PostgresClosure *pg = ctx->pg; + struct TALER_EXCHANGEDB_TableData td = { + .table = TALER_EXCHANGEDB_RT_COIN_DEPOSITS + }; + + for (unsigned int i = 0; i<num_results; i++) + { + struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ( + "serial", + &td.serial), + GNUNET_PQ_result_spec_uint64 ( + "batch_deposit_serial_id", + &td.details.coin_deposits.batch_deposit_serial_id), + GNUNET_PQ_result_spec_auto_from_type ( + "coin_pub", + &td.details.coin_deposits.coin_pub), + GNUNET_PQ_result_spec_auto_from_type ( + "coin_sig", + &td.details.coin_deposits.coin_sig), + TALER_PQ_RESULT_SPEC_AMOUNT ( + "amount_with_fee", + &td.details.coin_deposits.amount_with_fee), GNUNET_PQ_result_spec_end }; @@ -1035,8 +1309,8 @@ lrbt_cb_table_refunds (void *cls, "amount_with_fee", &td.details.refunds.amount_with_fee), GNUNET_PQ_result_spec_uint64 ( - "deposit_serial_id", - &td.details.refunds.deposit_serial_id), + "batch_deposit_serial_id", + &td.details.refunds.batch_deposit_serial_id), GNUNET_PQ_result_spec_end }; @@ -1137,8 +1411,8 @@ lrbt_cb_table_aggregation_tracking (void *cls, "serial", &td.serial), GNUNET_PQ_result_spec_uint64 ( - "deposit_serial_id", - &td.details.aggregation_tracking.deposit_serial_id), + "batch_deposit_serial_id", + &td.details.aggregation_tracking.batch_deposit_serial_id), GNUNET_PQ_result_spec_auto_from_type ( "wtid_raw", &td.details.aggregation_tracking.wtid_raw), @@ -2296,6 +2570,313 @@ lrbt_cb_table_profit_drains (void *cls, /** + * Function called with aml_staff table entries. + * + * @param cls closure + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +lrbt_cb_table_aml_staff (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct LookupRecordsByTableContext *ctx = cls; + struct TALER_EXCHANGEDB_TableData td = { + .table = TALER_EXCHANGEDB_RT_AML_STAFF + }; + + for (unsigned int i = 0; i<num_results; i++) + { + struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ( + "aml_staff_uuid", + &td.serial), + GNUNET_PQ_result_spec_auto_from_type ( + "decider_pub", + &td.details.aml_staff.decider_pub), + GNUNET_PQ_result_spec_auto_from_type ( + "master_sig", + &td.details.aml_staff.master_sig), + GNUNET_PQ_result_spec_string ( + "decider_name", + &td.details.aml_staff.decider_name), + GNUNET_PQ_result_spec_bool ( + "is_active", + &td.details.aml_staff.is_active), + GNUNET_PQ_result_spec_bool ( + "read_only", + &td.details.aml_staff.read_only), + GNUNET_PQ_result_spec_timestamp ( + "last_change", + &td.details.aml_staff.last_change), + GNUNET_PQ_result_spec_end + }; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + ctx->error = true; + return; + } + ctx->cb (ctx->cb_cls, + &td); + GNUNET_PQ_cleanup_result (rs); + } +} + + +/** + * Function called with aml_history table entries. + * + * @param cls closure + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +lrbt_cb_table_aml_history (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct LookupRecordsByTableContext *ctx = cls; + struct PostgresClosure *pg = ctx->pg; + struct TALER_EXCHANGEDB_TableData td = { + .table = TALER_EXCHANGEDB_RT_AML_HISTORY + }; + + for (unsigned int i = 0; i<num_results; i++) + { + uint32_t status32; + struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ( + "aml_history_serial_id", + &td.serial), + GNUNET_PQ_result_spec_auto_from_type ( + "h_payto", + &td.details.aml_history.h_payto), + TALER_PQ_RESULT_SPEC_AMOUNT ( + "new_threshold", + &td.details.aml_history.new_threshold), + GNUNET_PQ_result_spec_uint32 ( + "new_status", + &status32), + GNUNET_PQ_result_spec_timestamp ( + "decision_time", + &td.details.aml_history.decision_time), + GNUNET_PQ_result_spec_string ( + "justification", + &td.details.aml_history.justification), + GNUNET_PQ_result_spec_allow_null ( + GNUNET_PQ_result_spec_string ( + "kyc_requirements", + &td.details.aml_history.kyc_requirements), + NULL), + GNUNET_PQ_result_spec_uint64 ( + "kyc_req_row", + &td.details.aml_history.kyc_req_row), + GNUNET_PQ_result_spec_auto_from_type ( + "decider_pub", + &td.details.aml_history.decider_pub), + GNUNET_PQ_result_spec_auto_from_type ( + "decider_sig", + &td.details.aml_history.decider_sig), + GNUNET_PQ_result_spec_end + }; + + td.details.aml_history.kyc_requirements = NULL; + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + ctx->error = true; + return; + } + td.details.aml_history.new_status + = (enum TALER_AmlDecisionState) status32; + ctx->cb (ctx->cb_cls, + &td); + GNUNET_PQ_cleanup_result (rs); + } +} + + +/** + * Function called with kyc_attributes table entries. + * + * @param cls closure + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +lrbt_cb_table_kyc_attributes (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct LookupRecordsByTableContext *ctx = cls; + struct TALER_EXCHANGEDB_TableData td = { + .table = TALER_EXCHANGEDB_RT_KYC_ATTRIBUTES + }; + + for (unsigned int i = 0; i<num_results; i++) + { + struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ( + "kyc_attributes_serial_id", + &td.serial), + GNUNET_PQ_result_spec_auto_from_type ( + "h_payto", + &td.details.kyc_attributes.h_payto), + GNUNET_PQ_result_spec_auto_from_type ( + "kyc_prox", + &td.details.kyc_attributes.kyc_prox), + GNUNET_PQ_result_spec_string ( + "provider", + &td.details.kyc_attributes.provider), + GNUNET_PQ_result_spec_timestamp ( + "collection_time", + &td.details.kyc_attributes.collection_time), + GNUNET_PQ_result_spec_timestamp ( + "expiration_time", + &td.details.kyc_attributes.expiration_time), + GNUNET_PQ_result_spec_variable_size ( + "encrypted_attributes", + &td.details.kyc_attributes.encrypted_attributes, + &td.details.kyc_attributes.encrypted_attributes_size), + GNUNET_PQ_result_spec_end + }; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + ctx->error = true; + return; + } + ctx->cb (ctx->cb_cls, + &td); + GNUNET_PQ_cleanup_result (rs); + } +} + + +/** + * Function called with purse_deletion table entries. + * + * @param cls closure + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +lrbt_cb_table_purse_deletion (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct LookupRecordsByTableContext *ctx = cls; + struct TALER_EXCHANGEDB_TableData td = { + .table = TALER_EXCHANGEDB_RT_PURSE_DELETION + }; + + for (unsigned int i = 0; i<num_results; i++) + { + struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ( + "purse_deletion_serial_id", + &td.serial), + GNUNET_PQ_result_spec_auto_from_type ( + "purse_sig", + &td.details.purse_deletion.purse_sig), + GNUNET_PQ_result_spec_auto_from_type ( + "purse_pub", + &td.details.purse_deletion.purse_pub), + GNUNET_PQ_result_spec_end + }; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + ctx->error = true; + return; + } + ctx->cb (ctx->cb_cls, + &td); + GNUNET_PQ_cleanup_result (rs); + } +} + + +/** + * Function called with age_withdraw table entries. + * + * @param cls closure + * @param result the postgres result + * @param num_results the number of results in @a result + */ +static void +lrbt_cb_table_age_withdraw (void *cls, + PGresult *result, + unsigned int num_results) +{ + struct LookupRecordsByTableContext *ctx = cls; + struct PostgresClosure *pg = ctx->pg; + struct TALER_EXCHANGEDB_TableData td = { + .table = TALER_EXCHANGEDB_RT_AGE_WITHDRAW + }; + + for (unsigned int i = 0; i<num_results; i++) + { + struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_uint64 ( + "age_withdraw_id", + &td.serial), + GNUNET_PQ_result_spec_auto_from_type ( + "h_commitment", + &td.details.age_withdraw.h_commitment), + GNUNET_PQ_result_spec_uint16 ( + "max_age", + &td.details.age_withdraw.max_age), + TALER_PQ_RESULT_SPEC_AMOUNT ( + "amount_with_fee", + &td.details.age_withdraw.amount_with_fee), + GNUNET_PQ_result_spec_auto_from_type ( + "reserve_pub", + &td.details.age_withdraw.reserve_pub), + GNUNET_PQ_result_spec_auto_from_type ( + "reserve_sig", + &td.details.age_withdraw.reserve_sig), + GNUNET_PQ_result_spec_uint32 ( + "noreveal_index", + &td.details.age_withdraw.noreveal_index), + /* TODO[oec]: more fields! */ + GNUNET_PQ_result_spec_end + }; + + if (GNUNET_OK != + GNUNET_PQ_extract_result (result, + rs, + i)) + { + GNUNET_break (0); + ctx->error = true; + return; + } + ctx->cb (ctx->cb_cls, + &td); + GNUNET_PQ_cleanup_result (rs); + } +} + + +/** * Assign statement to @a n and PREPARE * @a sql under name @a n. */ @@ -2321,8 +2902,8 @@ TEH_PG_lookup_records_by_table (void *cls, .cb = cb, .cb_cls = cb_cls }; - GNUNET_PQ_PostgresResultHandler rh; - const char *statement; + GNUNET_PQ_PostgresResultHandler rh = NULL; + const char *statement = NULL; enum GNUNET_DB_QueryStatus qs; switch (table) @@ -2338,16 +2919,11 @@ TEH_PG_lookup_records_by_table (void *cls, ",expire_withdraw" ",expire_deposit" ",expire_legal" - ",coin_val" - ",coin_frac" - ",fee_withdraw_val" - ",fee_withdraw_frac" - ",fee_deposit_val" - ",fee_deposit_frac" - ",fee_refresh_val" - ",fee_refresh_frac" - ",fee_refund_val" - ",fee_refund_frac" + ",coin" + ",fee_withdraw" + ",fee_deposit" + ",fee_refresh" + ",fee_refund" ",age_mask" " FROM denominations" " WHERE denominations_serial > $1" @@ -2375,6 +2951,33 @@ TEH_PG_lookup_records_by_table (void *cls, " ORDER BY wire_target_serial_id ASC;"); rh = &lrbt_cb_table_wire_targets; break; + case TALER_EXCHANGEDB_RT_LEGITIMIZATION_PROCESSES: + XPREPARE ("select_above_serial_by_table_legitimization_processes", + "SELECT" + " legitimization_process_serial_id AS serial" + ",h_payto" + ",reserve_pub" + ",expiration_time" + ",provider_section" + ",provider_user_id" + ",provider_legitimization_id" + " FROM legitimization_processes" + " WHERE legitimization_process_serial_id > $1" + " ORDER BY legitimization_process_serial_id ASC;"); + rh = &lrbt_cb_table_legitimization_processes; + break; + case TALER_EXCHANGEDB_RT_LEGITIMIZATION_REQUIREMENTS: + XPREPARE ("select_above_serial_by_table_legitimization_requirements", + "SELECT" + " legitimization_requirement_serial_id AS serial" + ",h_payto" + ",reserve_pub" + ",required_checks" + " FROM legitimization_requirements" + " WHERE legitimization_requirement_serial_id > $1" + " ORDER BY legitimization_requirement_serial_id ASC;"); + rh = &lrbt_cb_table_legitimization_requirements; + break; case TALER_EXCHANGEDB_RT_RESERVES: XPREPARE ("select_above_serial_by_table_reserves", "SELECT" @@ -2393,8 +2996,7 @@ TEH_PG_lookup_records_by_table (void *cls, " reserve_in_serial_id AS serial" ",reserve_pub" ",wire_reference" - ",credit_val" - ",credit_frac" + ",credit" ",wire_source_h_payto" ",exchange_account_section" ",execution_date" @@ -2411,15 +3013,42 @@ TEH_PG_lookup_records_by_table (void *cls, ",execution_date" ",wtid" ",wire_target_h_payto" - ",amount_val" - ",amount_frac" - ",closing_fee_val" - ",closing_fee_frac" + ",amount" + ",closing_fee" " FROM reserves_close" " WHERE close_uuid > $1" " ORDER BY close_uuid ASC;"); rh = &lrbt_cb_table_reserves_close; break; + case TALER_EXCHANGEDB_RT_RESERVES_OPEN_REQUESTS: + XPREPARE ("select_above_serial_by_table_reserves_open_requests", + "SELECT" + " open_request_uuid AS serial" + ",reserve_pub" + ",request_timestamp" + ",expiration_date" + ",reserve_sig" + ",reserve_payment" + ",requested_purse_limit" + " FROM reserves_open_requests" + " WHERE open_request_uuid > $1" + " ORDER BY open_request_uuid ASC;"); + rh = &lrbt_cb_table_reserves_open_requests; + break; + case TALER_EXCHANGEDB_RT_RESERVES_OPEN_DEPOSITS: + XPREPARE ("select_above_serial_by_table_reserves_open_deposits", + "SELECT" + " reserves_open_deposit_uuid AS serial" + ",reserve_sig" + ",reserve_pub" + ",coin_pub" + ",coin_sig" + ",contribution" + " FROM reserves_open_deposits" + " WHERE reserves_open_deposit_uuid > $1" + " ORDER BY reserves_open_deposit_uuid ASC;"); + rh = &lrbt_cb_table_reserves_open_deposits; + break; case TALER_EXCHANGEDB_RT_RESERVES_OUT: XPREPARE ("select_above_serial_by_table_reserves_out", "SELECT" @@ -2430,8 +3059,7 @@ TEH_PG_lookup_records_by_table (void *cls, ",reserve_uuid" ",reserve_sig" ",execution_date" - ",amount_with_fee_val" - ",amount_with_fee_frac" + ",amount_with_fee" " FROM reserves_out" " JOIN reserves USING (reserve_uuid)" " WHERE reserve_out_serial_id > $1" @@ -2507,8 +3135,7 @@ TEH_PG_lookup_records_by_table (void *cls, " melt_serial_id AS serial" ",rc" ",old_coin_sig" - ",amount_with_fee_val" - ",amount_with_fee_frac" + ",amount_with_fee" ",noreveal_index" ",old_coin_pub" " FROM refresh_commitments" @@ -2544,31 +3171,40 @@ TEH_PG_lookup_records_by_table (void *cls, " ORDER BY rtc_serial ASC;"); rh = &lrbt_cb_table_refresh_transfer_keys; break; - case TALER_EXCHANGEDB_RT_DEPOSITS: - XPREPARE ("select_above_serial_by_table_deposits", + case TALER_EXCHANGEDB_RT_BATCH_DEPOSITS: + XPREPARE ("select_above_serial_by_table_batch_deposits", "SELECT" - " deposit_serial_id AS serial" + " batch_deposit_serial_id AS serial" ",shard" - ",coin_pub" - ",known_coin_id" - ",amount_with_fee_val" - ",amount_with_fee_frac" + ",merchant_pub" ",wallet_timestamp" ",exchange_timestamp" ",refund_deadline" ",wire_deadline" - ",merchant_pub" ",h_contract_terms" - ",coin_sig" + ",wallet_data_hash" ",wire_salt" ",wire_target_h_payto" ",done" ",policy_blocked" ",policy_details_serial_id" - " FROM deposits" - " WHERE deposit_serial_id > $1" - " ORDER BY deposit_serial_id ASC;"); - rh = &lrbt_cb_table_deposits; + " FROM batch_deposits" + " WHERE batch_deposit_serial_id > $1" + " ORDER BY batch_deposit_serial_id ASC;"); + rh = &lrbt_cb_table_batch_deposits; + break; + case TALER_EXCHANGEDB_RT_COIN_DEPOSITS: + XPREPARE ("select_above_serial_by_table_coin_deposits", + "SELECT" + " coin_deposit_serial_id AS serial" + ",batch_deposit_serial_id" + ",coin_pub" + ",coin_sig" + ",amount_with_fee" + " FROM coin_deposits" + " WHERE coin_deposit_serial_id > $1" + " ORDER BY coin_deposit_serial_id ASC;"); + rh = &lrbt_cb_table_coin_deposits; break; case TALER_EXCHANGEDB_RT_REFUNDS: XPREPARE ("select_above_serial_by_table_refunds", @@ -2577,9 +3213,8 @@ TEH_PG_lookup_records_by_table (void *cls, ",coin_pub" ",merchant_sig" ",rtransaction_id" - ",amount_with_fee_val" - ",amount_with_fee_frac" - ",deposit_serial_id" + ",amount_with_fee" + ",batch_deposit_serial_id" " FROM refunds" " WHERE refund_serial_id > $1" " ORDER BY refund_serial_id ASC;"); @@ -2593,8 +3228,7 @@ TEH_PG_lookup_records_by_table (void *cls, ",wtid_raw" ",wire_target_h_payto" ",exchange_account_section" - ",amount_val" - ",amount_frac" + ",amount" " FROM wire_out" " WHERE wireout_uuid > $1" " ORDER BY wireout_uuid ASC;"); @@ -2604,7 +3238,7 @@ TEH_PG_lookup_records_by_table (void *cls, XPREPARE ("select_above_serial_by_table_aggregation_tracking", "SELECT" " aggregation_serial_id AS serial" - ",deposit_serial_id" + ",batch_deposit_serial_id" ",wtid_raw" " FROM aggregation_tracking" " WHERE aggregation_serial_id > $1" @@ -2618,10 +3252,8 @@ TEH_PG_lookup_records_by_table (void *cls, ",wire_method" ",start_date" ",end_date" - ",wire_fee_val" - ",wire_fee_frac" - ",closing_fee_val" - ",closing_fee_frac" + ",wire_fee" + ",closing_fee" ",master_sig" " FROM wire_fee" " WHERE wire_fee_serial > $1" @@ -2634,12 +3266,9 @@ TEH_PG_lookup_records_by_table (void *cls, " global_fee_serial AS serial" ",start_date" ",end_date" - ",history_fee_val" - ",history_fee_frac" - ",account_fee_val" - ",account_fee_frac" - ",purse_fee_val" - ",purse_fee_frac" + ",history_fee" + ",account_fee" + ",purse_fee" ",purse_timeout" ",history_expiration" ",purse_account_limit" @@ -2655,8 +3284,7 @@ TEH_PG_lookup_records_by_table (void *cls, " recoup_uuid AS serial" ",coin_sig" ",coin_blind" - ",amount_val" - ",amount_frac" + ",amount" ",recoup_timestamp" ",coin_pub" ",reserve_out_serial_id" @@ -2671,8 +3299,7 @@ TEH_PG_lookup_records_by_table (void *cls, " recoup_refresh_uuid AS serial" ",coin_sig" ",coin_blind" - ",amount_val" - ",amount_frac" + ",amount" ",recoup_timestamp" ",coin_pub" ",known_coin_id" @@ -2705,10 +3332,8 @@ TEH_PG_lookup_records_by_table (void *cls, ",h_contract_terms" ",age_limit" ",flags" - ",amount_with_fee_val" - ",amount_with_fee_frac" - ",purse_fee_val" - ",purse_fee_frac" + ",amount_with_fee" + ",purse_fee" ",purse_sig" " FROM purse_requests" " WHERE purse_requests_serial_id > $1" @@ -2748,8 +3373,7 @@ TEH_PG_lookup_records_by_table (void *cls, ",partner_serial_id" ",purse_pub" ",coin_pub" - ",amount_with_fee_val" - ",amount_with_fee_frac" + ",amount_with_fee" ",coin_sig" " FROM purse_deposits" " WHERE purse_deposit_serial_id > $1" @@ -2776,8 +3400,7 @@ TEH_PG_lookup_records_by_table (void *cls, ",reserve_pub" ",request_timestamp" ",reserve_sig" - ",history_fee_val" - ",history_fee_frac" + ",history_fee" " FROM history_requests" " WHERE history_request_serial_id > $1" " ORDER BY history_request_serial_id ASC;"); @@ -2790,8 +3413,7 @@ TEH_PG_lookup_records_by_table (void *cls, ",reserve_pub" ",close_timestamp" ",reserve_sig" - ",close_val" - ",close_frac" + ",close" " FROM close_requests" " WHERE close_request_serial_id > $1" " ORDER BY close_request_serial_id ASC;"); @@ -2803,8 +3425,7 @@ TEH_PG_lookup_records_by_table (void *cls, " wad_out_serial_id" ",wad_id" ",partner_serial_id" - ",amount_val" - ",amount_frac" + ",amount" ",execution_time" " FROM wads_out" " WHERE wad_out_serial_id > $1" @@ -2820,12 +3441,9 @@ TEH_PG_lookup_records_by_table (void *cls, ",h_contract" ",purse_expiration" ",merge_timestamp" - ",amount_with_fee_val" - ",amount_with_fee_frac" - ",wad_fee_val" - ",wad_fee_frac" - ",deposit_fees_val" - ",deposit_fees_frac" + ",amount_with_fee" + ",wad_fee" + ",deposit_fees" ",reserve_sig" ",purse_sig" " FROM wad_out_entries" @@ -2839,8 +3457,7 @@ TEH_PG_lookup_records_by_table (void *cls, " wad_in_serial_id" ",wad_id" ",origin_exchange_url" - ",amount_val" - ",amount_frac" + ",amount" ",arrival_time" " FROM wads_in" " WHERE wad_in_serial_id > $1" @@ -2856,12 +3473,9 @@ TEH_PG_lookup_records_by_table (void *cls, ",h_contract" ",purse_expiration" ",merge_timestamp" - ",amount_with_fee_val" - ",amount_with_fee_frac" - ",wad_fee_val" - ",wad_fee_frac" - ",deposit_fees_val" - ",deposit_fees_frac" + ",amount_with_fee" + ",wad_fee" + ",deposit_fees" ",reserve_sig" ",purse_sig" " FROM wad_in_entries" @@ -2877,15 +3491,92 @@ TEH_PG_lookup_records_by_table (void *cls, ",account_section" ",payto_uri" ",trigger_date" - ",amount_val" - ",amount_frac" + ",amount" ",master_sig" " FROM profit_drains" " WHERE profit_drain_serial_id > $1" " ORDER BY profit_drain_serial_id ASC;"); rh = &lrbt_cb_table_profit_drains; break; - default: + + case TALER_EXCHANGEDB_RT_AML_STAFF: + XPREPARE ("select_above_serial_by_table_aml_staff", + "SELECT" + " aml_staff_uuid" + ",decider_pub" + ",master_sig" + ",decider_name" + ",is_active" + ",read_only" + ",last_change" + " FROM aml_staff" + " WHERE aml_staff_uuid > $1" + " ORDER BY aml_staff_uuid ASC;"); + rh = &lrbt_cb_table_aml_staff; + break; + case TALER_EXCHANGEDB_RT_AML_HISTORY: + XPREPARE ("select_above_serial_by_table_aml_history", + "SELECT" + " aml_history_serial_id" + ",h_payto" + ",new_threshold" + ",new_status" + ",decision_time" + ",justification" + ",kyc_requirements" + ",kyc_req_row" + ",decider_pub" + ",decider_sig" + " FROM aml_history" + " WHERE aml_history_serial_id > $1" + " ORDER BY aml_history_serial_id ASC;"); + rh = &lrbt_cb_table_aml_history; + break; + case TALER_EXCHANGEDB_RT_KYC_ATTRIBUTES: + XPREPARE ("select_above_serial_by_table_kyc_attributes", + "SELECT" + " kyc_attributes_serial_id" + ",h_payto" + ",kyc_prox" + ",provider" + ",collection_time" + ",expiration_time" + ",encrypted_attributes" + " FROM kyc_attributes" + " WHERE kyc_attributes_serial_id > $1" + " ORDER BY kyc_attributes_serial_id ASC;"); + rh = &lrbt_cb_table_kyc_attributes; + break; + case TALER_EXCHANGEDB_RT_PURSE_DELETION: + XPREPARE ("select_above_serial_by_table_purse_deletion", + "SELECT" + " purse_deletion_serial_id" + ",purse_pub" + ",purse_sig" + " FROM purse_deletion" + " WHERE purse_deletion_serial_id > $1" + " ORDER BY purse_deletion_serial_id ASC;"); + rh = &lrbt_cb_table_purse_deletion; + break; + case TALER_EXCHANGEDB_RT_AGE_WITHDRAW: + XPREPARE ("select_above_serial_by_table_age_withdraw", + "SELECT" + " age_withdraw_id" + ",h_commitment" + ",amount_with_fee" + ",max_age" + ",reserve_pub" + ",reserve_sig" + ",noreveal_index" + " FROM age_withdraw" + " WHERE age_withdraw_id > $1" + " ORDER BY age_withdraw_id ASC;"); + /* TODO[oec]: MORE FIELDS! */ + rh = &lrbt_cb_table_age_withdraw; + break; + } + if (NULL == rh) + { GNUNET_break (0); return GNUNET_DB_STATUS_HARD_ERROR; } |