[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: work on anastasis_backup.c
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: work on anastasis_backup.c |
Date: |
Fri, 05 Feb 2021 21:21:26 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new 24be8c5 work on anastasis_backup.c
24be8c5 is described below
commit 24be8c58ce360f586b001f3fafdb51119f1b9a72
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Fri Feb 5 21:21:24 2021 +0100
work on anastasis_backup.c
---
src/backend/anastasis-httpd_policy_upload.c | 21 ---
src/backend/anastasis-httpd_truth.c | 5 +-
src/include/anastasis.h | 112 ++++++++++----
src/include/anastasis_service.h | 48 +++---
src/include/anastasis_testing_lib.h | 38 +++--
src/lib/anastasis_backup.c | 202 ++++++++++---------------
src/lib/anastasis_recovery.c | 12 +-
src/reducer/anastasis_api_backup_redux.c | 69 ++-------
src/restclient/anastasis_api_challenge_run.c | 13 +-
src/restclient/anastasis_api_keyshare_lookup.c | 20 ++-
src/restclient/anastasis_api_policy_store.c | 84 ++--------
src/testing/testing_api_cmd_challenge_run.c | 12 +-
src/testing/testing_api_cmd_keyshare_lookup.c | 13 +-
src/testing/testing_api_cmd_policy_store.c | 61 ++------
src/testing/testing_cmd_secret_share.c | 147 ++++++------------
15 files changed, 307 insertions(+), 550 deletions(-)
diff --git a/src/backend/anastasis-httpd_policy_upload.c
b/src/backend/anastasis-httpd_policy_upload.c
index 331f20a..fa329e5 100644
--- a/src/backend/anastasis-httpd_policy_upload.c
+++ b/src/backend/anastasis-httpd_policy_upload.c
@@ -784,27 +784,6 @@ AH_handler_policy_post (struct MHD_Connection *connection,
}
puc->upload_size = (size_t) len;
}
- {
- // Check if header contains if-match
- const char *im;
-
- im = MHD_lookup_connection_value (connection,
- MHD_HEADER_KIND,
- MHD_HTTP_HEADER_IF_MATCH);
- if ( (NULL != im) &&
- (GNUNET_OK !=
- GNUNET_STRINGS_string_to_data (im,
- strlen (im),
- &puc->old_policy_upload_hash,
- sizeof
(puc->old_policy_upload_hash))) )
- {
- GNUNET_break_op (0);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_BAD_REQUEST,
- TALER_EC_SYNC_BAD_IF_MATCH,
- "If-Match does not include a
base32-encoded SHA-512 hash");
- }
- }
{
// Check if header contains Anastasis-Policy-Signature
const char *sig_s;
diff --git a/src/backend/anastasis-httpd_truth.c
b/src/backend/anastasis-httpd_truth.c
index 3945c7a..94d60bd 100644
--- a/src/backend/anastasis-httpd_truth.c
+++ b/src/backend/anastasis-httpd_truth.c
@@ -622,9 +622,6 @@ AH_handler_truth_get (struct MHD_Connection *connection,
const char *url,
struct TM_HandlerContext *hc)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Handling truth get\n");
-
struct GetContext *gc = hc->ctx;
struct ANASTASIS_CRYPTO_TruthPublicKeyP truth_public_key;
struct ANASTASIS_CRYPTO_TruthKeyP truth_key;
@@ -640,6 +637,8 @@ AH_handler_truth_get (struct MHD_Connection *connection,
TALER_amount_get_zero (AH_currency, &zero_amount);
bool zero_cost = false;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Handling truth get\n");
if (NULL != gc)
{
if (NULL != gc->resp)
diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index 5514ccd..1493281 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -490,35 +490,97 @@ ANASTASIS_policy_destroy (struct ANASTASIS_Policy *p);
/**
- * Function called with the results of a #secret_share().
- *
- * @param cls closure
- * @param current_etag sends back the etag of the upload (used to prevent
redundant uploads)
- * @param server_url url of the server that provided the @a ec response
- * @param ec status code of the request
- * @param http_status http status code
+ * Information about a provider requesting payment for storing a policy.
*/
-typedef void
-(*ANASTASIS_ShareResultCallback)(void *cls,
- const struct GNUNET_HashCode *current_etag,
- const char *server_url,
- const enum TALER_ErrorCode ec,
- unsigned int http_status);
+struct ANASTASIS_SharePaymentRequest
+{
+ /**
+ * Payment request URL.
+ */
+ const char *payment_request_url;
+
+ /**
+ * Base URL of the provider requesting payment.
+ */
+ const char *provider_url;
+};
+
+
+/**
+ * Result of uploading share data.
+ */
+enum ANASTASIS_ShareStatus
+{
+ ANASTASIS_SHARE_STATUS_SUCCESS = 0,
+ ANASTASIS_SHARE_STATUS_PAYMENT_REQUIRED,
+ ANASTASIS_SHARE_STATUS_PROVIDER_FAILED
+};
+
+
+/**
+ * Complete result of a secret sharing operation.
+ */
+struct ANASTASIS_ShareResult
+{
+ /**
+ * Status of the share secret operation.
+ */
+ enum ANASTASIS_ShareStatus ss;
+
+ /**
+ * Details about the result, depending on @e ss.
+ */
+ union
+ {
+
+ struct
+ {
+ /**
+ * Array of URLs with requested payments.
+ */
+ struct ANASTASIS_SharePaymentRequest *payment_requests;
+
+ /**
+ * Length of the payment_requests array.
+ */
+ unsigned int payment_requests_length;
+ } payment_required;
+
+ struct
+ {
+ /**
+ * Base URL of the failed provider.
+ */
+ const char *provider_url;
+
+ /**
+ * HTTP status returned by the provider.
+ */
+ unsigned int http_status;
+
+ /**
+ * Upload status of the provider.
+ */
+ enum ANASTASIS_UploadStatus ec;
+
+
+ } provider_failure;
+
+ } details;
+
+};
/**
- * Callback for a payment process for uploading a policy
+ * Function called with the results of a #ANASTASIS_secret_share().
*
- * @param cls closure for the callback
- * @param taler_pay_url url for the payment (taler://pay/Foo)
- * @param server_url url of the server to pay for
- * @param ec status of the request
+ * @param cls closure
+ * @param sr share result
*/
typedef void
-(*ANASTASIS_SharePaymentCallback)(void *cls,
- const char *taler_pay_url,
- const char *server_url,
- enum TALER_ErrorCode ec);
+(*ANASTASIS_ShareResultCallback)(void *cls,
+ const struct ANASTASIS_ShareResult *sr);
+
/**
* Defines a recovery document upload process (recovery document
@@ -546,11 +608,10 @@ struct ANASTASIS_PaymentDetails
/**
* Creates a recovery document with the created policies and uploads it to
- * all servers. FIXME: how do we know the upload(s) are completed?
+ * all servers.
*
* @param ctx the CURL context used to connect to the backend
* @param id_data used to create a account identifier on the escrow provider
- * @param last_etag NULL on 'first' use, otherwise 'current_etag' from
previous ShareResultCallback
* @param policies list of policies which are included in this recovery
document
* @param policies_length amount of policies in the document
* @param pds contains details of past payments
@@ -567,14 +628,11 @@ struct ANASTASIS_PaymentDetails
struct ANASTASIS_SecretShare *
ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
const json_t *id_data,
- const struct GNUNET_HashCode *last_etag,
const struct ANASTASIS_Policy *policies[],
unsigned int policies_len,
const struct ANASTASIS_PaymentDetails *pds,
unsigned int pds_len,
bool payment_requested,
- ANASTASIS_SharePaymentCallback spc,
- void *spc_cls,
ANASTASIS_ShareResultCallback src,
void *src_cls,
const void *core_secret,
diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h
index 9285029..9951905 100644
--- a/src/include/anastasis_service.h
+++ b/src/include/anastasis_service.h
@@ -106,30 +106,23 @@ enum ANASTASIS_UploadStatus
* Account expired or payment was explicitly requested
* by the client.
*/
- ANASTASIS_US_PAYMENT_REQUIRED = 1,
-
- /**
- * Conflicting backup existed on server. Client should
- * reconcile and try again with (using the provided
- * recovered backup as the previous backup).
- */
- ANASTASIS_US_CONFLICTING_POLICY = 2,
+ ANASTASIS_US_PAYMENT_REQUIRED,
/**
* HTTP interaction failed, see HTTP status.
*/
- ANASTASIS_US_HTTP_ERROR = 3,
+ ANASTASIS_US_HTTP_ERROR,
/**
* We had an internal error (not sure this can happen,
* but reserved for HTTP 400 status codes).
*/
- ANASTASIS_US_CLIENT_ERROR = 4,
+ ANASTASIS_US_CLIENT_ERROR,
/**
* Server had an internal error.
*/
- ANASTASIS_US_SERVER_ERROR = 5,
+ ANASTASIS_US_SERVER_ERROR,
/**
* Truth already exists
@@ -205,7 +198,7 @@ struct ANASTASIS_UploadDetails
/**
* Previous backup. Returned if @e us is
- * #ANASTASIS_US_CONFLICTING_BACKUP
+ * #ANASTASIS_US_CONFLICTING_POLICY
*/
struct
{
@@ -401,12 +394,10 @@ struct ANASTASIS_PolicyStoreOperation;
*
* @param cls closure
* @param http_status HTTP status code for this request
- * @param ec anastasis-specific error code
* @param obj the decoded response body
*/
typedef void
(*ANASTASIS_PolicyStoreCallback) (void *cls,
- enum ANASTASIS_ErrorCode ec,
unsigned int http_status,
const struct ANASTASIS_UploadDetails *up);
@@ -417,7 +408,6 @@ typedef void
* @param ctx the CURL context used to connect to the backend
* @param backend_url backend's base URL, including final "/"
* @param anastasis_priv private key of the user's account
- * @param prev_recovery_data_hash hash of the previous policy update, NULL for
the first upload ever
* @param recovery_data policy data to be stored
* @param recovery_data_size number of bytes in @a recovery_data
* @param payment_requested true if the client wants to pay more for the
account now
@@ -431,10 +421,9 @@ ANASTASIS_policy_store (
struct GNUNET_CURL_Context *ctx,
const char *backend_url,
const struct ANASTASIS_CRYPTO_AccountPrivateKeyP *anastasis_priv,
- const struct GNUNET_HashCode *prev_recovery_data_hash,
const void *recovery_data,
size_t recovery_data_size,
- int payment_requested,
+ bool payment_requested,
const struct ANASTASIS_PaymentSecretP *payment_secret,
ANASTASIS_PolicyStoreCallback cb,
void *cb_cls);
@@ -500,7 +489,6 @@ ANASTASIS_challenge_run (
const struct ANASTASIS_CRYPTO_TruthPublicKeyP *truth_public_key,
const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key,
const struct ANASTASIS_PaymentSecretP *payment_secret,
- bool payment_requested,
ANASTASIS_ChallengeRunCallback cb,
void *cb_cls);
@@ -533,7 +521,6 @@ typedef void
* @param backend_url base URL of the merchant backend
* @param truth_public_key identification of the Truth
* @param truth_key Key used to Decrypt the Truth on the Server
- * @param payment_request checks if payment was requested
* @param payment_secret secret from the previously done payment NULL to
trigger payment
* @param answer Answer for the different authentication methods(code, hash)
* @param answer_length size of the answer
@@ -542,17 +529,16 @@ typedef void
* @return handle for this operation, NULL upon errors
*/
struct ANASTASIS_KeyShareLookupOperation *
-ANASTASIS_keyshare_lookup (struct GNUNET_CURL_Context *ctx,
- const char *backend_url,
- const struct
- ANASTASIS_CRYPTO_TruthPublicKeyP *truth_public_key,
- const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key,
- int payment_requested,
- const struct
- ANASTASIS_PaymentSecretP *payment_secret,
- const char *answer,
- ANASTASIS_KeyShareLookupCallback cb,
- void *cb_cls);
+ANASTASIS_keyshare_lookup (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const struct ANASTASIS_CRYPTO_TruthPublicKeyP *truth_public_key,
+ const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key,
+ const struct ANASTASIS_PaymentSecretP *payment_secret,
+ const char *answer,
+ ANASTASIS_KeyShareLookupCallback cb,
+ void *cb_cls);
+
/**
* Cancel a GET /truth request.
@@ -636,6 +622,7 @@ typedef void
const char *policy,
const struct TALER_Amount *cost);
+
/**
* Does an EscrowProviderInspection GET /terms
* Receives an EscrowProviderInformation Callback
@@ -649,6 +636,7 @@ ANASTASIS_escrow_provider_inspect (const char *base_url,
ANASTASIS_EscrowProviderInformation cb,
void *cb_cls);
+
/**
* Cancels an EscrowProviderInspection
* @param epi reference to the request
diff --git a/src/include/anastasis_testing_lib.h
b/src/include/anastasis_testing_lib.h
index 11823a4..68104f5 100644
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@ -307,8 +307,6 @@ enum ANASTASIS_TESTING_PolicyStoreOption
* the policy store request.
* @param prev_upload reference to a previous upload we are
* supposed to update, NULL for none
- * @param last_upload reference to the last upload for the
- * same account, used to check result on MHD_HTTP_CONFLICT
* @param http_status expected HTTP status.
* @param pso policy store options
* @param recovery_data recovery data to post
@@ -316,15 +314,14 @@ enum ANASTASIS_TESTING_PolicyStoreOption
* @return the command
*/
struct TALER_TESTING_Command
-ANASTASIS_TESTING_cmd_policy_store (const char *label,
- const char *anastasis_url,
- const char *prev_upload,
- const char *last_upload,
- unsigned int http_status,
- enum
- ANASTASIS_TESTING_PolicyStoreOption pso,
- const void *recovery_data,
- size_t recovery_data_size);
+ANASTASIS_TESTING_cmd_policy_store (
+ const char *label,
+ const char *anastasis_url,
+ const char *prev_upload,
+ unsigned int http_status,
+ enum ANASTASIS_TESTING_PolicyStoreOption pso,
+ const void *recovery_data,
+ size_t recovery_data_size);
/**
* Make the "policy lookup" command.
@@ -440,16 +437,15 @@ ANASTASIS_TESTING_cmd_truth_store (const char *label,
* @return the command
*/
struct TALER_TESTING_Command
-ANASTASIS_TESTING_cmd_keyshare_lookup (const char *label,
- const char *anastasis_url,
- unsigned int http_status,
- char *answer,
- const struct
- ANASTASIS_CRYPTO_TruthKeyP key,
- const char *payment_ref,
- int payment_requested,
- const char *upload_ref,
- int lookup_mode);
+ANASTASIS_TESTING_cmd_keyshare_lookup (
+ const char *label,
+ const char *anastasis_url,
+ unsigned int http_status,
+ char *answer,
+ const struct ANASTASIS_CRYPTO_TruthKeyP key,
+ const char *payment_ref,
+ const char *upload_ref,
+ int lookup_mode);
/**
* Make the "challenge run" command.
diff --git a/src/lib/anastasis_backup.c b/src/lib/anastasis_backup.c
index 5f08a5d..e050e4c 100644
--- a/src/lib/anastasis_backup.c
+++ b/src/lib/anastasis_backup.c
@@ -474,19 +474,26 @@ struct PolicyStoreState
const char *anastasis_url;
/**
- * reference to SecretShare
+ * Payment request returned by this provider, if any.
*/
- struct ANASTASIS_SecretShare *ss;
+ char *payment_request;
/**
- * Callback which gives back the payment details
+ * reference to SecretShare
*/
- ANASTASIS_SharePaymentCallback spc;
+ struct ANASTASIS_SecretShare *ss;
+};
+
+/**
+* Defines a recovery document upload process (recovery document consists of
multiple policies)
+*/
+struct ANASTASIS_SecretShare
+{
/**
- * Closure for the payment callback
+ * Closure for the Result Callback
*/
- void *spc_cls;
+ struct GNUNET_CURL_Context *ctx;
/**
* Callback which gives back the result of the POST Request
@@ -498,28 +505,6 @@ struct PolicyStoreState
*/
void *src_cls;
- /**
- * Expected HTTP status code, usually #MHD_HTTP_NO_CONTENT.
- */
- unsigned int http_status;
-
- /**
- * Status of the transaction
- */
- enum ANASTASIS_ErrorCode ec;
-
-};
-
-/**
-* Defines a recovery document upload process (recovery document consists of
multiple policies)
-*/
-struct ANASTASIS_SecretShare
-{
- /**
- * Closure for the Result Callback
- */
- struct GNUNET_CURL_Context *ctx;
-
/**
* References for the upload states and operations (size of truths passed)
*/
@@ -542,103 +527,86 @@ struct ANASTASIS_SecretShare
*/
static void
policy_store_cb (void *cls,
- enum ANASTASIS_ErrorCode ec,
unsigned int http_status,
const struct ANASTASIS_UploadDetails *ud)
{
struct PolicyStoreState *pss = cls;
+ struct ANASTASIS_SecretShare *ss = pss->ss;
+ enum ANASTASIS_UploadStatus us;
pss->pso = NULL;
- pss->ec = ec;
- if ((http_status != pss->http_status) &&
- (http_status != MHD_HTTP_PAYMENT_REQUIRED))
+ if (NULL == ud)
+ us = ANASTASIS_US_HTTP_ERROR;
+ else
+ us = ud->us;
+ if ( (ANASTASIS_US_SUCCESS == us) &&
+ (0 != GNUNET_memcmp (&pss->curr_hash,
+ ud->details.curr_backup_hash)) )
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u/%d in %s:%u\n",
- http_status,
- (int) ec,
- __FILE__,
- __LINE__);
-
- if (NULL != pss->src)
+ GNUNET_break_op (0);
+ us = ANASTASIS_US_SERVER_ERROR;
+ }
+ switch (us)
+ {
+ case ANASTASIS_US_SUCCESS:
+ break;
+ case ANASTASIS_US_PAYMENT_REQUIRED:
+ pss->payment_request = GNUNET_strdup (ud->details.payment_request);
+ break;
+ case ANASTASIS_US_HTTP_ERROR:
+ case ANASTASIS_US_CLIENT_ERROR:
+ case ANASTASIS_US_SERVER_ERROR:
{
- pss->src (pss->src_cls,
- &pss->curr_hash,
- pss->anastasis_url,
- ec,
- http_status);
- pss->src = NULL;
+ struct ANASTASIS_ShareResult sr = {
+ .ss = ANASTASIS_SHARE_STATUS_PROVIDER_FAILED,
+ .details.provider_failure.provider_url = pss->anastasis_url,
+ .details.provider_failure.http_status = http_status,
+ .details.provider_failure.ec = us,
+ };
+
+ ss->src (ss->src_cls,
+ &sr);
+ ANASTASIS_secret_share_cancel (ss);
+ return;
}
- return;
+ case ANASTASIS_US_CONFLICTING_TRUTH:
+ GNUNET_break (0);
+ break;
}
- if (NULL != ud)
+ for (unsigned int i = 0; i<ss->pss_length; i++)
+ if (NULL != ss->pss[i].pso)
+ /* some upload is still pending, let's wait for it to finish */
+ return;
+
{
- switch (ud->us)
+ unsigned int pr_cnt = 0;
+ for (unsigned int i = 0; i<ss->pss_length; i++)
+ if (NULL != ss->pss[i].payment_request)
+ pr_cnt++;
{
- case ANASTASIS_US_SUCCESS:
- if (0 != GNUNET_memcmp (&pss->curr_hash,
- ud->details.curr_backup_hash))
- {
- GNUNET_break (0);
- return;
- }
- break;
- case ANASTASIS_US_PAYMENT_REQUIRED:
- {
- struct TALER_MERCHANT_PayUriData pd;
+ struct ANASTASIS_SharePaymentRequest spr[GNUNET_NZL (pr_cnt)];
+ unsigned int off = 0;
+ struct ANASTASIS_ShareResult sr;
- if (GNUNET_OK !=
- TALER_MERCHANT_parse_pay_uri (ud->details.payment_request,
- &pd))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Did not find `%s' in `%s'\n",
- "/-/-/",
- ud->details.payment_request);
- GNUNET_break (0);
- return;
- }
- TALER_MERCHANT_parse_pay_uri_free (&pd);
- memset (&pss->curr_hash,
- 0,
- sizeof (struct GNUNET_HashCode));
- if (NULL != pss->spc)
+ for (unsigned int i = 0; i<ss->pss_length; i++)
+ if (NULL != ss->pss[i].payment_request)
{
- pss->spc (pss->spc_cls,
- ud->details.payment_request,
- pss->anastasis_url,
- ec);
- pss->spc = NULL;
- return;
+ spr[off].payment_request_url = pss[i].payment_request;
+ spr[off].provider_url = pss[i].anastasis_url;
+ off++;
}
+ sr.ss = ANASTASIS_SHARE_STATUS_SUCCESS;
+ if (off > 0)
+ {
+ sr.ss = ANASTASIS_SHARE_STATUS_PAYMENT_REQUIRED;
+ sr.details.payment_required.payment_requests = spr;
+ sr.details.payment_required.payment_requests_length = pr_cnt;
}
- case ANASTASIS_US_CONFLICTING_POLICY:
- GNUNET_break (0);
- return;
- case ANASTASIS_US_HTTP_ERROR:
- break;
- case ANASTASIS_US_CLIENT_ERROR:
- GNUNET_break (0);
- return;
- case ANASTASIS_US_SERVER_ERROR:
- GNUNET_break (0);
- return;
- default:
- GNUNET_break (0);
- return;
- }
- if (NULL != pss->src)
- {
- pss->src (pss->src_cls,
- &pss->curr_hash,
- pss->anastasis_url,
- ec,
- http_status);
- pss->src = NULL;
- return;
+ ss->src (ss->src_cls,
+ &sr);
}
}
- GNUNET_break (0);
+ ANASTASIS_secret_share_cancel (ss);
}
@@ -687,14 +655,11 @@ get_num_urls (const struct ANASTASIS_Policy *policies[],
struct ANASTASIS_SecretShare *
ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
const json_t *id_data,
- const struct GNUNET_HashCode *last_etag,
const struct ANASTASIS_Policy *policies[],
unsigned int policies_len,
const struct ANASTASIS_PaymentDetails *pds,
unsigned int pds_len,
bool payment_requested,
- ANASTASIS_SharePaymentCallback spc,
- void *spc_cls,
ANASTASIS_ShareResultCallback src,
void *src_cls,
const void *core_secret,
@@ -718,22 +683,12 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
return NULL;
}
ss = GNUNET_new (struct ANASTASIS_SecretShare);
+ ss->src = src;
+ ss->src_cls = src_cls;
ss->pss = GNUNET_new_array (pss_length,
struct PolicyStoreState);
- for (unsigned int i = 0; i < pss_length; i++)
- {
- struct PolicyStoreState *pss = &ss->pss[i];
-
- pss->ss = ss;
- pss->http_status = MHD_HTTP_NO_CONTENT;
- pss->spc = spc;
- pss->spc_cls = spc_cls;
- pss->src = src;
- pss->src_cls = src_cls;
- }
ss->pss_length = pss_length;
ss->ctx = ctx;
-
{
struct ANASTASIS_CRYPTO_PolicyKeyP policy_keys[GNUNET_NZL (policies_len)];
@@ -926,6 +881,7 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
size_t recovery_data_size;
struct ANASTASIS_CRYPTO_AccountPrivateKeyP anastasis_priv;
+ pss->ss = ss;
ANASTASIS_CRYPTO_user_identifier_derive (id_data,
pss->server_salt,
&pss->id);
@@ -943,7 +899,6 @@ ANASTASIS_secret_share (struct GNUNET_CURL_Context *ctx,
ss->ctx,
pss->anastasis_url,
&anastasis_priv,
- last_etag,
recovery_data,
recovery_data_size,
payment_requested,
@@ -976,6 +931,7 @@ ANASTASIS_secret_share_cancel (struct ANASTASIS_SecretShare
*ss)
ANASTASIS_policy_store_cancel (ss->pss[i].pso);
ss->pss[i].pso = NULL;
}
+ GNUNET_free (ss->pss[i].payment_request);
}
GNUNET_free (ss->pss);
GNUNET_free (ss);
diff --git a/src/lib/anastasis_recovery.c b/src/lib/anastasis_recovery.c
index 73cf85d..a21e3c5 100644
--- a/src/lib/anastasis_recovery.c
+++ b/src/lib/anastasis_recovery.c
@@ -275,7 +275,6 @@ struct ANASTASIS_Challenge
*/
const char *payment_order_req;
- bool payment_requested;
};
@@ -483,7 +482,6 @@ ANASTASIS_challenge_answer (struct GNUNET_CURL_Context *ctx,
c->url,
&c->truth_public_key,
&c->truth_key,
- c->payment_requested,
&c->payment_secret,
str,
&keyshare_lookup_cb,
@@ -501,7 +499,6 @@ ANASTASIS_challenge_answer (struct GNUNET_CURL_Context *ctx,
c->url,
&c->truth_public_key,
&c->truth_key,
- c->payment_requested,
&c->payment_secret,
answer_str,
&keyshare_lookup_cb,
@@ -656,7 +653,6 @@ ANASTASIS_challenge_start (struct GNUNET_CURL_Context *ctx,
c->csc_cls = csc_cls;
c->cpc = cpc;
c->cpc_cls = cpc_cls;
- c->payment_requested = false;
if (c->payment_order_id != NULL)
{
@@ -665,17 +661,15 @@ ANASTASIS_challenge_start (struct GNUNET_CURL_Context
*ctx,
&c->payment_secret,
sizeof (struct
ANASTASIS_PaymentSecretP));
- c->payment_requested = true;
}
c->cro = ANASTASIS_challenge_run (c->ctx,
c->url,
&c->truth_public_key,
&c->truth_key,
- c->payment_requested
- ? &c->payment_secret
- : NULL,
- c->payment_requested,
+ GNUNET_is_zero (&c->payment_secret)
+ ? NULL
+ : &c->payment_secret,
&challenge_run_cb,
c);
if (NULL == c->cro)
diff --git a/src/reducer/anastasis_api_backup_redux.c
b/src/reducer/anastasis_api_backup_redux.c
index 3f017b3..7cdf202 100644
--- a/src/reducer/anastasis_api_backup_redux.c
+++ b/src/reducer/anastasis_api_backup_redux.c
@@ -1412,6 +1412,7 @@ initialize_policies (json_t *state,
}
+#if 0
/**
* Function called for payment routine for secret sharing.
*
@@ -1426,17 +1427,9 @@ secret_share_payment_cb (void *cls,
const char *server_url,
enum TALER_ErrorCode ec)
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "At %s:%d we are in SPC\n",
- __FILE__, __LINE__);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "At %s:%d the taler pay url is %s\n",
- __FILE__, __LINE__,
- taler_pay_url);
-
+ struct SecretShareState *sss = cls;
const char *upload_key;
json_t *upload_value;
- struct SecretShareState *sss = cls;
json_t *rec_doc_uploads = json_object_get (sss->state,
"recovery_document_uploads");
@@ -1469,22 +1462,11 @@ secret_share_payment_cb (void *cls,
TALER_MERCHANT_parse_pay_uri (taler_pay_url,
&pd))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Did not find `%s' in `%s'\n",
- "/-/-/",
- taler_pay_url);
GNUNET_break (0);
return;
}
sss->payment_order_id = GNUNET_strdup (pd.order_id);
TALER_MERCHANT_parse_pay_uri_free (&pd);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Order ID from Anastasis service is `%s'\n",
- sss->payment_order_id);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "At %s:%d Order ID from Anastasis service is %s\n",
- __FILE__, __LINE__,
- sss->payment_order_id);
set_state (sss->state,
ANASTASIS_backup_state_to_string (
ANASTASIS_BACKUP_STATE_POLICIES_PAYING));
@@ -1499,35 +1481,31 @@ secret_share_payment_cb (void *cls,
}
+#endif
+
+
/**
- * Function called with the results of a #secret_share().
+ * Function called with the results of an #ANASTASIS_secret_share().
*
* @param cls closure
- * @param @param current_etag sends back the etag of the upload (used to
prevent redundant uploads)
- * @param server_url url of the server to pay for
- * @param ec status code of the request
- * @param http_status http status code
+ * @param sr result of the operation
*/
static void
secret_share_result_cb (void *cls,
- const struct GNUNET_HashCode *current_etag,
- const char *server_url,
- const enum TALER_ErrorCode ec,
- unsigned int http_status)
+ const struct ANASTASIS_ShareResult *sr)
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "At %s:%d we are in SRC\n",
- __FILE__, __LINE__);
-
- const char *upload_key;
- json_t *upload_value;
struct SecretShareState *sss = cls;
json_t *rec_doc_uploads = json_object_get (sss->state,
"recovery_document_uploads");
sss->sso = NULL;
GNUNET_assert (json_is_object (rec_doc_uploads));
- json_object_foreach (rec_doc_uploads, upload_key, upload_value)
+#if 0
+ const char *upload_key;
+ json_t *upload_value;
+ json_object_foreach (rec_doc_uploads,
+ upload_key,
+ upload_value)
{
const char *url = json_string_value (
json_object_get (upload_value,
@@ -1544,16 +1522,6 @@ secret_share_result_cb (void *cls,
if (NULL != sss)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d etag is %s-%llu b\n", __FILE__, __LINE__,
- TALER_B2S (¤t_etag),
- (unsigned long long) sizeof (struct GNUNET_HashCode));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d error code is %d\n", __FILE__, __LINE__,
- ec);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d http status is %u\n", __FILE__, __LINE__,
- http_status);
if (http_status == sss->http_status)
{
if (check_uploads (rec_doc_uploads, true))
@@ -1587,6 +1555,7 @@ secret_share_result_cb (void *cls,
sss->cb = NULL;
return;
}
+#endif
GNUNET_break (0);
}
@@ -1683,21 +1652,15 @@ upload_rec_documents (json_t *state,
// FIXME: implement PaymentDetails
sss->sso = ANASTASIS_secret_share (ctx,
sss->id_data,
- NULL,
policy_arr,
policy_arr_length,
- (pds_len > 0)
- ? pds
- : NULL,
+ pds,
pds_len,
false, /* do not insist on payment */
- &secret_share_payment_cb,
- sss,
&secret_share_result_cb,
sss,
sss->core_secret,
sss->core_secret_size);
-
if (NULL == sss->sso)
{
GNUNET_break (0);
diff --git a/src/restclient/anastasis_api_challenge_run.c
b/src/restclient/anastasis_api_challenge_run.c
index fb6a589..f918404 100644
--- a/src/restclient/anastasis_api_challenge_run.c
+++ b/src/restclient/anastasis_api_challenge_run.c
@@ -241,7 +241,6 @@ ANASTASIS_challenge_run (
const struct ANASTASIS_CRYPTO_TruthPublicKeyP *truth_public_key,
const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key,
const struct ANASTASIS_PaymentSecretP *payment_secret,
- bool payment_requested,
ANASTASIS_ChallengeRunCallback cb,
void *cb_cls)
{
@@ -315,15 +314,9 @@ ANASTASIS_challenge_run (
pub_key_str);
GNUNET_free (pub_key_str);
}
- cro->url = (GNUNET_YES == payment_requested)
- ? TALER_url_join (backend_url,
- path,
- "pay",
- "y",
- NULL)
- : TALER_url_join (backend_url,
- path,
- NULL);
+ cro->url = TALER_url_join (backend_url,
+ path,
+ NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Url get request (challenge run): %s\n",
diff --git a/src/restclient/anastasis_api_keyshare_lookup.c
b/src/restclient/anastasis_api_keyshare_lookup.c
index f14d51f..23e5e1f 100644
--- a/src/restclient/anastasis_api_keyshare_lookup.c
+++ b/src/restclient/anastasis_api_keyshare_lookup.c
@@ -224,17 +224,15 @@ handle_header (char *buffer,
struct ANASTASIS_KeyShareLookupOperation *
-ANASTASIS_keyshare_lookup (struct GNUNET_CURL_Context *ctx,
- const char *backend_url,
- const struct
- ANASTASIS_CRYPTO_TruthPublicKeyP *truth_public_key,
- const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key,
- int payment_requested,
- const struct
- ANASTASIS_PaymentSecretP *payment_secret,
- const char *answer,
- ANASTASIS_KeyShareLookupCallback cb,
- void *cb_cls)
+ANASTASIS_keyshare_lookup (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const struct ANASTASIS_CRYPTO_TruthPublicKeyP *truth_public_key,
+ const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key,
+ const struct ANASTASIS_PaymentSecretP *payment_secret,
+ const char *answer,
+ ANASTASIS_KeyShareLookupCallback cb,
+ void *cb_cls)
{
struct ANASTASIS_KeyShareLookupOperation *kslo;
CURL *eh;
diff --git a/src/restclient/anastasis_api_policy_store.c
b/src/restclient/anastasis_api_policy_store.c
index cac5b82..c9cf8a2 100644
--- a/src/restclient/anastasis_api_policy_store.c
+++ b/src/restclient/anastasis_api_policy_store.c
@@ -107,7 +107,6 @@ handle_policy_store_finished (void *cls,
size_t data_size)
{
struct ANASTASIS_PolicyStoreOperation *pso = cls;
- enum TALER_ErrorCode ec = TALER_EC_INVALID;
struct ANASTASIS_UploadDetails ud;
struct ANASTASIS_UploadDetails *udp;
@@ -123,63 +122,33 @@ handle_policy_store_finished (void *cls,
ud.us = ANASTASIS_US_SUCCESS;
ud.details.curr_backup_hash = &pso->new_upload_hash;
udp = &ud;
- ec = TALER_EC_NONE;
break;
case MHD_HTTP_NOT_MODIFIED:
ud.us = ANASTASIS_US_SUCCESS;
ud.details.curr_backup_hash = &pso->new_upload_hash;
udp = &ud;
- ec = TALER_EC_NONE;
break;
case MHD_HTTP_BAD_REQUEST:
GNUNET_break (0);
- ec = TALER_JSON_get_error_code2 (data,
- data_size);
+ ud.us = ANASTASIS_US_CLIENT_ERROR;
break;
case MHD_HTTP_PAYMENT_REQUIRED:
ud.us = ANASTASIS_US_PAYMENT_REQUIRED;
ud.details.payment_request = pso->pay_uri;
udp = &ud;
- ec = TALER_EC_NONE;
- break;
- case MHD_HTTP_FORBIDDEN:
- GNUNET_break (0);
- ec = TALER_JSON_get_error_code2 (data,
- data_size);
- break;
- case MHD_HTTP_CONFLICT:
- ud.us = ANASTASIS_US_CONFLICTING_POLICY;
- GNUNET_CRYPTO_hash (data,
- data_size,
- &ud.details.recovered_backup.existing_backup_hash);
- ud.details.recovered_backup.existing_backup_size
- = data_size;
- ud.details.recovered_backup.existing_backup
- = data;
- udp = &ud;
- ec = TALER_EC_NONE;
- break;
- case MHD_HTTP_GONE:
- ec = TALER_JSON_get_error_code2 (data,
- data_size);
break;
case MHD_HTTP_LENGTH_REQUIRED:
GNUNET_break (0);
break;
- case MHD_HTTP_REQUEST_ENTITY_TOO_LARGE:
- ec = TALER_JSON_get_error_code2 (data,
- data_size);
- break;
- case MHD_HTTP_TOO_MANY_REQUESTS:
- ec = TALER_JSON_get_error_code2 (data,
- data_size);
- break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Internal server error: `%.*s\n",
(int) data_size,
(const char *) data);
break;
+ default:
+ ud.us = ANASTASIS_US_SERVER_ERROR;
+ break;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"At %s:%d Response code is: %i\n",
@@ -189,7 +158,6 @@ handle_policy_store_finished (void *cls,
if (NULL != pso->cb)
{
pso->cb (pso->cb_cls,
- ec,
response_code,
udp);
pso->cb = NULL;
@@ -262,18 +230,16 @@ handle_header (char *buffer,
struct ANASTASIS_PolicyStoreOperation *
-ANASTASIS_policy_store (struct GNUNET_CURL_Context *ctx,
- const char *backend_url,
- const struct
- ANASTASIS_CRYPTO_AccountPrivateKeyP *anastasis_priv,
- const struct
- GNUNET_HashCode *prev_recovery_data_hash,
- const void *recovery_data,
- size_t recovery_data_size,
- int payment_requested,
- const struct ANASTASIS_PaymentSecretP *payment_secret,
- ANASTASIS_PolicyStoreCallback cb,
- void *cb_cls)
+ANASTASIS_policy_store (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const struct ANASTASIS_CRYPTO_AccountPrivateKeyP *anastasis_priv,
+ const void *recovery_data,
+ size_t recovery_data_size,
+ bool payment_requested,
+ const struct ANASTASIS_PaymentSecretP *payment_secret,
+ ANASTASIS_PolicyStoreCallback cb,
+ void *cb_cls)
{
struct ANASTASIS_PolicyStoreOperation *pso;
struct ANASTASIS_AccountSignatureP account_sig;
@@ -334,28 +300,6 @@ ANASTASIS_policy_store (struct GNUNET_CURL_Context *ctx,
}
job_headers = ext;
- /* Setup If-Match header */
- if (NULL != prev_recovery_data_hash)
- {
- val = GNUNET_STRINGS_data_to_string_alloc (prev_recovery_data_hash,
- sizeof (struct
- GNUNET_HashCode));
- GNUNET_asprintf (&hdr,
- "%s: %s",
- MHD_HTTP_HEADER_IF_MATCH,
- val);
- GNUNET_free (val);
- ext = curl_slist_append (job_headers,
- hdr);
- GNUNET_free (hdr);
- if (NULL == ext)
- {
- GNUNET_break (0);
- curl_slist_free_all (job_headers);
- return NULL;
- }
- job_headers = ext;
- }
/* Setup Payment-Identifier header */
if (NULL != payment_secret)
{
diff --git a/src/testing/testing_api_cmd_challenge_run.c
b/src/testing/testing_api_cmd_challenge_run.c
index 50e0e86..a9fcf7b 100644
--- a/src/testing/testing_api_cmd_challenge_run.c
+++ b/src/testing/testing_api_cmd_challenge_run.c
@@ -90,10 +90,7 @@ struct ChallengeRunState
* Reference to payment command we expect to lookup.
*/
const char *payment_ref;
- /**
- * True if @e payment_order_req is initialized.
- */
- bool payment_order_set;
+
/**
* code we read in the file generated by the plugin
*/
@@ -245,7 +242,7 @@ challenge_run (void *cls,
struct TALER_TESTING_Interpreter *is)
{
struct ChallengeRunState *crs = cls;
- crs->payment_order_set = false;
+
crs->is = is;
if (NULL != crs->upload_reference)
{
@@ -285,6 +282,7 @@ challenge_run (void *cls,
if (NULL != crs->payment_ref)
{
const struct TALER_TESTING_Command *payment_cmd;
+
payment_cmd = TALER_TESTING_interpreter_lookup_command
(is,
crs->payment_ref);
@@ -317,7 +315,6 @@ challenge_run (void *cls,
TALER_TESTING_interpreter_fail (crs->is);
return;
}
- crs->payment_order_set = true;
}
char *pub_key_str;
@@ -332,10 +329,9 @@ challenge_run (void *cls,
crs->anastasis_url,
crs->truth_public_key,
&crs->truth_key,
- crs->payment_order_set
+ (NULL != crs->payment_ref)
? &crs->payment_order_req
: NULL,
- crs->payment_order_set,
&challenge_run_cb,
crs);
if (NULL == crs->cro)
diff --git a/src/testing/testing_api_cmd_keyshare_lookup.c
b/src/testing/testing_api_cmd_keyshare_lookup.c
index c243825..4c20bc1 100644
--- a/src/testing/testing_api_cmd_keyshare_lookup.c
+++ b/src/testing/testing_api_cmd_keyshare_lookup.c
@@ -86,11 +86,6 @@ struct KeyShareLookupState
*/
struct ANASTASIS_PaymentSecretP payment_secret;
- /**
- * if payment is needed or free
- */
- int payment_requested;
-
};
static void
@@ -194,7 +189,7 @@ keyshare_lookup_run (void *cls,
}
}
- if (ksls->payment_requested == 1)
+ if (NULL != ksls->payment_reference)
{
const char *order_id;
const struct TALER_TESTING_Command *payment_cmd;
@@ -202,7 +197,6 @@ keyshare_lookup_run (void *cls,
payment_cmd = TALER_TESTING_interpreter_lookup_command
(is,
ksls->payment_reference);
-
if (GNUNET_OK !=
TALER_TESTING_get_trait_order_id (payment_cmd,
0,
@@ -224,13 +218,12 @@ keyshare_lookup_run (void *cls,
TALER_TESTING_interpreter_fail (ksls->is);
return;
}
-
}
+
ksls->kslo = ANASTASIS_keyshare_lookup (is->ctx,
ksls->anastasis_url,
ksls->truth_public_key,
&ksls->truth_key,
- ksls->payment_requested,
&ksls->payment_secret,
ksls->answer,
&keyshare_lookup_cb,
@@ -285,7 +278,6 @@ ANASTASIS_TESTING_cmd_keyshare_lookup (const char *label,
const struct
ANASTASIS_CRYPTO_TruthKeyP key,
const char *payment_ref,
- int payment_requested,
const char *upload_ref,
int lookup_mode)
{
@@ -304,7 +296,6 @@ ANASTASIS_TESTING_cmd_keyshare_lookup (const char *label,
ksls->anastasis_url = anastasis_url;
ksls->upload_reference = upload_ref;
ksls->payment_reference = payment_ref;
- ksls->payment_requested = payment_requested;
ksls->answer = answer;
ksls->truth_key = key;
ksls->lookup_mode = lookup_mode;
diff --git a/src/testing/testing_api_cmd_policy_store.c
b/src/testing/testing_api_cmd_policy_store.c
index 3934662..e805d5c 100644
--- a/src/testing/testing_api_cmd_policy_store.c
+++ b/src/testing/testing_api_cmd_policy_store.c
@@ -110,12 +110,6 @@ struct PolicyStoreState
*/
const char *prev_upload;
- /**
- * Last upload, or NULL for none, usually same as @e prev_upload.
- * Used to check the response on #MHD_HTTP_CONFLICT.
- */
- const char *last_upload;
-
/**
* Payment order ID we got back, if any. Otherwise NULL.
*/
@@ -141,13 +135,11 @@ struct PolicyStoreState
* Function called with the results of a #policy_store().
*
* @param cls closure
- * @param ec Taler error code
* @param http_status HTTP status of the request
* @param ud details about the upload operation
*/
static void
policy_store_cb (void *cls,
- enum ANASTASIS_ErrorCode ec,
unsigned int http_status,
const struct ANASTASIS_UploadDetails *ud)
{
@@ -156,9 +148,8 @@ policy_store_cb (void *cls,
if (http_status != pss->http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u/%d to command %s in %s:%u\n",
+ "Unexpected response code %u to command %s in %s:%u\n",
http_status,
- (int) ec,
pss->is->commands[pss->is->ip].label,
__FILE__,
__LINE__);
@@ -200,28 +191,6 @@ policy_store_cb (void *cls,
sizeof (struct GNUNET_HashCode));
}
break;
- case ANASTASIS_US_CONFLICTING_POLICY:
- {
- const struct TALER_TESTING_Command *ref;
- const struct GNUNET_HashCode *h;
-
- ref = TALER_TESTING_interpreter_lookup_command
- (pss->is,
- pss->last_upload);
- GNUNET_assert (NULL != ref);
- GNUNET_assert (GNUNET_OK ==
- ANASTASIS_TESTING_get_trait_hash (ref,
-
ANASTASIS_TESTING_TRAIT_HASH_CURRENT,
- &h));
- if (0 != GNUNET_memcmp (h,
- &ud->details.recovered_backup.
- existing_backup_hash))
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (pss->is);
- return;
- }
- }
case ANASTASIS_US_HTTP_ERROR:
break;
case ANASTASIS_US_CLIENT_ERROR:
@@ -357,14 +326,6 @@ policy_store_run (void *cls,
pss->pso = ANASTASIS_policy_store (is->ctx,
pss->anastasis_url,
&pss->anastasis_priv,
- ( ( (NULL != pss->prev_upload) &&
- (GNUNET_NO == GNUNET_is_zero (
- &pss->prev_hash)) ) ||
- (0 !=
- (ANASTASIS_TESTING_PSO_PREV_HASH_WRONG
- & pss->psopt)) )
- ? &pss->prev_hash
- : NULL,
pss->recovery_data,
pss->recovery_data_size,
(0 !=
@@ -457,8 +418,6 @@ policy_store_traits (void *cls,
* the policy store request.
* @param prev_upload reference to a previous upload we are
* supposed to update, NULL for none
- * @param last_upload reference to the last upload for the
- * same account, used to check result on MHD_HTTP_CONFLICT
* @param http_status expected HTTP status.
* @param pso policy store options
* @param recovery_data recovery data to post
@@ -466,15 +425,14 @@ policy_store_traits (void *cls,
* @return the command
*/
struct TALER_TESTING_Command
-ANASTASIS_TESTING_cmd_policy_store (const char *label,
- const char *anastasis_url,
- const char *prev_upload,
- const char *last_upload,
- unsigned int http_status,
- enum
- ANASTASIS_TESTING_PolicyStoreOption pso,
- const void *recovery_data,
- size_t recovery_data_size)
+ANASTASIS_TESTING_cmd_policy_store (
+ const char *label,
+ const char *anastasis_url,
+ const char *prev_upload,
+ unsigned int http_status,
+ enum ANASTASIS_TESTING_PolicyStoreOption pso,
+ const void *recovery_data,
+ size_t recovery_data_size)
{
struct PolicyStoreState *pss;
@@ -485,7 +443,6 @@ ANASTASIS_TESTING_cmd_policy_store (const char *label,
pss->psopt = pso;
pss->anastasis_url = anastasis_url;
pss->prev_upload = prev_upload;
- pss->last_upload = last_upload;
{
struct TALER_TESTING_Command cmd = {
.cls = pss,
diff --git a/src/testing/testing_cmd_secret_share.c
b/src/testing/testing_cmd_secret_share.c
index 3259aa0..5a9b5dc 100644
--- a/src/testing/testing_cmd_secret_share.c
+++ b/src/testing/testing_cmd_secret_share.c
@@ -81,7 +81,7 @@ struct SecretShareState
/**
* Expected status code.
*/
- unsigned int http_status;
+ enum ANASTASIS_ShareStatus want_status;
/**
* The /truth GET operation handle.
@@ -116,112 +116,60 @@ struct SecretShareState
/**
- * Function called for payment routine.
+ * Function called with the results of a #ANASTASIS_secret_share().
*
* @param cls closure
- * @param taler_pay_url url for the payment (taler://pay/Foo)
- * @param server_url url of the server to pay for
- * @param ec status of the request
+ * @param sr result from the operation
*/
static void
-secret_share_payment_cb (void *cls,
- const char *taler_pay_url,
- const char *server_url,
- enum TALER_ErrorCode ec)
+secret_share_result_cb (void *cls,
+ const struct ANASTASIS_ShareResult *sr)
{
struct SecretShareState *sss = cls;
- sss->sso = NULL;
+ sss->sso = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "At %s:%d we are in SPC\n",
+ "At %s:%d we are in SRC\n",
__FILE__, __LINE__);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "At %s:%d the taler pay url is %s\n",
- __FILE__, __LINE__,
- taler_pay_url);
- if (sss->http_status != MHD_HTTP_PAYMENT_REQUIRED)
+ if (sr->ss != sss->want_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u/%d to command %s in %s:%u\n",
- sss->http_status,
- (int) ec,
+ "Unexpected response code %u to command %s in %s:%u\n",
+ sr->ss,
sss->is->commands[sss->is->ip].label,
__FILE__,
__LINE__);
TALER_TESTING_interpreter_fail (sss->is);
return;
}
-
- struct TALER_MERCHANT_PayUriData pd;
-
- if (GNUNET_OK !=
- TALER_MERCHANT_parse_pay_uri (taler_pay_url,
- &pd))
- {
- GNUNET_break (0);
- TALER_TESTING_interpreter_fail (sss->is);
- return;
- }
- sss->payment_order_id = GNUNET_strdup (pd.order_id);
- TALER_MERCHANT_parse_pay_uri_free (&pd);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Order ID from Anastasis service is `%s'\n",
- sss->payment_order_id);
-
- TALER_TESTING_interpreter_next (sss->is);
-}
-
-
-/**
- * Function called with the results of a #secret_share().
- *
- * @param cls closure
- * @param @param current_etag sends back the etag of the upload (used to
prevent redundant uploads)
- * @param server_url url of the server to pay for
- * @param ec status code of the request
- * @param http_status http status code
- */
-static void
-secret_share_result_cb (void *cls,
- const struct GNUNET_HashCode *current_etag,
- const char *server_url,
- const enum TALER_ErrorCode ec,
- unsigned int http_status)
-{
- struct SecretShareState *sss = cls;
- sss->sso = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "At %s:%d we are in SRC\n",
- __FILE__, __LINE__);
- if (NULL != sss)
+ switch (sr->ss)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d etag is %s-%llu b\n", __FILE__, __LINE__,
- TALER_B2S (¤t_etag),
- (unsigned long long) sizeof (struct GNUNET_HashCode));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d error code is %d\n", __FILE__, __LINE__,
- ec);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d http status is %u\n", __FILE__, __LINE__,
- http_status);
-
- if (http_status != sss->http_status)
+ case ANASTASIS_SHARE_STATUS_SUCCESS:
+ break;
+ case ANASTASIS_SHARE_STATUS_PAYMENT_REQUIRED:
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u/%d to command %s in %s:%u\n",
- http_status,
- (int) ec,
- sss->is->commands[sss->is->ip].label,
- __FILE__,
- __LINE__);
- TALER_TESTING_interpreter_fail (sss->is);
- return;
+ struct TALER_MERCHANT_PayUriData pd;
+
+ GNUNET_assert (0 < sr->details.payment_required.payment_requests_length);
+ if (GNUNET_OK !=
+ TALER_MERCHANT_parse_pay_uri (
+
sr->details.payment_required.payment_requests[0].payment_request_url,
+ &pd))
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (sss->is);
+ return;
+ }
+ sss->payment_order_id = GNUNET_strdup (pd.order_id);
+ TALER_MERCHANT_parse_pay_uri_free (&pd);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Order ID from Anastasis service is `%s'\n",
+ sss->payment_order_id);
}
- TALER_TESTING_interpreter_next (sss->is);
- return;
+ case ANASTASIS_SHARE_STATUS_PROVIDER_FAILED:
+ break;
}
- TALER_TESTING_interpreter_fail (sss->is);
+ TALER_TESTING_interpreter_next (sss->is);
}
@@ -344,14 +292,11 @@ secret_share_run (void *cls,
}
sss->sso = ANASTASIS_secret_share (is->ctx,
sss->id_data,
- NULL,
policies,
sss->cmd_label_array_length,
pds,
pds_len,
- false, /* we never insist on payment */
- &secret_share_payment_cb,
- sss,
+ false,
&secret_share_result_cb,
sss,
sss->core_secret,
@@ -444,22 +389,22 @@ secret_share_traits (void *cls,
* @return the command
*/
struct TALER_TESTING_Command
-ANASTASIS_TESTING_cmd_secret_share (const char *label,
- const char *anastasis_url,
- const char *prev_secret_share,
- const json_t *id_data,
- const void *core_secret,
- size_t core_secret_size,
- unsigned int http_status,
- enum
- ANASTASIS_TESTING_SecretShareOption sso,
- ...)
+ANASTASIS_TESTING_cmd_secret_share (
+ const char *label,
+ const char *anastasis_url,
+ const char *prev_secret_share,
+ const json_t *id_data,
+ const void *core_secret,
+ size_t core_secret_size,
+ enum ANASTASIS_ShareStatus want_status,
+ enum ANASTASIS_TESTING_SecretShareOption sso,
+ ...)
{
struct SecretShareState *sss;
va_list ap;
sss = GNUNET_new (struct SecretShareState);
- sss->http_status = http_status;
+ sss->want_status = want_status;
sss->ssopt = sso;
sss->anastasis_url = anastasis_url;
sss->label = label;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: work on anastasis_backup.c,
gnunet <=