-more auditor API atomization
This commit is contained in:
parent
a37a8d34d5
commit
af77a2a178
@ -277,7 +277,8 @@ typedef void
|
|||||||
* finished processing the /version reply). If either check fails, we do
|
* finished processing the /version reply). If either check fails, we do
|
||||||
* NOT initiate the transaction with the auditor and instead return NULL.
|
* NOT initiate the transaction with the auditor and instead return NULL.
|
||||||
*
|
*
|
||||||
* @param auditor the auditor handle; the auditor must be ready to operate
|
* @param ctx the context for CURL requests
|
||||||
|
* @param url HTTP base URL for the auditor
|
||||||
* @param h_wire hash of merchant wire details
|
* @param h_wire hash of merchant wire details
|
||||||
* @param h_policy hash over the policy, if any
|
* @param h_policy hash over the policy, if any
|
||||||
* @param h_contract_terms hash of the contact of the merchant with the customer (further details are never disclosed to the auditor)
|
* @param h_contract_terms hash of the contact of the merchant with the customer (further details are never disclosed to the auditor)
|
||||||
@ -301,7 +302,8 @@ typedef void
|
|||||||
*/
|
*/
|
||||||
struct TALER_AUDITOR_DepositConfirmationHandle *
|
struct TALER_AUDITOR_DepositConfirmationHandle *
|
||||||
TALER_AUDITOR_deposit_confirmation (
|
TALER_AUDITOR_deposit_confirmation (
|
||||||
struct TALER_AUDITOR_Handle *auditor,
|
struct GNUNET_CURL_Context *ctx,
|
||||||
|
const char *url,
|
||||||
const struct TALER_MerchantWireHashP *h_wire,
|
const struct TALER_MerchantWireHashP *h_wire,
|
||||||
const struct TALER_ExtensionPolicyHashP *h_policy,
|
const struct TALER_ExtensionPolicyHashP *h_policy,
|
||||||
const struct TALER_PrivateContractHashP *h_contract_terms,
|
const struct TALER_PrivateContractHashP *h_contract_terms,
|
||||||
|
@ -38,11 +38,6 @@
|
|||||||
struct TALER_AUDITOR_DepositConfirmationHandle
|
struct TALER_AUDITOR_DepositConfirmationHandle
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* The connection to auditor this request handle will use
|
|
||||||
*/
|
|
||||||
struct TALER_AUDITOR_Handle *auditor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The url for this request.
|
* The url for this request.
|
||||||
*/
|
*/
|
||||||
@ -237,7 +232,8 @@ verify_signatures (const struct TALER_MerchantWireHashP *h_wire,
|
|||||||
|
|
||||||
struct TALER_AUDITOR_DepositConfirmationHandle *
|
struct TALER_AUDITOR_DepositConfirmationHandle *
|
||||||
TALER_AUDITOR_deposit_confirmation (
|
TALER_AUDITOR_deposit_confirmation (
|
||||||
struct TALER_AUDITOR_Handle *auditor,
|
struct GNUNET_CURL_Context *ctx,
|
||||||
|
const char *url,
|
||||||
const struct TALER_MerchantWireHashP *h_wire,
|
const struct TALER_MerchantWireHashP *h_wire,
|
||||||
const struct TALER_ExtensionPolicyHashP *h_policy,
|
const struct TALER_ExtensionPolicyHashP *h_policy,
|
||||||
const struct TALER_PrivateContractHashP *h_contract_terms,
|
const struct TALER_PrivateContractHashP *h_contract_terms,
|
||||||
@ -258,12 +254,9 @@ TALER_AUDITOR_deposit_confirmation (
|
|||||||
void *cb_cls)
|
void *cb_cls)
|
||||||
{
|
{
|
||||||
struct TALER_AUDITOR_DepositConfirmationHandle *dh;
|
struct TALER_AUDITOR_DepositConfirmationHandle *dh;
|
||||||
struct GNUNET_CURL_Context *ctx;
|
|
||||||
json_t *deposit_confirmation_obj;
|
json_t *deposit_confirmation_obj;
|
||||||
CURL *eh;
|
CURL *eh;
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_YES ==
|
|
||||||
TALER_AUDITOR_handle_is_ready_ (auditor));
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
verify_signatures (h_wire,
|
verify_signatures (h_wire,
|
||||||
h_policy,
|
h_policy,
|
||||||
@ -322,18 +315,17 @@ TALER_AUDITOR_deposit_confirmation (
|
|||||||
GNUNET_JSON_pack_data_auto ("exchange_pub",
|
GNUNET_JSON_pack_data_auto ("exchange_pub",
|
||||||
exchange_pub));
|
exchange_pub));
|
||||||
dh = GNUNET_new (struct TALER_AUDITOR_DepositConfirmationHandle);
|
dh = GNUNET_new (struct TALER_AUDITOR_DepositConfirmationHandle);
|
||||||
dh->auditor = auditor;
|
|
||||||
dh->cb = cb;
|
dh->cb = cb;
|
||||||
dh->cb_cls = cb_cls;
|
dh->cb_cls = cb_cls;
|
||||||
dh->url = TALER_AUDITOR_path_to_url_ (auditor,
|
dh->url = TALER_url_join (url,
|
||||||
"/deposit-confirmation");
|
"deposit-confirmation",
|
||||||
|
NULL);
|
||||||
if (NULL == dh->url)
|
if (NULL == dh->url)
|
||||||
{
|
{
|
||||||
GNUNET_free (dh);
|
GNUNET_free (dh);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
eh = TALER_AUDITOR_curl_easy_get_ (dh->url);
|
eh = TALER_AUDITOR_curl_easy_get_ (dh->url);
|
||||||
|
|
||||||
if ( (NULL == eh) ||
|
if ( (NULL == eh) ||
|
||||||
(CURLE_OK !=
|
(CURLE_OK !=
|
||||||
curl_easy_setopt (eh,
|
curl_easy_setopt (eh,
|
||||||
@ -356,7 +348,6 @@ TALER_AUDITOR_deposit_confirmation (
|
|||||||
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
||||||
"URL for deposit-confirmation: `%s'\n",
|
"URL for deposit-confirmation: `%s'\n",
|
||||||
dh->url);
|
dh->url);
|
||||||
ctx = TALER_AUDITOR_handle_to_context_ (auditor);
|
|
||||||
dh->job = GNUNET_CURL_job_add2 (ctx,
|
dh->job = GNUNET_CURL_job_add2 (ctx,
|
||||||
eh,
|
eh,
|
||||||
dh->ctx.headers,
|
dh->ctx.headers,
|
||||||
|
@ -55,6 +55,11 @@ struct TALER_EXCHANGE_BatchDepositHandle
|
|||||||
*/
|
*/
|
||||||
struct TALER_EXCHANGE_Handle *exchange;
|
struct TALER_EXCHANGE_Handle *exchange;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Context for our curl request(s).
|
||||||
|
*/
|
||||||
|
struct GNUNET_CURL_Context *ctx;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The url for this request.
|
* The url for this request.
|
||||||
*/
|
*/
|
||||||
@ -64,7 +69,7 @@ struct TALER_EXCHANGE_BatchDepositHandle
|
|||||||
* Context for #TEH_curl_easy_post(). Keeps the data that must
|
* Context for #TEH_curl_easy_post(). Keeps the data that must
|
||||||
* persist for Curl to make the upload.
|
* persist for Curl to make the upload.
|
||||||
*/
|
*/
|
||||||
struct TALER_CURL_PostContext ctx;
|
struct TALER_CURL_PostContext post_ctx;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle for the request.
|
* Handle for the request.
|
||||||
@ -136,13 +141,13 @@ struct TALER_EXCHANGE_BatchDepositHandle
|
|||||||
* launch a deposit confirmation interaction.
|
* launch a deposit confirmation interaction.
|
||||||
*
|
*
|
||||||
* @param cls closure
|
* @param cls closure
|
||||||
* @param ah handle to the auditor
|
* @param auditor_url base URL of the auditor
|
||||||
* @param auditor_pub public key of the auditor
|
* @param auditor_pub public key of the auditor
|
||||||
* @return NULL if no deposit confirmation interaction was launched
|
* @return NULL if no deposit confirmation interaction was launched
|
||||||
*/
|
*/
|
||||||
static struct TEAH_AuditorInteractionEntry *
|
static struct TEAH_AuditorInteractionEntry *
|
||||||
auditor_cb (void *cls,
|
auditor_cb (void *cls,
|
||||||
struct TALER_AUDITOR_Handle *ah,
|
const char *auditor_url,
|
||||||
const struct TALER_AuditorPublicKeyP *auditor_pub)
|
const struct TALER_AuditorPublicKeyP *auditor_pub)
|
||||||
{
|
{
|
||||||
struct TALER_EXCHANGE_BatchDepositHandle *dh = cls;
|
struct TALER_EXCHANGE_BatchDepositHandle *dh = cls;
|
||||||
@ -183,7 +188,8 @@ auditor_cb (void *cls,
|
|||||||
&dki->fees.deposit));
|
&dki->fees.deposit));
|
||||||
aie = GNUNET_new (struct TEAH_AuditorInteractionEntry);
|
aie = GNUNET_new (struct TEAH_AuditorInteractionEntry);
|
||||||
aie->dch = TALER_AUDITOR_deposit_confirmation (
|
aie->dch = TALER_AUDITOR_deposit_confirmation (
|
||||||
ah,
|
dh->ctx,
|
||||||
|
auditor_url,
|
||||||
&dh->h_wire,
|
&dh->h_wire,
|
||||||
&dh->h_policy,
|
&dh->h_policy,
|
||||||
&dh->dcd.h_contract_terms,
|
&dh->dcd.h_contract_terms,
|
||||||
@ -464,7 +470,6 @@ TALER_EXCHANGE_batch_deposit (
|
|||||||
{
|
{
|
||||||
const struct TALER_EXCHANGE_Keys *key_state;
|
const struct TALER_EXCHANGE_Keys *key_state;
|
||||||
struct TALER_EXCHANGE_BatchDepositHandle *dh;
|
struct TALER_EXCHANGE_BatchDepositHandle *dh;
|
||||||
struct GNUNET_CURL_Context *ctx;
|
|
||||||
json_t *deposit_obj;
|
json_t *deposit_obj;
|
||||||
json_t *deposits;
|
json_t *deposits;
|
||||||
CURL *eh;
|
CURL *eh;
|
||||||
@ -600,7 +605,7 @@ TALER_EXCHANGE_batch_deposit (
|
|||||||
eh = TALER_EXCHANGE_curl_easy_get_ (dh->url);
|
eh = TALER_EXCHANGE_curl_easy_get_ (dh->url);
|
||||||
if ( (NULL == eh) ||
|
if ( (NULL == eh) ||
|
||||||
(GNUNET_OK !=
|
(GNUNET_OK !=
|
||||||
TALER_curl_easy_post (&dh->ctx,
|
TALER_curl_easy_post (&dh->post_ctx,
|
||||||
eh,
|
eh,
|
||||||
deposit_obj)) )
|
deposit_obj)) )
|
||||||
{
|
{
|
||||||
@ -618,10 +623,10 @@ TALER_EXCHANGE_batch_deposit (
|
|||||||
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
||||||
"URL for deposit: `%s'\n",
|
"URL for deposit: `%s'\n",
|
||||||
dh->url);
|
dh->url);
|
||||||
ctx = TEAH_handle_to_context (exchange);
|
dh->ctx = TEAH_handle_to_context (exchange);
|
||||||
dh->job = GNUNET_CURL_job_add2 (ctx,
|
dh->job = GNUNET_CURL_job_add2 (dh->ctx,
|
||||||
eh,
|
eh,
|
||||||
dh->ctx.headers,
|
dh->post_ctx.headers,
|
||||||
&handle_deposit_finished,
|
&handle_deposit_finished,
|
||||||
dh);
|
dh);
|
||||||
return dh;
|
return dh;
|
||||||
@ -648,7 +653,7 @@ TALER_EXCHANGE_batch_deposit_cancel (
|
|||||||
GNUNET_free (deposit->url);
|
GNUNET_free (deposit->url);
|
||||||
GNUNET_free (deposit->cdds);
|
GNUNET_free (deposit->cdds);
|
||||||
GNUNET_free (deposit->exchange_sigs);
|
GNUNET_free (deposit->exchange_sigs);
|
||||||
TALER_curl_easy_post_finished (&deposit->ctx);
|
TALER_curl_easy_post_finished (&deposit->post_ctx);
|
||||||
GNUNET_free (deposit);
|
GNUNET_free (deposit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
This file is part of TALER
|
This file is part of TALER
|
||||||
Copyright (C) 2014-2021 Taler Systems SA
|
Copyright (C) 2014-2023 Taler Systems SA
|
||||||
|
|
||||||
TALER is free software; you can redistribute it and/or modify it under the
|
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
|
terms of the GNU General Public License as published by the Free Software
|
||||||
@ -55,6 +55,11 @@ struct TALER_EXCHANGE_DepositHandle
|
|||||||
*/
|
*/
|
||||||
struct TALER_EXCHANGE_Handle *exchange;
|
struct TALER_EXCHANGE_Handle *exchange;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Our CURL context.
|
||||||
|
*/
|
||||||
|
struct GNUNET_CURL_Context *ctx;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The url for this request.
|
* The url for this request.
|
||||||
*/
|
*/
|
||||||
@ -64,7 +69,7 @@ struct TALER_EXCHANGE_DepositHandle
|
|||||||
* Context for #TEH_curl_easy_post(). Keeps the data that must
|
* Context for #TEH_curl_easy_post(). Keeps the data that must
|
||||||
* persist for Curl to make the upload.
|
* persist for Curl to make the upload.
|
||||||
*/
|
*/
|
||||||
struct TALER_CURL_PostContext ctx;
|
struct TALER_CURL_PostContext post_ctx;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle for the request.
|
* Handle for the request.
|
||||||
@ -131,13 +136,13 @@ struct TALER_EXCHANGE_DepositHandle
|
|||||||
* launch a deposit confirmation interaction.
|
* launch a deposit confirmation interaction.
|
||||||
*
|
*
|
||||||
* @param cls closure
|
* @param cls closure
|
||||||
* @param ah handle to the auditor
|
* @param auditor_url base URL of the auditor
|
||||||
* @param auditor_pub public key of the auditor
|
* @param auditor_pub public key of the auditor
|
||||||
* @return NULL if no deposit confirmation interaction was launched
|
* @return NULL if no deposit confirmation interaction was launched
|
||||||
*/
|
*/
|
||||||
static struct TEAH_AuditorInteractionEntry *
|
static struct TEAH_AuditorInteractionEntry *
|
||||||
auditor_cb (void *cls,
|
auditor_cb (void *cls,
|
||||||
struct TALER_AUDITOR_Handle *ah,
|
const char *auditor_url,
|
||||||
const struct TALER_AuditorPublicKeyP *auditor_pub)
|
const struct TALER_AuditorPublicKeyP *auditor_pub)
|
||||||
{
|
{
|
||||||
struct TALER_EXCHANGE_DepositHandle *dh = cls;
|
struct TALER_EXCHANGE_DepositHandle *dh = cls;
|
||||||
@ -175,7 +180,8 @@ auditor_cb (void *cls,
|
|||||||
&dki->fees.deposit));
|
&dki->fees.deposit));
|
||||||
aie = GNUNET_new (struct TEAH_AuditorInteractionEntry);
|
aie = GNUNET_new (struct TEAH_AuditorInteractionEntry);
|
||||||
aie->dch = TALER_AUDITOR_deposit_confirmation (
|
aie->dch = TALER_AUDITOR_deposit_confirmation (
|
||||||
ah,
|
dh->ctx,
|
||||||
|
auditor_url,
|
||||||
&dh->h_wire,
|
&dh->h_wire,
|
||||||
&dh->h_policy,
|
&dh->h_policy,
|
||||||
&dh->dcd.h_contract_terms,
|
&dh->dcd.h_contract_terms,
|
||||||
@ -389,7 +395,6 @@ TALER_EXCHANGE_deposit (
|
|||||||
{
|
{
|
||||||
const struct TALER_EXCHANGE_Keys *key_state;
|
const struct TALER_EXCHANGE_Keys *key_state;
|
||||||
struct TALER_EXCHANGE_DepositHandle *dh;
|
struct TALER_EXCHANGE_DepositHandle *dh;
|
||||||
struct GNUNET_CURL_Context *ctx;
|
|
||||||
json_t *deposit_obj;
|
json_t *deposit_obj;
|
||||||
CURL *eh;
|
CURL *eh;
|
||||||
const struct TALER_EXCHANGE_DenomPublicKey *dki;
|
const struct TALER_EXCHANGE_DenomPublicKey *dki;
|
||||||
@ -506,7 +511,7 @@ TALER_EXCHANGE_deposit (
|
|||||||
eh = TALER_EXCHANGE_curl_easy_get_ (dh->url);
|
eh = TALER_EXCHANGE_curl_easy_get_ (dh->url);
|
||||||
if ( (NULL == eh) ||
|
if ( (NULL == eh) ||
|
||||||
(GNUNET_OK !=
|
(GNUNET_OK !=
|
||||||
TALER_curl_easy_post (&dh->ctx,
|
TALER_curl_easy_post (&dh->post_ctx,
|
||||||
eh,
|
eh,
|
||||||
deposit_obj)) )
|
deposit_obj)) )
|
||||||
{
|
{
|
||||||
@ -523,10 +528,10 @@ TALER_EXCHANGE_deposit (
|
|||||||
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
||||||
"URL for deposit: `%s'\n",
|
"URL for deposit: `%s'\n",
|
||||||
dh->url);
|
dh->url);
|
||||||
ctx = TEAH_handle_to_context (exchange);
|
dh->ctx = TEAH_handle_to_context (exchange);
|
||||||
dh->job = GNUNET_CURL_job_add2 (ctx,
|
dh->job = GNUNET_CURL_job_add2 (dh->ctx,
|
||||||
eh,
|
eh,
|
||||||
dh->ctx.headers,
|
dh->post_ctx.headers,
|
||||||
&handle_deposit_finished,
|
&handle_deposit_finished,
|
||||||
dh);
|
dh);
|
||||||
return dh;
|
return dh;
|
||||||
@ -549,7 +554,7 @@ TALER_EXCHANGE_deposit_cancel (struct TALER_EXCHANGE_DepositHandle *deposit)
|
|||||||
deposit->job = NULL;
|
deposit->job = NULL;
|
||||||
}
|
}
|
||||||
GNUNET_free (deposit->url);
|
GNUNET_free (deposit->url);
|
||||||
TALER_curl_easy_post_finished (&deposit->ctx);
|
TALER_curl_easy_post_finished (&deposit->post_ctx);
|
||||||
GNUNET_free (deposit);
|
GNUNET_free (deposit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ TEAH_get_auditors_for_dc (struct TALER_EXCHANGE_Handle *h,
|
|||||||
if (! ale->is_up)
|
if (! ale->is_up)
|
||||||
continue;
|
continue;
|
||||||
aie = ac (ac_cls,
|
aie = ac (ac_cls,
|
||||||
ale->ah,
|
ale->auditor_url,
|
||||||
&ale->auditor_pub);
|
&ale->auditor_pub);
|
||||||
if (NULL != aie)
|
if (NULL != aie)
|
||||||
{
|
{
|
||||||
|
@ -178,13 +178,13 @@ struct TALER_EXCHANGE_Handle
|
|||||||
* launch a deposit confirmation interaction.
|
* launch a deposit confirmation interaction.
|
||||||
*
|
*
|
||||||
* @param cls closure
|
* @param cls closure
|
||||||
* @param ah handle to the auditor
|
* @param auditor_url base URL of the auditor
|
||||||
* @param auditor_pub public key of the auditor
|
* @param auditor_pub public key of the auditor
|
||||||
* @return NULL if no deposit confirmation interaction was launched
|
* @return NULL if no deposit confirmation interaction was launched
|
||||||
*/
|
*/
|
||||||
typedef struct TEAH_AuditorInteractionEntry *
|
typedef struct TEAH_AuditorInteractionEntry *
|
||||||
(*TEAH_AuditorCallback)(void *cls,
|
(*TEAH_AuditorCallback)(void *cls,
|
||||||
struct TALER_AUDITOR_Handle *ah,
|
const char *auditor_url,
|
||||||
const struct TALER_AuditorPublicKeyP *auditor_pub);
|
const struct TALER_AuditorPublicKeyP *auditor_pub);
|
||||||
|
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ deposit_confirmation_run (void *cls,
|
|||||||
const struct TALER_CoinSpendPrivateKeyP *coin_priv;
|
const struct TALER_CoinSpendPrivateKeyP *coin_priv;
|
||||||
const struct TALER_EXCHANGE_Keys *keys;
|
const struct TALER_EXCHANGE_Keys *keys;
|
||||||
const struct TALER_EXCHANGE_SigningPublicKey *spk;
|
const struct TALER_EXCHANGE_SigningPublicKey *spk;
|
||||||
struct TALER_AUDITOR_Handle *auditor;
|
const char *auditor_url;
|
||||||
struct TALER_EXCHANGE_Handle *exchange
|
struct TALER_EXCHANGE_Handle *exchange
|
||||||
= TALER_TESTING_get_exchange (is);
|
= TALER_TESTING_get_exchange (is);
|
||||||
|
|
||||||
@ -231,9 +231,14 @@ deposit_confirmation_run (void *cls,
|
|||||||
TALER_TESTING_interpreter_fail (is);
|
TALER_TESTING_interpreter_fail (is);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GNUNET_assert (GNUNET_OK ==
|
if (GNUNET_OK !=
|
||||||
TALER_TESTING_get_trait_auditor (auditor_cmd,
|
TALER_TESTING_get_trait_auditor_url (auditor_cmd,
|
||||||
&auditor));
|
&auditor_url))
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
TALER_TESTING_interpreter_fail (is);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
deposit_cmd
|
deposit_cmd
|
||||||
= TALER_TESTING_interpreter_lookup_command (is,
|
= TALER_TESTING_interpreter_lookup_command (is,
|
||||||
@ -319,7 +324,9 @@ deposit_confirmation_run (void *cls,
|
|||||||
if (GNUNET_TIME_absolute_is_zero (refund_deadline.abs_time))
|
if (GNUNET_TIME_absolute_is_zero (refund_deadline.abs_time))
|
||||||
refund_deadline = timestamp;
|
refund_deadline = timestamp;
|
||||||
}
|
}
|
||||||
dcs->dc = TALER_AUDITOR_deposit_confirmation (auditor,
|
dcs->dc = TALER_AUDITOR_deposit_confirmation (
|
||||||
|
TALER_TESTING_interpreter_get_context (is),
|
||||||
|
auditor_url,
|
||||||
&h_wire,
|
&h_wire,
|
||||||
&no_h_policy,
|
&no_h_policy,
|
||||||
&h_contract_terms,
|
&h_contract_terms,
|
||||||
|
Loading…
Reference in New Issue
Block a user