commit 55e4498e02d4c4e37d4533fbb26de31d574a962b
parent af46617bce368276ca0b910f4a76c8d0d5c1dc0a
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 28 Jul 2024 15:05:05 +0200
fix track transfer
Diffstat:
10 files changed, 145 insertions(+), 104 deletions(-)
diff --git a/src/exchange/taler-exchange-httpd_deposits_get.c b/src/exchange/taler-exchange-httpd_deposits_get.c
@@ -389,6 +389,9 @@ handle_track_transaction_request (
MHD_suspend_connection (connection);
return MHD_YES;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "KYC required with row %llu\n",
+ (unsigned long long) ctx->kyc.requirement_row);
return TALER_MHD_REPLY_JSON_PACK (
connection,
MHD_HTTP_ACCEPTED,
diff --git a/src/exchangedb/pg_lookup_transfer_by_deposit.c b/src/exchangedb/pg_lookup_transfer_by_deposit.c
@@ -66,8 +66,10 @@ TEH_PG_lookup_transfer_by_deposit (
GNUNET_PQ_result_spec_end
};
+ memset (kyc,
+ 0,
+ sizeof (*kyc));
/* check if the aggregation record exists and get it */
- // FIXME: KYC initialization logic REMOVED, needs to be added back!
PREPARE (pg,
"lookup_deposit_wtid",
"SELECT"
@@ -111,6 +113,7 @@ TEH_PG_lookup_transfer_by_deposit (
h_wire))
{
*pending = false;
+ kyc->ok = true;
GNUNET_PQ_cleanup_result (rs);
return qs;
}
@@ -141,6 +144,10 @@ TEH_PG_lookup_transfer_by_deposit (
deposit_fee),
GNUNET_PQ_result_spec_timestamp ("wire_deadline",
exec_time),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_uint64 ("legitimization_requirement_serial_id",
+ &kyc->requirement_row),
+ NULL),
GNUNET_PQ_result_spec_end
};
@@ -152,6 +159,7 @@ TEH_PG_lookup_transfer_by_deposit (
",cdep.amount_with_fee"
",denom.fee_deposit"
",bdep.wire_deadline"
+ ",agt.legitimization_requirement_serial_id"
" FROM coin_deposits cdep"
" JOIN batch_deposits bdep"
" USING (batch_deposit_serial_id)"
@@ -161,6 +169,9 @@ TEH_PG_lookup_transfer_by_deposit (
" ON (kc.coin_pub = cdep.coin_pub)"
" JOIN denominations denom"
" USING (denominations_serial)"
+ " LEFT JOIN aggregation_transient agt "
+ " ON ( (bdep.wire_target_h_payto = agt.wire_target_h_payto) AND"
+ " (bdep.merchant_pub = agt.merchant_pub) )"
" WHERE cdep.coin_pub=$1"
" AND bdep.merchant_pub=$3"
" AND bdep.h_contract_terms=$2"
@@ -186,6 +197,8 @@ TEH_PG_lookup_transfer_by_deposit (
return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
}
GNUNET_PQ_cleanup_result (rs2);
+ if (0 == kyc->requirement_row)
+ kyc->ok = true; /* technically: unknown */
}
return qs;
}
diff --git a/src/exchangedb/pg_update_kyc_process_by_row.c b/src/exchangedb/pg_update_kyc_process_by_row.c
@@ -45,23 +45,22 @@ TEH_PG_update_kyc_process_by_row (
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&process_row),
GNUNET_PQ_query_param_string (provider_name),
- GNUNET_PQ_query_param_auto_from_type (h_payto),
+ GNUNET_PQ_query_param_auto_from_type (h_payto), /*3*/
(NULL != provider_account_id)
? GNUNET_PQ_query_param_string (provider_account_id)
- : GNUNET_PQ_query_param_null (),
+ : GNUNET_PQ_query_param_null (), /*4*/
(NULL != provider_legitimization_id)
? GNUNET_PQ_query_param_string (provider_legitimization_id)
- : GNUNET_PQ_query_param_null (),
+ : GNUNET_PQ_query_param_null (), /*5*/
(NULL != redirect_url)
? GNUNET_PQ_query_param_string (redirect_url)
- : GNUNET_PQ_query_param_null (),
+ : GNUNET_PQ_query_param_null (), /*6*/
GNUNET_PQ_query_param_absolute_time (&expiration),
- GNUNET_PQ_query_param_string (provider_name),
- GNUNET_PQ_query_param_uint32 (&ec32),
+ GNUNET_PQ_query_param_uint32 (&ec32), /* 8 */
(NULL != error_message_hint)
? GNUNET_PQ_query_param_string (error_message_hint)
: GNUNET_PQ_query_param_null (),
- GNUNET_PQ_query_param_bool (finished),
+ GNUNET_PQ_query_param_bool (finished), /* 10 */
GNUNET_PQ_query_param_end
};
enum GNUNET_DB_QueryStatus qs;
diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h
@@ -315,10 +315,10 @@ struct TALER_TESTING_Command
* @return #GNUNET_OK on success
*/
enum GNUNET_GenericReturnValue
- (*traits)(void *cls,
- const void **ret,
- const char *trait,
- unsigned int index);
+ (*traits)(void *cls,
+ const void **ret,
+ const char *trait,
+ unsigned int index);
/**
* When did the execution of this command start?
@@ -1595,11 +1595,11 @@ TALER_TESTING_cmd_refresh_link_with_retry (struct TALER_TESTING_Command cmd);
* @return the command.
*/
struct TALER_TESTING_Command
-TALER_TESTING_cmd_track_transaction (const char *label,
- const char *transaction_reference,
- unsigned int coin_index,
- unsigned int expected_response_code,
- const char *bank_transfer_reference);
+TALER_TESTING_cmd_deposits_get (const char *label,
+ const char *transaction_reference,
+ unsigned int coin_index,
+ unsigned int expected_response_code,
+ const char *bank_transfer_reference);
/**
* Make a "track transfer" CMD where no "expected"-arguments,
@@ -2627,7 +2627,7 @@ TALER_TESTING_get_trait (const struct TALER_TESTING_Trait *traits,
enum GNUNET_GenericReturnValue \
TALER_TESTING_get_trait_ ## name ( \
const struct TALER_TESTING_Command *cmd, \
- type * *ret); \
+ type **ret); \
struct TALER_TESTING_Trait \
TALER_TESTING_make_trait_ ## name ( \
type * value);
@@ -2670,11 +2670,11 @@ TALER_TESTING_get_trait (const struct TALER_TESTING_Trait *traits,
TALER_TESTING_get_trait_ ## name ( \
const struct TALER_TESTING_Command *cmd, \
unsigned int index, \
- type * *ret); \
+ type **ret); \
struct TALER_TESTING_Trait \
TALER_TESTING_make_trait_ ## name ( \
unsigned int index, \
- type * value);
+ type *value);
/**
diff --git a/src/lib/exchange_api_deposits_get.c b/src/lib/exchange_api_deposits_get.c
@@ -117,16 +117,21 @@ handle_deposit_wtid_finished (void *cls,
case MHD_HTTP_OK:
{
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_fixed_auto ("wtid",
- &dr.details.ok.wtid),
- GNUNET_JSON_spec_timestamp ("execution_time",
- &dr.details.ok.execution_time),
- TALER_JSON_spec_amount_any ("coin_contribution",
- &dr.details.ok.coin_contribution),
- GNUNET_JSON_spec_fixed_auto ("exchange_sig",
- &dr.details.ok.exchange_sig),
- GNUNET_JSON_spec_fixed_auto ("exchange_pub",
- &dr.details.ok.exchange_pub),
+ GNUNET_JSON_spec_fixed_auto (
+ "wtid",
+ &dr.details.ok.wtid),
+ GNUNET_JSON_spec_timestamp (
+ "execution_time",
+ &dr.details.ok.execution_time),
+ TALER_JSON_spec_amount_any (
+ "coin_contribution",
+ &dr.details.ok.coin_contribution),
+ GNUNET_JSON_spec_fixed_auto (
+ "exchange_sig",
+ &dr.details.ok.exchange_sig),
+ GNUNET_JSON_spec_fixed_auto (
+ "exchange_pub",
+ &dr.details.ok.exchange_pub),
GNUNET_JSON_spec_end ()
};
const struct TALER_EXCHANGE_Keys *key_state;
@@ -178,19 +183,22 @@ handle_deposit_wtid_finished (void *cls,
/* Transaction known, but not executed yet */
bool no_legi = false;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_timestamp ("execution_time",
- &dr.details.accepted.execution_time),
+ GNUNET_JSON_spec_timestamp (
+ "execution_time",
+ &dr.details.accepted.execution_time),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_fixed_auto (
"account_pub",
&dr.details.accepted.account_pub),
NULL),
GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_uint64 ("requirement_row",
- &dr.details.accepted.requirement_row),
+ GNUNET_JSON_spec_uint64 (
+ "requirement_row",
+ &dr.details.accepted.requirement_row),
&no_legi),
- GNUNET_JSON_spec_bool ("kyc_ok",
- &dr.details.accepted.kyc_ok),
+ GNUNET_JSON_spec_bool (
+ "kyc_ok",
+ &dr.details.accepted.kyc_ok),
GNUNET_JSON_spec_end ()
};
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
@@ -37,7 +37,7 @@ libtalertwistertesting_la_LDFLAGS = \
endif
libtalertesting_la_LDFLAGS = \
- -version-info 0:0:0 \
+ -version-info 1:0:0 \
-no-undefined
libtalertesting_la_SOURCES = \
testing_api_cmd_age_withdraw.c \
diff --git a/src/testing/test_exchange_api.c b/src/testing/test_exchange_api.c
@@ -69,7 +69,8 @@ static bool uses_cs;
* @param label label to use for the command.
*/
#define CMD_EXEC_WIREWATCH(label) \
- TALER_TESTING_cmd_exec_wirewatch2 (label, config_file, "exchange-account-2")
+ TALER_TESTING_cmd_exec_wirewatch2 (label, config_file, \
+ "exchange-account-2")
/**
* Execute the taler-exchange-aggregator, closer and transfer commands with
@@ -78,9 +79,9 @@ static bool uses_cs;
* @param label label to use for the command.
*/
#define CMD_EXEC_AGGREGATOR(label) \
- TALER_TESTING_cmd_sleep ("sleep-before-aggregator", 2), \
- TALER_TESTING_cmd_exec_aggregator (label "-aggregator", config_file), \
- TALER_TESTING_cmd_exec_transfer (label "-transfer", config_file)
+ TALER_TESTING_cmd_sleep ("sleep-before-aggregator", 2), \
+ TALER_TESTING_cmd_exec_aggregator (label "-aggregator", config_file), \
+ TALER_TESTING_cmd_exec_transfer (label "-transfer", config_file)
/**
@@ -91,9 +92,9 @@ static bool uses_cs;
* @param amount amount to transfer, i.e. "EUR:1"
*/
#define CMD_TRANSFER_TO_EXCHANGE(label,amount) \
- TALER_TESTING_cmd_admin_add_incoming (label, amount, \
- &cred.ba, \
- cred.user42_payto)
+ TALER_TESTING_cmd_admin_add_incoming (label, amount, \
+ &cred.ba, \
+ cred.user42_payto)
/**
* Main function that will tell the interpreter what commands to
@@ -426,20 +427,20 @@ run (void *cls,
* execution of transactions, the answer should be that
* the exchange knows about the deposit, but has no WTID yet.
*/
- TALER_TESTING_cmd_track_transaction ("deposit-wtid-found",
- "deposit-simple",
- 0,
- MHD_HTTP_ACCEPTED,
- NULL),
+ TALER_TESTING_cmd_deposits_get ("deposit-wtid-found",
+ "deposit-simple",
+ 0,
+ MHD_HTTP_ACCEPTED,
+ NULL),
/* Try resolving a deposit's WTID for a failed deposit.
* As the deposit failed, the answer should be that the
* exchange does NOT know about the deposit.
*/
- TALER_TESTING_cmd_track_transaction ("deposit-wtid-failing",
- "deposit-double-2",
- 0,
- MHD_HTTP_NOT_FOUND,
- NULL),
+ TALER_TESTING_cmd_deposits_get ("deposit-wtid-failing",
+ "deposit-double-2",
+ 0,
+ MHD_HTTP_NOT_FOUND,
+ NULL),
/* Try resolving an undefined (all zeros) WTID; this
* should fail as obviously the exchange didn't use that
* WTID value for any transaction.
@@ -507,11 +508,11 @@ run (void *cls,
: TALER_TESTING_cmd_sleep ("dummy",
0),
TALER_TESTING_cmd_check_bank_empty ("check_bank_empty"),
- TALER_TESTING_cmd_track_transaction ("deposit-wtid-ok",
- "deposit-simple",
- 0,
- MHD_HTTP_OK,
- "check_bank_transfer-499c"),
+ TALER_TESTING_cmd_deposits_get ("deposit-wtid-ok",
+ "deposit-simple",
+ 0,
+ MHD_HTTP_OK,
+ "check_bank_transfer-499c"),
TALER_TESTING_cmd_track_transfer ("wire-deposit-success-bank",
"check_bank_transfer-99c1",
MHD_HTTP_OK,
diff --git a/src/testing/test_kyc_api.c b/src/testing/test_kyc_api.c
@@ -111,13 +111,13 @@ run (void *cls,
"withdraw-coin-1-no-kyc",
"create-reserve-1",
"EUR:10",
- 0, /* age restriction off */
+ 0, /* age restriction off */
MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS),
TALER_TESTING_cmd_withdraw_amount (
"withdraw-coin-1",
"create-reserve-1",
"EUR:5",
- 0, /* age restriction off */
+ 0, /* age restriction off */
MHD_HTTP_OK),
TALER_TESTING_cmd_end ()
};
@@ -130,7 +130,7 @@ run (void *cls,
"withdraw-coin-1-lacking-kyc",
"create-reserve-1",
"EUR:5",
- 0, /* age restriction off */
+ 0, /* age restriction off */
MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS),
TALER_TESTING_cmd_check_kyc_get (
"check-kyc-withdraw",
@@ -156,7 +156,7 @@ run (void *cls,
"withdraw-coin-1-with-kyc",
"create-reserve-1",
"EUR:5",
- 0, /* age restriction off */
+ 0, /* age restriction off */
MHD_HTTP_OK),
/* Attestations above are bound to the originating *bank* account,
not to the reserve (!). Hence, they are NOT found here! */
@@ -177,7 +177,7 @@ run (void *cls,
GNUNET_TIME_UNIT_ZERO,
"EUR:5",
MHD_HTTP_OK),
- TALER_TESTING_cmd_track_transaction (
+ TALER_TESTING_cmd_deposits_get (
"track-deposit",
"deposit-simple",
0,
@@ -188,17 +188,26 @@ run (void *cls,
struct TALER_TESTING_Command track[] = {
CMD_EXEC_AGGREGATOR ("run-aggregator-before-kyc"),
- TALER_TESTING_cmd_check_bank_empty ("check_bank_empty-no-kyc"),
- TALER_TESTING_cmd_track_transaction (
+ TALER_TESTING_cmd_check_bank_empty (
+ "check_bank_empty-no-kyc"),
+ TALER_TESTING_cmd_deposits_get (
"track-deposit-kyc-ready",
"deposit-simple",
0,
MHD_HTTP_ACCEPTED,
NULL),
+ TALER_TESTING_cmd_admin_add_kycauth (
+ "setup-account-key-deposit",
+ "EUR:0.01",
+ &cred.ba,
+ cred.user43_payto,
+ NULL /* create new key */),
+ CMD_EXEC_WIREWATCH (
+ "import-kyc-account-deposit"),
TALER_TESTING_cmd_check_kyc_get (
"check-kyc-deposit",
"track-deposit-kyc-ready",
- "FIXME",
+ "setup-account-key-deposit",
MHD_HTTP_ACCEPTED),
TALER_TESTING_cmd_get_kyc_info (
"get-kyc-info-deposit",
@@ -658,7 +667,6 @@ run (void *cls,
NULL,
true,
true),
-#if FIXME
TALER_TESTING_cmd_batch (
"withdraw",
withdraw),
@@ -683,7 +691,6 @@ run (void *cls,
TALER_TESTING_cmd_batch (
"pull",
pull),
-#endif
TALER_TESTING_cmd_batch ("aml",
aml),
TALER_TESTING_cmd_end ()
diff --git a/src/testing/testing_api_cmd_deposits_get.c b/src/testing/testing_api_cmd_deposits_get.c
@@ -107,8 +107,9 @@ struct TrackTransactionState
* @param dr GET deposit response details
*/
static void
-deposit_wtid_cb (void *cls,
- const struct TALER_EXCHANGE_GetDepositResponse *dr)
+deposit_wtid_cb (
+ void *cls,
+ const struct TALER_EXCHANGE_GetDepositResponse *dr)
{
struct TrackTransactionState *tts = cls;
struct TALER_TESTING_Interpreter *is = tts->is;
@@ -133,7 +134,8 @@ deposit_wtid_cb (void *cls,
/* _this_ wire transfer subject line. */
bank_transfer_cmd
= TALER_TESTING_interpreter_lookup_command (is,
- tts->bank_transfer_reference);
+ tts->bank_transfer_reference
+ );
if (NULL == bank_transfer_cmd)
{
GNUNET_break (0);
@@ -186,9 +188,10 @@ deposit_wtid_cb (void *cls,
* @param is the interpreter state.
*/
static void
-track_transaction_run (void *cls,
- const struct TALER_TESTING_Command *cmd,
- struct TALER_TESTING_Interpreter *is)
+deposits_get_run (
+ void *cls,
+ const struct TALER_TESTING_Command *cmd,
+ struct TALER_TESTING_Interpreter *is)
{
struct TrackTransactionState *tts = cls;
const struct TALER_TESTING_Command *transaction_cmd;
@@ -295,8 +298,9 @@ track_transaction_run (void *cls,
* @param cmd the command which is being cleaned up.
*/
static void
-track_transaction_cleanup (void *cls,
- const struct TALER_TESTING_Command *cmd)
+deposits_get_cleanup (
+ void *cls,
+ const struct TALER_TESTING_Command *cmd)
{
struct TrackTransactionState *tts = cls;
@@ -322,10 +326,10 @@ track_transaction_cleanup (void *cls,
* @return #GNUNET_OK on success.
*/
static enum GNUNET_GenericReturnValue
-track_transaction_traits (void *cls,
- const void **ret,
- const char *trait,
- unsigned int index)
+deposits_get_traits (void *cls,
+ const void **ret,
+ const char *trait,
+ unsigned int index)
{
struct TrackTransactionState *tts = cls;
struct TALER_TESTING_Trait traits[] = {
@@ -345,11 +349,12 @@ track_transaction_traits (void *cls,
struct TALER_TESTING_Command
-TALER_TESTING_cmd_track_transaction (const char *label,
- const char *transaction_reference,
- unsigned int coin_index,
- unsigned int expected_response_code,
- const char *bank_transfer_reference)
+TALER_TESTING_cmd_deposits_get (
+ const char *label,
+ const char *transaction_reference,
+ unsigned int coin_index,
+ unsigned int expected_response_code,
+ const char *bank_transfer_reference)
{
struct TrackTransactionState *tts;
@@ -362,9 +367,9 @@ TALER_TESTING_cmd_track_transaction (const char *label,
struct TALER_TESTING_Command cmd = {
.cls = tts,
.label = label,
- .run = &track_transaction_run,
- .cleanup = &track_transaction_cleanup,
- .traits = &track_transaction_traits
+ .run = &deposits_get_run,
+ .cleanup = &deposits_get_cleanup,
+ .traits = &deposits_get_traits
};
return cmd;
diff --git a/src/testing/testing_api_cmd_transfer_get.c b/src/testing/testing_api_cmd_transfer_get.c
@@ -95,8 +95,9 @@ struct TrackTransferState
* @param cmd the command which is being cleaned up.
*/
static void
-track_transfer_cleanup (void *cls,
- const struct TALER_TESTING_Command *cmd)
+track_transfer_cleanup (
+ void *cls,
+ const struct TALER_TESTING_Command *cmd)
{
struct TrackTransferState *tts = cls;
@@ -121,8 +122,9 @@ track_transfer_cleanup (void *cls,
* @param tgr response details
*/
static void
-track_transfer_cb (void *cls,
- const struct TALER_EXCHANGE_TransfersGetResponse *tgr)
+track_transfer_cb (
+ void *cls,
+ const struct TALER_EXCHANGE_TransfersGetResponse *tgr)
{
struct TrackTransferState *tts = cls;
const struct TALER_EXCHANGE_HttpResponse *hr = &tgr->hr;
@@ -302,9 +304,10 @@ track_transfer_cb (void *cls,
* @param is the interpreter state.
*/
static void
-track_transfer_run (void *cls,
- const struct TALER_TESTING_Command *cmd,
- struct TALER_TESTING_Interpreter *is)
+track_transfer_run (
+ void *cls,
+ const struct TALER_TESTING_Command *cmd,
+ struct TALER_TESTING_Interpreter *is)
{
/* looking for a wtid to track .. */
struct TrackTransferState *tts = cls;
@@ -354,9 +357,10 @@ track_transfer_run (void *cls,
struct TALER_TESTING_Command
-TALER_TESTING_cmd_track_transfer_empty (const char *label,
- const char *wtid_reference,
- unsigned int expected_response_code)
+TALER_TESTING_cmd_track_transfer_empty (
+ const char *label,
+ const char *wtid_reference,
+ unsigned int expected_response_code)
{
struct TrackTransferState *tts;
@@ -377,11 +381,12 @@ TALER_TESTING_cmd_track_transfer_empty (const char *label,
struct TALER_TESTING_Command
-TALER_TESTING_cmd_track_transfer (const char *label,
- const char *wtid_reference,
- unsigned int expected_response_code,
- const char *expected_total_amount,
- const char *expected_wire_fee)
+TALER_TESTING_cmd_track_transfer (
+ const char *label,
+ const char *wtid_reference,
+ unsigned int expected_response_code,
+ const char *expected_total_amount,
+ const char *expected_wire_fee)
{
struct TrackTransferState *tts;