diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-11-20 23:48:13 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-11-20 23:48:13 +0100 |
commit | 3c358444a40466762cf10d20784b3a64fb984d2a (patch) | |
tree | 0d028cd41e27541366e23ee9941a2a7f6cfd684d | |
parent | 1fe62d241647614ea275fdaf0334ca3cec0a3505 (diff) |
implement #9346
-rw-r--r-- | src/auditor/taler-helper-auditor-aggregation.c | 14 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-coins.c | 12 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-purses.c | 8 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-reserves.c | 14 | ||||
-rw-r--r-- | src/benchmark/taler-exchange-benchmark.c | 4 | ||||
-rw-r--r-- | src/exchange/Makefile.am | 2 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_config.h | 2 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_reserves_get.c | 26 | ||||
-rw-r--r-- | src/exchange/taler-exchange-wirewatch.c | 9 | ||||
-rw-r--r-- | src/exchangedb/pg_get_reserve_balance.c | 26 | ||||
-rw-r--r-- | src/exchangedb/pg_get_reserve_balance.h | 12 | ||||
-rw-r--r-- | src/include/taler_exchange_service.h | 6 | ||||
-rw-r--r-- | src/include/taler_exchangedb_plugin.h | 30 | ||||
-rw-r--r-- | src/lib/exchange_api_handle.c | 4 | ||||
-rw-r--r-- | src/lib/exchange_api_reserves_get.c | 5 | ||||
-rw-r--r-- | src/testing/test_exchange_api.c | 4 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_exec_wirewatch.c | 1 |
17 files changed, 120 insertions, 59 deletions
diff --git a/src/auditor/taler-helper-auditor-aggregation.c b/src/auditor/taler-helper-auditor-aggregation.c index 6d8c21dbe..fc1825ecd 100644 --- a/src/auditor/taler-helper-auditor-aggregation.c +++ b/src/auditor/taler-helper-auditor-aggregation.c @@ -445,9 +445,9 @@ check_transaction_history_for_deposit ( { struct TALER_AUDITORDB_RowInconsistency ri = { .row_id = tl->serial_id, - .diagnostic = - "multiple deposits of the same coin into the same contract detected", - .row_table = "deposits" + .diagnostic = (char *) + "multiple deposits of the same coin into the same contract detected", + .row_table = (char *) "deposits" }; qs = TALER_ARL_adb->insert_row_inconsistency ( @@ -901,7 +901,7 @@ wire_transfer_information_cb ( { struct TALER_AUDITORDB_BadSigLosses bsl = { .problem_row_id = rowid, - .operation = "wire", + .operation = (char *) "wire", .loss = *coin_value, .operation_specific_pub = coin.coin_pub.eddsa_pub }; @@ -1130,7 +1130,7 @@ get_wire_fee (struct AggregationContext *ac, { struct TALER_AUDITORDB_FeeTimeInconsistency ftib = { .problem_row_id = 0, /* FIXME: fetch above! */ - .diagnostic = "start date before previous end date", + .diagnostic = (char *) "start date before previous end date", .time = wfi->start_date.abs_time, .type = (char *) method }; @@ -1152,7 +1152,7 @@ get_wire_fee (struct AggregationContext *ac, { struct TALER_AUDITORDB_FeeTimeInconsistency ftia = { .problem_row_id = 0, /* FIXME: fetch above! */ - .diagnostic = "end date date after next start date", + .diagnostic = (char *) "end date date after next start date", .time = wfi->end_date.abs_time, .type = (char *) method }; @@ -1342,7 +1342,7 @@ check_wire_out_cb (void *cls, { struct TALER_AUDITORDB_WireOutInconsistency woi = { .destination_account = payto_uri, - .diagnostic = "aggregated amount does not match expectations", + .diagnostic = (char *) "aggregated amount does not match expectations", .wire_out_row_id = rowid, .expected = final_amount, .claimed = *amount diff --git a/src/auditor/taler-helper-auditor-coins.c b/src/auditor/taler-helper-auditor-coins.c index 571d164ff..d8758c877 100644 --- a/src/auditor/taler-helper-auditor-coins.c +++ b/src/auditor/taler-helper-auditor-coins.c @@ -1387,7 +1387,7 @@ refresh_session_cb (void *cls, { struct TALER_AUDITORDB_BadSigLosses bsl = { .problem_row_id = rowid, - .operation = "melt", + .operation = (char *) "melt", .loss = *amount_with_fee, .operation_specific_pub = coin_pub->eddsa_pub }; @@ -1732,7 +1732,7 @@ deposit_cb (void *cls, { struct TALER_AUDITORDB_BadSigLosses bsl = { .problem_row_id = rowid, - .operation = "deposit", + .operation = (char *) "deposit", .loss = deposit->amount_with_fee, .operation_specific_pub = deposit->coin.coin_pub.eddsa_pub }; @@ -1869,7 +1869,7 @@ refund_cb (void *cls, { struct TALER_AUDITORDB_BadSigLosses bsl = { .problem_row_id = rowid, - .operation = "refund", + .operation = (char *) "refund", .loss = *amount_with_fee, .operation_specific_pub = coin_pub->eddsa_pub }; @@ -2291,7 +2291,7 @@ recoup_cb (void *cls, { struct TALER_AUDITORDB_BadSigLosses bsl = { .problem_row_id = rowid, - .operation = "recoup", + .operation = (char *) "recoup", .loss = *amount, .operation_specific_pub = coin->coin_pub.eddsa_pub }; @@ -2422,7 +2422,7 @@ recoup_refresh_cb (void *cls, { struct TALER_AUDITORDB_BadSigLosses bsl = { .problem_row_id = rowid, - .operation = "recoup-refresh", + .operation = (char *) "recoup-refresh", .loss = *amount, .operation_specific_pub = coin->coin_pub.eddsa_pub }; @@ -2613,7 +2613,7 @@ purse_deposit_cb ( { struct TALER_AUDITORDB_BadSigLosses bsl = { .problem_row_id = rowid, - .operation = "purse-deposit", + .operation = (char *) "purse-deposit", .loss = deposit->amount, .operation_specific_pub = deposit->coin_pub.eddsa_pub }; diff --git a/src/auditor/taler-helper-auditor-purses.c b/src/auditor/taler-helper-auditor-purses.c index 00a95953f..2accf72f9 100644 --- a/src/auditor/taler-helper-auditor-purses.c +++ b/src/auditor/taler-helper-auditor-purses.c @@ -506,7 +506,7 @@ handle_purse_requested ( { struct TALER_AUDITORDB_BadSigLosses bsl = { .problem_row_id = rowid, - .operation = "purse-request", + .operation = (char *) "purse-request", .loss = *target_amount, .operation_specific_pub = purse_pub->eddsa_pub }; @@ -631,7 +631,7 @@ handle_purse_deposits ( { struct TALER_AUDITORDB_BadSigLosses bsl = { .problem_row_id = rowid, - .operation = "purse-deposit", + .operation = (char *) "purse-deposit", .loss = deposit->amount, .operation_specific_pub = deposit->coin_pub.eddsa_pub }; @@ -738,7 +738,7 @@ handle_purse_merged ( { struct TALER_AUDITORDB_BadSigLosses bsl = { .problem_row_id = rowid, - .operation = "merge-purse", + .operation = (char *) "merge-purse", .loss = *amount, .operation_specific_pub = merge_pub->eddsa_pub }; @@ -847,7 +847,7 @@ handle_account_merged ( { struct TALER_AUDITORDB_BadSigLosses bsl = { .problem_row_id = rowid, - .operation = "account-merge", + .operation = (char *) "account-merge", .loss = *purse_fee, .operation_specific_pub = reserve_pub->eddsa_pub }; diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c index 2983bc112..209203048 100644 --- a/src/auditor/taler-helper-auditor-reserves.c +++ b/src/auditor/taler-helper-auditor-reserves.c @@ -611,7 +611,7 @@ handle_reserve_out ( { struct TALER_AUDITORDB_BadSigLosses bsl = { .problem_row_id = rowid, - .operation = "withdraw", + .operation = (char *) "withdraw", .loss = *amount_with_fee, .operation_specific_pub = reserve_pub->eddsa_pub }; @@ -722,7 +722,7 @@ handle_recoup_by_reserve ( { struct TALER_AUDITORDB_BadSigLosses bslr = { .problem_row_id = rowid, - .operation = "recoup", + .operation = (char *) "recoup", .loss = *amount, .operation_specific_pub = coin->coin_pub.eddsa_pub }; @@ -801,7 +801,7 @@ handle_recoup_by_reserve ( { struct TALER_AUDITORDB_BadSigLosses bslrm = { .problem_row_id = rev_rowid, - .operation = "recoup-master", + .operation = (char *) "recoup-master", .loss = *amount, .operation_specific_pub = TALER_ARL_master_pub.eddsa_pub }; @@ -947,7 +947,7 @@ handle_reserve_open ( { struct TALER_AUDITORDB_BadSigLosses bsl = { .problem_row_id = rowid, - .operation = "reserve-open", + .operation = (char *) "reserve-open", .loss = *reserve_payment, .operation_specific_pub = reserve_pub->eddsa_pub }; @@ -1102,7 +1102,7 @@ handle_reserve_closed ( { struct TALER_AUDITORDB_BadSigLosses bsl = { .problem_row_id = close_request_row, - .operation = "close-request", + .operation = (char *) "close-request", .loss = *amount_with_fee, .operation_specific_pub = reserve_pub->eddsa_pub }; @@ -1248,7 +1248,7 @@ handle_account_merged ( { struct TALER_AUDITORDB_BadSigLosses bsl = { .problem_row_id = rowid, - .operation = "account-merge", + .operation = (char *) "account-merge", .loss = *purse_fee, .operation_specific_pub = reserve_pub->eddsa_pub }; @@ -1576,7 +1576,7 @@ verify_reserve_balance (void *cls, .reserve_pub = rs->reserve_pub, .balance = nbalance, .expiration_time = rs->a_expiration_date.abs_time, - .diagnostic = "could not determine closing fee" + .diagnostic = (char *) "could not determine closing fee" }; qs = TALER_ARL_adb->insert_reserve_not_closed_inconsistency ( diff --git a/src/benchmark/taler-exchange-benchmark.c b/src/benchmark/taler-exchange-benchmark.c index a21b89bd5..9a69736a1 100644 --- a/src/benchmark/taler-exchange-benchmark.c +++ b/src/benchmark/taler-exchange-benchmark.c @@ -552,9 +552,9 @@ main (int argc, return EXIT_INVALIDARGUMENT; } if (NULL == exchange_bank_section) - exchange_bank_section = "exchange-account-1"; + exchange_bank_section = (char *) "exchange-account-1"; if (NULL == loglev) - loglev = "INFO"; + loglev = (char *) "INFO"; GNUNET_log_setup ("taler-exchange-benchmark", loglev, logfile); diff --git a/src/exchange/Makefile.am b/src/exchange/Makefile.am index ad065d449..117264212 100644 --- a/src/exchange/Makefile.am +++ b/src/exchange/Makefile.am @@ -209,8 +209,8 @@ taler_exchange_httpd_LDADD = \ $(top_builddir)/src/extensions/libtalerextensions.la \ -lmicrohttpd \ -lgnunetcurl \ - -lgnunetutil \ -lgnunetjson \ + -lgnunetutil \ -ljansson \ -lcurl \ -lz \ diff --git a/src/exchange/taler-exchange-httpd_config.h b/src/exchange/taler-exchange-httpd_config.h index e033ac29c..01237a80c 100644 --- a/src/exchange/taler-exchange-httpd_config.h +++ b/src/exchange/taler-exchange-httpd_config.h @@ -41,7 +41,7 @@ * * Returned via both /config and /keys endpoints. */ -#define EXCHANGE_PROTOCOL_VERSION "22:0:5" +#define EXCHANGE_PROTOCOL_VERSION "23:0:6" /** diff --git a/src/exchange/taler-exchange-httpd_reserves_get.c b/src/exchange/taler-exchange-httpd_reserves_get.c index 0775a4c65..043a93811 100644 --- a/src/exchange/taler-exchange-httpd_reserves_get.c +++ b/src/exchange/taler-exchange-httpd_reserves_get.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2023 Taler Systems SA + Copyright (C) 2014-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software @@ -77,6 +77,12 @@ struct ReservePoller struct TALER_Amount balance; /** + * Last origin account of the reserve, NULL if only + * P2P payments were made. + */ + struct TALER_FullPayto origin_account; + + /** * True if we are still suspended. */ bool suspended; @@ -134,6 +140,7 @@ rp_cleanup (struct TEH_RequestContext *rc) GNUNET_CONTAINER_DLL_remove (rp_head, rp_tail, rp); + GNUNET_free (rp->origin_account.full_payto); GNUNET_free (rp); } @@ -213,9 +220,11 @@ TEH_handler_reserves_get ( { enum GNUNET_DB_QueryStatus qs; + GNUNET_free (rp->origin_account.full_payto); qs = TEH_plugin->get_reserve_balance (TEH_plugin->cls, &rp->reserve_pub, - &rp->balance); + &rp->balance, + &rp->origin_account); switch (qs) { case GNUNET_DB_STATUS_SOFT_ERROR: @@ -234,10 +243,15 @@ TEH_handler_reserves_get ( GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Got reserve balance of %s\n", TALER_amount2s (&rp->balance)); - return TALER_MHD_REPLY_JSON_PACK (rc->connection, - MHD_HTTP_OK, - TALER_JSON_pack_amount ("balance", - &rp->balance)); + return TALER_MHD_REPLY_JSON_PACK ( + rc->connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_allow_null ( + GNUNET_JSON_pack_string ( + "last_origin", + rp->origin_account.full_payto)), + TALER_JSON_pack_amount ("balance", + &rp->balance)); case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: if (! GNUNET_TIME_absolute_is_future (rp->timeout)) { diff --git a/src/exchange/taler-exchange-wirewatch.c b/src/exchange/taler-exchange-wirewatch.c index 72545e916..37cac6721 100644 --- a/src/exchange/taler-exchange-wirewatch.c +++ b/src/exchange/taler-exchange-wirewatch.c @@ -596,6 +596,9 @@ process_reply (const struct TALER_BANK_CreditDetails *details, struct TALER_EXCHANGEDB_ReserveInInfo *res = &reserves[j++]; /* add to batch, do later */ + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Importing reserve transfer over %s\n", + TALER_amount2s (&cd->amount)); res->reserve_pub = &cd->details.reserve.reserve_pub; res->balance = &cd->amount; res->execution_time = cd->execution_date; @@ -606,6 +609,9 @@ process_reply (const struct TALER_BANK_CreditDetails *details, break; case TALER_BANK_CT_KYCAUTH: { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Importing KYC auth transfer over %s\n", + TALER_amount2s (&cd->amount)); qs = db_plugin->kycauth_in_insert ( db_plugin->cls, &cd->details.kycauth.account_pub, @@ -633,6 +639,9 @@ process_reply (const struct TALER_BANK_CreditDetails *details, } case TALER_BANK_CT_WAD: { + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Importing WAD transfer over %s\n", + TALER_amount2s (&cd->amount)); qs = db_plugin->wad_in_insert ( db_plugin->cls, &cd->details.wad.wad_id, diff --git a/src/exchangedb/pg_get_reserve_balance.c b/src/exchangedb/pg_get_reserve_balance.c index 140bf3b70..1e1f6425e 100644 --- a/src/exchangedb/pg_get_reserve_balance.c +++ b/src/exchangedb/pg_get_reserve_balance.c @@ -25,10 +25,13 @@ #include "pg_get_reserve_balance.h" #include "pg_helper.h" + enum GNUNET_DB_QueryStatus -TEH_PG_get_reserve_balance (void *cls, - const struct TALER_ReservePublicKeyP *reserve_pub, - struct TALER_Amount *balance) +TEH_PG_get_reserve_balance ( + void *cls, + const struct TALER_ReservePublicKeyP *reserve_pub, + struct TALER_Amount *balance, + struct TALER_FullPayto *origin_account) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -39,15 +42,26 @@ TEH_PG_get_reserve_balance (void *cls, TALER_PQ_result_spec_amount ("current_balance", pg->currency, balance), + GNUNET_PQ_result_spec_allow_null ( + GNUNET_PQ_result_spec_string ("payto_uri", + &origin_account->full_payto), + NULL), GNUNET_PQ_result_spec_end }; + origin_account->full_payto = NULL; PREPARE (pg, "get_reserve_balance", "SELECT" - " current_balance" - " FROM reserves" - " WHERE reserve_pub=$1;"); + " r.current_balance" + " ,wt.payto_uri" + " FROM reserves r" + " LEFT JOIN reserves_in ri" + " USING (reserve_pub)" + " LEFT JOIN wire_targets wt" + " ON (wt.wire_target_h_payto = ri.wire_source_h_payto)" + " WHERE r.reserve_pub=$1" + " LIMIT 1;"); return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "get_reserve_balance", params, diff --git a/src/exchangedb/pg_get_reserve_balance.h b/src/exchangedb/pg_get_reserve_balance.h index 6dc88d906..41fb16ea7 100644 --- a/src/exchangedb/pg_get_reserve_balance.h +++ b/src/exchangedb/pg_get_reserve_balance.h @@ -30,11 +30,15 @@ * @param cls the `struct PostgresClosure` with the plugin-specific state * @param reserve_pub public key of the reserve * @param[out] balance set to the reserve balance - * @return transaction status + * @param[out] origin_account set to URI of the origin account, NULL + * if we have no origin account (reserve created by P2P merge) +* @return transaction status */ enum GNUNET_DB_QueryStatus -TEH_PG_get_reserve_balance (void *cls, - const struct TALER_ReservePublicKeyP *reserve_pub, - struct TALER_Amount *balance); +TEH_PG_get_reserve_balance ( + void *cls, + const struct TALER_ReservePublicKeyP *reserve_pub, + struct TALER_Amount *balance, + struct TALER_FullPayto *origin_account); #endif diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h index c561e0e8f..d761dfc19 100644 --- a/src/include/taler_exchange_service.h +++ b/src/include/taler_exchange_service.h @@ -2486,6 +2486,12 @@ struct TALER_EXCHANGE_ReserveSummary */ struct TALER_Amount balance; + /** + * payto://-URI of the last bank account that wired funds + * to the reserve, NULL for none (can happen if reserve + * was funded via P2P merge). + */ + struct TALER_FullPayto last_origin; } ok; } details; diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index 88d05ce24..3c5846d2d 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -4415,13 +4415,14 @@ struct TALER_EXCHANGEDB_Plugin * @return transaction status */ enum GNUNET_DB_QueryStatus - (*get_reserve_history)(void *cls, - const struct TALER_ReservePublicKeyP *reserve_pub, - uint64_t start_off, - uint64_t etag_in, - uint64_t *etag_out, - struct TALER_Amount *balance, - struct TALER_EXCHANGEDB_ReserveHistory **rhp); + (*get_reserve_history)( + void *cls, + const struct TALER_ReservePublicKeyP *reserve_pub, + uint64_t start_off, + uint64_t etag_in, + uint64_t *etag_out, + struct TALER_Amount *balance, + struct TALER_EXCHANGEDB_ReserveHistory **rhp); /** @@ -4430,12 +4431,16 @@ struct TALER_EXCHANGEDB_Plugin * @param cls the @e cls of this struct with the plugin-specific state * @param reserve_pub public key of the reserve * @param[out] balance set to the reserve balance + * @param[out] origin_account set to URI of the origin account, NULL + * if we have no origin account (reserve created by P2P merge) * @return transaction status */ enum GNUNET_DB_QueryStatus - (*get_reserve_balance)(void *cls, - const struct TALER_ReservePublicKeyP *reserve_pub, - struct TALER_Amount *balance); + (*get_reserve_balance)( + void *cls, + const struct TALER_ReservePublicKeyP *reserve_pub, + struct TALER_Amount *balance, + struct TALER_FullPayto *origin_account); /** @@ -4445,8 +4450,9 @@ struct TALER_EXCHANGEDB_Plugin * @param rh history to free. */ void - (*free_reserve_history) (void *cls, - struct TALER_EXCHANGEDB_ReserveHistory *rh); + (*free_reserve_history) ( + void *cls, + struct TALER_EXCHANGEDB_ReserveHistory *rh); /** diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c index d03a6b5f6..03140636d 100644 --- a/src/lib/exchange_api_handle.c +++ b/src/lib/exchange_api_handle.c @@ -40,12 +40,12 @@ * Which version of the Taler protocol is implemented * by this library? Used to determine compatibility. */ -#define EXCHANGE_PROTOCOL_CURRENT 22 +#define EXCHANGE_PROTOCOL_CURRENT 23 /** * How many versions are we backwards compatible with? */ -#define EXCHANGE_PROTOCOL_AGE 5 +#define EXCHANGE_PROTOCOL_AGE 6 /** * Set to 1 for extra debug logging. diff --git a/src/lib/exchange_api_reserves_get.c b/src/lib/exchange_api_reserves_get.c index b6980dd1d..db43ee8e6 100644 --- a/src/lib/exchange_api_reserves_get.c +++ b/src/lib/exchange_api_reserves_get.c @@ -85,6 +85,11 @@ handle_reserves_get_ok (struct TALER_EXCHANGE_ReservesGetHandle *rgh, struct GNUNET_JSON_Specification spec[] = { TALER_JSON_spec_amount_any ("balance", &rs.details.ok.balance), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_string ( + "last_origin", + (const char **) &rs.details.ok.last_origin.full_payto), + NULL), GNUNET_JSON_spec_end () }; diff --git a/src/testing/test_exchange_api.c b/src/testing/test_exchange_api.c index 964e7e8ef..225c44ee4 100644 --- a/src/testing/test_exchange_api.c +++ b/src/testing/test_exchange_api.c @@ -132,7 +132,9 @@ run (void *cls, */ CMD_EXEC_WIREWATCH ("wirewatch-1"), TALER_TESTING_cmd_reserve_poll_finish ("finish-poll-reserve-1", - GNUNET_TIME_UNIT_SECONDS, + GNUNET_TIME_relative_multiply ( + GNUNET_TIME_UNIT_SECONDS, + 2), "poll-reserve-1"), /** * Withdraw EUR:5. diff --git a/src/testing/testing_api_cmd_exec_wirewatch.c b/src/testing/testing_api_cmd_exec_wirewatch.c index b6ed4f0f1..5b465d8f0 100644 --- a/src/testing/testing_api_cmd_exec_wirewatch.c +++ b/src/testing/testing_api_cmd_exec_wirewatch.c @@ -72,6 +72,7 @@ wirewatch_run (void *cls, "taler-exchange-wirewatch", "taler-exchange-wirewatch", "-c", ws->config_filename, + "-L", "INFO", "-S", "1", "-w", "0", "-t", /* exit when done */ |