-more dB work

This commit is contained in:
Christian Grothoff 2021-10-30 21:26:40 +02:00
parent bc57abc3da
commit 2faf102a05
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
11 changed files with 217 additions and 212 deletions

View File

@ -358,9 +358,9 @@ struct WireCheckContext
struct TALER_Amount total_deposits; struct TALER_Amount total_deposits;
/** /**
* Hash of the wire transfer details of the receiver. * Target account details of the receiver.
*/ */
struct TALER_MerchantWireHash h_wire; const char *payto_uri;
/** /**
* Execution time of the wire transfer. * Execution time of the wire transfer.
@ -682,8 +682,7 @@ check_transaction_history_for_deposit (
* @param[in,out] cls a `struct WireCheckContext` * @param[in,out] cls a `struct WireCheckContext`
* @param rowid which row in the table is the information from (for diagnostics) * @param rowid which row in the table is the information from (for diagnostics)
* @param merchant_pub public key of the merchant (should be same for all callbacks with the same @e cls) * @param merchant_pub public key of the merchant (should be same for all callbacks with the same @e cls)
* @param h_wire hash of wire transfer details of the merchant (should be same for all callbacks with the same @e cls) * @param account_pay_uri where did we transfer the funds?
* @param account_details where did we transfer the funds?
* @param exec_time execution time of the wire transfer (should be same for all callbacks with the same @e cls) * @param exec_time execution time of the wire transfer (should be same for all callbacks with the same @e cls)
* @param h_contract_terms which proposal was this payment about * @param h_contract_terms which proposal was this payment about
* @param denom_pub denomination of @a coin_pub * @param denom_pub denomination of @a coin_pub
@ -698,8 +697,7 @@ wire_transfer_information_cb (
void *cls, void *cls,
uint64_t rowid, uint64_t rowid,
const struct TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_MerchantPublicKeyP *merchant_pub,
const struct TALER_MerchantWireHash *h_wire, const char *account_pay_uri,
const json_t *account_details,
struct GNUNET_TIME_Absolute exec_time, struct GNUNET_TIME_Absolute exec_time,
const struct TALER_PrivateContractHash *h_contract_terms, const struct TALER_PrivateContractHash *h_contract_terms,
const struct TALER_DenominationPublicKey *denom_pub, const struct TALER_DenominationPublicKey *denom_pub,
@ -714,24 +712,6 @@ wire_transfer_information_cb (
struct TALER_EXCHANGEDB_TransactionList *tl; struct TALER_EXCHANGEDB_TransactionList *tl;
struct TALER_CoinPublicInfo coin; struct TALER_CoinPublicInfo coin;
enum GNUNET_DB_QueryStatus qs; enum GNUNET_DB_QueryStatus qs;
struct TALER_MerchantWireHash hw;
if (GNUNET_OK !=
TALER_JSON_merchant_wire_signature_hash (account_details,
&hw))
{
report_row_inconsistency ("aggregation",
rowid,
"failed to compute hash of given wire data");
}
else if (0 !=
GNUNET_memcmp (&hw,
h_wire))
{
report_row_inconsistency ("aggregation",
rowid,
"database contains wrong hash code for wire details");
}
/* Obtain coin's transaction history */ /* Obtain coin's transaction history */
qs = TALER_ARL_edb->get_coin_transactions (TALER_ARL_edb->cls, qs = TALER_ARL_edb->get_coin_transactions (TALER_ARL_edb->cls,
@ -857,14 +837,13 @@ wire_transfer_information_cb (
"aggregation (contribution)", "aggregation (contribution)",
rowid, rowid,
&coin_value_without_fee, &coin_value_without_fee,
& &total_deposit_without_refunds,
total_deposit_without_refunds,
-1); -1);
} }
} }
/* Check other details of wire transfer match */ /* Check other details of wire transfer match */
if (0 != GNUNET_memcmp (h_wire, if (0 != strcmp (account_pay_uri,
&wcc->h_wire)) wcc->payto_uri))
{ {
report_row_inconsistency ("aggregation", report_row_inconsistency ("aggregation",
rowid, rowid,
@ -1007,16 +986,16 @@ get_wire_fee (struct AggregationContext *ac,
* @param rowid identifier of the respective row in the database * @param rowid identifier of the respective row in the database
* @param date timestamp of the wire transfer (roughly) * @param date timestamp of the wire transfer (roughly)
* @param wtid wire transfer subject * @param wtid wire transfer subject
* @param wire wire transfer details of the receiver * @param payto_uri bank account details of the receiver
* @param amount amount that was wired * @param amount amount that was wired
* @return #GNUNET_OK to continue, #GNUNET_SYSERR to stop iteration * @return #GNUNET_OK to continue, #GNUNET_SYSERR to stop iteration
*/ */
static int static enum GNUNET_GenericReturnValue
check_wire_out_cb (void *cls, check_wire_out_cb (void *cls,
uint64_t rowid, uint64_t rowid,
struct GNUNET_TIME_Absolute date, struct GNUNET_TIME_Absolute date,
const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_WireTransferIdentifierRawP *wtid,
const json_t *wire, const char *payto_uri,
const struct TALER_Amount *amount) const struct TALER_Amount *amount)
{ {
struct AggregationContext *ac = cls; struct AggregationContext *ac = cls;
@ -1035,7 +1014,7 @@ check_wire_out_cb (void *cls,
TALER_B2S (wtid), TALER_B2S (wtid),
TALER_amount2s (amount), TALER_amount2s (amount),
GNUNET_STRINGS_absolute_time_to_string (date)); GNUNET_STRINGS_absolute_time_to_string (date));
if (NULL == (method = TALER_JSON_wire_to_method (wire))) if (NULL == (method = TALER_payto_get_method (payto_uri)))
{ {
report_row_inconsistency ("wire_out", report_row_inconsistency ("wire_out",
rowid, rowid,
@ -1049,14 +1028,7 @@ check_wire_out_cb (void *cls,
GNUNET_assert (GNUNET_OK == GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (amount->currency, TALER_amount_set_zero (amount->currency,
&wcc.total_deposits)); &wcc.total_deposits));
if (GNUNET_OK != wcc.payto_uri = payto_uri;
TALER_JSON_merchant_wire_signature_hash (wire,
&wcc.h_wire))
{
GNUNET_break (0);
GNUNET_free (method);
return GNUNET_SYSERR;
}
qs = TALER_ARL_edb->lookup_wire_transfer (TALER_ARL_edb->cls, qs = TALER_ARL_edb->lookup_wire_transfer (TALER_ARL_edb->cls,
wtid, wtid,
&wire_transfer_information_cb, &wire_transfer_information_cb,
@ -1156,8 +1128,8 @@ check_wire_out_cb (void *cls,
TALER_ARL_report (report_wire_out_inconsistencies, TALER_ARL_report (report_wire_out_inconsistencies,
GNUNET_JSON_PACK ( GNUNET_JSON_PACK (
GNUNET_JSON_pack_object_incref ("destination_account", GNUNET_JSON_pack_string ("destination_account",
(json_t *) wire), payto_uri),
GNUNET_JSON_pack_uint64 ("rowid", GNUNET_JSON_pack_uint64 ("rowid",
rowid), rowid),
TALER_JSON_pack_amount ("expected", TALER_JSON_pack_amount ("expected",

View File

@ -942,16 +942,16 @@ check_time_difference (const char *table,
* @param rowid unique serial ID for the refresh session in our DB * @param rowid unique serial ID for the refresh session in our DB
* @param date timestamp of the transfer (roughly) * @param date timestamp of the transfer (roughly)
* @param wtid wire transfer subject * @param wtid wire transfer subject
* @param wire wire transfer details of the receiver * @param payto_uri wire transfer details of the receiver
* @param amount amount that was wired * @param amount amount that was wired
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
*/ */
static int static enum GNUNET_GenericReturnValue
wire_out_cb (void *cls, wire_out_cb (void *cls,
uint64_t rowid, uint64_t rowid,
struct GNUNET_TIME_Absolute date, struct GNUNET_TIME_Absolute date,
const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_WireTransferIdentifierRawP *wtid,
const json_t *wire, const char *payto_uri,
const struct TALER_Amount *amount) const struct TALER_Amount *amount)
{ {
struct WireAccount *wa = cls; struct WireAccount *wa = cls;
@ -997,62 +997,55 @@ wire_out_cb (void *cls,
return GNUNET_SYSERR; return GNUNET_SYSERR;
return GNUNET_OK; return GNUNET_OK;
} }
if (0 != strcasecmp (payto_uri,
roi->details.credit_account_uri))
{ {
char *payto_uri; /* Destination bank account is wrong in actual wire transfer, so
we should count the wire transfer as entirely spurious, and
payto_uri = TALER_JSON_wire_to_payto (wire); additionally consider the justified wire transfer as missing. */
if (0 != strcasecmp (payto_uri, TALER_ARL_report (report_wire_out_inconsistencies,
roi->details.credit_account_uri)) GNUNET_JSON_PACK (
{ GNUNET_JSON_pack_uint64 ("row",
/* Destination bank account is wrong in actual wire transfer, so rowid),
we should count the wire transfer as entirely spurious, and TALER_JSON_pack_amount ("amount_wired",
additionally consider the justified wire transfer as missing. */ &roi->details.amount),
TALER_ARL_report (report_wire_out_inconsistencies, TALER_JSON_pack_amount ("amount_justified",
GNUNET_JSON_PACK ( &zero),
GNUNET_JSON_pack_uint64 ("row", GNUNET_JSON_pack_data_auto ("wtid", wtid),
rowid), TALER_JSON_pack_time_abs_human ("timestamp",
TALER_JSON_pack_amount ("amount_wired", date),
&roi->details.amount), GNUNET_JSON_pack_string ("diagnostic",
TALER_JSON_pack_amount ("amount_justified", "receiver account mismatch"),
&zero), GNUNET_JSON_pack_string ("target",
GNUNET_JSON_pack_data_auto ("wtid", wtid), payto_uri),
TALER_JSON_pack_time_abs_human ("timestamp", GNUNET_JSON_pack_string ("account_section",
date), wa->ai->section_name)));
GNUNET_JSON_pack_string ("diagnostic", TALER_ARL_amount_add (&total_bad_amount_out_plus,
"receiver account mismatch"), &total_bad_amount_out_plus,
GNUNET_JSON_pack_string ("target", &roi->details.amount);
payto_uri), TALER_ARL_report (report_wire_out_inconsistencies,
GNUNET_JSON_pack_string ("account_section", GNUNET_JSON_PACK (
wa->ai->section_name))); GNUNET_JSON_pack_uint64 ("row",
TALER_ARL_amount_add (&total_bad_amount_out_plus, rowid),
&total_bad_amount_out_plus, TALER_JSON_pack_amount ("amount_wired",
&roi->details.amount); &zero),
TALER_ARL_report (report_wire_out_inconsistencies, TALER_JSON_pack_amount ("amount_justified",
GNUNET_JSON_PACK ( amount),
GNUNET_JSON_pack_uint64 ("row", GNUNET_JSON_pack_data_auto ("wtid",
rowid), wtid),
TALER_JSON_pack_amount ("amount_wired", TALER_JSON_pack_time_abs_human ("timestamp",
&zero), date),
TALER_JSON_pack_amount ("amount_justified", GNUNET_JSON_pack_string ("diagnostic",
amount), "receiver account mismatch"),
GNUNET_JSON_pack_data_auto ("wtid", GNUNET_JSON_pack_string ("target",
wtid), roi->details.
TALER_JSON_pack_time_abs_human ("timestamp", credit_account_uri),
date), GNUNET_JSON_pack_string ("account_section",
GNUNET_JSON_pack_string ("diagnostic", wa->ai->section_name)));
"receiver account mismatch"), TALER_ARL_amount_add (&total_bad_amount_out_minus,
GNUNET_JSON_pack_string ("target", &total_bad_amount_out_minus,
roi->details. amount);
credit_account_uri), goto cleanup;
GNUNET_JSON_pack_string ("account_section",
wa->ai->section_name)));
TALER_ARL_amount_add (&total_bad_amount_out_minus,
&total_bad_amount_out_minus,
amount);
GNUNET_free (payto_uri);
goto cleanup;
}
GNUNET_free (payto_uri);
} }
if (0 != TALER_amount_cmp (&roi->details.amount, if (0 != TALER_amount_cmp (&roi->details.amount,
amount)) amount))

View File

@ -77,7 +77,7 @@ struct AggregatedDepositDetail
* @param connection connection to the client * @param connection connection to the client
* @param total total amount that was transferred * @param total total amount that was transferred
* @param merchant_pub public key of the merchant * @param merchant_pub public key of the merchant
* @param h_wire destination account * @param payto_uri destination account
* @param wire_fee wire fee that was charged * @param wire_fee wire fee that was charged
* @param exec_time execution time of the wire transfer * @param exec_time execution time of the wire transfer
* @param wdd_head linked list with details about the combined deposits * @param wdd_head linked list with details about the combined deposits
@ -87,7 +87,7 @@ static MHD_RESULT
reply_transfer_details (struct MHD_Connection *connection, reply_transfer_details (struct MHD_Connection *connection,
const struct TALER_Amount *total, const struct TALER_Amount *total,
const struct TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_MerchantPublicKeyP *merchant_pub,
const struct TALER_MerchantWireHash *h_wire, const char *payto_uri,
const struct TALER_Amount *wire_fee, const struct TALER_Amount *wire_fee,
struct GNUNET_TIME_Absolute exec_time, struct GNUNET_TIME_Absolute exec_time,
const struct AggregatedDepositDetail *wdd_head) const struct AggregatedDepositDetail *wdd_head)
@ -145,7 +145,8 @@ reply_transfer_details (struct MHD_Connection *connection,
TALER_amount_hton (&wdp.wire_fee, TALER_amount_hton (&wdp.wire_fee,
wire_fee); wire_fee);
wdp.merchant_pub = *merchant_pub; wdp.merchant_pub = *merchant_pub;
wdp.h_wire = *h_wire; TALER_payto_hash (payto_uri,
&wdp.h_payto);
GNUNET_CRYPTO_hash_context_finish (hash_context, GNUNET_CRYPTO_hash_context_finish (hash_context,
&wdp.h_details); &wdp.h_details);
{ {
@ -172,8 +173,8 @@ reply_transfer_details (struct MHD_Connection *connection,
wire_fee), wire_fee),
GNUNET_JSON_pack_data_auto ("merchant_pub", GNUNET_JSON_pack_data_auto ("merchant_pub",
merchant_pub), merchant_pub),
GNUNET_JSON_pack_data_auto ("h_wire", GNUNET_JSON_pack_data_auto ("h_payto",
h_wire), &wdp.h_payto),
GNUNET_JSON_pack_time_abs ("execution_time", GNUNET_JSON_pack_time_abs ("execution_time",
exec_time), exec_time),
GNUNET_JSON_pack_array_steal ("deposits", GNUNET_JSON_pack_array_steal ("deposits",
@ -210,12 +211,6 @@ struct WtidTransactionContext
*/ */
struct TALER_MerchantPublicKeyP merchant_pub; struct TALER_MerchantPublicKeyP merchant_pub;
/**
* Hash of the wire details of the merchant (identical for all
* deposits), only valid if @e is_valid is #GNUNET_YES.
*/
struct TALER_MerchantWireHash h_wire;
/** /**
* Wire fee applicable at @e exec_time. * Wire fee applicable at @e exec_time.
*/ */
@ -237,9 +232,9 @@ struct WtidTransactionContext
struct AggregatedDepositDetail *wdd_tail; struct AggregatedDepositDetail *wdd_tail;
/** /**
* Which method was used to wire the funds? * Where were the funds wired?
*/ */
char *wire_method; char *payto_uri;
/** /**
* JSON array with details about the individual deposits. * JSON array with details about the individual deposits.
@ -253,7 +248,7 @@ struct WtidTransactionContext
* (as they should). Set to #GNUNET_SYSERR if we encountered an * (as they should). Set to #GNUNET_SYSERR if we encountered an
* internal error. * internal error.
*/ */
int is_valid; enum GNUNET_GenericReturnValue is_valid;
}; };
@ -265,8 +260,7 @@ struct WtidTransactionContext
* @param cls our context for transmission * @param cls our context for transmission
* @param rowid which row in the DB is the information from (for diagnostics), ignored * @param rowid which row in the DB is the information from (for diagnostics), ignored
* @param merchant_pub public key of the merchant (should be same for all callbacks with the same @e cls) * @param merchant_pub public key of the merchant (should be same for all callbacks with the same @e cls)
* @param h_wire hash of wire transfer details of the merchant (should be same for all callbacks with the same @e cls) * @param account_payto_uri where the funds were sent
* @param wire where the funds were sent
* @param exec_time execution time of the wire transfer (should be same for all callbacks with the same @e cls) * @param exec_time execution time of the wire transfer (should be same for all callbacks with the same @e cls)
* @param h_contract_terms which proposal was this payment about * @param h_contract_terms which proposal was this payment about
* @param denom_pub denomination public key of the @a coin_pub (ignored) * @param denom_pub denomination public key of the @a coin_pub (ignored)
@ -278,8 +272,7 @@ static void
handle_deposit_data (void *cls, handle_deposit_data (void *cls,
uint64_t rowid, uint64_t rowid,
const struct TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_MerchantPublicKeyP *merchant_pub,
const struct TALER_MerchantWireHash *h_wire, const char *account_payto_uri,
const json_t *wire,
struct GNUNET_TIME_Absolute exec_time, struct GNUNET_TIME_Absolute exec_time,
const struct TALER_PrivateContractHash *h_contract_terms, const struct TALER_PrivateContractHash *h_contract_terms,
const struct TALER_DenominationPublicKey *denom_pub, const struct TALER_DenominationPublicKey *denom_pub,
@ -288,25 +281,17 @@ handle_deposit_data (void *cls,
const struct TALER_Amount *deposit_fee) const struct TALER_Amount *deposit_fee)
{ {
struct WtidTransactionContext *ctx = cls; struct WtidTransactionContext *ctx = cls;
char *wire_method;
(void) rowid; (void) rowid;
(void) denom_pub; (void) denom_pub;
if (GNUNET_SYSERR == ctx->is_valid) if (GNUNET_SYSERR == ctx->is_valid)
return; return;
if (NULL == (wire_method = TALER_JSON_wire_to_method (wire)))
{
GNUNET_break (0);
ctx->is_valid = GNUNET_SYSERR;
return;
}
if (GNUNET_NO == ctx->is_valid) if (GNUNET_NO == ctx->is_valid)
{ {
/* First one we encounter, setup general information in 'ctx' */ /* First one we encounter, setup general information in 'ctx' */
ctx->merchant_pub = *merchant_pub; ctx->merchant_pub = *merchant_pub;
ctx->h_wire = *h_wire; ctx->payto_uri = GNUNET_strdup (account_payto_uri);
ctx->exec_time = exec_time; ctx->exec_time = exec_time;
ctx->wire_method = wire_method; /* captures the reference */
ctx->is_valid = GNUNET_YES; ctx->is_valid = GNUNET_YES;
if (0 > if (0 >
TALER_amount_subtract (&ctx->total, TALER_amount_subtract (&ctx->total,
@ -326,17 +311,13 @@ handle_deposit_data (void *cls,
(it should, otherwise the deposits should not have been aggregated) */ (it should, otherwise the deposits should not have been aggregated) */
if ( (0 != GNUNET_memcmp (&ctx->merchant_pub, if ( (0 != GNUNET_memcmp (&ctx->merchant_pub,
merchant_pub)) || merchant_pub)) ||
(0 != strcmp (wire_method, (0 != strcmp (account_payto_uri,
ctx->wire_method)) || ctx->payto_uri)) )
(0 != GNUNET_memcmp (&ctx->h_wire,
h_wire)) )
{ {
GNUNET_break (0); GNUNET_break (0);
ctx->is_valid = GNUNET_SYSERR; ctx->is_valid = GNUNET_SYSERR;
GNUNET_free (wire_method);
return; return;
} }
GNUNET_free (wire_method);
if (0 > if (0 >
TALER_amount_subtract (&delta, TALER_amount_subtract (&delta,
deposit_value, deposit_value,
@ -389,8 +370,7 @@ free_ctx (struct WtidTransactionContext *ctx)
wdd); wdd);
GNUNET_free (wdd); GNUNET_free (wdd);
} }
GNUNET_free (ctx->wire_method); GNUNET_free (ctx->payto_uri);
ctx->wire_method = NULL;
} }
@ -458,14 +438,29 @@ get_transfer_deposits (void *cls,
NULL); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
qs = TEH_plugin->get_wire_fee (TEH_plugin->cls, {
ctx->wire_method, char *wire_method;
ctx->exec_time,
&wire_fee_start_date, wire_method = TALER_payto_get_method (ctx->payto_uri);
&wire_fee_end_date, if (NULL == wire_method)
&ctx->wire_fee, {
&closing_fee, GNUNET_break (0);
&wire_fee_master_sig); *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_DB_INVARIANT_FAILURE,
"payto:// without wire method encountered");
return GNUNET_DB_STATUS_HARD_ERROR;
}
qs = TEH_plugin->get_wire_fee (TEH_plugin->cls,
wire_method,
ctx->exec_time,
&wire_fee_start_date,
&wire_fee_end_date,
&ctx->wire_fee,
&closing_fee,
&wire_fee_master_sig);
GNUNET_free (wire_method);
}
if (0 >= qs) if (0 >= qs)
{ {
if ( (GNUNET_DB_STATUS_HARD_ERROR == qs) || if ( (GNUNET_DB_STATUS_HARD_ERROR == qs) ||
@ -530,7 +525,7 @@ TEH_handler_transfers_get (struct TEH_RequestContext *rc,
mhd_ret = reply_transfer_details (rc->connection, mhd_ret = reply_transfer_details (rc->connection,
&ctx.total, &ctx.total,
&ctx.merchant_pub, &ctx.merchant_pub,
&ctx.h_wire, ctx.payto_uri,
&ctx.wire_fee, &ctx.wire_fee,
ctx.exec_time, ctx.exec_time,
ctx.wdd_head); ctx.wdd_head);

View File

@ -143,8 +143,8 @@ CREATE INDEX IF NOT EXISTS reserves_in_exchange_account_serial
reserve_in_serial_id DESC reserve_in_serial_id DESC
); );
qq
CREATE TABLE IF NOT EXISTS reserves_close CREATE TABLE IF NOT EXISTS reserves_closeq
(close_uuid BIGSERIAL PRIMARY KEY (close_uuid BIGSERIAL PRIMARY KEY
,reserve_uuid INT8 NOT NULL REFERENCES reserves (reserve_uuid) ON DELETE CASCADE ,reserve_uuid INT8 NOT NULL REFERENCES reserves (reserve_uuid) ON DELETE CASCADE
,execution_date INT8 NOT NULL ,execution_date INT8 NOT NULL

View File

@ -1,6 +1,6 @@
/* /*
This file is part of GNUnet This file is part of GNUnet
Copyright (C) 2020 Taler Systems SA Copyright (C) 2020, 2021 Taler Systems SA
GNUnet is free software: you can redistribute it and/or modify it GNUnet is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published under the terms of the GNU Affero General Public License as published
@ -99,6 +99,37 @@ irbt_cb_table_denomination_revocations (
} }
/**
* Function called with denominations records to insert into table.
*
* @param pg plugin context
* @param td record to insert
*/
static enum GNUNET_DB_QueryStatus
irbt_cb_table_wire_targets (struct PostgresClosure *pg,
const struct TALER_EXCHANGEDB_TableData *td)
{
struct TALER_PaytoHash payto_hash;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (&payto_hash),
GNUNET_PQ_query_param_string (
td->details.wire_targets.payto_uri),
GNUNET_PQ_query_param_auto_from_type (
&td->details.wire_targets.kyc_ok),
GNUNET_PQ_query_param_string (
td->details.wire_targets.oauth_username),
GNUNET_PQ_query_param_end
};
TALER_payto_hash (
td->details.wire_targets.payto_uri,
&payto_hash);
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"insert_into_table_wire_targets",
params);
}
/** /**
* Function called with reserves records to insert into table. * Function called with reserves records to insert into table.
* *
@ -112,7 +143,6 @@ irbt_cb_table_reserves (struct PostgresClosure *pg,
struct GNUNET_PQ_QueryParam params[] = { struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial), GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_auto_from_type (&td->details.reserves.reserve_pub), GNUNET_PQ_query_param_auto_from_type (&td->details.reserves.reserve_pub),
GNUNET_PQ_query_param_string (td->details.reserves.account_details),
TALER_PQ_query_param_amount (&td->details.reserves.current_balance), TALER_PQ_query_param_amount (&td->details.reserves.current_balance),
TALER_PQ_query_param_absolute_time (&td->details.reserves.expiration_date), TALER_PQ_query_param_absolute_time (&td->details.reserves.expiration_date),
TALER_PQ_query_param_absolute_time (&td->details.reserves.gc_date), TALER_PQ_query_param_absolute_time (&td->details.reserves.gc_date),
@ -139,8 +169,7 @@ irbt_cb_table_reserves_in (struct PostgresClosure *pg,
GNUNET_PQ_query_param_uint64 (&td->serial), GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_uint64 (&td->details.reserves_in.wire_reference), GNUNET_PQ_query_param_uint64 (&td->details.reserves_in.wire_reference),
TALER_PQ_query_param_amount (&td->details.reserves_in.credit), TALER_PQ_query_param_amount (&td->details.reserves_in.credit),
GNUNET_PQ_query_param_string ( GNUNET_PQ_query_param_uint64 (&td->details.reserves_in.sender_account),
td->details.reserves_in.sender_account_details),
GNUNET_PQ_query_param_string ( GNUNET_PQ_query_param_string (
td->details.reserves_in.exchange_account_section), td->details.reserves_in.exchange_account_section),
TALER_PQ_query_param_absolute_time ( TALER_PQ_query_param_absolute_time (
@ -170,7 +199,8 @@ irbt_cb_table_reserves_close (struct PostgresClosure *pg,
TALER_PQ_query_param_absolute_time ( TALER_PQ_query_param_absolute_time (
&td->details.reserves_close.execution_date), &td->details.reserves_close.execution_date),
GNUNET_PQ_query_param_auto_from_type (&td->details.reserves_close.wtid), GNUNET_PQ_query_param_auto_from_type (&td->details.reserves_close.wtid),
GNUNET_PQ_query_param_string (td->details.reserves_close.receiver_account), GNUNET_PQ_query_param_uint64 (
&td->details.reserves_close.wire_target_serial_id),
TALER_PQ_query_param_amount (&td->details.reserves_close.amount), TALER_PQ_query_param_amount (&td->details.reserves_close.amount),
TALER_PQ_query_param_amount (&td->details.reserves_close.closing_fee), TALER_PQ_query_param_amount (&td->details.reserves_close.closing_fee),
GNUNET_PQ_query_param_uint64 (&td->details.reserves_close.reserve_uuid), GNUNET_PQ_query_param_uint64 (&td->details.reserves_close.reserve_uuid),
@ -462,9 +492,11 @@ irbt_cb_table_deposits (struct PostgresClosure *pg,
{ {
uint8_t tiny = td->details.deposits.tiny ? 1 : 0; uint8_t tiny = td->details.deposits.tiny ? 1 : 0;
uint8_t done = td->details.deposits.done ? 1 : 0; uint8_t done = td->details.deposits.done ? 1 : 0;
struct TALER_MerchantWireHash h_wire; uint8_t extension_blocked = td->details.deposits.extension_blocked ? 1 : 0;
struct GNUNET_PQ_QueryParam params[] = { struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial), GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_uint64 (&td->details.deposits.shard),
GNUNET_PQ_query_param_uint64 (&td->details.deposits.known_coin_id),
TALER_PQ_query_param_amount (&td->details.deposits.amount_with_fee), TALER_PQ_query_param_amount (&td->details.deposits.amount_with_fee),
TALER_PQ_query_param_absolute_time (&td->details.deposits.wallet_timestamp), TALER_PQ_query_param_absolute_time (&td->details.deposits.wallet_timestamp),
TALER_PQ_query_param_absolute_time ( TALER_PQ_query_param_absolute_time (
@ -474,17 +506,16 @@ irbt_cb_table_deposits (struct PostgresClosure *pg,
GNUNET_PQ_query_param_auto_from_type (&td->details.deposits.merchant_pub), GNUNET_PQ_query_param_auto_from_type (&td->details.deposits.merchant_pub),
GNUNET_PQ_query_param_auto_from_type ( GNUNET_PQ_query_param_auto_from_type (
&td->details.deposits.h_contract_terms), &td->details.deposits.h_contract_terms),
GNUNET_PQ_query_param_auto_from_type (&h_wire),
GNUNET_PQ_query_param_auto_from_type (&td->details.deposits.coin_sig), GNUNET_PQ_query_param_auto_from_type (&td->details.deposits.coin_sig),
TALER_PQ_query_param_json (td->details.deposits.wire), GNUNET_PQ_query_param_auto_from_type (&td->details.deposits.wire_salt),
GNUNET_PQ_query_param_uint64 (&td->details.deposits.wire_target_serial_id),
GNUNET_PQ_query_param_auto_from_type (&tiny), GNUNET_PQ_query_param_auto_from_type (&tiny),
GNUNET_PQ_query_param_auto_from_type (&done), GNUNET_PQ_query_param_auto_from_type (&done),
GNUNET_PQ_query_param_uint64 (&td->details.deposits.known_coin_id), GNUNET_PQ_query_param_auto_from_type (&extension_blocked),
TALER_PQ_query_param_json (td->details.deposits.extension_options),
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
TALER_JSON_merchant_wire_signature_hash (td->details.deposits.wire,
&h_wire);
return GNUNET_PQ_eval_prepared_non_select (pg->conn, return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"insert_into_table_deposits", "insert_into_table_deposits",
params); params);
@ -530,7 +561,7 @@ irbt_cb_table_wire_out (struct PostgresClosure *pg,
GNUNET_PQ_query_param_uint64 (&td->serial), GNUNET_PQ_query_param_uint64 (&td->serial),
TALER_PQ_query_param_absolute_time (&td->details.wire_out.execution_date), TALER_PQ_query_param_absolute_time (&td->details.wire_out.execution_date),
GNUNET_PQ_query_param_auto_from_type (&td->details.wire_out.wtid_raw), GNUNET_PQ_query_param_auto_from_type (&td->details.wire_out.wtid_raw),
TALER_PQ_query_param_json (td->details.wire_out.wire_target), GNUNET_PQ_query_param_uint64 (&td->details.wire_out.wire_target_serial_id),
GNUNET_PQ_query_param_string ( GNUNET_PQ_query_param_string (
td->details.wire_out.exchange_account_section), td->details.wire_out.exchange_account_section),
TALER_PQ_query_param_amount (&td->details.wire_out.amount), TALER_PQ_query_param_amount (&td->details.wire_out.amount),

View File

@ -1,6 +1,6 @@
/* /*
This file is part of GNUnet This file is part of GNUnet
Copyright (C) 2020 Taler Systems SA Copyright (C) 2020, 2021 Taler Systems SA
GNUnet is free software: you can redistribute it and/or modify it GNUnet is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published under the terms of the GNU Affero General Public License as published
@ -156,7 +156,6 @@ lrbt_cb_table_wire_targets (void *cls,
unsigned int num_results) unsigned int num_results)
{ {
struct LookupRecordsByTableContext *ctx = cls; struct LookupRecordsByTableContext *ctx = cls;
struct PostgresClosure *pg = ctx->pg;
struct TALER_EXCHANGEDB_TableData td = { struct TALER_EXCHANGEDB_TableData td = {
.table = TALER_EXCHANGEDB_RT_WIRE_TARGETS .table = TALER_EXCHANGEDB_RT_WIRE_TARGETS
}; };
@ -216,8 +215,6 @@ lrbt_cb_table_reserves (void *cls,
&td.serial), &td.serial),
GNUNET_PQ_result_spec_auto_from_type ("reserve_pub", GNUNET_PQ_result_spec_auto_from_type ("reserve_pub",
&td.details.reserves.reserve_pub), &td.details.reserves.reserve_pub),
GNUNET_PQ_result_spec_string ("account_details",
&td.details.reserves.account_details),
TALER_PQ_RESULT_SPEC_AMOUNT ("current_balance", TALER_PQ_RESULT_SPEC_AMOUNT ("current_balance",
&td.details.reserves.current_balance), &td.details.reserves.current_balance),
TALER_PQ_result_spec_absolute_time ("expiration_date", TALER_PQ_result_spec_absolute_time ("expiration_date",
@ -270,12 +267,11 @@ lrbt_cb_table_reserves_in (void *cls,
&td.details.reserves_in.wire_reference), &td.details.reserves_in.wire_reference),
TALER_PQ_RESULT_SPEC_AMOUNT ("credit", TALER_PQ_RESULT_SPEC_AMOUNT ("credit",
&td.details.reserves_in.credit), &td.details.reserves_in.credit),
GNUNET_PQ_result_spec_string ("sender_account_details", GNUNET_PQ_result_spec_uint64 ("sender_account",
&td.details.reserves_in. &td.details.reserves_in.sender_account),
sender_account_details), GNUNET_PQ_result_spec_string (
GNUNET_PQ_result_spec_string ("exchange_account_section", "exchange_account_section",
&td.details.reserves_in. &td.details.reserves_in.exchange_account_section),
exchange_account_section),
TALER_PQ_result_spec_absolute_time ("execution_date", TALER_PQ_result_spec_absolute_time ("execution_date",
&td.details.reserves_in.execution_date), &td.details.reserves_in.execution_date),
GNUNET_PQ_result_spec_uint64 ("reserve_uuid", GNUNET_PQ_result_spec_uint64 ("reserve_uuid",
@ -322,21 +318,20 @@ lrbt_cb_table_reserves_close (void *cls,
struct GNUNET_PQ_ResultSpec rs[] = { struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("serial", GNUNET_PQ_result_spec_uint64 ("serial",
&td.serial), &td.serial),
GNUNET_PQ_result_spec_uint64 ("reserve_uuid",
&td.details.reserves_close.reserve_uuid),
TALER_PQ_result_spec_absolute_time ( TALER_PQ_result_spec_absolute_time (
"execution_date", "execution_date",
&td.details.reserves_close.execution_date), &td.details.reserves_close.execution_date),
GNUNET_PQ_result_spec_auto_from_type ("wtid", GNUNET_PQ_result_spec_auto_from_type ("wtid",
&td.details.reserves_close.wtid), &td.details.reserves_close.wtid),
GNUNET_PQ_result_spec_string ( GNUNET_PQ_result_spec_uint64 (
"receiver_account", "wire_target_serial_id",
&td.details.reserves_close.receiver_account), &td.details.reserves_close.wire_target_serial_id),
TALER_PQ_RESULT_SPEC_AMOUNT ("amount", TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
&td.details.reserves_close.amount), &td.details.reserves_close.amount),
TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee", TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee",
&td.details.reserves_close.closing_fee), &td.details.reserves_close.closing_fee),
GNUNET_PQ_result_spec_uint64 ("reserve_uuid",
&td.details.reserves_close.reserve_uuid),
GNUNET_PQ_result_spec_end GNUNET_PQ_result_spec_end
}; };
@ -377,25 +372,30 @@ lrbt_cb_table_reserves_out (void *cls,
for (unsigned int i = 0; i<num_results; i++) for (unsigned int i = 0; i<num_results; i++)
{ {
struct GNUNET_PQ_ResultSpec rs[] = { struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("serial", GNUNET_PQ_result_spec_uint64 (
&td.serial), "serial",
GNUNET_PQ_result_spec_auto_from_type ("h_blind_ev", &td.serial),
&td.details.reserves_out.h_blind_ev), GNUNET_PQ_result_spec_auto_from_type (
"h_blind_ev",
&td.details.reserves_out.h_blind_ev),
GNUNET_PQ_result_spec_uint64 (
"denominations_serial",
&td.details.reserves_out.denominations_serial),
TALER_PQ_result_spec_denom_sig ( TALER_PQ_result_spec_denom_sig (
"denom_sig", "denom_sig",
&td.details.reserves_out.denom_sig), &td.details.reserves_out.denom_sig),
GNUNET_PQ_result_spec_auto_from_type ("reserve_sig", GNUNET_PQ_result_spec_uint64 (
&td.details.reserves_out.reserve_sig), "reserve_uuid",
&td.details.reserves_out.reserve_uuid),
GNUNET_PQ_result_spec_auto_from_type (
"reserve_sig",
&td.details.reserves_out.reserve_sig),
TALER_PQ_result_spec_absolute_time ( TALER_PQ_result_spec_absolute_time (
"execution_date", "execution_date",
&td.details.reserves_out.execution_date), &td.details.reserves_out.execution_date),
TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee", TALER_PQ_RESULT_SPEC_AMOUNT (
&td.details.reserves_out.amount_with_fee), "amount_with_fee",
GNUNET_PQ_result_spec_uint64 ("reserve_uuid", &td.details.reserves_out.amount_with_fee),
&td.details.reserves_out.reserve_uuid),
GNUNET_PQ_result_spec_uint64 ("denominations_serial",
&td.details.reserves_out.
denominations_serial),
GNUNET_PQ_result_spec_end GNUNET_PQ_result_spec_end
}; };
@ -883,6 +883,9 @@ lrbt_cb_table_deposits (void *cls,
GNUNET_PQ_result_spec_uint64 ( GNUNET_PQ_result_spec_uint64 (
"shard", "shard",
&td.details.deposits.shard), &td.details.deposits.shard),
GNUNET_PQ_result_spec_uint64 (
"known_coin_id",
&td.details.deposits.known_coin_id),
TALER_PQ_RESULT_SPEC_AMOUNT ( TALER_PQ_RESULT_SPEC_AMOUNT (
"amount_with_fee", "amount_with_fee",
&td.details.deposits.amount_with_fee), &td.details.deposits.amount_with_fee),
@ -907,24 +910,24 @@ lrbt_cb_table_deposits (void *cls,
GNUNET_PQ_result_spec_auto_from_type ( GNUNET_PQ_result_spec_auto_from_type (
"coin_sig", "coin_sig",
&td.details.deposits.coin_sig), &td.details.deposits.coin_sig),
GNUNET_PQ_result_spec_auto_from_type (
"wire_salt",
&td.details.deposits.wire_salt),
GNUNET_PQ_result_spec_uint64 ( GNUNET_PQ_result_spec_uint64 (
"wire_target_serial_id", "wire_target_serial_id",
&td.details.deposits.wire_target_serial_id), &td.details.deposits.wire_target_serial_id),
GNUNET_PQ_result_spec_json (
"extension_options",
&td.details.deposits.extension_options),
GNUNET_PQ_result_spec_auto_from_type (
"extension_blocked",
&td.details.deposits.extension_blocked),
GNUNET_PQ_result_spec_auto_from_type ( GNUNET_PQ_result_spec_auto_from_type (
"tiny", "tiny",
&td.details.deposits.tiny), &td.details.deposits.tiny),
GNUNET_PQ_result_spec_auto_from_type ( GNUNET_PQ_result_spec_auto_from_type (
"done", "done",
&td.details.deposits.done), &td.details.deposits.done),
GNUNET_PQ_result_spec_uint64 ( GNUNET_PQ_result_spec_auto_from_type (
"known_coin_id", "extension_blocked",
&td.details.deposits.known_coin_id), &td.details.deposits.extension_blocked),
TALER_PQ_result_spec_json (
"extension_options",
&td.details.deposits.extension_options),
GNUNET_PQ_result_spec_end GNUNET_PQ_result_spec_end
}; };
@ -1019,17 +1022,21 @@ lrbt_cb_table_wire_out (void *cls,
struct GNUNET_PQ_ResultSpec rs[] = { struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("serial", GNUNET_PQ_result_spec_uint64 ("serial",
&td.serial), &td.serial),
TALER_PQ_result_spec_absolute_time ("execution_date", TALER_PQ_result_spec_absolute_time (
&td.details.wire_out.execution_date), "execution_date",
GNUNET_PQ_result_spec_auto_from_type ("wtid_raw", &td.details.wire_out.execution_date),
&td.details.wire_out.wtid_raw), GNUNET_PQ_result_spec_auto_from_type (
TALER_PQ_result_spec_json ("wire_target", "wtid_raw",
&td.details.wire_out.wire_target), &td.details.wire_out.wtid_raw),
GNUNET_PQ_result_spec_uint64 (
"wire_target_serial_id",
&td.details.wire_out.wire_target_serial_id),
GNUNET_PQ_result_spec_string ( GNUNET_PQ_result_spec_string (
"exchange_account_section", "exchange_account_section",
&td.details.wire_out.exchange_account_section), &td.details.wire_out.exchange_account_section),
TALER_PQ_RESULT_SPEC_AMOUNT ("amount", TALER_PQ_RESULT_SPEC_AMOUNT (
&td.details.wire_out.amount), "amount",
&td.details.wire_out.amount),
GNUNET_PQ_result_spec_end GNUNET_PQ_result_spec_end
}; };

View File

@ -10729,6 +10729,10 @@ postgres_lookup_records_by_table (void *cls,
statement = "select_above_serial_by_table_denomination_revocations"; statement = "select_above_serial_by_table_denomination_revocations";
rh = &lrbt_cb_table_denomination_revocations; rh = &lrbt_cb_table_denomination_revocations;
break; break;
case TALER_EXCHANGEDB_RT_WIRE_TARGETS:
statement = "select_above_serial_by_table_wire_targets";
rh = &lrbt_cb_table_wire_targets;
break;
case TALER_EXCHANGEDB_RT_RESERVES: case TALER_EXCHANGEDB_RT_RESERVES:
statement = "select_above_serial_by_table_reserves"; statement = "select_above_serial_by_table_reserves";
rh = &lrbt_cb_table_reserves; rh = &lrbt_cb_table_reserves;
@ -10862,6 +10866,9 @@ postgres_insert_records_by_table (void *cls,
case TALER_EXCHANGEDB_RT_DENOMINATION_REVOCATIONS: case TALER_EXCHANGEDB_RT_DENOMINATION_REVOCATIONS:
rh = &irbt_cb_table_denomination_revocations; rh = &irbt_cb_table_denomination_revocations;
break; break;
case TALER_EXCHANGEDB_RT_WIRE_TARGETS:
rh = &irbt_cb_table_wire_targets;
break;
case TALER_EXCHANGEDB_RT_RESERVES: case TALER_EXCHANGEDB_RT_RESERVES:
rh = &irbt_cb_table_reserves; rh = &irbt_cb_table_reserves;
break; break;

View File

@ -1709,9 +1709,9 @@ struct TALER_EXCHANGE_TransferData
struct TALER_ExchangeSignatureP exchange_sig; struct TALER_ExchangeSignatureP exchange_sig;
/** /**
* hash of the wire transfer address the transfer went to * hash of the payto:// URI the transfer went to
*/ */
struct TALER_MerchantWireHash h_wire; struct TALER_PaytoHash h_wire;
/** /**
* time when the exchange claims to have performed the wire transfer * time when the exchange claims to have performed the wire transfer

View File

@ -230,7 +230,7 @@ struct TALER_EXCHANGEDB_TableData
uint64_t reserve_uuid; uint64_t reserve_uuid;
struct GNUNET_TIME_Absolute execution_date; struct GNUNET_TIME_Absolute execution_date;
struct TALER_WireTransferIdentifierRawP wtid; struct TALER_WireTransferIdentifierRawP wtid;
uint64_t receiver_account; uint64_t wire_target_serial_id;
struct TALER_Amount amount; struct TALER_Amount amount;
struct TALER_Amount closing_fee; struct TALER_Amount closing_fee;
} reserves_close; } reserves_close;

View File

@ -1383,9 +1383,9 @@ struct TALER_WireDepositDataPS
struct TALER_MerchantPublicKeyP merchant_pub; struct TALER_MerchantPublicKeyP merchant_pub;
/** /**
* Hash of wire details of the merchant. * Hash of bank account of the merchant.
*/ */
struct TALER_MerchantWireHash h_wire; struct TALER_PaytoHash h_payto;
/** /**
* Hash of the individual deposits that were aggregated, * Hash of the individual deposits that were aggregated,

View File

@ -79,7 +79,7 @@ struct TALER_EXCHANGE_TransfersGetHandle
* @return #GNUNET_OK if we are done and all is well, * @return #GNUNET_OK if we are done and all is well,
* #GNUNET_SYSERR if the response was bogus * #GNUNET_SYSERR if the response was bogus
*/ */
static int static enum GNUNET_GenericReturnValue
check_transfers_get_response_ok ( check_transfers_get_response_ok (
struct TALER_EXCHANGE_TransfersGetHandle *wdh, struct TALER_EXCHANGE_TransfersGetHandle *wdh,
const json_t *json) const json_t *json)
@ -92,7 +92,7 @@ check_transfers_get_response_ok (
TALER_JSON_spec_amount_any ("total", &td.total_amount), TALER_JSON_spec_amount_any ("total", &td.total_amount),
TALER_JSON_spec_amount_any ("wire_fee", &td.wire_fee), TALER_JSON_spec_amount_any ("wire_fee", &td.wire_fee),
GNUNET_JSON_spec_fixed_auto ("merchant_pub", &merchant_pub), GNUNET_JSON_spec_fixed_auto ("merchant_pub", &merchant_pub),
GNUNET_JSON_spec_fixed_auto ("h_wire", &td.h_wire), GNUNET_JSON_spec_fixed_auto ("h_payto", &td.h_payto),
TALER_JSON_spec_absolute_time ("execution_time", &td.execution_time), TALER_JSON_spec_absolute_time ("execution_time", &td.execution_time),
GNUNET_JSON_spec_json ("deposits", &details_j), GNUNET_JSON_spec_json ("deposits", &details_j),
GNUNET_JSON_spec_fixed_auto ("exchange_sig", &td.exchange_sig), GNUNET_JSON_spec_fixed_auto ("exchange_sig", &td.exchange_sig),
@ -199,7 +199,7 @@ check_transfers_get_response_ok (
TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT), TALER_SIGNATURE_EXCHANGE_CONFIRM_WIRE_DEPOSIT),
.purpose.size = htonl (sizeof (wdp)), .purpose.size = htonl (sizeof (wdp)),
.merchant_pub = merchant_pub, .merchant_pub = merchant_pub,
.h_wire = td.h_wire .h_payto = td.h_payto
}; };
TALER_amount_hton (&wdp.total, TALER_amount_hton (&wdp.total,