summaryrefslogtreecommitdiff
path: root/src/exchange-tools
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-03-19 15:23:11 +0100
committerChristian Grothoff <christian@grothoff.org>2016-03-19 15:23:11 +0100
commit0d1eced630f4ed05ad95fdbb4354fd428c9cdbf6 (patch)
tree0ed4d6f189ed72287a0e003446c87a2b6db70c1a /src/exchange-tools
parentd229f78da3b0b7f851d3541f59651b4f600c879d (diff)
downloadexchange-0d1eced630f4ed05ad95fdbb4354fd428c9cdbf6.tar.gz
exchange-0d1eced630f4ed05ad95fdbb4354fd428c9cdbf6.tar.bz2
exchange-0d1eced630f4ed05ad95fdbb4354fd428c9cdbf6.zip
first refactoring of JSON logic to address #4150 and #4237
Diffstat (limited to 'src/exchange-tools')
-rw-r--r--src/exchange-tools/Makefile.am4
-rw-r--r--src/exchange-tools/taler-exchange-keyup.c14
-rw-r--r--src/exchange-tools/taler-exchange-sepa.c38
3 files changed, 42 insertions, 14 deletions
diff --git a/src/exchange-tools/Makefile.am b/src/exchange-tools/Makefile.am
index 4ffabd15d..fda9cefa3 100644
--- a/src/exchange-tools/Makefile.am
+++ b/src/exchange-tools/Makefile.am
@@ -38,7 +38,9 @@ taler_exchange_sepa_SOURCES = \
taler_exchange_sepa_LDADD = \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/util/libtalerutil.la \
- -lgnunetutil -ljansson $(XLIB)
+ -lgnunetjson \
+ -lgnunetutil \
+ -ljansson $(XLIB)
taler_exchange_sepa_LDFLAGS = $(POSTGRESQL_LDFLAGS)
taler_exchange_keycheck_SOURCES = \
diff --git a/src/exchange-tools/taler-exchange-keyup.c b/src/exchange-tools/taler-exchange-keyup.c
index 779e3a3d3..861a9a7c8 100644
--- a/src/exchange-tools/taler-exchange-keyup.c
+++ b/src/exchange-tools/taler-exchange-keyup.c
@@ -518,7 +518,7 @@ exchange_keys_update_signkeys ()
"must be longer than signkey_duration");
return GNUNET_SYSERR;
}
- TALER_round_rel_time (&signkey_duration);
+ GNUNET_TIME_round_rel (&signkey_duration);
GNUNET_asprintf (&signkey_dir,
"%s" DIR_SEPARATOR_STR TALER_EXCHANGEDB_DIR_SIGNING_KEYS,
exchange_directory);
@@ -600,7 +600,7 @@ get_cointype_params (const char *ct,
"duration_withdraw");
return GNUNET_SYSERR;
}
- TALER_round_rel_time (&params->duration_withdraw);
+ GNUNET_TIME_round_rel (&params->duration_withdraw);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_time (kcfg,
ct,
@@ -612,7 +612,7 @@ get_cointype_params (const char *ct,
"duration_spend");
return GNUNET_SYSERR;
}
- TALER_round_rel_time (&params->duration_spend);
+ GNUNET_TIME_round_rel (&params->duration_spend);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_time (kcfg,
ct,
@@ -624,7 +624,7 @@ get_cointype_params (const char *ct,
"duration_legal");
return GNUNET_SYSERR;
}
- TALER_round_rel_time (&params->duration_legal);
+ GNUNET_TIME_round_rel (&params->duration_legal);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_time (kcfg,
ct,
@@ -636,7 +636,7 @@ get_cointype_params (const char *ct,
"exchange_denom_duration_overlap");
return GNUNET_SYSERR;
}
- TALER_round_rel_time (&params->duration_overlap);
+ GNUNET_TIME_round_rel (&params->duration_overlap);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (kcfg,
ct,
@@ -927,7 +927,7 @@ main (int argc,
{
now = GNUNET_TIME_absolute_get ();
}
- TALER_round_abs_time (&now);
+ GNUNET_TIME_round_abs (&now);
kcfg = TALER_config_load (exchange_directory);
if (NULL == kcfg)
@@ -1017,7 +1017,7 @@ main (int argc,
_("must not be zero"));
return GNUNET_SYSERR;
}
- TALER_round_rel_time (&lookahead_sign);
+ GNUNET_TIME_round_rel (&lookahead_sign);
lookahead_sign_stamp = GNUNET_TIME_absolute_add (now,
lookahead_sign);
diff --git a/src/exchange-tools/taler-exchange-sepa.c b/src/exchange-tools/taler-exchange-sepa.c
index a3ac95436..1bfb49132 100644
--- a/src/exchange-tools/taler-exchange-sepa.c
+++ b/src/exchange-tools/taler-exchange-sepa.c
@@ -20,6 +20,7 @@
*/
#include <platform.h>
#include <jansson.h>
+#include <gnunet/gnunet_json_lib.h>
#include "taler_crypto_lib.h"
#include "taler_signatures.h"
@@ -35,6 +36,11 @@ static char *masterkeyfile;
static char *sepa_name;
/**
+ * Account holder address.
+ */
+static char *sepa_address;
+
+/**
* IBAN number.
*/
static char *iban;
@@ -63,6 +69,9 @@ main (int argc,
char *const *argv)
{
static const struct GNUNET_GETOPT_CommandLineOption options[] = {
+ {'a', "address", "ADDRESS",
+ "account holder address", 1,
+ &GNUNET_GETOPT_set_string, &sepa_address},
{'b', "bic", "BICCODE",
"bank BIC code", 1,
&GNUNET_GETOPT_set_string, &bic},
@@ -88,6 +97,7 @@ main (int argc,
struct GNUNET_HashContext *hc;
json_t *reply;
char *json_str;
+ struct GNUNET_HashCode salt;
GNUNET_assert (GNUNET_OK ==
GNUNET_log_setup ("taler-exchange-sepa",
@@ -112,8 +122,20 @@ main (int argc,
masterkeyfile);
return 1;
}
+ if ( (NULL == sepa_address) ||
+ (NULL == iban) ||
+ (NULL == sepa_name) ||
+ (NULL == bic) )
+ {
+ fprintf (stderr,
+ "Required arguments missing\n");
+ return 1;
+ }
/* Compute message to sign */
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
+ &salt,
+ sizeof (salt));
hc = GNUNET_CRYPTO_hash_context_start ();
GNUNET_CRYPTO_hash_context_read (hc,
sepa_name,
@@ -132,27 +154,31 @@ main (int argc,
&wsd.purpose,
&sig.eddsa_signature);
GNUNET_free (eddsa_priv);
-
+
/* build JSON message */
- reply = json_pack ("{s:s, s:s, s:s, s:o}",
+ reply = json_pack ("{s:s, s:s, s:s, s:s, s:s, s:o, s:o}",
+ "type", "sepa",
+ "address", sepa_address,
"receiver_name", sepa_name,
"iban", iban,
"bic", bic,
- "sig", TALER_json_from_data (&sig,
- sizeof (sig)));
+ "salt", GNUNET_JSON_from_data (&salt,
+ sizeof (salt)),
+ "sig", GNUNET_JSON_from_data (&sig,
+ sizeof (sig)));
GNUNET_assert (NULL != reply);
/* dump result to stdout */
json_str = json_dumps (reply, JSON_INDENT(2));
GNUNET_assert (NULL != json_str);
-
+
if (NULL != output_filename)
{
fclose (stdout);
stdout = fopen (output_filename,
"w+");
}
- fprintf (stdout,
+ fprintf (stdout,
"%s",
json_str);
fflush (stdout);