[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] branch master updated (39e51a95b -> 6996910ae)
From: |
gnunet |
Subject: |
[taler-exchange] branch master updated (39e51a95b -> 6996910ae) |
Date: |
Sun, 01 Sep 2024 17:10:43 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a change to branch master
in repository exchange.
from 39e51a95b work on #9039
new 01373461c add idempotency check for batch-deposit on kyc failure
new 6996910ae modify libtalerexchange to support batch-deposit 451 reply
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/exchange/taler-exchange-httpd_batch-deposit.c | 52 ++++-----
src/exchangedb/Makefile.am | 1 +
.../exchange_do_check_deposit_idempotent.sql | 123 +++++++++++++++++++++
src/exchangedb/perf_deposits_get_ready.c | 3 +-
src/exchangedb/perf_select_refunds_by_coin.c | 2 +-
..._deposit.c => pg_do_check_deposit_idempotent.c} | 25 ++---
..._deposit.h => pg_do_check_deposit_idempotent.h} | 24 ++--
src/exchangedb/plugin_exchangedb_postgres.c | 3 +
src/exchangedb/procedures.sql.in | 1 +
src/include/taler_exchange_service.h | 63 ++++++-----
src/include/taler_exchangedb_plugin.h | 17 +++
src/lib/Makefile.am | 2 +-
src/lib/exchange_api_batch_deposit.c | 26 ++++-
src/testing/Makefile.am | 2 +-
src/testing/testing_api_cmd_batch_deposit.c | 27 ++++-
15 files changed, 271 insertions(+), 100 deletions(-)
create mode 100644 src/exchangedb/exchange_do_check_deposit_idempotent.sql
copy src/exchangedb/{pg_do_deposit.c => pg_do_check_deposit_idempotent.c} (86%)
copy src/exchangedb/{pg_do_deposit.h => pg_do_check_deposit_idempotent.h} (62%)
diff --git a/src/exchange/taler-exchange-httpd_batch-deposit.c
b/src/exchange/taler-exchange-httpd_batch-deposit.c
index b18acd8aa..9cf58e4a5 100644
--- a/src/exchange/taler-exchange-httpd_batch-deposit.c
+++ b/src/exchange/taler-exchange-httpd_batch-deposit.c
@@ -451,43 +451,31 @@ static bool
check_request_idempotent (
struct BatchDepositContext *bdc)
{
-#if FIXME_PLACEHOLDER
const struct TEH_RequestContext *rc = bdc->rc;
+ enum GNUNET_DB_QueryStatus qs;
+ bool is_idempotent;
- for (unsigned int i = 0; i<bwc->planchets_length; i++)
+ qs = TEH_plugin->do_check_deposit_idempotent (
+ TEH_plugin->cls,
+ &bdc->bd,
+ &bdc->exchange_timestamp,
+ &is_idempotent);
+ if (0 > qs)
{
- struct PlanchetContext *pc = &bwc->planchets[i];
- enum GNUNET_DB_QueryStatus qs;
- struct TALER_EXCHANGEDB_CollectableBlindcoin collectable;
-
- qs = TEH_plugin->get_withdraw_info (
- TEH_plugin->cls,
- &pc->collectable.h_coin_envelope,
- &collectable);
- if (0 > qs)
- {
- /* FIXME: soft error not handled correctly! */
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
- finish_loop (bwc,
- TALER_MHD_reply_with_error (
- rc->connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_DB_FETCH_FAILED,
- "get_withdraw_info"));
- return true;
- }
- if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
- return false;
- pc->collectable = collectable;
+ GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
+ finish_loop (bdc,
+ TALER_MHD_reply_with_error (
+ rc->connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "get_withdraw_info"));
+ return true;
}
- /* generate idempotent reply */
- TEH_METRICS_num_requests[TEH_MT_REQUEST_IDEMPOTENT_BATCH_WITHDRAW]++;
- bwc->phase = BDC_PHASE_GENERATE_REPLY_SUCCESS;
+ if ( (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) ||
+ (! is_idempotent) )
+ return false;
+ bdc->phase = BDC_PHASE_REPLY_SUCCESS;
return true;
-#else
- GNUNET_break (0); // NOT IMPLEMENTED
- return false;
-#endif
}
diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am
index a81c2d722..724370efb 100644
--- a/src/exchangedb/Makefile.am
+++ b/src/exchangedb/Makefile.am
@@ -130,6 +130,7 @@ libtaler_plugin_exchangedb_postgres_la_SOURCES = \
pg_profit_drains_get_pending.h pg_profit_drains_get_pending.c \
pg_get_drain_profit.h pg_get_drain_profit.c \
pg_get_purse_deposit.h pg_get_purse_deposit.c \
+ pg_do_check_deposit_idempotent.h pg_do_check_deposit_idempotent.c \
pg_insert_contract.h pg_insert_contract.c \
pg_select_contract.h pg_select_contract.c \
pg_select_purse_merge.h pg_select_purse_merge.c \
diff --git a/src/exchangedb/exchange_do_check_deposit_idempotent.sql
b/src/exchangedb/exchange_do_check_deposit_idempotent.sql
new file mode 100644
index 000000000..1e7414dc0
--- /dev/null
+++ b/src/exchangedb/exchange_do_check_deposit_idempotent.sql
@@ -0,0 +1,123 @@
+--
+-- This file is part of TALER
+-- Copyright (C) 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
+-- Foundation; either version 3, or (at your option) any later version.
+--
+-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR
+-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License along with
+-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+--
+CREATE OR REPLACE FUNCTION exchange_do_check_deposit_idempotent(
+ -- For batch_deposits
+ IN in_shard INT8,
+ IN in_merchant_pub BYTEA,
+ IN in_wallet_timestamp INT8,
+ IN in_exchange_timestamp INT8,
+ IN in_refund_deadline INT8,
+ IN in_wire_deadline INT8,
+ IN in_h_contract_terms BYTEA,
+ IN in_wallet_data_hash BYTEA, -- can be NULL
+ IN in_wire_salt BYTEA,
+ IN in_wire_target_h_payto BYTEA,
+ IN in_policy_details_serial_id INT8, -- can be NULL
+ IN in_policy_blocked BOOLEAN,
+ -- For wire_targets
+ IN in_receiver_wire_account TEXT,
+ -- For coin_deposits
+ IN ina_coin_pub BYTEA[],
+ IN ina_coin_sig BYTEA[],
+ IN ina_amount_with_fee taler_amount[],
+ OUT out_exchange_timestamp INT8,
+ OUT out_is_idempotent BOOL
+ )
+LANGUAGE plpgsql
+AS $$
+DECLARE
+ wtsi INT8; -- wire target serial id
+ bdsi INT8; -- batch_deposits serial id
+ i INT4;
+ ini_amount_with_fee taler_amount;
+ ini_coin_pub BYTEA;
+ ini_coin_sig BYTEA;
+BEGIN
+-- Shards:
+-- SELECT wire_targets (by h_payto);
+-- INSERT batch_deposits (by shard, merchant_pub), ON CONFLICT
idempotency check;
+-- PERFORM[] coin_deposits (by coin_pub), ON CONFLICT idempotency
check;
+
+out_exchange_timestamp = in_exchange_timestamp;
+
+-- First, get the 'wtsi'
+SELECT wire_target_serial_id
+ INTO wtsi
+ FROM wire_targets
+ WHERE wire_target_h_payto=in_wire_target_h_payto
+ AND payto_uri=in_receiver_wire_account;
+
+IF NOT FOUND
+THEN
+ out_is_idempotent = FALSE;
+ RETURN;
+END IF;
+
+
+-- Idempotency check: see if an identical record exists.
+-- We do select over merchant_pub, h_contract_terms and wire_target_h_payto
+-- first to maximally increase the chance of using the existing index.
+SELECT
+ exchange_timestamp
+ ,batch_deposit_serial_id
+ INTO
+ out_exchange_timestamp
+ ,bdsi
+ FROM batch_deposits
+ WHERE shard=in_shard
+ AND merchant_pub=in_merchant_pub
+ AND h_contract_terms=in_h_contract_terms
+ AND wire_target_h_payto=in_wire_target_h_payto
+ -- now check the rest, too
+ AND ( (wallet_data_hash=in_wallet_data_hash) OR
+ (wallet_data_hash IS NULL AND in_wallet_data_hash IS NULL) )
+ AND wire_salt=in_wire_salt
+ AND wallet_timestamp=in_wallet_timestamp
+ AND refund_deadline=in_refund_deadline
+ AND wire_deadline=in_wire_deadline
+ AND ( (policy_details_serial_id=in_policy_details_serial_id) OR
+ (policy_details_serial_id IS NULL AND in_policy_details_serial_id IS
NULL) );
+
+IF NOT FOUND
+THEN
+ out_is_idempotent=FALSE;
+ RETURN;
+END IF;
+
+
+-- Check each coin
+
+FOR i IN 1..array_length(ina_coin_pub,1)
+LOOP
+ ini_coin_pub = ina_coin_pub[i];
+ ini_coin_sig = ina_coin_sig[i];
+ ini_amount_with_fee = ina_amount_with_fee[i];
+
+ PERFORM FROM coin_deposits
+ WHERE batch_deposit_serial_id=bdsi
+ AND coin_pub=ini_coin_pub
+ AND coin_sig=ini_coin_sig
+ AND amount_with_fee=ini_amount_with_fee;
+ IF NOT FOUND
+ THEN
+ out_is_idempotent=FALSE;
+ RETURN;
+ END IF;
+END LOOP; -- end FOR all coins
+
+out_is_idempotent=TRUE;
+
+END $$;
diff --git a/src/exchangedb/perf_deposits_get_ready.c
b/src/exchangedb/perf_deposits_get_ready.c
index 005ea6843..1cb8c595a 100644
--- a/src/exchangedb/perf_deposits_get_ready.c
+++ b/src/exchangedb/perf_deposits_get_ready.c
@@ -68,8 +68,6 @@ static int result;
*/
static struct TALER_EXCHANGEDB_Plugin *plugin;
-static struct TALER_DenomFeeSet fees;
-
static struct TALER_MerchantWireHashP h_wire_wt;
/**
@@ -203,6 +201,7 @@ run (void *cls)
unsigned int *perm;
unsigned long long duration_sq;
struct TALER_EXCHANGEDB_RefreshRevealedCoin *ccoin;
+ struct TALER_DenomFeeSet fees;
struct GNUNET_CRYPTO_BlindingInputValues bi = {
.cipher = GNUNET_CRYPTO_BSA_RSA,
.rc = 0
diff --git a/src/exchangedb/perf_select_refunds_by_coin.c
b/src/exchangedb/perf_select_refunds_by_coin.c
index 84825d6d7..6b9592919 100644
--- a/src/exchangedb/perf_select_refunds_by_coin.c
+++ b/src/exchangedb/perf_select_refunds_by_coin.c
@@ -67,7 +67,6 @@ static int result;
*/
static struct TALER_EXCHANGEDB_Plugin *plugin;
-static struct TALER_DenomFeeSet fees;
static struct TALER_MerchantWireHashP h_wire_wt;
@@ -231,6 +230,7 @@ run (void *cls)
unsigned long long duration_sq;
struct TALER_EXCHANGEDB_RefreshRevealedCoin *ccoin;
struct TALER_DenominationPublicKey *new_denom_pubs = NULL;
+ struct TALER_DenomFeeSet fees;
unsigned int count = 0;
ref = GNUNET_new_array (ROUNDS + 1,
diff --git a/src/exchangedb/pg_do_deposit.c
b/src/exchangedb/pg_do_check_deposit_idempotent.c
similarity index 86%
copy from src/exchangedb/pg_do_deposit.c
copy to src/exchangedb/pg_do_check_deposit_idempotent.c
index 0ba45b628..8a15200e0 100644
--- a/src/exchangedb/pg_do_deposit.c
+++ b/src/exchangedb/pg_do_check_deposit_idempotent.c
@@ -22,19 +22,17 @@
#include "taler_error_codes.h"
#include "taler_dbevents.h"
#include "taler_pq_lib.h"
-#include "pg_do_deposit.h"
+#include "pg_do_check_deposit_idempotent.h"
#include "pg_helper.h"
#include "pg_compute_shard.h"
enum GNUNET_DB_QueryStatus
-TEH_PG_do_deposit (
+TEH_PG_do_check_deposit_idempotent (
void *cls,
const struct TALER_EXCHANGEDB_BatchDeposit *bd,
struct GNUNET_TIME_Timestamp *exchange_timestamp,
- bool *balance_ok,
- uint32_t *bad_balance_index,
- bool *ctr_conflict)
+ bool *is_idempotent)
{
struct PostgresClosure *pg = cls;
uint64_t deposit_shard = TEH_PG_compute_shard (&bd->merchant_pub);
@@ -79,12 +77,8 @@ TEH_PG_do_deposit (
GNUNET_PQ_result_spec_timestamp ("exchange_timestamp",
exchange_timestamp),
&no_time),
- GNUNET_PQ_result_spec_allow_null (
- GNUNET_PQ_result_spec_uint32 ("insufficient_balance_coin_index",
- bad_balance_index),
- balance_ok),
- GNUNET_PQ_result_spec_bool ("conflicted",
- ctr_conflict),
+ GNUNET_PQ_result_spec_bool ("is_idempotent",
+ is_idempotent),
GNUNET_PQ_result_spec_end
};
enum GNUNET_DB_QueryStatus qs;
@@ -103,15 +97,14 @@ TEH_PG_do_deposit (
TALER_B2S (&cdi->coin.coin_pub));
}
PREPARE (pg,
- "call_deposit",
+ "call_check_deposit_idempotent",
"SELECT "
" out_exchange_timestamp AS exchange_timestamp"
- ",out_insufficient_balance_coin_index AS
insufficient_balance_coin_index"
- ",out_conflict AS conflicted"
- " FROM exchange_do_deposit"
+ ",out_is_idempotent AS is_idempotent"
+ " FROM exchange_do_check_deposit_idempotent"
" ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16);");
qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "call_deposit",
+
"call_check_deposit_idempotent",
params,
rs);
GNUNET_PQ_cleanup_query_params_closures (params);
diff --git a/src/exchangedb/pg_do_deposit.h
b/src/exchangedb/pg_do_check_deposit_idempotent.h
similarity index 62%
copy from src/exchangedb/pg_do_deposit.h
copy to src/exchangedb/pg_do_check_deposit_idempotent.h
index 449ec04be..8aa00bba6 100644
--- a/src/exchangedb/pg_do_deposit.h
+++ b/src/exchangedb/pg_do_check_deposit_idempotent.h
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2022 Taler Systems SA
+ Copyright (C) 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
@@ -14,12 +14,12 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
- * @file exchangedb/pg_do_deposit.h
- * @brief implementation of the do_deposit function for Postgres
+ * @file exchangedb/pg_do_check_deposit_idempotent.h
+ * @brief implementation of the do_check_deposit_idempotent function for
Postgres
* @author Christian Grothoff
*/
-#ifndef PG_DO_DEPOSIT_H
-#define PG_DO_DEPOSIT_H
+#ifndef PG_DO_CHECK_DEPOSIT_IDEMPOTENT_H
+#define PG_DO_CHECK_DEPOSIT_IDEMPOTENT_H
#include "taler_util.h"
#include "taler_json_lib.h"
@@ -27,25 +27,19 @@
/**
- * Perform deposit operation, checking for sufficient balance
- * of the coins and possibly persisting the deposit details.
+ * Check ifdeposit operation is idempotent to existing one.
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
* @param bd batch deposit operation details
* @param[in,out] exchange_timestamp time to use for the deposit (possibly
updated)
- * @param[out] balance_ok set to true if the balance was sufficient
- * @param[out] bad_balance_index set to the first index of a coin for which
the balance was insufficient,
- * only used if @a balance_ok is set to false.
- * @param[out] in_conflict set to true if the deposit conflicted
+ * @param[out] is_idempotent set to true if the request is idempotent
* @return query execution status
*/
enum GNUNET_DB_QueryStatus
-TEH_PG_do_deposit (
+TEH_PG_do_check_deposit_idempotent (
void *cls,
const struct TALER_EXCHANGEDB_BatchDeposit *bd,
struct GNUNET_TIME_Timestamp *exchange_timestamp,
- bool *balance_ok,
- uint32_t *bad_balance_index,
- bool *in_conflict);
+ bool *is_idempotent);
#endif
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c
b/src/exchangedb/plugin_exchangedb_postgres.c
index 3915e3a46..00c4d519d 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -38,6 +38,7 @@
#include "pg_delete_aggregation_transient.h"
#include "pg_get_link_data.h"
#include "pg_helper.h"
+#include "pg_do_check_deposit_idempotent.h"
#include "pg_do_reserve_open.h"
#include "pg_get_coin_transactions.h"
#include "pg_get_expired_reserves.h"
@@ -744,6 +745,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
= &TEH_PG_select_aml_decisions;
plugin->select_deposit_amounts_for_kyc_check
= &TEH_PG_select_deposit_amounts_for_kyc_check;
+ plugin->do_check_deposit_idempotent
+ = &TEH_PG_do_check_deposit_idempotent;
plugin->insert_signkey_revocation
= &TEH_PG_insert_signkey_revocation;
plugin->select_aml_attributes
diff --git a/src/exchangedb/procedures.sql.in b/src/exchangedb/procedures.sql.in
index 5339bbb7c..b7c29ae7f 100644
--- a/src/exchangedb/procedures.sql.in
+++ b/src/exchangedb/procedures.sql.in
@@ -27,6 +27,7 @@ SET search_path TO exchange;
#include "exchange_do_batch_withdraw_insert.sql"
#include "exchange_do_age_withdraw.sql"
#include "exchange_do_deposit.sql"
+#include "exchange_do_check_deposit_idempotent.sql"
#include "exchange_do_melt.sql"
#include "exchange_do_select_deposits_missing_wire.sql"
#include "exchange_do_select_justification_for_missing_wire.sql"
diff --git a/src/include/taler_exchange_service.h
b/src/include/taler_exchange_service.h
index e845f5ed8..3e6840266 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -36,7 +36,35 @@
* Version of the Taler Exchange API, in hex.
* Thus 0.8.4-1 = 0x00080401.
*/
-#define TALER_EXCHANGE_API_VERSION 0x00100001
+#define TALER_EXCHANGE_API_VERSION 0x00100002
+
+/**
+ * Information returned when a client needs to pass
+ * a KYC check before the transaction may succeed.
+ */
+struct TALER_EXCHANGE_KycNeededRedirect
+{
+
+ /**
+ * Hash of the payto-URI of the account to KYC;
+ */
+ struct TALER_PaytoHashP h_payto;
+
+ /**
+ * Public key needed to access the KYC state of
+ * this account. All zeros if a wire transfer
+ * is required first to establish the key.
+ */
+ union TALER_AccountPublicKeyP account_pub;
+
+ /**
+ * Legitimization requirement that the merchant should use
+ * to check for its KYC status, 0 if not known.
+ */
+ uint64_t requirement_row;
+
+};
+
/* ********************* /keys *********************** */
@@ -1235,6 +1263,11 @@ struct TALER_EXCHANGE_BatchDepositResult
} conflict;
+ /**
+ * Details if the status is #MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS.
+ */
+ struct TALER_EXCHANGE_KycNeededRedirect unavailable_for_legal_reasons;
+
} details;
};
@@ -2509,34 +2542,6 @@ TALER_EXCHANGE_reserves_history_cancel (
struct TALER_EXCHANGE_ReservesHistoryHandle *rsh);
-/**
- * Information returned when a client needs to pass
- * a KYC check before the transaction may succeed.
- */
-struct TALER_EXCHANGE_KycNeededRedirect
-{
-
- /**
- * Hash of the payto-URI of the account to KYC;
- */
- struct TALER_PaytoHashP h_payto;
-
- /**
- * Public key needed to access the KYC state of
- * this account. All zeros if a wire transfer
- * is required first to establish the key.
- */
- union TALER_AccountPublicKeyP account_pub;
-
- /**
- * Legitimization requirement that the merchant should use
- * to check for its KYC status, 0 if not known.
- */
- uint64_t requirement_row;
-
-};
-
-
/**
* Information input into the withdraw process per coin.
*/
diff --git a/src/include/taler_exchangedb_plugin.h
b/src/include/taler_exchangedb_plugin.h
index 278994287..0b0e5fb0b 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -4217,6 +4217,23 @@ struct TALER_EXCHANGEDB_Plugin
bool *ctr_conflict);
+ /**
+ * Check ifdeposit operation is idempotent to existing one.
+ *
+ * @param cls the `struct PostgresClosure` with the plugin-specific state
+ * @param bd batch deposit operation details
+ * @param[in,out] exchange_timestamp time to use for the deposit (possibly
updated)
+ * @param[out] is_idempotent set to true if the request is idempotent
+ * @return query execution status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*do_check_deposit_idempotent)(
+ void *cls,
+ const struct TALER_EXCHANGEDB_BatchDeposit *bd,
+ struct GNUNET_TIME_Timestamp *exchange_timestamp,
+ bool *is_idempotent);
+
+
/**
* Perform melt operation, checking for sufficient balance
* of the coin and possibly persisting the melt details.
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index df2c32109..d1fc1c9d1 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -18,7 +18,7 @@ lib_LTLIBRARIES = \
libtalerexchange.la
libtalerexchange_la_LDFLAGS = \
- -version-info 10:0:0 \
+ -version-info 11:0:1 \
-no-undefined
libtalerexchange_la_SOURCES = \
exchange_api_add_aml_decision.c \
diff --git a/src/lib/exchange_api_batch_deposit.c
b/src/lib/exchange_api_batch_deposit.c
index 3dab64526..8aa1bb83f 100644
--- a/src/lib/exchange_api_batch_deposit.c
+++ b/src/lib/exchange_api_batch_deposit.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 General Public License as published by the Free Software
@@ -464,6 +464,30 @@ handle_deposit_finished (void *cls,
dr->hr.ec = TALER_JSON_get_error_code (j);
dr->hr.hint = TALER_JSON_get_error_hint (j);
break;
+ case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS:
+ {
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_fixed_auto (
+ "h_payto",
+ &dr->details.unavailable_for_legal_reasons.h_payto),
+ GNUNET_JSON_spec_uint64 (
+ "requirement_row",
+ &dr->details.unavailable_for_legal_reasons.requirement_row),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (j,
+ spec,
+ NULL, NULL))
+ {
+ GNUNET_break_op (0);
+ dr->hr.http_status = 0;
+ dr->hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
+ break;
+ }
+ }
+ break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
dr->hr.ec = TALER_JSON_get_error_code (j);
dr->hr.hint = TALER_JSON_get_error_hint (j);
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index 56e66451b..68bf4cd08 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -37,7 +37,7 @@ libtalertwistertesting_la_LDFLAGS = \
endif
libtalertesting_la_LDFLAGS = \
- -version-info 1:0:0 \
+ -version-info 2:0:1 \
-no-undefined
libtalertesting_la_SOURCES = \
testing_api_cmd_age_withdraw.c \
diff --git a/src/testing/testing_api_cmd_batch_deposit.c
b/src/testing/testing_api_cmd_batch_deposit.c
index 5139d3524..27a2a1165 100644
--- a/src/testing/testing_api_cmd_batch_deposit.c
+++ b/src/testing/testing_api_cmd_batch_deposit.c
@@ -39,7 +39,7 @@
* How long do we wait AT MOST when retrying?
*/
#define MAX_BACKOFF GNUNET_TIME_relative_multiply ( \
- GNUNET_TIME_UNIT_MILLISECONDS, 100)
+ GNUNET_TIME_UNIT_MILLISECONDS, 100)
/**
@@ -171,6 +171,18 @@ struct BatchDepositState
*/
struct TALER_ExchangeSignatureP exchange_sig;
+ /**
+ * Set to the KYC requirement payto hash *if* the exchange replied with a
+ * request for KYC.
+ */
+ struct TALER_PaytoHashP h_payto;
+
+ /**
+ * Set to the KYC requirement row *if* the exchange replied with
+ * a request for KYC.
+ */
+ uint64_t requirement_row;
+
/**
* Reference to previous deposit operation.
* Only present if we're supposed to replay the previous deposit.
@@ -218,12 +230,21 @@ batch_deposit_cb (void *cls,
ds->expected_response_code);
return;
}
- if (MHD_HTTP_OK == dr->hr.http_status)
+ switch (dr->hr.http_status)
{
+ case MHD_HTTP_OK:
ds->deposit_succeeded = GNUNET_YES;
ds->exchange_timestamp = dr->details.ok.deposit_timestamp;
ds->exchange_pub = *dr->details.ok.exchange_pub;
ds->exchange_sig = *dr->details.ok.exchange_sig;
+ break;
+ case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS:
+ /* nothing to check */
+ ds->requirement_row
+ = dr->details.unavailable_for_legal_reasons.requirement_row;
+ ds->h_payto
+ = dr->details.unavailable_for_legal_reasons.h_payto;
+ break;
}
TALER_TESTING_interpreter_next (ds->is);
}
@@ -548,6 +569,8 @@ batch_deposit_traits (void *cls,
&ds->wire_deadline),
TALER_TESTING_make_trait_refund_deadline (index,
&ds->refund_deadline),
+ TALER_TESTING_make_trait_legi_requirement_row (&ds->requirement_row),
+ TALER_TESTING_make_trait_h_payto (&ds->h_payto),
TALER_TESTING_trait_end ()
};
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-exchange] branch master updated (39e51a95b -> 6996910ae),
gnunet <=