commit 2abe6e1e38289b00e6b9abdd181fa2a721d51573 parent 09921cbb0bcea8c0d765a1d15b516f55d0918006 Author: Marcello Stanisci <marcello.stanisci@inria.fr> Date: Wed, 4 May 2016 14:06:24 +0200 Merge branch 'master' of ssh://taler.net/var/git/merchant Diffstat:
19 files changed, 158 insertions(+), 906 deletions(-)
diff --git a/Makefile.am b/Makefile.am @@ -2,7 +2,7 @@ SUBDIRS = src copylib examples ACLOCAL_AMFLAGS = -I m4 -EXTRA_DIST = AUTHORS COPYING.GPL COPING.AGPL COPYING.LGPL +EXTRA_DIST = AUTHORS COPYING.GPL COPYING.AGPL COPYING.LGPL app: mkdir -p $(PACKAGE)-frontend-$(VERSION)-app diff --git a/src/Makefile.am b/src/Makefile.am @@ -1,3 +1,3 @@ # This Makefile is in the public domain AM_CPPFLAGS = -I$(top_srcdir)/src/include -SUBDIRS = include backenddb backend +SUBDIRS = include backenddb backend lib diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am @@ -6,6 +6,9 @@ pkgcfgdir = $(prefix)/share/taler/config.d/ pkgcfg_DATA = \ merchant.conf +EXTRA_DIST = \ + $(pkgcfg_DATA) + bin_PROGRAMS = \ taler-merchant-httpd diff --git a/src/backenddb/Makefile.am b/src/backenddb/Makefile.am @@ -60,3 +60,6 @@ test_merchantdb_postgres_LDADD = \ TESTS = \ test-merchantdb-postgres + +EXTRA_DIST = \ + test-merchantdb-postgres.conf diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c @@ -238,7 +238,7 @@ postgres_check_payment(void *cls, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not check if contract %llu is in DB: %s\n", - transaction_id, + (unsigned long long) transaction_id, sqlstate); PQclear (res); return GNUNET_SYSERR; diff --git a/src/include/Makefile.am b/src/include/Makefile.am @@ -6,4 +6,5 @@ talerincludedir = $(includedir)/taler talerinclude_HEADERS = \ taler_merchantdb_lib.h \ + taler_merchantdb_plugin.h \ taler_merchant_service.h diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am @@ -52,4 +52,7 @@ test_merchant_api_LDADD = \ -ljansson EXTRA_DIST = \ - test_merchant.conf + test_merchant_api.conf \ + test_merchant_api_home/.local/share/taler/exchange/offline-keys/master.priv \ + test_merchant_api_home/.config/taler/merchant/wire/test.json \ + test_merchant.priv diff --git a/src/lib/merchant_api_context.c b/src/lib/merchant_api_context.c @@ -1,536 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2014, 2015, 2016 GNUnet e.V. - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU Lesser General Public License as published by the Free Software - Foundation; either version 2.1, 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 Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License along with - TALER; see the file COPYING.LGPL. If not, If not, see - <http://www.gnu.org/licenses/> -*/ -/** - * @file merchant-lib/merchant_api_context.c - * @brief Implementation of the context part of the merchant's HTTP API - * @author Sree Harsha Totakura <sreeharsha@totakura.in> - * @author Christian Grothoff - */ -#include "platform.h" -#include <curl/curl.h> -#include "taler_merchant_service.h" -#include "merchant_api_context.h" - - -/** - * Log error related to CURL operations. - * - * @param type log level - * @param function which function failed to run - * @param code what was the curl error code - */ -#define CURL_STRERROR(type, function, code) \ - GNUNET_log (type, \ - "Curl function `%s' has failed at `%s:%d' with error: %s\n", \ - function, __FILE__, __LINE__, curl_easy_strerror (code)); - -/** - * Print JSON parsing related error information - */ -#define JSON_WARN(error) \ - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, \ - "JSON parsing failed at %s:%u: %s (%s)\n", \ - __FILE__, __LINE__, error.text, error.source) - - -/** - * Failsafe flag. Raised if our constructor fails to initialize - * the Curl library. - */ -static int TALER_MERCHANT_curl_fail; - - -/** - * Jobs are CURL requests running within a `struct TALER_MERCHANT_Context`. - */ -struct MAC_Job -{ - - /** - * We keep jobs in a DLL. - */ - struct MAC_Job *next; - - /** - * We keep jobs in a DLL. - */ - struct MAC_Job *prev; - - /** - * Easy handle of the job. - */ - CURL *easy_handle; - - /** - * Context this job runs in. - */ - struct TALER_MERCHANT_Context *ctx; - - /** - * Function to call upon completion. - */ - MAC_JobCompletionCallback jcc; - - /** - * Closure for @e jcc. - */ - void *jcc_cls; - -}; - - -/** - * Context - */ -struct TALER_MERCHANT_Context -{ - /** - * Curl multi handle - */ - CURLM *multi; - - /** - * Curl share handle - */ - CURLSH *share; - - /** - * We keep jobs in a DLL. - */ - struct MAC_Job *jobs_head; - - /** - * We keep jobs in a DLL. - */ - struct MAC_Job *jobs_tail; - - /** - * HTTP header "application/json", created once and used - * for all requests that need it. - */ - struct curl_slist *json_header; - -}; - - -/** - * Initialise this library. This function should be called before using any of - * the following functions. - * - * @return library context - */ -struct TALER_MERCHANT_Context * -TALER_MERCHANT_init () -{ - struct TALER_MERCHANT_Context *ctx; - CURLM *multi; - CURLSH *share; - - if (TALER_MERCHANT_curl_fail) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Curl was not initialised properly\n"); - return NULL; - } - if (NULL == (multi = curl_multi_init ())) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to create a Curl multi handle\n"); - return NULL; - } - if (NULL == (share = curl_share_init ())) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to create a Curl share handle\n"); - return NULL; - } - ctx = GNUNET_new (struct TALER_MERCHANT_Context); - ctx->multi = multi; - ctx->share = share; - GNUNET_assert (NULL != (ctx->json_header = - curl_slist_append (NULL, - "Content-Type: application/json"))); - return ctx; -} - - -/** - * Schedule a CURL request to be executed and call the given @a jcc - * upon its completion. Note that the context will make use of the - * CURLOPT_PRIVATE facility of the CURL @a eh. Applications can - * instead use #MAC_easy_to_closure to extract the @a jcc_cls argument - * from a valid @a eh afterwards. - * - * This function modifies the CURL handle to add the - * "Content-Type: application/json" header if @a add_json is set. - * - * @param ctx context to execute the job in - * @param eh curl easy handle for the request, will - * be executed AND cleaned up - * @param add_json add "application/json" content type header - * @param jcc callback to invoke upon completion - * @param jcc_cls closure for @a jcc - */ -struct MAC_Job * -MAC_job_add (struct TALER_MERCHANT_Context *ctx, - CURL *eh, - int add_json, - MAC_JobCompletionCallback jcc, - void *jcc_cls) -{ - struct MAC_Job *job; - - if (GNUNET_YES == add_json) - GNUNET_assert (CURLE_OK == - curl_easy_setopt (eh, - CURLOPT_HTTPHEADER, - ctx->json_header)); - - job = GNUNET_new (struct MAC_Job); - job->easy_handle = eh; - job->ctx = ctx; - job->jcc = jcc; - job->jcc_cls = jcc_cls; - GNUNET_CONTAINER_DLL_insert (ctx->jobs_head, - ctx->jobs_tail, - job); - GNUNET_assert (CURLE_OK == - curl_easy_setopt (eh, - CURLOPT_PRIVATE, - job)); - GNUNET_assert (CURLE_OK == - curl_easy_setopt (eh, - CURLOPT_SHARE, - ctx->share)); - GNUNET_assert (CURLM_OK == - curl_multi_add_handle (ctx->multi, - eh)); - return job; -} - - -/** - * Obtain the `jcc_cls` argument from an `eh` that was - * given to #MAC_job_add(). - * - * @param eh easy handle that was used - * @return the `jcc_cls` that was given to #MAC_job_add(). - */ -void * -MAC_easy_to_closure (CURL *eh) -{ - struct MAC_Job *job; - - GNUNET_assert (CURLE_OK == - curl_easy_getinfo (eh, - CURLINFO_PRIVATE, - (char **) &job)); - return job->jcc_cls; -} - - -/** - * Cancel a job. Must only be called before the job completion - * callback is called for the respective job. - * - * @param job job to cancel - */ -void -MAC_job_cancel (struct MAC_Job *job) -{ - struct TALER_MERCHANT_Context *ctx = job->ctx; - - GNUNET_CONTAINER_DLL_remove (ctx->jobs_head, - ctx->jobs_tail, - job); - GNUNET_assert (CURLM_OK == - curl_multi_remove_handle (ctx->multi, - job->easy_handle)); - curl_easy_cleanup (job->easy_handle); - GNUNET_free (job); -} - - -/** - * Run the main event loop for the Taler interaction. - * - * @param ctx the library context - */ -void -TALER_MERCHANT_perform (struct TALER_MERCHANT_Context *ctx) -{ - CURLMsg *cmsg; - struct MAC_Job *job; - int n_running; - int n_completed; - - (void) curl_multi_perform (ctx->multi, - &n_running); - while (NULL != (cmsg = curl_multi_info_read (ctx->multi, - &n_completed))) - { - /* Only documented return value is CURLMSG_DONE */ - GNUNET_break (CURLMSG_DONE == cmsg->msg); - GNUNET_assert (CURLE_OK == - curl_easy_getinfo (cmsg->easy_handle, - CURLINFO_PRIVATE, - (char *) &job)); - GNUNET_assert (job->ctx == ctx); - job->jcc (job->jcc_cls, - cmsg->easy_handle); - MAC_job_cancel (job); - } -} - - -/** - * Obtain the information for a select() call to wait until - * #TALER_MERCHANT_perform() is ready again. Note that calling - * any other TALER_MERCHANT-API may also imply that the library - * is again ready for #TALER_MERCHANT_perform(). - * - * Basically, a client should use this API to prepare for select(), - * then block on select(), then call #TALER_MERCHANT_perform() and then - * start again until the work with the context is done. - * - * This function will NOT zero out the sets and assumes that @a max_fd - * and @a timeout are already set to minimal applicable values. It is - * safe to give this API FD-sets and @a max_fd and @a timeout that are - * already initialized to some other descriptors that need to go into - * the select() call. - * - * @param ctx context to get the event loop information for - * @param read_fd_set will be set for any pending read operations - * @param write_fd_set will be set for any pending write operations - * @param except_fd_set is here because curl_multi_fdset() has this argument - * @param max_fd set to the highest FD included in any set; - * if the existing sets have no FDs in it, the initial - * value should be "-1". (Note that `max_fd + 1` will need - * to be passed to select().) - * @param timeout set to the timeout in milliseconds (!); -1 means - * no timeout (NULL, blocking forever is OK), 0 means to - * proceed immediately with #TALER_MERCHANT_perform(). - */ -void -TALER_MERCHANT_get_select_info (struct TALER_MERCHANT_Context *ctx, - fd_set *read_fd_set, - fd_set *write_fd_set, - fd_set *except_fd_set, - int *max_fd, - long *timeout) -{ - long to; - int m; - - m = -1; - GNUNET_assert (CURLM_OK == - curl_multi_fdset (ctx->multi, - read_fd_set, - write_fd_set, - except_fd_set, - &m)); - *max_fd = GNUNET_MAX (m, *max_fd); - to = *timeout; - GNUNET_assert (CURLM_OK == - curl_multi_timeout (ctx->multi, - &to)); - /* Only if what we got back from curl is smaller than what we - already had (-1 == infinity!), then update timeout */ - if ( (to < *timeout) && - (-1 != to) ) - *timeout = to; - if ( (-1 == (*timeout)) && - (NULL != ctx->jobs_head) ) - *timeout = 1000 * 60 * 5; /* curl is not always good about giving timeouts */ -} - - -/** - * Cleanup library initialisation resources. This function should be called - * after using this library to cleanup the resources occupied during library's - * initialisation. - * - * @param ctx the library context - */ -void -TALER_MERCHANT_fini (struct TALER_MERCHANT_Context *ctx) -{ - /* all jobs must have been cancelled at this time, assert this */ - GNUNET_assert (NULL == ctx->jobs_head); - curl_share_cleanup (ctx->share); - curl_multi_cleanup (ctx->multi); - curl_slist_free_all (ctx->json_header); - GNUNET_free (ctx); -} - - -/** - * Callback used when downloading the reply to an HTTP request. - * Just appends all of the data to the `buf` in the - * `struct MAC_DownloadBuffer` for further processing. The size of - * the download is limited to #GNUNET_MAX_MALLOC_CHECKED, if - * the download exceeds this size, we abort with an error. - * - * @param bufptr data downloaded via HTTP - * @param size size of an item in @a bufptr - * @param nitems number of items in @a bufptr - * @param cls the `struct KeysRequest` - * @return number of bytes processed from @a bufptr - */ -size_t -MAC_download_cb (char *bufptr, - size_t size, - size_t nitems, - void *cls) -{ - struct MAC_DownloadBuffer *db = cls; - size_t msize; - void *buf; - - if (0 == size * nitems) - { - /* Nothing (left) to do */ - return 0; - } - msize = size * nitems; - if ( (msize + db->buf_size) >= GNUNET_MAX_MALLOC_CHECKED) - { - db->eno = ENOMEM; - return 0; /* signals an error to curl */ - } - db->buf = GNUNET_realloc (db->buf, - db->buf_size + msize); - buf = db->buf + db->buf_size; - memcpy (buf, bufptr, msize); - db->buf_size += msize; - return msize; -} - - -/** - * Obtain information about the final result about the - * HTTP download. If the download was successful, parses - * the JSON in the @a db and returns it. Also returns - * the HTTP @a response_code. If the download failed, - * the return value is NULL. The response code is set - * in any case, on download errors to zero. - * - * Calling this function also cleans up @a db. - * - * @param db download buffer - * @param eh CURL handle (to get the response code) - * @param[out] response_code set to the HTTP response code - * (or zero if we aborted the download, i.e. - * because the response was too big, or if - * the JSON we received was malformed). - * @return NULL if downloading a JSON reply failed - */ -json_t * -MAC_download_get_result (struct MAC_DownloadBuffer *db, - CURL *eh, - long *response_code) -{ - json_t *json; - json_error_t error; - char *ct; - - if ( (CURLE_OK != - curl_easy_getinfo (eh, - CURLINFO_CONTENT_TYPE, - &ct)) || - (NULL == ct) || - (0 != strcasecmp (ct, - "application/json")) ) - { - /* No content type or explicitly not JSON, refuse to parse - (but keep response code) */ - if (CURLE_OK != - curl_easy_getinfo (eh, - CURLINFO_RESPONSE_CODE, - response_code)) - { - /* unexpected error... */ - GNUNET_break (0); - *response_code = 0; - } - return NULL; - } - - json = NULL; - if (0 == db->eno) - { - json = json_loadb (db->buf, - db->buf_size, - JSON_REJECT_DUPLICATES | JSON_DISABLE_EOF_CHECK, - &error); - if (NULL == json) - { - JSON_WARN (error); - *response_code = 0; - } - } - GNUNET_free_non_null (db->buf); - db->buf = NULL; - db->buf_size = 0; - if (NULL != json) - { - if (CURLE_OK != - curl_easy_getinfo (eh, - CURLINFO_RESPONSE_CODE, - response_code)) - { - /* unexpected error... */ - GNUNET_break (0); - *response_code = 0; - } - } - return json; -} - - -/** - * Initial global setup logic, specifically runs the Curl setup. - */ -__attribute__ ((constructor)) -void -TALER_MERCHANT_constructor__ (void) -{ - CURLcode ret; - - if (CURLE_OK != (ret = curl_global_init (CURL_GLOBAL_DEFAULT))) - { - CURL_STRERROR (GNUNET_ERROR_TYPE_ERROR, - "curl_global_init", - ret); - TALER_MERCHANT_curl_fail = 1; - } -} - - -/** - * Cleans up after us, specifically runs the Curl cleanup. - */ -__attribute__ ((destructor)) -void -TALER_MERCHANT_destructor__ (void) -{ - if (TALER_MERCHANT_curl_fail) - return; - curl_global_cleanup (); -} - -/* end of merchant_api_context.c */ diff --git a/src/lib/merchant_api_context.h b/src/lib/merchant_api_context.h @@ -1,169 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2014, 2015, 2016 GNUnet e.V. - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU Lesser 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 Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License along with - TALER; see the file COPYING.LGPL. If not, If not, see - <http://www.gnu.org/licenses/> -*/ -/** - * @file merchant-lib/merchant_api_context.h - * @brief Internal interface to the context part of the merchant's HTTP API - * @author Sree Harsha Totakura <sreeharsha@totakura.in> - * @author Christian Grothoff - */ -#include "platform.h" -#include <curl/curl.h> -#include <gnunet/gnunet_util_lib.h> -#include "taler_merchant_service.h" -#include <taler/taler_signatures.h> - - -/** - * Entry in the context's job queue. - */ -struct MAC_Job; - -/** - * Function to call upon completion of a job. - * - * @param cls closure - * @param eh original easy handle (for inspection) - */ -typedef void -(*MAC_JobCompletionCallback)(void *cls, - CURL *eh); - - -/** - * Schedule a CURL request to be executed and call the given @a jcc - * upon its completion. Note that the context will make use of the - * CURLOPT_PRIVATE facility of the CURL @a eh. Applications can - * instead use #MAC_easy_to_closure to extract the @a jcc_cls argument - * from a valid @a eh afterwards. - * - * This function modifies the CURL handle to add the - * "Content-Type: application/json" header if @a add_json is set. - * - * @param ctx context to execute the job in - * @param eh curl easy handle for the request, will - * be executed AND cleaned up - * @param add_json add "application/json" content type header - * @param jcc callback to invoke upon completion - * @param jcc_cls closure for @a jcc - */ -struct MAC_Job * -MAC_job_add (struct TALER_MERCHANT_Context *ctx, - CURL *eh, - int add_json, - MAC_JobCompletionCallback jcc, - void *jcc_cls); - - -/** - * Obtain the `jcc_cls` argument from an `eh` that was - * given to #MAC_job_add(). - * - * @param eh easy handle that was used - * @return the `jcc_cls` that was given to #MAC_job_add(). - */ -void * -MAC_easy_to_closure (CURL *eh); - - -/** - * Cancel a job. Must only be called before the job completion - * callback is called for the respective job. - * - * @param job job to cancel - */ -void -MAC_job_cancel (struct MAC_Job *job); - - -/** - * @brief Buffer data structure we use to buffer the HTTP download - * before giving it to the JSON parser. - */ -struct MAC_DownloadBuffer -{ - - /** - * Download buffer - */ - void *buf; - - /** - * The size of the download buffer - */ - size_t buf_size; - - /** - * Error code (based on libc errno) if we failed to download - * (i.e. response too large). - */ - int eno; - -}; - - -/** - * Callback used when downloading the reply to an HTTP request. - * Just appends all of the data to the `buf` in the - * `struct MAC_DownloadBuffer` for further processing. The size of - * the download is limited to #GNUNET_MAX_MALLOC_CHECKED, if - * the download exceeds this size, we abort with an error. - * - * Should be used by the various routines as the - * CURLOPT_WRITEFUNCTION. A `struct MAC_DownloadBuffer` needs to be - * passed to the CURLOPT_WRITEDATA. - * - * Afterwards, `eno` needs to be checked to ensure that the download - * completed correctly. - * - * @param bufptr data downloaded via HTTP - * @param size size of an item in @a bufptr - * @param nitems number of items in @a bufptr - * @param cls the `struct KeysRequest` - * @return number of bytes processed from @a bufptr - */ -size_t -MAC_download_cb (char *bufptr, - size_t size, - size_t nitems, - void *cls); - - -/** - * Obtain information about the final result about the - * HTTP download. If the download was successful, parses - * the JSON in the @a db and returns it. Also returns - * the HTTP @a response_code. If the download failed, - * the return value is NULL. The response code is set - * in any case, on download errors to zero. - * - * Calling this function also cleans up @a db. - * - * @param db download buffer - * @param eh CURL handle (to get the response code) - * @param[out] response_code set to the HTTP response code - * (or zero if we aborted the download, i.e. - * because the response was too big, or if - * the JSON we received was malformed). - * @return NULL if downloading a JSON reply failed - */ -json_t * -MAC_download_get_result (struct MAC_DownloadBuffer *db, - CURL *eh, - long *response_code); - - -/* end of merchant_api_context.h */ diff --git a/src/lib/merchant_api_pay.c b/src/lib/merchant_api_pay.c @@ -114,7 +114,7 @@ handle_pay_finished (void *cls, /* unexpected response code */ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unexpected response code %u\n", - response_code); + (unsigned int) response_code); GNUNET_break (0); response_code = 0; break; diff --git a/src/lib/test-exchange-home/config/exchange-common.conf b/src/lib/test-exchange-home/config/exchange-common.conf @@ -1,30 +0,0 @@ -[exchange] -# Currency supported by the exchange (can only be one) -CURRENCY = EUR - -# Wire format supported by the exchange -# We use 'test' for testing of the actual -# coin operations, and 'sepa' to test SEPA-specific routines. -WIREFORMAT = test sepa - -# HTTP port the exchange listens to -PORT = 8081 - -# Master public key used to sign the exchange's various keys -MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG - -# How to access our database -DB = postgres - -# Is this is a testcase, use transient DB actions? -TESTRUN = YES - -[exchangedb-postgres] - -DB_CONN_STR = "postgres:///talercheck" - -[exchange-wire-sepa] -SEPA_RESPONSE_FILE = "test-exchange-home/sepa.json" - -[exchange-wire-test] -REDIRECT_URL = "http://www.taler.net/" diff --git a/src/lib/test-exchange-home/config/exchange-keyup.conf b/src/lib/test-exchange-home/config/exchange-keyup.conf @@ -1,86 +0,0 @@ -[exchange_keys] - -# how long is one signkey valid? -signkey_duration = 4 weeks - -# how long are the signatures with the signkey valid? -legal_duration = 2 years - -# how long do we generate denomination and signing keys -# ahead of time? -lookahead_sign = 32 weeks 1 day - -# how long do we provide to clients denomination and signing keys -# ahead of time? -lookahead_provide = 4 weeks 1 day - - -# Coin definitions are detected because the section -# name begins with "coin_". The rest of the -# name is free, but of course following the convention -# of "coin_$CURRENCY[_$SUBUNIT]_$VALUE" make sense. -[coin_eur_ct_1] -value = EUR:0.01 -duration_overlap = 5 minutes -duration_withdraw = 7 days -duration_spend = 2 years -duration_legal = 3 years -fee_withdraw = EUR:0.00 -fee_deposit = EUR:0.00 -fee_refresh = EUR:0.01 -rsa_keysize = 1024 - -[coin_eur_ct_10] -value = EUR:0.10 -duration_overlap = 5 minutes -duration_withdraw = 7 days -duration_spend = 2 years -duration_legal = 3 years -fee_withdraw = EUR:0.01 -fee_deposit = EUR:0.01 -fee_refresh = EUR:0.03 -rsa_keysize = 1024 - -[coin_eur_1] -value = EUR:1 -duration_overlap = 5 minutes -duration_withdraw = 7 days -duration_spend = 2 years -duration_legal = 3 years -fee_withdraw = EUR:0.01 -fee_deposit = EUR:0.01 -fee_refresh = EUR:0.03 -rsa_keysize = 1024 - -[coin_eur_5] -value = EUR:5 -duration_overlap = 5 minutes -duration_withdraw = 7 days -duration_spend = 2 years -duration_legal = 3 years -fee_withdraw = EUR:0.01 -fee_deposit = EUR:0.01 -fee_refresh = EUR:0.03 -rsa_keysize = 1024 - -[coin_eur_10] -value = EUR:10 -duration_overlap = 5 minutes -duration_withdraw = 7 days -duration_spend = 2 years -duration_legal = 3 years -fee_withdraw = EUR:0.01 -fee_deposit = EUR:0.01 -fee_refresh = EUR:0.03 -rsa_keysize = 1024 - -[coin_eur_1000] -value = EUR:1000 -duration_overlap = 5 minutes -duration_withdraw = 7 days -duration_spend = 2 years -duration_legal = 3 years -fee_withdraw = EUR:0.01 -fee_deposit = EUR:0.01 -fee_refresh = EUR:0.03 -rsa_keysize = 2048 diff --git a/src/lib/test-exchange-home/master.priv b/src/lib/test-exchange-home/master.priv @@ -1 +0,0 @@ -p^-33XX!\0qmU_ -\ No newline at end of file diff --git a/src/lib/test-exchange-home/sepa.json b/src/lib/test-exchange-home/sepa.json @@ -1,6 +0,0 @@ -{ - "receiver_name": "Max Mustermann", - "iban": "DE89370400440532013000", - "bic": "COBADEFF370", - "sig": "8M5YJXM68PRAXKH76HYEBCJW657B23JA0RFGNDMZK2379YZMT626H1BN89KC0M1KJBWGYEN5Z763Q0Y7MCTZQ6BPPT7D9KFCTW60C10" -} -\ No newline at end of file diff --git a/src/lib/test_merchant.conf b/src/lib/test_merchant.conf @@ -1,55 +0,0 @@ -# Sample configuration file for a merchant. -[merchant] - -# Which port do we run the backend on? (HTTP server) -PORT = 8082 - -# FIXME: is this one used? -HOSTNAME = localhost - -# Where is our private key? -KEYFILE = test_merchant.priv - -# What currency does this backend accept? -CURRENCY = EUR - -# FIXME: to be revised -TRUSTED_EXCHANGES = taler - -# How quickly do we want the exchange to send us our money? -# Used only if the frontend does not specify a value. -# FIXME: EDATE is a bit short, 'execution_delay'? -EDATE = 3 week - -# Which plugin (backend) do we use for the DB. -DB = postgres - -[exchange-taler] -URI = http://localhost:8081/ -MASTER_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG - -# Auditors must be in sections "auditor-", the rest of the section -# name could be anything. -[auditor-ezb] -# Informal name of the auditor. Just for the user. -NAME = European Central Bank - -# URI of the auditor (especially for in the future, when the -# auditor offers an automated issue reporting system). -# Not really used today. -URI = http://taler.ezb.eu/ - -# This is the important bit: the signing key of the auditor. -PUBLIC_KEY = 9QXF7XY7E9VPV47B5Z806NDFSX2VJ79SVHHD29QEQ3BG31ANHZ60 - -# This specifies which database we use. -[merchantdb-postgres] -CONFIG = postgres:///talercheck - -# "wire-" sections include wire details, here for SEPA. -[wire-sepa] -IBAN = DE67830654080004822650 -NAME = GNUNET E.V -BIC = GENODEF1SRL -SALT = 17919252168512238964 -ADDRESS = "Garching" diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c @@ -789,9 +789,9 @@ find_pk (const struct TALER_EXCHANGE_Keys *keys, GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Have denomination key for `%s', but with wrong expiration range %llu vs [%llu,%llu)\n", str, - now.abs_value_us, - pk->valid_from.abs_value_us, - pk->withdraw_valid_until.abs_value_us); + (unsigned long long) now.abs_value_us, + (unsigned long long) pk->valid_from.abs_value_us, + (unsigned long long) pk->withdraw_valid_until.abs_value_us); GNUNET_free (str); return NULL; } @@ -902,7 +902,6 @@ interpreter_run (void *cls) fail (is); return; } - trigger_context_task (); return; case OC_WITHDRAW_STATUS: GNUNET_assert (NULL != @@ -918,7 +917,6 @@ interpreter_run (void *cls) &reserve_pub, &reserve_status_cb, is); - trigger_context_task (); return; case OC_WITHDRAW_SIGN: GNUNET_assert (NULL != @@ -978,7 +976,6 @@ interpreter_run (void *cls) fail (is); return; } - trigger_context_task (); return; case OC_PAY: { @@ -1130,7 +1127,6 @@ interpreter_run (void *cls) fail (is); return; } - trigger_context_task (); return; default: GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -1324,7 +1320,7 @@ run (void *cls) { .oc = OC_ADMIN_ADD_INCOMING, .label = "create-reserve-1", .expected_response_code = MHD_HTTP_OK, - .details.admin_add_incoming.wire = "{ \"type\":\"TEST\", \"bank\":\"source bank\", \"account\":42 }", + .details.pay.wire_details = "{ \"type\":\"test\", \"bank_uri\":\"http://localhost/\", \"account\":62 }", .details.admin_add_incoming.amount = "EUR:5.01" }, /* Withdraw a 5 EUR coin, at fee of 1 ct */ { .oc = OC_WITHDRAW_SIGN, @@ -1348,7 +1344,7 @@ run (void *cls) .details.pay.coin_ref = "withdraw-coin-1", .details.pay.amount_with_fee = "EUR:5", .details.pay.amount_without_fee = "EUR:4.99", - .details.pay.wire_details = "{ \"type\":\"TEST\", \"bank\":\"dest bank\", \"account\":42 }", + .details.pay.wire_details = "{ \"type\":\"test\", \"bank_uri\":\"http://localhost/\", \"account\":62 }", .details.pay.contract = "{ \"items\":[ {\"name\":\"ice cream\", \"value\":1} ] }", .details.pay.transaction_id = 1 }, @@ -1361,7 +1357,7 @@ run (void *cls) .details.pay.coin_ref = "withdraw-coin-1", .details.pay.amount_with_fee = "EUR:5", .details.pay.amount_without_fee = "EUR:4.99", - .details.pay.wire_details = "{ \"type\":\"TEST\", \"bank\":\"dest bank\", \"account\":43 }", + .details.pay.wire_details = "{ \"type\":\"test\", \"bank_uri\":\"http://localhost/\", \"account\":62 }", .details.pay.contract = "{ \"items\":[{ \"name\":\"ice cream\", \"value\":1} ] }", .details.pay.transaction_id = 1 }, /* Try to double-spend the 5 EUR coin at the same merchant (but different @@ -1374,7 +1370,7 @@ run (void *cls) .details.pay.coin_ref = "withdraw-coin-1", .details.pay.amount_with_fee = "EUR:5", .details.pay.amount_without_fee = "EUR:4.99", - .details.pay.wire_details = "{ \"type\":\"TEST\", \"bank\":\"dest bank\", \"account\":42 }", + .details.pay.wire_details = "{ \"type\":\"test\", \"bank_uri\":\"http://localhost/\", \"account\":62 }", .details.pay.contract = "{ \"items\":[ {\"name\":\"ice cream\", \"value\":1} ] }", .details.pay.transaction_id = 2 }, /* Try to double-spend the 5 EUR coin at the same merchant (but different @@ -1387,7 +1383,7 @@ run (void *cls) .details.pay.coin_ref = "withdraw-coin-1", .details.pay.amount_with_fee = "EUR:5", .details.pay.amount_without_fee = "EUR:4.99", - .details.pay.wire_details = "{ \"type\":\"TEST\", \"bank\":\"dest bank\", \"account\":42 }", + .details.pay.wire_details = "{ \"type\":\"test\", \"bank_uri\":\"http://localhost/\", \"account\":62 }", .details.pay.contract = "{ \"items\":[ {\"name\":\"ice cream\", \"value\":2} ] }", .details.pay.transaction_id = 1 }, @@ -1433,6 +1429,8 @@ main (int argc, struct GNUNET_OS_Process *exchanged; struct GNUNET_OS_Process *merchantd; + unsetenv ("XDG_DATA_HOME"); + unsetenv ("XDG_CONFIG_HOME"); GNUNET_log_setup ("test-merchant-api", "WARNING", NULL); @@ -1446,8 +1444,7 @@ main (int argc, NULL, NULL, NULL, "taler-exchange-keyup", "taler-exchange-keyup", - "-d", "test-exchange-home", - "-m", "test-exchange-home/master.priv", + "-c", "test_merchant_api.conf", NULL); GNUNET_OS_process_wait (proc); GNUNET_OS_process_destroy (proc); @@ -1456,7 +1453,7 @@ main (int argc, NULL, NULL, NULL, "taler-exchange-httpd", "taler-exchange-httpd", - "-d", "test-exchange-home", + "-c", "test_merchant_api.conf", NULL); /* give child time to start and bind against the socket */ fprintf (stderr, "Waiting for taler-exchange-httpd to be ready"); @@ -1472,7 +1469,7 @@ main (int argc, NULL, NULL, NULL, "taler-merchant-httpd", "taler-merchant-httpd", - "-c", "test_merchant.conf", + "-c", "test_merchant_api.conf", NULL); /* give child time to start and bind against the socket */ fprintf (stderr, "Waiting for taler-merchant-httpd to be ready"); diff --git a/src/lib/test_merchant_api.conf b/src/lib/test_merchant_api.conf @@ -0,0 +1,123 @@ +# This file is in the public domain. +# +[PATHS] +# Persistant data storage for the testcase +TALER_TEST_HOME = test_merchant_api_home/ + +[merchant] + +# Which port do we run the backend on? (HTTP server) +PORT = 8082 + +# FIXME: is this one used? +HOSTNAME = localhost + +# Where is our private key? +KEYFILE = test_merchant.priv + +# What currency does this backend accept? +CURRENCY = EUR + +# How quickly do we want the exchange to send us our money? +# Used only if the frontend does not specify a value. +# FIXME: EDATE is a bit short, 'execution_delay'? +EDATE = 3 week + +# Which plugin (backend) do we use for the DB. +DB = postgres + +# Which wireformat do we use? +WIREFORMAT = test + +[exchange-taler] +URI = http://localhost:8081/ +MASTER_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG + + + +# Auditors must be in sections "auditor-", the rest of the section +# name could be anything. +[auditor-ezb] +# Informal name of the auditor. Just for the user. +NAME = European Central Bank + +# URI of the auditor (especially for in the future, when the +# auditor offers an automated issue reporting system). +# Not really used today. +URI = http://taler.ezb.eu/ + +# This is the important bit: the signing key of the auditor. +PUBLIC_KEY = 9QXF7XY7E9VPV47B5Z806NDFSX2VJ79SVHHD29QEQ3BG31ANHZ60 + +# This specifies which database we use. +[merchantdb-postgres] +CONFIG = postgres:///talercheck + +# "wire-" sections include wire details, here for SEPA. +[wire-sepa] +IBAN = DE67830654080004822650 +NAME = GNUNET E.V +BIC = GENODEF1SRL +SALT = 17919252168512238964 +ADDRESS = "Garching" + + +[exchange] +# How to access our database +DB = postgres +# HTTP port the exchange listens to +PORT = 8081 +# Wire format supported by the exchange +WIREFORMAT = test +# Our public key +MASTER_PUBLIC_KEY = T1VVFQZZARQ1CMF4BN58EE7SKTW5AV2BS18S87ZEGYS4S29J6DNG + +[exchangedb-postgres] +DB_CONN_STR = "postgres:///talercheck" + +[exchange-wire-incoming-test] +# This is the response we give out for the /wire request. It provides +# wallets with the bank information for transfers to the exchange. +TEST_RESPONSE_FILE = ${TALER_CONFIG_HOME}/test.json + +[exchange-wire-outgoing-test] +# What is the main website of the bank? +BANK_URI = "http://localhost:8082/" +# Into which account at the 'bank' should (incoming) wire transfers be made? +BANK_ACCOUNT_NUMBER = 2 + +[coin_eur_ct_1] +value = EUR:0.01 +duration_overlap = 5 minutes +duration_withdraw = 7 days +duration_spend = 2 years +duration_legal = 3 years +fee_withdraw = EUR:0.00 +fee_deposit = EUR:0.00 +fee_refresh = EUR:0.01 +fee_refund = EUR:0.01 +rsa_keysize = 1024 + +[coin_eur_ct_10] +value = EUR:0.10 +duration_overlap = 5 minutes +duration_withdraw = 7 days +duration_spend = 2 years +duration_legal = 3 years +fee_withdraw = EUR:0.01 +fee_deposit = EUR:0.01 +fee_refresh = EUR:0.03 +fee_refund = EUR:0.01 +rsa_keysize = 1024 + +[coin_eur_1] +value = EUR:1 +duration_overlap = 5 minutes +duration_withdraw = 7 days +duration_spend = 2 years +duration_legal = 3 years +fee_withdraw = EUR:0.01 +fee_deposit = EUR:0.01 +fee_refresh = EUR:0.03 +fee_refund = EUR:0.01 +rsa_keysize = 1024 diff --git a/src/lib/test_merchant_api_home/.config/taler/merchant/wire/test.json b/src/lib/test_merchant_api_home/.config/taler/merchant/wire/test.json @@ -0,0 +1,5 @@ +{ + "type":"test", + "bank_uri":"http://localhost/", + "account_number":62 +} diff --git a/src/lib/test_merchant_api_home/.local/share/taler/exchange/offline-keys/master.priv b/src/lib/test_merchant_api_home/.local/share/taler/exchange/offline-keys/master.priv @@ -0,0 +1 @@ +k;d_U}A.w"!Gv_m"_ +\ No newline at end of file