[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] 02/02: modify libtalerexchange to support batch-deposit
From: |
gnunet |
Subject: |
[taler-exchange] 02/02: modify libtalerexchange to support batch-deposit 451 reply |
Date: |
Sun, 01 Sep 2024 17:10:45 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository exchange.
commit 6996910aeee8fad4f0d249590b46570d514d2eb3
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Sep 1 17:10:22 2024 +0200
modify libtalerexchange to support batch-deposit 451 reply
---
src/include/taler_exchange_service.h | 63 ++++++++++++++++-------------
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 ++++++++++++-
5 files changed, 86 insertions(+), 34 deletions(-)
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/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.