diff options
Diffstat (limited to 'src/exchange-lib')
| -rw-r--r-- | src/exchange-lib/Makefile.am | 4 | ||||
| -rw-r--r-- | src/exchange-lib/exchange_api_admin.c | 10 | ||||
| -rw-r--r-- | src/exchange-lib/exchange_api_deposit.c | 28 | ||||
| -rw-r--r-- | src/exchange-lib/exchange_api_deposit_wtid.c | 11 | ||||
| -rw-r--r-- | src/exchange-lib/exchange_api_json.c | 42 | ||||
| -rw-r--r-- | src/exchange-lib/exchange_api_refresh.c | 26 | ||||
| -rw-r--r-- | src/exchange-lib/exchange_api_reserve.c | 9 | ||||
| -rw-r--r-- | src/exchange-lib/exchange_api_wire.c | 146 | ||||
| -rw-r--r-- | src/exchange-lib/exchange_api_wire_deposits.c | 1 | ||||
| -rw-r--r-- | src/exchange-lib/test-exchange-home/sepa.json | 9 | ||||
| -rw-r--r-- | src/exchange-lib/test_exchange_api.c | 27 | 
11 files changed, 128 insertions, 185 deletions
| diff --git a/src/exchange-lib/Makefile.am b/src/exchange-lib/Makefile.am index 6d5e842b..a043e860 100644 --- a/src/exchange-lib/Makefile.am +++ b/src/exchange-lib/Makefile.am @@ -28,6 +28,9 @@ libtalerexchange_la_SOURCES = \    exchange_api_wire_deposits.c  libtalerexchange_la_LIBADD = \ +  $(top_builddir)/src/json/libtalerjson.la \ +  $(top_builddir)/src/util/libtalerutil.la \ +  -lgnunetjson \    -lgnunetutil \    -ljansson \    $(XLIB) @@ -51,6 +54,7 @@ test_exchange_api_SOURCES = \  test_exchange_api_LDADD = \    libtalerexchange.la \    $(LIBGCRYPT_LIBS) \ +  $(top_builddir)/src/json/libtalerjson.la \    $(top_builddir)/src/util/libtalerutil.la \    -lgnunetutil \    -ljansson diff --git a/src/exchange-lib/exchange_api_admin.c b/src/exchange-lib/exchange_api_admin.c index 3dcbb80e..4ed761fb 100644 --- a/src/exchange-lib/exchange_api_admin.c +++ b/src/exchange-lib/exchange_api_admin.c @@ -24,6 +24,8 @@  #include <jansson.h>  #include <microhttpd.h> /* just for HTTP status codes */  #include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include "taler_json_lib.h"  #include "taler_exchange_service.h"  #include "exchange_api_json.h"  #include "exchange_api_context.h" @@ -174,7 +176,7 @@ TALER_EXCHANGE_admin_add_incoming (struct TALER_EXCHANGE_Handle *exchange,    CURL *eh;    GNUNET_assert (GNUNET_OK == -                 TALER_round_abs_time (&execution_date)); +                 GNUNET_TIME_round_abs (&execution_date));    if (GNUNET_YES !=        MAH_handle_is_ready (exchange))    { @@ -183,10 +185,10 @@ TALER_EXCHANGE_admin_add_incoming (struct TALER_EXCHANGE_Handle *exchange,    }    admin_obj = json_pack ("{s:o, s:o," /* reserve_pub/amount */                           " s:o, s:O}", /* execution_Date/wire */ -                         "reserve_pub", TALER_json_from_data (reserve_pub, +                         "reserve_pub", GNUNET_JSON_from_data (reserve_pub,                                                                 sizeof (*reserve_pub)), -                         "amount", TALER_json_from_amount (amount), -                         "execution_date", TALER_json_from_abs (execution_date), +                         "amount", TALER_JSON_from_amount (amount), +                         "execution_date", GNUNET_JSON_from_time_abs (execution_date),                           "wire", wire);    aai = GNUNET_new (struct TALER_EXCHANGE_AdminAddIncomingHandle);    aai->exchange = exchange; diff --git a/src/exchange-lib/exchange_api_deposit.c b/src/exchange-lib/exchange_api_deposit.c index deba4877..ef7a59e6 100644 --- a/src/exchange-lib/exchange_api_deposit.c +++ b/src/exchange-lib/exchange_api_deposit.c @@ -25,6 +25,8 @@  #include <jansson.h>  #include <microhttpd.h> /* just for HTTP status codes */  #include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include "taler_json_lib.h"  #include "taler_exchange_service.h"  #include "exchange_api_common.h"  #include "exchange_api_json.h" @@ -411,7 +413,7 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange,    struct GNUNET_HashCode h_wire;    struct TALER_Amount amount_without_fee; -  (void) TALER_round_abs_time (&wire_deadline); +  (void) GNUNET_TIME_round_abs (&wire_deadline);    if (GNUNET_YES !=        MAH_handle_is_ready (exchange))    { @@ -420,7 +422,7 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange,    }    /* initialize h_wire */    if (GNUNET_OK != -      TALER_hash_json (wire_details, +      TALER_JSON_hash (wire_details,                         &h_wire))    {      GNUNET_break (0); @@ -468,23 +470,23 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange,                             " s:I, s:o," /* transaction id, merchant_pub */                             " s:o, s:o," /* refund_deadline, wire_deadline */                             " s:o}",     /* coin_sig */ -                           "f", TALER_json_from_amount (amount), +                           "f", TALER_JSON_from_amount (amount),                             "wire", wire_details, -                           "H_wire", TALER_json_from_data (&h_wire, +                           "H_wire", GNUNET_JSON_from_data (&h_wire,                                                             sizeof (h_wire)), -                           "H_contract", TALER_json_from_data (h_contract, +                           "H_contract", GNUNET_JSON_from_data (h_contract,                                                                 sizeof (struct GNUNET_HashCode)), -                           "coin_pub", TALER_json_from_data (coin_pub, +                           "coin_pub", GNUNET_JSON_from_data (coin_pub,                                                               sizeof (*coin_pub)), -                           "denom_pub", TALER_json_from_rsa_public_key (denom_pub->rsa_public_key), -                           "ub_sig", TALER_json_from_rsa_signature (denom_sig->rsa_signature), -                           "timestamp", TALER_json_from_abs (timestamp), +                           "denom_pub", GNUNET_JSON_from_rsa_public_key (denom_pub->rsa_public_key), +                           "ub_sig", GNUNET_JSON_from_rsa_signature (denom_sig->rsa_signature), +                           "timestamp", GNUNET_JSON_from_time_abs (timestamp),                             "transaction_id", (json_int_t) transaction_id, -                           "merchant_pub", TALER_json_from_data (merchant_pub, +                           "merchant_pub", GNUNET_JSON_from_data (merchant_pub,                                                                   sizeof (*merchant_pub)), -                           "refund_deadline", TALER_json_from_abs (refund_deadline), -                           "edate", TALER_json_from_abs (wire_deadline), -                           "coin_sig", TALER_json_from_data (coin_sig, +                           "refund_deadline", GNUNET_JSON_from_time_abs (refund_deadline), +                           "edate", GNUNET_JSON_from_time_abs (wire_deadline), +                           "coin_sig", GNUNET_JSON_from_data (coin_sig,                                                               sizeof (*coin_sig))                             ); diff --git a/src/exchange-lib/exchange_api_deposit_wtid.c b/src/exchange-lib/exchange_api_deposit_wtid.c index 83beb03a..f3b5d2c0 100644 --- a/src/exchange-lib/exchange_api_deposit_wtid.c +++ b/src/exchange-lib/exchange_api_deposit_wtid.c @@ -24,6 +24,7 @@  #include <jansson.h>  #include <microhttpd.h> /* just for HTTP status codes */  #include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h>  #include "taler_exchange_service.h"  #include "exchange_api_common.h"  #include "exchange_api_json.h" @@ -296,16 +297,16 @@ TALER_EXCHANGE_deposit_wtid (struct TALER_EXCHANGE_Handle *exchange,    deposit_wtid_obj = json_pack ("{s:o, s:o," /* H_wire, H_contract */                                  " s:o, s:I," /* coin_pub, transaction_id */                                  " s:o, s:o}", /* merchant_pub, merchant_sig */ -                                "H_wire", TALER_json_from_data (h_wire, +                                "H_wire", GNUNET_JSON_from_data (h_wire,                                                                  sizeof (struct GNUNET_HashCode)), -                                "H_contract", TALER_json_from_data (h_contract, +                                "H_contract", GNUNET_JSON_from_data (h_contract,                                                                      sizeof (struct GNUNET_HashCode)), -                                "coin_pub", TALER_json_from_data (coin_pub, +                                "coin_pub", GNUNET_JSON_from_data (coin_pub,                                                                    sizeof (*coin_pub)),                                  "transaction_id", (json_int_t) transaction_id, -                                "merchant_pub", TALER_json_from_data (&dtp.merchant, +                                "merchant_pub", GNUNET_JSON_from_data (&dtp.merchant,                                                                        sizeof (struct TALER_MerchantPublicKeyP)), -                                "merchant_sig", TALER_json_from_data (&merchant_sig, +                                "merchant_sig", GNUNET_JSON_from_data (&merchant_sig,                                                                        sizeof (merchant_sig)));    dwh = GNUNET_new (struct TALER_EXCHANGE_DepositWtidHandle); diff --git a/src/exchange-lib/exchange_api_json.c b/src/exchange-lib/exchange_api_json.c index d91feba0..d6c54be5 100644 --- a/src/exchange-lib/exchange_api_json.c +++ b/src/exchange-lib/exchange_api_json.c @@ -22,6 +22,7 @@   */  #include "platform.h"  #include "exchange_api_json.h" +#include "taler_json_lib.h"  /**   * Navigate and parse data in a JSON tree. @@ -53,24 +54,39 @@ parse_json (json_t *root,        GNUNET_assert (0);        return i;      case MAJ_CMD_AMOUNT: -      if (GNUNET_OK != -          TALER_json_to_amount (pos, -                                spec[i].details.amount))        { -        GNUNET_break_op (0); -        return i; +        struct GNUNET_JSON_Specification nspec[] = { +          TALER_JSON_spec_amount (NULL, spec[i].details.amount), +          GNUNET_JSON_spec_end () +        }; + +        if (GNUNET_OK != +            GNUNET_JSON_parse (pos, +                               nspec, +                               NULL, NULL)) +        { +          GNUNET_break_op (0); +          return i; +        } +        break;        } -      break;      case MAJ_CMD_TIME_ABSOLUTE: -      if (GNUNET_OK != -          TALER_json_to_abs (pos, -                             spec[i].details.abs_time))        { -        GNUNET_break_op (0); -        return i; +        struct GNUNET_JSON_Specification nspec[] = { +          GNUNET_JSON_spec_absolute_time (NULL, spec[i].details.abs_time), +          GNUNET_JSON_spec_end () +        }; + +        if (GNUNET_OK != +            GNUNET_JSON_parse (pos, +                               nspec, +                               NULL, NULL)) +        { +          GNUNET_break_op (0); +          return i; +        } +        break;        } -      break; -      case MAJ_CMD_STRING:        {          const char *str; diff --git a/src/exchange-lib/exchange_api_refresh.c b/src/exchange-lib/exchange_api_refresh.c index 03d59ea3..bcec1354 100644 --- a/src/exchange-lib/exchange_api_refresh.c +++ b/src/exchange-lib/exchange_api_refresh.c @@ -24,6 +24,8 @@  #include <jansson.h>  #include <microhttpd.h> /* just for HTTP status codes */  #include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> +#include "taler_json_lib.h"  #include "taler_exchange_service.h"  #include "exchange_api_common.h"  #include "exchange_api_json.h" @@ -1373,17 +1375,17 @@ melted_coin_to_json (const struct GNUNET_HashCode *melt_session_hash,                              &confirm_sig.eddsa_signature);    return json_pack ("{s:o, s:o, s:o, s:o, s:o}",                      "coin_pub", -                    TALER_json_from_data (&melt.coin_pub, +                    GNUNET_JSON_from_data (&melt.coin_pub,                                            sizeof (melt.coin_pub)),                      "denom_pub", -                    TALER_json_from_rsa_public_key (mc->pub_key.rsa_public_key), +                    GNUNET_JSON_from_rsa_public_key (mc->pub_key.rsa_public_key),                      "denom_sig", -                    TALER_json_from_rsa_signature (mc->sig.rsa_signature), +                    GNUNET_JSON_from_rsa_signature (mc->sig.rsa_signature),                      "confirm_sig", -                    TALER_json_from_data (&confirm_sig, +                    GNUNET_JSON_from_data (&confirm_sig,                                            sizeof (confirm_sig)),                      "value_with_fee", -                    TALER_json_from_amount (&mc->melt_amount_with_fee)); +                    TALER_JSON_from_amount (&mc->melt_amount_with_fee));  } @@ -1472,7 +1474,7 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange,        GNUNET_CRYPTO_ecdhe_key_get_public (&mc->transfer_priv[j].ecdhe_priv,                                            &transfer_pub.ecdhe_pub);        json_array_append (tmp, -                         TALER_json_from_data (&transfer_pub, +                         GNUNET_JSON_from_data (&transfer_pub,                                                 sizeof (transfer_pub)));      }      json_array_append (transfer_pubs, @@ -1497,7 +1499,7 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange,                                               &trans_sec,                                               &els));        json_array_append (tmp, -                         TALER_json_from_data (&els, +                         GNUNET_JSON_from_data (&els,                                                 sizeof (els)));      }      json_array_append (secret_encs, @@ -1508,7 +1510,7 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange,    for (i=0;i<md->num_fresh_coins;i++)    {      json_array_append (new_denoms, -                       TALER_json_from_rsa_public_key +                       GNUNET_JSON_from_rsa_public_key                         (md->fresh_pks[i].rsa_public_key));    } @@ -1533,7 +1535,7 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange,                                                   &buf_len);        GNUNET_assert (NULL != buf);        json_array_append (tmp, -                         TALER_json_from_data (buf, +                         GNUNET_JSON_from_data (buf,                                                 buf_len));        GNUNET_free (buf);        GNUNET_free (rle); @@ -1564,7 +1566,7 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange,                                                md->fresh_pks[i].rsa_public_key,                                                &coin_ev);        json_array_append (tmp, -                         TALER_json_from_data (coin_ev, +                         GNUNET_JSON_from_data (coin_ev,                                                 coin_ev_size));        GNUNET_free (coin_ev);      } @@ -1975,7 +1977,7 @@ TALER_EXCHANGE_refresh_reveal (struct TALER_EXCHANGE_Handle *exchange,        const struct MeltedCoin *mc = &md->melted_coins[i];        json_array_append (tmp, -                         TALER_json_from_data (&mc->transfer_priv[j], +                         GNUNET_JSON_from_data (&mc->transfer_priv[j],                                                 sizeof (struct TALER_TransferPrivateKeyP)));      }      json_array_append (transfer_privs, @@ -1985,7 +1987,7 @@ TALER_EXCHANGE_refresh_reveal (struct TALER_EXCHANGE_Handle *exchange,    /* build main JSON request */    reveal_obj = json_pack ("{s:o, s:o}",                            "session_hash", -                          TALER_json_from_data (&md->melt_session_hash, +                          GNUNET_JSON_from_data (&md->melt_session_hash,                                                  sizeof (struct GNUNET_HashCode)),                            "transfer_privs",                            transfer_privs); diff --git a/src/exchange-lib/exchange_api_reserve.c b/src/exchange-lib/exchange_api_reserve.c index e694b8d9..1237f7cb 100644 --- a/src/exchange-lib/exchange_api_reserve.c +++ b/src/exchange-lib/exchange_api_reserve.c @@ -24,6 +24,7 @@  #include <jansson.h>  #include <microhttpd.h> /* just for HTTP status codes */  #include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h>  #include "taler_exchange_service.h"  #include "exchange_api_json.h"  #include "exchange_api_context.h" @@ -859,12 +860,12 @@ TALER_EXCHANGE_reserve_withdraw (struct TALER_EXCHANGE_Handle *exchange,                                             &reserve_sig.eddsa_signature));    withdraw_obj = json_pack ("{s:o, s:o," /* denom_pub and coin_ev */                              " s:o, s:o}",/* reserve_pub and reserve_sig */ -                            "denom_pub", TALER_json_from_rsa_public_key (pk->key.rsa_public_key), -                            "coin_ev", TALER_json_from_data (coin_ev, +                            "denom_pub", GNUNET_JSON_from_rsa_public_key (pk->key.rsa_public_key), +                            "coin_ev", GNUNET_JSON_from_data (coin_ev,                                                               coin_ev_size), -                            "reserve_pub", TALER_json_from_data (&wsh->reserve_pub, +                            "reserve_pub", GNUNET_JSON_from_data (&wsh->reserve_pub,                                                                   sizeof (struct TALER_ReservePublicKeyP)), -                            "reserve_sig", TALER_json_from_data (&reserve_sig, +                            "reserve_sig", GNUNET_JSON_from_data (&reserve_sig,                                                                   sizeof (reserve_sig)));    GNUNET_free (coin_ev); diff --git a/src/exchange-lib/exchange_api_wire.c b/src/exchange-lib/exchange_api_wire.c index f01c5000..35c443ff 100644 --- a/src/exchange-lib/exchange_api_wire.c +++ b/src/exchange-lib/exchange_api_wire.c @@ -25,11 +25,11 @@  #include <microhttpd.h> /* just for HTTP status codes */  #include <gnunet/gnunet_util_lib.h>  #include "taler_exchange_service.h" +#include "taler_wire_plugin.h"  #include "exchange_api_common.h"  #include "exchange_api_json.h"  #include "exchange_api_context.h"  #include "exchange_api_handle.h" -#include "taler_signatures.h"  /** @@ -84,93 +84,6 @@ struct TALER_EXCHANGE_WireHandle  /**   * Verify that the signature on the "200 OK" response - * for /wire/test from the exchange is valid. - * Accepts everything. - * - * @param wh wire handle - * @param json json reply with the signature - * @return #GNUNET_SYSERR if @a json is invalid, - *         #GNUNET_NO if the method is unknown, - *         #GNUNET_OK if the json is valid - */ -static int -verify_wire_test_signature_ok (const struct TALER_EXCHANGE_WireHandle *wh, -                               json_t *json) -{ -  return GNUNET_OK; -} - - -/** - * Verify that the signature on the "200 OK" response - * for /wire/sepa from the exchange is valid. - * - * @param wh wire handle - * @param json json reply with the signature - * @return #GNUNET_SYSERR if @a json is invalid, - *         #GNUNET_NO if the method is unknown, - *         #GNUNET_OK if the json is valid - */ -static int -verify_wire_sepa_signature_ok (const struct TALER_EXCHANGE_WireHandle *wh, -                               json_t *json) -{ -  struct TALER_MasterSignatureP exchange_sig; -  struct TALER_MasterWireSepaDetailsPS mp; -  const char *receiver_name; -  const char *iban; -  const char *bic; -  const struct TALER_EXCHANGE_Keys *key_state; -  struct GNUNET_HashContext *hc; -  struct MAJ_Specification spec[] = { -    MAJ_spec_fixed_auto ("sig", &exchange_sig), -    MAJ_spec_string ("receiver_name", &receiver_name), -    MAJ_spec_string ("iban", &iban), -    MAJ_spec_string ("bic", &bic), -    MAJ_spec_end -  }; - -  if (GNUNET_OK != -      MAJ_parse_json (json, -                      spec)) -  { -    GNUNET_break_op (0); -    return GNUNET_SYSERR; -  } - -  key_state = TALER_EXCHANGE_get_keys (wh->exchange); -  mp.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SEPA_DETAILS); -  mp.purpose.size = htonl (sizeof (struct TALER_MasterWireSepaDetailsPS)); -  hc = GNUNET_CRYPTO_hash_context_start (); -  GNUNET_CRYPTO_hash_context_read (hc, -                                   receiver_name, -                                   strlen (receiver_name) + 1); -  GNUNET_CRYPTO_hash_context_read (hc, -                                   iban, -                                   strlen (iban) + 1); -  GNUNET_CRYPTO_hash_context_read (hc, -                                   bic, -                                   strlen (bic) + 1); -  GNUNET_CRYPTO_hash_context_finish (hc, -                                     &mp.h_sepa_details); - -  if (GNUNET_OK != -      GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_SEPA_DETAILS, -                                  &mp.purpose, -                                  &exchange_sig.eddsa_signature, -                                  &key_state->master_pub.eddsa_pub)) -  { -    GNUNET_break_op (0); -    MAJ_parse_free (spec); -    return GNUNET_SYSERR; -  } -  MAJ_parse_free (spec); -  return GNUNET_OK; -} - - -/** - * Verify that the signature on the "200 OK" response   * for /wire/METHOD from the exchange is valid.   *   * @param wh wire handle with key material @@ -185,37 +98,33 @@ verify_wire_method_signature_ok (const struct TALER_EXCHANGE_WireHandle *wh,                                   const char *method,                                   json_t *json)  { -  struct -  { -    /** -     * Name fo the method. -     */ -    const char *method; - -    /** -     * Handler to invoke to verify signature. -     * -     * @param wh wire handle with key material -     * @param json json reply with signature to verify -     */ -    int (*handler)(const struct TALER_EXCHANGE_WireHandle *wh, -                   json_t *json); -  } handlers[] = { -    { "test", &verify_wire_test_signature_ok }, -    { "sepa", &verify_wire_sepa_signature_ok }, -    { NULL, NULL } -  }; -  unsigned int i; +  const struct TALER_EXCHANGE_Keys *key_state; +  struct TALER_WIRE_Plugin *plugin; +  char *lib_name; +  int ret; -  for (i=0;NULL != handlers[i].method; i++) -    if (0 == strcasecmp (handlers[i].method, -                         method)) -      return handlers[i].handler (wh, -                                  json); -  GNUNET_log (GNUNET_ERROR_TYPE_INFO, -              "Wire transfer method `%s' not supported\n", -              method); -  return GNUNET_NO; +  key_state = TALER_EXCHANGE_get_keys (wh->exchange); +  (void) GNUNET_asprintf (&lib_name, +                          "libtaler_plugin_wire_%s", +                          method); +  plugin = GNUNET_PLUGIN_load (lib_name, +                               NULL); +  if (NULL == plugin) +  { +    GNUNET_free (lib_name); +    GNUNET_log (GNUNET_ERROR_TYPE_INFO, +                "Wire transfer method `%s' not supported\n", +                method); +    return GNUNET_NO; +  } +  plugin->library_name = lib_name; +  ret = plugin->wire_validate (plugin->cls, +                               json, +                               &key_state->master_pub); +  GNUNET_PLUGIN_unload (lib_name, +                        plugin); +  GNUNET_free (lib_name); +  return (GNUNET_YES == ret) ? GNUNET_OK : GNUNET_SYSERR;  } @@ -312,6 +221,7 @@ handle_wire_method_finished (void *cls,            json_string_value (json_array_get (wh->methods,                                               wh->methods_off-1)),            json); +  json_decref (json);    /* trigger request for the next /wire/method */    request_wire_method (wh);  } diff --git a/src/exchange-lib/exchange_api_wire_deposits.c b/src/exchange-lib/exchange_api_wire_deposits.c index 281ae209..40625602 100644 --- a/src/exchange-lib/exchange_api_wire_deposits.c +++ b/src/exchange-lib/exchange_api_wire_deposits.c @@ -24,6 +24,7 @@  #include <jansson.h>  #include <microhttpd.h> /* just for HTTP status codes */  #include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h>  #include "taler_exchange_service.h"  #include "exchange_api_common.h"  #include "exchange_api_json.h" diff --git a/src/exchange-lib/test-exchange-home/sepa.json b/src/exchange-lib/test-exchange-home/sepa.json index 36d12f66..92ca2556 100644 --- a/src/exchange-lib/test-exchange-home/sepa.json +++ b/src/exchange-lib/test-exchange-home/sepa.json @@ -1,6 +1,9 @@  { -  "receiver_name": "Max Mustermann", -  "iban": "DE89370400440532013000", +  "type": "sepa",    "bic": "COBADEFF370", -  "sig": "8M5YJXM68PRAXKH76HYEBCJW657B23JA0RFGNDMZK2379YZMT626H1BN89KC0M1KJBWGYEN5Z763Q0Y7MCTZQ6BPPT7D9KFCTW60C10" +  "address": "Musterstadt", +  "iban": "DE89370400440532013000", +  "receiver_name": "Max Musterman", +  "salt": "J5AP2BJ8MQAM1WQYQ9YPTAHZVTDXCT3RKHX851S5Q2A42T11K796MNMKJ78VBGDKCFMETMBDPM35D81NCCN77YRW92GDFSQ6P4CZ720", +  "sig": "FF4JZ1FPNVEFPM6ZXD3QN1M225T9X912PX1GJDWGGJX6KBSTR2EZHK24E1PYW7P64YGGQG7Q9HJW0XE36HBBYZWXW83PKVZEYNVG038"  }
\ No newline at end of file diff --git a/src/exchange-lib/test_exchange_api.c b/src/exchange-lib/test_exchange_api.c index 890e8075..fc0945d6 100644 --- a/src/exchange-lib/test_exchange_api.c +++ b/src/exchange-lib/test_exchange_api.c @@ -23,6 +23,7 @@  #include "taler_util.h"  #include "taler_signatures.h"  #include "taler_exchange_service.h" +#include "taler_json_lib.h"  #include <gnunet/gnunet_util_lib.h>  #include <microhttpd.h> @@ -1502,7 +1503,7 @@ interpreter_run (void *cls,        return;      }      execution_date = GNUNET_TIME_absolute_get (); -    TALER_round_abs_time (&execution_date); +    GNUNET_TIME_round_abs (&execution_date);      cmd->details.admin_add_incoming.aih        = TALER_EXCHANGE_admin_add_incoming (exchange,                                         &reserve_pub, @@ -1664,7 +1665,7 @@ interpreter_run (void *cls,          fail (is);          return;        } -      TALER_hash_json (contract, +      TALER_JSON_hash (contract,                         &h_contract);        wire = json_loads (cmd->details.deposit.wire_details,                           JSON_REJECT_DUPLICATES, @@ -1698,7 +1699,7 @@ interpreter_run (void *cls,        wire_deadline = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_DAYS);        timestamp = GNUNET_TIME_absolute_get (); -      TALER_round_abs_time (×tamp); +      GNUNET_TIME_round_abs (×tamp);        {          struct TALER_DepositRequestPS dr; @@ -1706,7 +1707,7 @@ interpreter_run (void *cls,          dr.purpose.size = htonl (sizeof (struct TALER_DepositRequestPS));          dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_DEPOSIT);          dr.h_contract = h_contract; -        TALER_hash_json (wire, +        TALER_JSON_hash (wire,                           &dr.h_wire);          dr.timestamp = GNUNET_TIME_absolute_hton (timestamp);          dr.refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline); @@ -1964,14 +1965,14 @@ interpreter_run (void *cls,                           JSON_REJECT_DUPLICATES,                           NULL);        GNUNET_assert (NULL != wire); -      TALER_hash_json (wire, +      TALER_JSON_hash (wire,                         &h_wire);        json_decref (wire);        contract = json_loads (ref->details.deposit.contract,                               JSON_REJECT_DUPLICATES,                               NULL);        GNUNET_assert (NULL != contract); -      TALER_hash_json (contract, +      TALER_JSON_hash (contract,                         &h_contract);        json_decref (contract);        cmd->details.deposit_wtid.dwh @@ -2349,7 +2350,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_number\":42 }", +      .details.admin_add_incoming.wire = "{ \"type\":\"test\", \"bank\":\"source bank\", \"account_number\":42 }",        .details.admin_add_incoming.amount = "EUR:5.01" },      /* Withdraw a 5 EUR coin, at fee of 1 ct */      { .oc = OC_WITHDRAW_SIGN, @@ -2370,7 +2371,7 @@ run (void *cls,        .expected_response_code = MHD_HTTP_OK,        .details.deposit.amount = "EUR:5",        .details.deposit.coin_ref = "withdraw-coin-1", -      .details.deposit.wire_details = "{ \"type\":\"TEST\", \"bank\":\"dest bank\", \"account_number\":42 }", +      .details.deposit.wire_details = "{ \"type\":\"test\", \"bank\":\"dest bank\", \"account_number\":42 }",        .details.deposit.contract = "{ \"items\": [ { \"name\":\"ice cream\", \"value\":1 } ] }",        .details.deposit.transaction_id = 1 }, @@ -2387,7 +2388,7 @@ run (void *cls,        .expected_response_code = MHD_HTTP_FORBIDDEN,        .details.deposit.amount = "EUR:5",        .details.deposit.coin_ref = "withdraw-coin-1", -      .details.deposit.wire_details = "{ \"type\":\"TEST\", \"bank\":\"dest bank\", \"account_number\":43 }", +      .details.deposit.wire_details = "{ \"type\":\"test\", \"bank\":\"dest bank\", \"account_number\":43 }",        .details.deposit.contract = "{ \"items\": [ { \"name\":\"ice cream\", \"value\":1 } ] }",        .details.deposit.transaction_id = 1 },      /* Try to double-spend the 5 EUR coin at the same merchant (but different @@ -2397,7 +2398,7 @@ run (void *cls,        .expected_response_code = MHD_HTTP_FORBIDDEN,        .details.deposit.amount = "EUR:5",        .details.deposit.coin_ref = "withdraw-coin-1", -      .details.deposit.wire_details = "{ \"type\":\"TEST\", \"bank\":\"dest bank\", \"account_number\":42 }", +      .details.deposit.wire_details = "{ \"type\":\"test\", \"bank\":\"dest bank\", \"account_number\":42 }",        .details.deposit.contract = "{ \"items\": [ { \"name\":\"ice cream\", \"value\":1 } ] }",        .details.deposit.transaction_id = 2 },      /* Try to double-spend the 5 EUR coin at the same merchant (but different @@ -2407,7 +2408,7 @@ run (void *cls,        .expected_response_code = MHD_HTTP_FORBIDDEN,        .details.deposit.amount = "EUR:5",        .details.deposit.coin_ref = "withdraw-coin-1", -      .details.deposit.wire_details = "{ \"type\":\"TEST\", \"bank\":\"dest bank\", \"account_number\":42 }", +      .details.deposit.wire_details = "{ \"type\":\"test\", \"bank\":\"dest bank\", \"account_number\":42 }",        .details.deposit.contract = "{ \"items\":[{ \"name\":\"ice cream\", \"value\":2 } ] }",        .details.deposit.transaction_id = 1 }, @@ -2417,7 +2418,7 @@ run (void *cls,      { .oc = OC_ADMIN_ADD_INCOMING,        .label = "refresh-create-reserve-1",        .expected_response_code = MHD_HTTP_OK, -      .details.admin_add_incoming.wire = "{ \"type\":\"TEST\", \"bank\":\"source bank\", \"account_number\":424 }", +      .details.admin_add_incoming.wire = "{ \"type\":\"test\", \"bank\":\"source bank\", \"account_number\":424 }",        .details.admin_add_incoming.amount = "EUR:5.01" },      /* Withdraw a 5 EUR coin, at fee of 1 ct */      { .oc = OC_WITHDRAW_SIGN, @@ -2432,7 +2433,7 @@ run (void *cls,        .expected_response_code = MHD_HTTP_OK,        .details.deposit.amount = "EUR:1",        .details.deposit.coin_ref = "refresh-withdraw-coin-1", -      .details.deposit.wire_details = "{ \"type\":\"TEST\", \"bank\":\"dest bank\", \"account_number\":42 }", +      .details.deposit.wire_details = "{ \"type\":\"test\", \"bank\":\"dest bank\", \"account_number\":42 }",        .details.deposit.contract = "{ \"items\" : [ { \"name\":\"ice cream\", \"value\":\"EUR:1\" } ] }",        .details.deposit.transaction_id = 42421 }, | 
