towards fixing #5447
This commit is contained in:
parent
2a01aaa917
commit
12123a7aed
@ -24,10 +24,10 @@ EXTRA_DIST = \
|
||||
|
||||
SUBDIRS = include util wire json $(PQ_DIR) $(BANK_LIB) wire-plugins exchangedb exchange exchange-tools auditordb auditor
|
||||
if HAVE_LIBCURL
|
||||
SUBDIRS += exchange-lib auditor-lib benchmark
|
||||
SUBDIRS += auditor-lib exchange-lib benchmark
|
||||
else
|
||||
if HAVE_LIBGNURL
|
||||
SUBDIRS += exchange-lib auditor-lib benchmark
|
||||
SUBDIRS += auditor-lib exchange-lib benchmark
|
||||
endif
|
||||
endif
|
||||
|
||||
|
@ -27,6 +27,7 @@ libtalerexchange_la_SOURCES = \
|
||||
exchange_api_track_transfer.c \
|
||||
exchange_api_wire.c
|
||||
libtalerexchange_la_LIBADD = \
|
||||
$(top_builddir)/src/auditor-lib/libtalerauditor.la \
|
||||
$(top_builddir)/src/json/libtalerjson.la \
|
||||
$(top_builddir)/src/util/libtalerutil.la \
|
||||
-lgnunetcurl \
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <gnunet/gnunet_json_lib.h>
|
||||
#include <gnunet/gnunet_curl_lib.h>
|
||||
#include "taler_json_lib.h"
|
||||
#include "taler_auditor_service.h"
|
||||
#include "taler_exchange_service.h"
|
||||
#include "exchange_api_handle.h"
|
||||
#include "taler_signatures.h"
|
||||
@ -83,10 +84,29 @@ struct TALER_EXCHANGE_DepositHandle
|
||||
* Total value of the coin being transacted with.
|
||||
*/
|
||||
struct TALER_Amount coin_value;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Signature of functions called with the result from our call to the
|
||||
* auditor's /deposit-confirmation handler.
|
||||
*
|
||||
* @param cls closure
|
||||
* @param http_status HTTP status code, 200 on success
|
||||
* @param ec taler protocol error status code, 0 on success
|
||||
* @param json raw json response
|
||||
*/
|
||||
static void
|
||||
acc_confirmation_cb (void *cls,
|
||||
unsigned int http_status,
|
||||
enum TALER_ErrorCode ec,
|
||||
const json_t *json)
|
||||
{
|
||||
/* FIXME: clean up state, some logging on errors! */
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Verify that the signature on the "200 OK" response
|
||||
* from the exchange is valid.
|
||||
@ -135,6 +155,37 @@ verify_deposit_signature_ok (const struct TALER_EXCHANGE_DepositHandle *dh,
|
||||
GNUNET_break_op (0);
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
if (0 /* #5447: replace with "for all auditors, if auditor selected for DC notification... */)
|
||||
{
|
||||
struct TALER_AUDITOR_DepositConfirmationHandle *dch;
|
||||
const struct TALER_EXCHANGE_SigningPublicKey *spk;
|
||||
struct TALER_Amount amount_without_fee;
|
||||
|
||||
spk = TALER_EXCHANGE_get_signing_key_details (key_state,
|
||||
exchange_pub);
|
||||
GNUNET_assert (NULL != spk);
|
||||
TALER_amount_ntoh (&amount_without_fee,
|
||||
&dh->depconf.amount_without_fee);
|
||||
dch = TALER_AUDITOR_deposit_confirmation (NULL /* FIXME: auditor */,
|
||||
&dh->depconf.h_wire,
|
||||
&dh->depconf.h_contract_terms,
|
||||
GNUNET_TIME_absolute_ntoh (dh->depconf.timestamp),
|
||||
GNUNET_TIME_absolute_ntoh (dh->depconf.refund_deadline),
|
||||
&amount_without_fee,
|
||||
&dh->depconf.coin_pub,
|
||||
&dh->depconf.merchant,
|
||||
exchange_pub,
|
||||
exchange_sig,
|
||||
&key_state->master_pub,
|
||||
spk->valid_from,
|
||||
spk->valid_until,
|
||||
spk->valid_legal,
|
||||
&spk->master_sig,
|
||||
&acc_confirmation_cb,
|
||||
NULL /* FIXME: context! */);
|
||||
}
|
||||
|
||||
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <gnunet/gnunet_curl_lib.h>
|
||||
#include "taler_json_lib.h"
|
||||
#include "taler_exchange_service.h"
|
||||
#include "taler_auditor_service.h"
|
||||
#include "taler_signatures.h"
|
||||
#include "exchange_api_handle.h"
|
||||
#include "curl_defaults.h"
|
||||
@ -90,6 +91,77 @@ enum ExchangeHandleState
|
||||
struct KeysRequest;
|
||||
|
||||
|
||||
/**
|
||||
* Entry in list of ongoing interactions with an auditor.
|
||||
*/
|
||||
struct AuditorInteractionEntry
|
||||
{
|
||||
/**
|
||||
* DLL entry.
|
||||
*/
|
||||
struct AuditorInteractionEntry *next;
|
||||
|
||||
/**
|
||||
* DLL entry.
|
||||
*/
|
||||
struct AuditorInteractionEntry *prev;
|
||||
|
||||
/**
|
||||
* Interaction state.
|
||||
*/
|
||||
struct TALER_AUDITOR_DepositConfirmationHandle *dch;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Entry in DLL of auditors used by an exchange.
|
||||
*/
|
||||
struct AuditorListEntry
|
||||
{
|
||||
/**
|
||||
* Next pointer of DLL.
|
||||
*/
|
||||
struct AuditorListEntry *next;
|
||||
|
||||
/**
|
||||
* Prev pointer of DLL.
|
||||
*/
|
||||
struct AuditorListEntry *prev;
|
||||
|
||||
/**
|
||||
* Base URL of the auditor.
|
||||
*/
|
||||
const char *auditor_url;
|
||||
|
||||
/**
|
||||
* Handle to the auditor.
|
||||
*/
|
||||
struct TALER_AUDITOR_Handle *ah;
|
||||
|
||||
/**
|
||||
* Head of DLL of interactions with this auditor.
|
||||
*/
|
||||
struct AuditorInteractionEntry *ai_head;
|
||||
|
||||
/**
|
||||
* Tail of DLL of interactions with this auditor.
|
||||
*/
|
||||
struct AuditorInteractionEntry *ai_tail;
|
||||
|
||||
/**
|
||||
* Public key of the auditor.
|
||||
*/
|
||||
struct TALER_AuditorPublicKeyP auditor_pub;
|
||||
|
||||
/**
|
||||
* Flag indicating that the auditor is available and that protocol
|
||||
* version compatibility is given.
|
||||
*/
|
||||
int is_up;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Handle to the exchange
|
||||
*/
|
||||
@ -133,6 +205,16 @@ struct TALER_EXCHANGE_Handle
|
||||
*/
|
||||
json_t *key_data_raw;
|
||||
|
||||
/**
|
||||
* Head of DLL of auditors of this exchange.
|
||||
*/
|
||||
struct AuditorListEntry *auditors_head;
|
||||
|
||||
/**
|
||||
* Tail of DLL of auditors of this exchange.
|
||||
*/
|
||||
struct AuditorListEntry *auditors_tail;
|
||||
|
||||
/**
|
||||
* Key data of the exchange, only valid if
|
||||
* @e handshake_complete is past stage #MHS_CERT.
|
||||
@ -152,8 +234,8 @@ struct TALER_EXCHANGE_Handle
|
||||
/**
|
||||
* Stage of the exchange's initialization routines.
|
||||
*/
|
||||
enum ExchangeHandleState state;
|
||||
|
||||
enum ExchangeHandleState state;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -188,6 +270,24 @@ struct KeysRequest
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Iterate over all available auditors for @a h, calling
|
||||
* @param ah and giving it a chance to start a deposit
|
||||
* confirmation interaction.
|
||||
*
|
||||
* @param h exchange to go over auditors for
|
||||
* @param ac function to call per auditor
|
||||
* @param ac_cls closure for @a ac
|
||||
*/
|
||||
void
|
||||
TEAH_get_auditors_for_dc (struct TALER_EXCHANGE_Handle *h,
|
||||
TEAH_AuditorCallback ac,
|
||||
void *ac_cls)
|
||||
{
|
||||
// FIXME!
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Release memory occupied by a keys request.
|
||||
* Note that this does not cancel the request
|
||||
@ -1541,6 +1641,30 @@ TALER_EXCHANGE_disconnect (struct TALER_EXCHANGE_Handle *exchange)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Lookup the given @a pub in @a keys.
|
||||
*
|
||||
* @param keys the exchange's key set
|
||||
* @param pub claimed current online signing key for the exchange
|
||||
* @return NULL if @a pub was not found
|
||||
*/
|
||||
const struct TALER_EXCHANGE_SigningPublicKey *
|
||||
TALER_EXCHANGE_get_signing_key_details (const struct TALER_EXCHANGE_Keys *keys,
|
||||
const struct TALER_ExchangePublicKeyP *pub)
|
||||
{
|
||||
for (unsigned int i=0;i<keys->num_sign_keys;i++)
|
||||
{
|
||||
struct TALER_EXCHANGE_SigningPublicKey *spk = &keys->sign_keys[i];
|
||||
|
||||
if (0 == memcmp (pub,
|
||||
&spk->key,
|
||||
sizeof (struct TALER_ExchangePublicKeyP)))
|
||||
return spk;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if the given @a pub is a the current signing key from the exchange
|
||||
* according to @a keys.
|
||||
@ -1567,6 +1691,7 @@ TALER_EXCHANGE_test_signing_key (const struct TALER_EXCHANGE_Keys *keys,
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get exchange's base URL.
|
||||
*
|
||||
|
@ -21,7 +21,39 @@
|
||||
*/
|
||||
#include "platform.h"
|
||||
#include <gnunet/gnunet_curl_lib.h>
|
||||
#include "taler_auditor_service.h"
|
||||
#include "taler_exchange_service.h"
|
||||
#include "taler_crypto_lib.h"
|
||||
|
||||
|
||||
/**
|
||||
* Function called for each auditor to give us a chance to possibly
|
||||
* launch a deposit confirmation interaction.
|
||||
*
|
||||
* @param cls closure
|
||||
* @param ah handle to the auditor
|
||||
* @param auditor_pub public key of the auditor
|
||||
* @return NULL if no deposit confirmation interaction was launched
|
||||
*/
|
||||
typedef struct TALER_AUDITOR_DepositConfirmationHandle *
|
||||
(*TEAH_AuditorCallback)(void *cls,
|
||||
struct TALER_AUDITOR_Handle *ah,
|
||||
const struct TALER_AuditorPublicKeyP *auditor_pub);
|
||||
|
||||
|
||||
/**
|
||||
* Iterate over all available auditors for @a h, calling
|
||||
* @param ah and giving it a chance to start a deposit
|
||||
* confirmation interaction.
|
||||
*
|
||||
* @param h exchange to go over auditors for
|
||||
* @param ac function to call per auditor
|
||||
* @param ac_cls closure for @a ac
|
||||
*/
|
||||
void
|
||||
TEAH_get_auditors_for_dc (struct TALER_EXCHANGE_Handle *h,
|
||||
TEAH_AuditorCallback ac,
|
||||
void *ac_cls);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -204,7 +204,7 @@ typedef void
|
||||
* @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 ep_legal_end when does @a exchange_pub legal validity end
|
||||
* @param master_sig master signature affirming validity of @a exchange_pub
|
||||
* @param cb the callback to call when a reply for this request is available
|
||||
* @param cb_cls closure for the above callback
|
||||
@ -225,7 +225,7 @@ TALER_AUDITOR_deposit_confirmation (struct TALER_AUDITOR_Handle *auditor,
|
||||
const struct TALER_MasterPublicKeyP *master_pub,
|
||||
struct GNUNET_TIME_Absolute ep_start,
|
||||
struct GNUNET_TIME_Absolute ep_expire,
|
||||
struct GNUNET_TIME_Absolute ep_end,
|
||||
struct GNUNET_TIME_Absolute ep_legal_end,
|
||||
const struct TALER_MasterSignatureP *master_sig,
|
||||
TALER_AUDITOR_DepositConfirmationResultCallback cb,
|
||||
void *cb_cls);
|
||||
|
@ -459,6 +459,18 @@ TALER_EXCHANGE_test_signing_key (const struct TALER_EXCHANGE_Keys *keys,
|
||||
const struct TALER_ExchangePublicKeyP *pub);
|
||||
|
||||
|
||||
/**
|
||||
* Lookup the given @a pub in @a keys.
|
||||
*
|
||||
* @param keys the exchange's key set
|
||||
* @param pub claimed current online signing key for the exchange
|
||||
* @return NULL if @a pub was not found
|
||||
*/
|
||||
const struct TALER_EXCHANGE_SigningPublicKey *
|
||||
TALER_EXCHANGE_get_signing_key_details (const struct TALER_EXCHANGE_Keys *keys,
|
||||
const struct TALER_ExchangePublicKeyP *pub);
|
||||
|
||||
|
||||
/**
|
||||
* Get exchange's base URL.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user