2018-10-22 16:00:06 +02:00
|
|
|
|
/*
|
|
|
|
|
This file is part of TALER
|
2021-07-31 20:27:16 +02:00
|
|
|
|
Copyright (C) 2014-2021 Taler Systems SA
|
2018-10-22 16:00:06 +02:00
|
|
|
|
|
|
|
|
|
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/>
|
|
|
|
|
*/
|
|
|
|
|
/**
|
2020-01-17 22:13:40 +01:00
|
|
|
|
* @file lib/auditor_api_deposit_confirmation.c
|
2018-10-22 16:00:06 +02:00
|
|
|
|
* @brief Implementation of the /deposit request of the auditor's HTTP API
|
|
|
|
|
* @author Christian Grothoff
|
|
|
|
|
*/
|
|
|
|
|
#include "platform.h"
|
|
|
|
|
#include <jansson.h>
|
|
|
|
|
#include <microhttpd.h> /* just for HTTP status codes */
|
|
|
|
|
#include <gnunet/gnunet_util_lib.h>
|
|
|
|
|
#include <gnunet/gnunet_json_lib.h>
|
|
|
|
|
#include <gnunet/gnunet_curl_lib.h>
|
|
|
|
|
#include "taler_json_lib.h"
|
|
|
|
|
#include "taler_auditor_service.h"
|
|
|
|
|
#include "auditor_api_handle.h"
|
|
|
|
|
#include "taler_signatures.h"
|
2019-01-11 21:27:34 +01:00
|
|
|
|
#include "auditor_api_curl_defaults.h"
|
2018-10-22 16:00:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief A DepositConfirmation Handle
|
|
|
|
|
*/
|
|
|
|
|
struct TALER_AUDITOR_DepositConfirmationHandle
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The connection to auditor this request handle will use
|
|
|
|
|
*/
|
|
|
|
|
struct TALER_AUDITOR_Handle *auditor;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The url for this request.
|
|
|
|
|
*/
|
|
|
|
|
char *url;
|
|
|
|
|
|
|
|
|
|
/**
|
2019-05-03 17:36:58 +02:00
|
|
|
|
* Context for #TEH_curl_easy_post(). Keeps the data that must
|
|
|
|
|
* persist for Curl to make the upload.
|
2018-10-22 16:00:06 +02:00
|
|
|
|
*/
|
2020-01-17 23:01:17 +01:00
|
|
|
|
struct TALER_CURL_PostContext ctx;
|
2018-10-22 16:00:06 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handle for the request.
|
|
|
|
|
*/
|
|
|
|
|
struct GNUNET_CURL_Job *job;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Function to call with the result.
|
|
|
|
|
*/
|
|
|
|
|
TALER_AUDITOR_DepositConfirmationResultCallback cb;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Closure for @a cb.
|
|
|
|
|
*/
|
|
|
|
|
void *cb_cls;
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Function called when we're done processing the
|
|
|
|
|
* HTTP /deposit-confirmation request.
|
|
|
|
|
*
|
|
|
|
|
* @param cls the `struct TALER_AUDITOR_DepositConfirmationHandle`
|
|
|
|
|
* @param response_code HTTP response code, 0 on error
|
2018-10-27 18:38:43 +02:00
|
|
|
|
* @param djson parsed JSON result, NULL on error
|
2018-10-22 16:00:06 +02:00
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
handle_deposit_confirmation_finished (void *cls,
|
2019-08-25 16:18:24 +02:00
|
|
|
|
long response_code,
|
|
|
|
|
const void *djson)
|
2018-10-22 16:00:06 +02:00
|
|
|
|
{
|
2018-10-27 18:38:43 +02:00
|
|
|
|
const json_t *json = djson;
|
2018-10-22 16:00:06 +02:00
|
|
|
|
struct TALER_AUDITOR_DepositConfirmationHandle *dh = cls;
|
2020-04-05 22:05:38 +02:00
|
|
|
|
struct TALER_AUDITOR_HttpResponse hr = {
|
|
|
|
|
.reply = json,
|
|
|
|
|
.http_status = (unsigned int) response_code
|
|
|
|
|
};
|
2018-10-22 16:00:06 +02:00
|
|
|
|
|
|
|
|
|
dh->job = NULL;
|
|
|
|
|
switch (response_code)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
2020-11-07 18:51:14 +01:00
|
|
|
|
hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
|
2018-10-22 16:00:06 +02:00
|
|
|
|
break;
|
|
|
|
|
case MHD_HTTP_OK:
|
2020-04-05 22:05:38 +02:00
|
|
|
|
hr.ec = TALER_EC_NONE;
|
2018-10-22 16:00:06 +02:00
|
|
|
|
break;
|
|
|
|
|
case MHD_HTTP_BAD_REQUEST:
|
2020-04-05 22:05:38 +02:00
|
|
|
|
hr.ec = TALER_JSON_get_error_code (json);
|
|
|
|
|
hr.hint = TALER_JSON_get_error_hint (json);
|
2018-10-22 16:00:06 +02:00
|
|
|
|
/* This should never happen, either us or the auditor is buggy
|
|
|
|
|
(or API version conflict); just pass JSON reply to the application */
|
|
|
|
|
break;
|
2019-11-23 22:21:47 +01:00
|
|
|
|
case MHD_HTTP_FORBIDDEN:
|
2020-04-05 22:05:38 +02:00
|
|
|
|
hr.ec = TALER_JSON_get_error_code (json);
|
|
|
|
|
hr.hint = TALER_JSON_get_error_hint (json);
|
2018-10-22 16:00:06 +02:00
|
|
|
|
/* Nothing really to verify, auditor says one of the signatures is
|
|
|
|
|
invalid; as we checked them, this should never happen, we
|
|
|
|
|
should pass the JSON reply to the application */
|
|
|
|
|
break;
|
|
|
|
|
case MHD_HTTP_NOT_FOUND:
|
2020-04-05 22:05:38 +02:00
|
|
|
|
hr.ec = TALER_JSON_get_error_code (json);
|
|
|
|
|
hr.hint = TALER_JSON_get_error_hint (json);
|
2018-10-22 16:00:06 +02:00
|
|
|
|
/* Nothing really to verify, this should never
|
|
|
|
|
happen, we should pass the JSON reply to the application */
|
|
|
|
|
break;
|
2020-12-26 16:40:43 +01:00
|
|
|
|
case MHD_HTTP_GONE:
|
|
|
|
|
hr.ec = TALER_JSON_get_error_code (json);
|
|
|
|
|
hr.hint = TALER_JSON_get_error_hint (json);
|
|
|
|
|
/* Nothing really to verify, auditor says one of the signatures is
|
|
|
|
|
invalid; as we checked them, this should never happen, we
|
|
|
|
|
should pass the JSON reply to the application */
|
|
|
|
|
break;
|
2018-10-22 16:00:06 +02:00
|
|
|
|
case MHD_HTTP_INTERNAL_SERVER_ERROR:
|
2020-04-05 22:05:38 +02:00
|
|
|
|
hr.ec = TALER_JSON_get_error_code (json);
|
|
|
|
|
hr.hint = TALER_JSON_get_error_hint (json);
|
2018-10-22 16:00:06 +02:00
|
|
|
|
/* Server had an internal issue; we should retry, but this API
|
|
|
|
|
leaves this to the application */
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
/* unexpected response code */
|
2020-04-05 22:05:38 +02:00
|
|
|
|
hr.ec = TALER_JSON_get_error_code (json);
|
|
|
|
|
hr.hint = TALER_JSON_get_error_hint (json);
|
2018-10-22 16:00:06 +02:00
|
|
|
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
2020-12-20 20:03:59 +01:00
|
|
|
|
"Unexpected response code %u/%d for auditor deposit confirmation\n",
|
2020-03-10 18:51:08 +01:00
|
|
|
|
(unsigned int) response_code,
|
2020-04-05 22:05:38 +02:00
|
|
|
|
hr.ec);
|
2018-10-22 16:00:06 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
dh->cb (dh->cb_cls,
|
2020-04-05 22:05:38 +02:00
|
|
|
|
&hr);
|
2018-10-22 16:00:06 +02:00
|
|
|
|
TALER_AUDITOR_deposit_confirmation_cancel (dh);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Verify signature information about the deposit-confirmation.
|
|
|
|
|
*
|
2018-10-27 18:58:44 +02:00
|
|
|
|
* @param h_wire hash of merchant wire details
|
2018-10-22 16:00:06 +02:00
|
|
|
|
* @param h_contract_terms hash of the contact of the merchant with the customer (further details are never disclosed to the auditor)
|
2020-05-07 20:22:02 +02:00
|
|
|
|
* @param exchange_timestamp timestamp when the deposit was received by the wallet
|
2018-10-27 18:58:44 +02:00
|
|
|
|
* @param refund_deadline date until which the merchant can issue a refund to the customer via the auditor (can be zero if refunds are not allowed); must not be after the @a wire_deadline
|
|
|
|
|
* @param amount_without_fee the amount confirmed to be wired by the exchange to the merchant
|
2018-10-22 16:00:06 +02:00
|
|
|
|
* @param coin_pub coin’s public key
|
|
|
|
|
* @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests)
|
2018-10-27 18:58:44 +02:00
|
|
|
|
* @param exchange_sig the signature made with purpose #TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT
|
|
|
|
|
* @param exchange_pub the public key of the exchange that matches @a exchange_sig
|
|
|
|
|
* @param master_pub master public key of the exchange
|
|
|
|
|
* @param ep_start when does @a exchange_pub validity start
|
|
|
|
|
* @param ep_expire when does @a exchange_pub usage end
|
|
|
|
|
* @param ep_end when does @a exchange_pub legal validity end
|
|
|
|
|
* @param master_sig master signature affirming validity of @a exchange_pub
|
2018-10-22 16:00:06 +02:00
|
|
|
|
* @return #GNUNET_OK if signatures are OK, #GNUNET_SYSERR if not
|
|
|
|
|
*/
|
|
|
|
|
static int
|
2018-10-27 18:58:44 +02:00
|
|
|
|
verify_signatures (const struct GNUNET_HashCode *h_wire,
|
2018-10-22 16:00:06 +02:00
|
|
|
|
const struct GNUNET_HashCode *h_contract_terms,
|
2020-05-07 20:22:02 +02:00
|
|
|
|
struct GNUNET_TIME_Absolute exchange_timestamp,
|
2018-10-22 16:00:06 +02:00
|
|
|
|
struct GNUNET_TIME_Absolute refund_deadline,
|
2018-10-27 18:58:44 +02:00
|
|
|
|
const struct TALER_Amount *amount_without_fee,
|
|
|
|
|
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
|
|
|
|
const struct TALER_MerchantPublicKeyP *merchant_pub,
|
2018-10-27 18:38:43 +02:00
|
|
|
|
const struct TALER_ExchangePublicKeyP *exchange_pub,
|
2018-11-17 15:15:51 +01:00
|
|
|
|
const struct TALER_ExchangeSignatureP *exchange_sig,
|
2018-10-27 18:38:43 +02:00
|
|
|
|
const struct TALER_MasterPublicKeyP *master_pub,
|
2018-10-27 18:58:44 +02:00
|
|
|
|
struct GNUNET_TIME_Absolute ep_start,
|
|
|
|
|
struct GNUNET_TIME_Absolute ep_expire,
|
|
|
|
|
struct GNUNET_TIME_Absolute ep_end,
|
2018-10-27 18:38:43 +02:00
|
|
|
|
const struct TALER_MasterSignatureP *master_sig)
|
2018-10-22 16:00:06 +02:00
|
|
|
|
{
|
2018-11-17 15:15:51 +01:00
|
|
|
|
{
|
2020-04-08 18:18:20 +02:00
|
|
|
|
struct TALER_DepositConfirmationPS dc = {
|
|
|
|
|
.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT),
|
|
|
|
|
.purpose.size = htonl (sizeof (dc)),
|
|
|
|
|
.h_contract_terms = *h_contract_terms,
|
|
|
|
|
.h_wire = *h_wire,
|
2020-05-07 20:22:02 +02:00
|
|
|
|
.exchange_timestamp = GNUNET_TIME_absolute_hton (exchange_timestamp),
|
2020-04-08 18:18:20 +02:00
|
|
|
|
.refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline),
|
|
|
|
|
.coin_pub = *coin_pub,
|
|
|
|
|
.merchant = *merchant_pub
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TALER_amount_hton (&dc.amount_without_fee,
|
|
|
|
|
amount_without_fee);
|
|
|
|
|
if (GNUNET_OK !=
|
|
|
|
|
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT,
|
|
|
|
|
&dc,
|
|
|
|
|
&exchange_sig->eddsa_signature,
|
|
|
|
|
&exchange_pub->eddsa_pub))
|
2018-10-22 16:00:06 +02:00
|
|
|
|
{
|
2020-04-08 18:18:20 +02:00
|
|
|
|
GNUNET_break_op (0);
|
|
|
|
|
TALER_LOG_WARNING (
|
|
|
|
|
"Invalid signature on /deposit-confirmation request!\n");
|
|
|
|
|
{
|
|
|
|
|
TALER_LOG_DEBUG ("... amount_without_fee was %s\n",
|
|
|
|
|
TALER_amount2s (amount_without_fee));
|
|
|
|
|
}
|
|
|
|
|
return GNUNET_SYSERR;
|
2018-10-22 16:00:06 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-04 20:29:18 +01:00
|
|
|
|
if (GNUNET_OK !=
|
|
|
|
|
TALER_exchange_offline_signkey_validity_verify (
|
|
|
|
|
exchange_pub,
|
|
|
|
|
ep_start,
|
|
|
|
|
ep_expire,
|
|
|
|
|
ep_end,
|
|
|
|
|
master_pub,
|
|
|
|
|
master_sig))
|
2018-10-27 18:58:44 +02:00
|
|
|
|
{
|
2020-12-04 20:29:18 +01:00
|
|
|
|
GNUNET_break (0);
|
|
|
|
|
TALER_LOG_WARNING ("Invalid signature on exchange signing key!\n");
|
|
|
|
|
return GNUNET_SYSERR;
|
2018-10-27 18:58:44 +02:00
|
|
|
|
}
|
2021-08-07 16:31:33 +02:00
|
|
|
|
if (GNUNET_TIME_relative_is_zero (
|
|
|
|
|
GNUNET_TIME_absolute_get_remaining (ep_end)))
|
2018-10-27 18:58:44 +02:00
|
|
|
|
{
|
|
|
|
|
GNUNET_break (0);
|
|
|
|
|
TALER_LOG_WARNING ("Exchange signing key is no longer valid!\n");
|
|
|
|
|
return GNUNET_SYSERR;
|
|
|
|
|
}
|
2018-10-22 16:00:06 +02:00
|
|
|
|
return GNUNET_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Submit a deposit-confirmation permission to the auditor and get the
|
|
|
|
|
* auditor's response. Note that while we return the response
|
|
|
|
|
* verbatim to the caller for further processing, we do already verify
|
|
|
|
|
* that the response is well-formed. If the auditor's reply is not
|
|
|
|
|
* well-formed, we return an HTTP status code of zero to @a cb.
|
|
|
|
|
*
|
|
|
|
|
* We also verify that the @a exchange_sig is valid for this deposit-confirmation
|
|
|
|
|
* request, and that the @a master_sig is a valid signature for @a
|
|
|
|
|
* exchange_pub. Also, the @a auditor must be ready to operate (i.e. have
|
|
|
|
|
* finished processing the /version reply). If either check fails, we do
|
|
|
|
|
* NOT initiate the transaction with the auditor and instead return NULL.
|
|
|
|
|
*
|
|
|
|
|
* @param auditor the auditor handle; the auditor must be ready to operate
|
2018-10-27 18:58:44 +02:00
|
|
|
|
* @param h_wire hash of merchant wire details
|
2018-10-22 16:00:06 +02:00
|
|
|
|
* @param h_contract_terms hash of the contact of the merchant with the customer (further details are never disclosed to the auditor)
|
2020-05-07 20:22:02 +02:00
|
|
|
|
* @param exchange_timestamp timestamp when deposit was received by the exchange
|
2018-10-22 16:00:06 +02:00
|
|
|
|
* @param refund_deadline date until which the merchant can issue a refund to the customer via the auditor (can be zero if refunds are not allowed); must not be after the @a wire_deadline
|
2018-10-27 18:58:44 +02:00
|
|
|
|
* @param amount_without_fee the amount confirmed to be wired by the exchange to the merchant
|
|
|
|
|
* @param coin_pub coin’s public key
|
|
|
|
|
* @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests)
|
|
|
|
|
* @param exchange_sig the signature made with purpose #TALER_SIGNATURE_EXCHANGE_CONFIRM_DEPOSIT
|
|
|
|
|
* @param exchange_pub the public key of the exchange that matches @a exchange_sig
|
|
|
|
|
* @param master_pub master public key of the exchange
|
|
|
|
|
* @param ep_start when does @a exchange_pub validity start
|
|
|
|
|
* @param ep_expire when does @a exchange_pub usage end
|
|
|
|
|
* @param ep_end when does @a exchange_pub legal validity end
|
|
|
|
|
* @param master_sig master signature affirming validity of @a exchange_pub
|
2018-10-22 16:00:06 +02:00
|
|
|
|
* @param cb the callback to call when a reply for this request is available
|
|
|
|
|
* @param cb_cls closure for the above callback
|
|
|
|
|
* @return a handle for this request; NULL if the inputs are invalid (i.e.
|
|
|
|
|
* signatures fail to verify). In this case, the callback is not called.
|
|
|
|
|
*/
|
|
|
|
|
struct TALER_AUDITOR_DepositConfirmationHandle *
|
2020-03-17 17:47:53 +01:00
|
|
|
|
TALER_AUDITOR_deposit_confirmation (
|
|
|
|
|
struct TALER_AUDITOR_Handle *auditor,
|
|
|
|
|
const struct GNUNET_HashCode *h_wire,
|
|
|
|
|
const struct GNUNET_HashCode *h_contract_terms,
|
2020-05-07 20:22:02 +02:00
|
|
|
|
struct GNUNET_TIME_Absolute exchange_timestamp,
|
2020-03-17 17:47:53 +01:00
|
|
|
|
struct GNUNET_TIME_Absolute refund_deadline,
|
|
|
|
|
const struct TALER_Amount *amount_without_fee,
|
|
|
|
|
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
|
|
|
|
const struct TALER_MerchantPublicKeyP *merchant_pub,
|
|
|
|
|
const struct TALER_ExchangePublicKeyP *exchange_pub,
|
|
|
|
|
const struct TALER_ExchangeSignatureP *exchange_sig,
|
|
|
|
|
const struct TALER_MasterPublicKeyP *master_pub,
|
|
|
|
|
struct GNUNET_TIME_Absolute ep_start,
|
|
|
|
|
struct GNUNET_TIME_Absolute ep_expire,
|
|
|
|
|
struct GNUNET_TIME_Absolute ep_end,
|
|
|
|
|
const struct TALER_MasterSignatureP *master_sig,
|
|
|
|
|
TALER_AUDITOR_DepositConfirmationResultCallback cb,
|
|
|
|
|
void *cb_cls)
|
2018-10-22 16:00:06 +02:00
|
|
|
|
{
|
|
|
|
|
struct TALER_AUDITOR_DepositConfirmationHandle *dh;
|
|
|
|
|
struct GNUNET_CURL_Context *ctx;
|
|
|
|
|
json_t *deposit_confirmation_obj;
|
|
|
|
|
CURL *eh;
|
|
|
|
|
|
2020-05-07 20:22:02 +02:00
|
|
|
|
(void) GNUNET_TIME_round_abs (&exchange_timestamp);
|
2018-10-22 16:00:06 +02:00
|
|
|
|
(void) GNUNET_TIME_round_abs (&refund_deadline);
|
2018-10-27 18:58:44 +02:00
|
|
|
|
(void) GNUNET_TIME_round_abs (&ep_start);
|
|
|
|
|
(void) GNUNET_TIME_round_abs (&ep_expire);
|
|
|
|
|
(void) GNUNET_TIME_round_abs (&ep_end);
|
2018-10-22 16:00:06 +02:00
|
|
|
|
GNUNET_assert (GNUNET_YES ==
|
2020-03-03 17:14:00 +01:00
|
|
|
|
TALER_AUDITOR_handle_is_ready_ (auditor));
|
2018-10-22 16:00:06 +02:00
|
|
|
|
if (GNUNET_OK !=
|
2018-10-27 18:58:44 +02:00
|
|
|
|
verify_signatures (h_wire,
|
2018-10-22 16:00:06 +02:00
|
|
|
|
h_contract_terms,
|
2020-05-07 20:22:02 +02:00
|
|
|
|
exchange_timestamp,
|
2018-10-22 16:00:06 +02:00
|
|
|
|
refund_deadline,
|
2018-10-27 18:58:44 +02:00
|
|
|
|
amount_without_fee,
|
|
|
|
|
coin_pub,
|
|
|
|
|
merchant_pub,
|
|
|
|
|
exchange_pub,
|
|
|
|
|
exchange_sig,
|
|
|
|
|
master_pub,
|
|
|
|
|
ep_start,
|
|
|
|
|
ep_expire,
|
|
|
|
|
ep_end,
|
|
|
|
|
master_sig))
|
2018-10-22 16:00:06 +02:00
|
|
|
|
{
|
|
|
|
|
GNUNET_break_op (0);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deposit_confirmation_obj
|
2021-07-31 20:27:16 +02:00
|
|
|
|
= GNUNET_JSON_PACK (
|
|
|
|
|
GNUNET_JSON_pack_data_auto ("h_wire",
|
|
|
|
|
h_wire),
|
|
|
|
|
GNUNET_JSON_pack_data_auto ("h_contract_terms",
|
|
|
|
|
h_contract_terms),
|
|
|
|
|
GNUNET_JSON_pack_time_abs ("exchange_timestamp",
|
|
|
|
|
exchange_timestamp),
|
|
|
|
|
GNUNET_JSON_pack_time_abs ("refund_deadline",
|
|
|
|
|
refund_deadline),
|
|
|
|
|
TALER_JSON_pack_amount ("amount_without_fee",
|
|
|
|
|
amount_without_fee),
|
|
|
|
|
GNUNET_JSON_pack_data_auto ("coin_pub",
|
|
|
|
|
coin_pub),
|
|
|
|
|
GNUNET_JSON_pack_data_auto ("merchant_pub",
|
|
|
|
|
merchant_pub),
|
|
|
|
|
GNUNET_JSON_pack_data_auto ("exchange_sig",
|
|
|
|
|
exchange_sig),
|
|
|
|
|
GNUNET_JSON_pack_data_auto ("master_pub",
|
|
|
|
|
master_pub),
|
|
|
|
|
GNUNET_JSON_pack_time_abs ("ep_start",
|
|
|
|
|
ep_start),
|
|
|
|
|
GNUNET_JSON_pack_time_abs ("ep_expire",
|
|
|
|
|
ep_expire),
|
|
|
|
|
GNUNET_JSON_pack_time_abs ("ep_end",
|
|
|
|
|
ep_end),
|
|
|
|
|
GNUNET_JSON_pack_data_auto ("master_sig",
|
|
|
|
|
master_sig),
|
|
|
|
|
GNUNET_JSON_pack_data_auto ("exchange_pub",
|
|
|
|
|
exchange_pub));
|
2018-10-22 16:00:06 +02:00
|
|
|
|
dh = GNUNET_new (struct TALER_AUDITOR_DepositConfirmationHandle);
|
|
|
|
|
dh->auditor = auditor;
|
|
|
|
|
dh->cb = cb;
|
|
|
|
|
dh->cb_cls = cb_cls;
|
2020-03-03 17:14:00 +01:00
|
|
|
|
dh->url = TALER_AUDITOR_path_to_url_ (auditor,
|
|
|
|
|
"/deposit-confirmation");
|
2021-03-05 21:41:55 +01:00
|
|
|
|
if (NULL == dh->url)
|
|
|
|
|
{
|
|
|
|
|
GNUNET_free (dh);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2020-03-03 17:14:00 +01:00
|
|
|
|
eh = TALER_AUDITOR_curl_easy_get_ (dh->url);
|
2018-10-22 16:00:06 +02:00
|
|
|
|
|
2020-03-03 17:14:00 +01:00
|
|
|
|
if ( (NULL == eh) ||
|
|
|
|
|
(CURLE_OK !=
|
|
|
|
|
curl_easy_setopt (eh,
|
|
|
|
|
CURLOPT_CUSTOMREQUEST,
|
|
|
|
|
"PUT")) ||
|
|
|
|
|
(GNUNET_OK !=
|
|
|
|
|
TALER_curl_easy_post (&dh->ctx,
|
|
|
|
|
eh,
|
|
|
|
|
deposit_confirmation_obj)) )
|
2019-05-03 17:36:58 +02:00
|
|
|
|
{
|
|
|
|
|
GNUNET_break (0);
|
2020-03-03 17:14:00 +01:00
|
|
|
|
if (NULL != eh)
|
|
|
|
|
curl_easy_cleanup (eh);
|
2019-05-03 17:36:58 +02:00
|
|
|
|
json_decref (deposit_confirmation_obj);
|
|
|
|
|
GNUNET_free (dh->url);
|
|
|
|
|
GNUNET_free (dh);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
json_decref (deposit_confirmation_obj);
|
|
|
|
|
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
|
|
|
|
"URL for deposit-confirmation: `%s'\n",
|
|
|
|
|
dh->url);
|
2020-03-03 17:14:00 +01:00
|
|
|
|
ctx = TALER_AUDITOR_handle_to_context_ (auditor);
|
2019-07-28 15:39:28 +02:00
|
|
|
|
dh->job = GNUNET_CURL_job_add2 (ctx,
|
|
|
|
|
eh,
|
|
|
|
|
dh->ctx.headers,
|
|
|
|
|
&handle_deposit_confirmation_finished,
|
|
|
|
|
dh);
|
2018-10-22 16:00:06 +02:00
|
|
|
|
return dh;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Cancel a deposit-confirmation permission request. This function cannot be used
|
|
|
|
|
* on a request handle if a response is already served for it.
|
|
|
|
|
*
|
2020-01-18 14:24:55 +01:00
|
|
|
|
* @param deposit_confirmation the deposit-confirmation permission request handle
|
2018-10-22 16:00:06 +02:00
|
|
|
|
*/
|
|
|
|
|
void
|
2020-03-17 17:47:53 +01:00
|
|
|
|
TALER_AUDITOR_deposit_confirmation_cancel (
|
|
|
|
|
struct TALER_AUDITOR_DepositConfirmationHandle *deposit_confirmation)
|
2018-10-22 16:00:06 +02:00
|
|
|
|
{
|
|
|
|
|
if (NULL != deposit_confirmation->job)
|
|
|
|
|
{
|
|
|
|
|
GNUNET_CURL_job_cancel (deposit_confirmation->job);
|
|
|
|
|
deposit_confirmation->job = NULL;
|
|
|
|
|
}
|
|
|
|
|
GNUNET_free (deposit_confirmation->url);
|
2019-05-23 20:46:51 +02:00
|
|
|
|
TALER_curl_easy_post_finished (&deposit_confirmation->ctx);
|
2018-10-22 16:00:06 +02:00
|
|
|
|
GNUNET_free (deposit_confirmation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* end of auditor_api_deposit_confirmation.c */
|