commit 4d97a94d5a3a91eae84adb6e1626b9d2a71e3943
parent e650214142bb9dadd54fe76d6235e115aa4bd4e5
Author: Christian Grothoff <christian@grothoff.org>
Date: Fri, 1 Nov 2024 04:20:14 +0100
working through DB
Diffstat:
15 files changed, 75 insertions(+), 73 deletions(-)
diff --git a/src/exchangedb/pg_get_expired_reserves.c b/src/exchangedb/pg_get_expired_reserves.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
+ Copyright (C) 2022, 2024 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -68,20 +68,19 @@ reserve_expired_cb (void *cls,
{
struct ExpiredReserveContext *erc = cls;
struct PostgresClosure *pg = erc->pg;
- enum GNUNET_GenericReturnValue ret;
+ enum GNUNET_GenericReturnValue ret = GNUNET_OK;
- ret = GNUNET_OK;
for (unsigned int i = 0; i<num_results; i++)
{
struct GNUNET_TIME_Timestamp exp_date;
- char *account_details;
+ struct TALER_FullPayto account_details;
struct TALER_ReservePublicKeyP reserve_pub;
struct TALER_Amount remaining_balance;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_timestamp ("expiration_date",
&exp_date),
GNUNET_PQ_result_spec_string ("account_details",
- &account_details),
+ &account_details.full_payto),
GNUNET_PQ_result_spec_auto_from_type ("reserve_pub",
&reserve_pub),
TALER_PQ_result_spec_amount ("current_balance",
@@ -114,10 +113,11 @@ reserve_expired_cb (void *cls,
enum GNUNET_DB_QueryStatus
-TEH_PG_get_expired_reserves (void *cls,
- struct GNUNET_TIME_Timestamp now,
- TALER_EXCHANGEDB_ReserveExpiredCallback rec,
- void *rec_cls)
+TEH_PG_get_expired_reserves (
+ void *cls,
+ struct GNUNET_TIME_Timestamp now,
+ TALER_EXCHANGEDB_ReserveExpiredCallback rec,
+ void *rec_cls)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
diff --git a/src/exchangedb/pg_get_ready_deposit.c b/src/exchangedb/pg_get_ready_deposit.c
@@ -31,7 +31,7 @@ TEH_PG_get_ready_deposit (void *cls,
uint64_t start_shard_row,
uint64_t end_shard_row,
struct TALER_MerchantPublicKeyP *merchant_pub,
- char **payto_uri)
+ struct TALER_FullPayto *payto_uri)
{
struct PostgresClosure *pg = cls;
struct GNUNET_TIME_Absolute now
@@ -46,7 +46,7 @@ TEH_PG_get_ready_deposit (void *cls,
GNUNET_PQ_result_spec_auto_from_type ("merchant_pub",
merchant_pub),
GNUNET_PQ_result_spec_string ("payto_uri",
- payto_uri),
+ &payto_uri->full_payto),
GNUNET_PQ_result_spec_end
};
const char *query = "deposits_get_ready";
diff --git a/src/exchangedb/pg_get_unfinished_close_requests.c b/src/exchangedb/pg_get_unfinished_close_requests.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
+ Copyright (C) 2022, 2024 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -68,13 +68,12 @@ reserve_cb (void *cls,
{
struct CloseReserveContext *erc = cls;
struct PostgresClosure *pg = erc->pg;
- enum GNUNET_GenericReturnValue ret;
+ enum GNUNET_GenericReturnValue ret = GNUNET_OK;
- ret = GNUNET_OK;
for (unsigned int i = 0; i<num_results; i++)
{
struct GNUNET_TIME_Timestamp exp_date;
- char *account_details;
+ struct TALER_FullPayto account_details;
struct TALER_ReservePublicKeyP reserve_pub;
struct TALER_Amount remaining_balance;
uint64_t close_request_row;
@@ -82,7 +81,7 @@ reserve_cb (void *cls,
GNUNET_PQ_result_spec_timestamp ("expiration_date",
&exp_date),
GNUNET_PQ_result_spec_string ("account_details",
- &account_details),
+ &account_details.full_payto),
GNUNET_PQ_result_spec_auto_from_type ("reserve_pub",
&reserve_pub),
TALER_PQ_RESULT_SPEC_AMOUNT ("close",
@@ -137,7 +136,7 @@ TEH_PG_get_unfinished_close_requests (
"get_unfinished_close_requests",
"UPDATE close_requests AS rc"
" SET done=TRUE"
- " WHERE done=FALSE"
+ " WHERE NOT done"
" RETURNING"
" reserve_pub"
" ,close_request_serial_id"
@@ -145,7 +144,8 @@ TEH_PG_get_unfinished_close_requests (
" ,close"
" ,(SELECT payto_uri"
" FROM reserves_in ri"
- " JOIN wire_targets wt ON (ri.wire_source_h_payto = wt.wire_target_h_payto)"
+ " JOIN wire_targets wt"
+ " ON (ri.wire_source_h_payto = wt.wire_target_h_payto)"
" WHERE ri.reserve_pub=rc.reserve_pub)"
" AS account_details;");
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
diff --git a/src/exchangedb/pg_get_wire_accounts.c b/src/exchangedb/pg_get_wire_accounts.c
@@ -65,7 +65,7 @@ get_wire_accounts_cb (void *cls,
for (unsigned int i = 0; i < num_results; i++)
{
- char *payto_uri;
+ struct TALER_FullPayto payto_uri;
char *conversion_url = NULL;
json_t *debit_restrictions = NULL;
json_t *credit_restrictions = NULL;
@@ -74,7 +74,7 @@ get_wire_accounts_cb (void *cls,
int64_t priority;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_string ("payto_uri",
- &payto_uri),
+ &payto_uri.full_payto),
GNUNET_PQ_result_spec_allow_null (
GNUNET_PQ_result_spec_string ("conversion_url",
&conversion_url),
diff --git a/src/exchangedb/pg_insert_wire.c b/src/exchangedb/pg_insert_wire.c
@@ -27,19 +27,20 @@
enum GNUNET_DB_QueryStatus
-TEH_PG_insert_wire (void *cls,
- const char *payto_uri,
- const char *conversion_url,
- const json_t *debit_restrictions,
- const json_t *credit_restrictions,
- struct GNUNET_TIME_Timestamp start_date,
- const struct TALER_MasterSignatureP *master_sig,
- const char *bank_label,
- int64_t priority)
+TEH_PG_insert_wire (
+ void *cls,
+ const struct TALER_FullPayto payto_uri,
+ const char *conversion_url,
+ const json_t *debit_restrictions,
+ const json_t *credit_restrictions,
+ struct GNUNET_TIME_Timestamp start_date,
+ const struct TALER_MasterSignatureP *master_sig,
+ const char *bank_label,
+ int64_t priority)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_string (payto_uri),
+ GNUNET_PQ_query_param_string (payto_uri.full_payto),
NULL == conversion_url
? GNUNET_PQ_query_param_null ()
: GNUNET_PQ_query_param_string (conversion_url),
diff --git a/src/exchangedb/pg_kycauth_in_insert.h b/src/exchangedb/pg_kycauth_in_insert.h
@@ -44,7 +44,7 @@ TEH_PG_kycauth_in_insert (
const union TALER_AccountPublicKeyP *account_pub,
const struct TALER_Amount *credit_amount,
struct GNUNET_TIME_Timestamp execution_date,
- const char *debit_account_uri,
+ const struct TALER_FullPayto debit_account_uri,
const char *section_name,
uint64_t serial_id);
diff --git a/src/exchangedb/pg_lookup_transfer_by_deposit.c b/src/exchangedb/pg_lookup_transfer_by_deposit.c
@@ -49,7 +49,7 @@ TEH_PG_lookup_transfer_by_deposit (
GNUNET_PQ_query_param_auto_from_type (merchant_pub),
GNUNET_PQ_query_param_end
};
- char *payto_uri;
+ struct TALER_FullPayto payto_uri;
struct TALER_WireSaltP wire_salt;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_from_type ("wtid_raw",
@@ -57,7 +57,7 @@ TEH_PG_lookup_transfer_by_deposit (
GNUNET_PQ_result_spec_auto_from_type ("wire_salt",
&wire_salt),
GNUNET_PQ_result_spec_string ("payto_uri",
- &payto_uri),
+ &payto_uri.full_payto),
GNUNET_PQ_result_spec_timestamp ("execution_date",
exec_time),
TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee",
@@ -143,7 +143,7 @@ TEH_PG_lookup_transfer_by_deposit (
GNUNET_PQ_result_spec_auto_from_type ("wire_salt",
&wire_salt),
GNUNET_PQ_result_spec_string ("payto_uri",
- &payto_uri),
+ &payto_uri.full_payto),
TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee",
amount_with_fee),
TALER_PQ_RESULT_SPEC_AMOUNT ("fee_deposit",
diff --git a/src/exchangedb/pg_lookup_wire_timestamp.c b/src/exchangedb/pg_lookup_wire_timestamp.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
+ Copyright (C) 2022, 2024 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -28,12 +28,12 @@
enum GNUNET_DB_QueryStatus
TEH_PG_lookup_wire_timestamp (void *cls,
- const char *payto_uri,
+ const struct TALER_FullPayto payto_uri,
struct GNUNET_TIME_Timestamp *last_date)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_string (payto_uri),
+ GNUNET_PQ_query_param_string (payto_uri.full_payto),
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
@@ -42,7 +42,6 @@ TEH_PG_lookup_wire_timestamp (void *cls,
GNUNET_PQ_result_spec_end
};
-
PREPARE (pg,
"lookup_wire_timestamp",
"SELECT"
diff --git a/src/exchangedb/pg_lookup_wire_transfer.c b/src/exchangedb/pg_lookup_wire_transfer.c
@@ -80,14 +80,14 @@ handle_wt_result (void *cls,
struct TALER_Amount amount_with_fee;
struct TALER_Amount deposit_fee;
struct TALER_DenominationPublicKey denom_pub;
- char *payto_uri;
+ struct TALER_FullPayto payto_uri;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("aggregation_serial_id",
&rowid),
GNUNET_PQ_result_spec_auto_from_type ("h_contract_terms",
&h_contract_terms),
GNUNET_PQ_result_spec_string ("payto_uri",
- &payto_uri),
+ &payto_uri.full_payto),
GNUNET_PQ_result_spec_auto_from_type ("wire_target_h_payto",
&h_payto),
TALER_PQ_result_spec_denom_pub ("denom_pub",
diff --git a/src/exchangedb/pg_select_reserves_in_above_serial_id.c b/src/exchangedb/pg_select_reserves_in_above_serial_id.c
@@ -73,7 +73,7 @@ reserves_in_serial_helper_cb (void *cls,
{
struct TALER_ReservePublicKeyP reserve_pub;
struct TALER_Amount credit;
- char *sender_account_details;
+ struct TALER_FullPayto sender_account_details;
struct GNUNET_TIME_Timestamp execution_date;
uint64_t rowid;
uint64_t wire_reference;
@@ -87,7 +87,7 @@ reserves_in_serial_helper_cb (void *cls,
GNUNET_PQ_result_spec_timestamp ("execution_date",
&execution_date),
GNUNET_PQ_result_spec_string ("sender_account_details",
- &sender_account_details),
+ &sender_account_details.full_payto),
GNUNET_PQ_result_spec_uint64 ("reserve_in_serial_id",
&rowid),
GNUNET_PQ_result_spec_end
diff --git a/src/exchangedb/pg_select_reserves_in_above_serial_id_by_account.c b/src/exchangedb/pg_select_reserves_in_above_serial_id_by_account.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
+ Copyright (C) 2022, 2024 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -74,7 +74,7 @@ reserves_in_serial_helper_cb (void *cls,
{
struct TALER_ReservePublicKeyP reserve_pub;
struct TALER_Amount credit;
- char *sender_account_details;
+ struct TALER_FullPayto sender_account_details;
struct GNUNET_TIME_Timestamp execution_date;
uint64_t rowid;
uint64_t wire_reference;
@@ -88,7 +88,7 @@ reserves_in_serial_helper_cb (void *cls,
GNUNET_PQ_result_spec_timestamp ("execution_date",
&execution_date),
GNUNET_PQ_result_spec_string ("sender_account_details",
- &sender_account_details),
+ &sender_account_details.full_payto),
GNUNET_PQ_result_spec_uint64 ("reserve_in_serial_id",
&rowid),
GNUNET_PQ_result_spec_end
@@ -157,11 +157,12 @@ TEH_PG_select_reserves_in_above_serial_id_by_account (
" WHERE reserve_in_serial_id>=$1"
" AND exchange_account_section=$2"
" ORDER BY reserve_in_serial_id ASC;");
- qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
- "audit_reserves_in_get_transactions_incr_by_account",
- params,
- &reserves_in_serial_helper_cb,
- &risc);
+ qs = GNUNET_PQ_eval_prepared_multi_select (
+ pg->conn,
+ "audit_reserves_in_get_transactions_incr_by_account",
+ params,
+ &reserves_in_serial_helper_cb,
+ &risc);
if (GNUNET_OK != risc.status)
return GNUNET_DB_STATUS_HARD_ERROR;
return qs;
diff --git a/src/exchangedb/pg_select_wire_out_above_serial_id.c b/src/exchangedb/pg_select_wire_out_above_serial_id.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
+ Copyright (C) 2022, 2024 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -74,7 +74,7 @@ wire_out_serial_helper_cb (void *cls,
uint64_t rowid;
struct GNUNET_TIME_Timestamp date;
struct TALER_WireTransferIdentifierRawP wtid;
- char *payto_uri;
+ struct TALER_FullPayto payto_uri;
struct TALER_Amount amount;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("wireout_uuid",
@@ -84,7 +84,7 @@ wire_out_serial_helper_cb (void *cls,
GNUNET_PQ_result_spec_auto_from_type ("wtid_raw",
&wtid),
GNUNET_PQ_result_spec_string ("payto_uri",
- &payto_uri),
+ &payto_uri.full_payto),
TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
&amount),
GNUNET_PQ_result_spec_end
@@ -132,7 +132,7 @@ TEH_PG_select_wire_out_above_serial_id (
.status = GNUNET_OK
};
enum GNUNET_DB_QueryStatus qs;
- /* Used in #postgres_select_wire_out_above_serial_id() */
+
PREPARE (pg,
"audit_get_wire_incr",
"SELECT"
@@ -142,8 +142,8 @@ TEH_PG_select_wire_out_above_serial_id (
",payto_uri"
",amount"
" FROM wire_out"
- " JOIN wire_targets"
- " USING (wire_target_h_payto)"
+ " JOIN wire_targets"
+ " USING (wire_target_h_payto)"
" WHERE wireout_uuid>=$1"
" ORDER BY wireout_uuid ASC;");
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
diff --git a/src/exchangedb/pg_select_wire_out_above_serial_id_by_account.c b/src/exchangedb/pg_select_wire_out_above_serial_id_by_account.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
+ Copyright (C) 2022, 2024 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -74,7 +74,7 @@ wire_out_serial_helper_cb (void *cls,
uint64_t rowid;
struct GNUNET_TIME_Timestamp date;
struct TALER_WireTransferIdentifierRawP wtid;
- char *payto_uri;
+ struct TALER_FullPayto payto_uri;
struct TALER_Amount amount;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("wireout_uuid",
@@ -84,7 +84,7 @@ wire_out_serial_helper_cb (void *cls,
GNUNET_PQ_result_spec_auto_from_type ("wtid_raw",
&wtid),
GNUNET_PQ_result_spec_string ("payto_uri",
- &payto_uri),
+ &payto_uri.full_payto),
TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
&amount),
GNUNET_PQ_result_spec_end
diff --git a/src/exchangedb/pg_trigger_kyc_rule_for_account.c b/src/exchangedb/pg_trigger_kyc_rule_for_account.c
@@ -29,7 +29,7 @@
enum GNUNET_DB_QueryStatus
TEH_PG_trigger_kyc_rule_for_account (
void *cls,
- const struct TLAER_FullPayto payto_uri,
+ const struct TALER_FullPayto payto_uri,
const struct TALER_NormalizedPaytoHashP *h_payto,
const union TALER_AccountPublicKeyP *set_account_pub,
const struct TALER_MerchantPublicKeyP *check_merchant_pub,
@@ -90,8 +90,8 @@ TEH_PG_trigger_kyc_rule_for_account (
" FROM exchange_do_trigger_kyc_rule_for_account"
"($1, $2, $3, $4, $5, $6, $7, $8, $9);");
if (NULL != payto_uri.full_payto)
- TALER_full_payto_normalize_and_hash (payto_uri,
- &h_full_payto);
+ TALER_full_payto_hash (payto_uri,
+ &h_full_payto);
qs = GNUNET_PQ_eval_prepared_singleton_select (
pg->conn,
"trigger_kyc_rule_for_account",
diff --git a/src/exchangedb/pg_update_wire.c b/src/exchangedb/pg_update_wire.c
@@ -27,20 +27,21 @@
enum GNUNET_DB_QueryStatus
-TEH_PG_update_wire (void *cls,
- const char *payto_uri,
- const char *conversion_url,
- const json_t *debit_restrictions,
- const json_t *credit_restrictions,
- struct GNUNET_TIME_Timestamp change_date,
- const struct TALER_MasterSignatureP *master_sig,
- const char *bank_label,
- int64_t priority,
- bool enabled)
+TEH_PG_update_wire (
+ void *cls,
+ const struct TALER_FullPayto payto_uri,
+ const char *conversion_url,
+ const json_t *debit_restrictions,
+ const json_t *credit_restrictions,
+ struct GNUNET_TIME_Timestamp change_date,
+ const struct TALER_MasterSignatureP *master_sig,
+ const char *bank_label,
+ int64_t priority,
+ bool enabled)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_string (payto_uri),
+ GNUNET_PQ_query_param_string (payto_uri.full_payto),
GNUNET_PQ_query_param_bool (enabled),
NULL == conversion_url
? GNUNET_PQ_query_param_null ()