summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-11-19 18:27:27 +0100
committerFlorian Dold <florian.dold@gmail.com>2016-11-19 18:27:38 +0100
commitf3c4d643298b4adb24a92a17fb579522d86a296a (patch)
treec257ab816d4cb405bc2d47e254128162487264b0
parent134e0677361a57dd9737ebd8e85c5e4c33a7953b (diff)
downloadexchange-f3c4d643298b4adb24a92a17fb579522d86a296a.tar.gz
exchange-f3c4d643298b4adb24a92a17fb579522d86a296a.tar.bz2
exchange-f3c4d643298b4adb24a92a17fb579522d86a296a.zip
taler-exchange-wire: infer method from JSON if possible
-rw-r--r--src/exchange-tools/taler-exchange-wire.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/exchange-tools/taler-exchange-wire.c b/src/exchange-tools/taler-exchange-wire.c
index 1c2d5ce90..7249398d3 100644
--- a/src/exchange-tools/taler-exchange-wire.c
+++ b/src/exchange-tools/taler-exchange-wire.c
@@ -40,7 +40,7 @@ static char *json_in;
/**
* Which wire method is this for?
*/
-static char *method;
+static const char *method;
/**
* Where to write the result.
@@ -108,13 +108,6 @@ run (void *cls,
global_ret = 1;
return;
}
- if (NULL == method)
- {
- fprintf (stderr,
- "Required -t argument missing\n");
- global_ret = 1;
- return;
- }
j = json_loads (json_in,
JSON_REJECT_DUPLICATES,
&err);
@@ -127,9 +120,24 @@ run (void *cls,
global_ret = 1;
return;
}
- json_object_set_new (j,
- "type",
- json_string (method));
+ if (NULL == method)
+ {
+ json_t *test;
+ test = json_object_get(j, "type");
+ if (NULL == test || (NULL == (method = json_string_value (test))))
+ {
+ fprintf (stderr,
+ "Required -t argument missing\n");
+ global_ret = 1;
+ return;
+ }
+ }
+ else
+ {
+ json_object_set_new (j,
+ "type",
+ json_string (method));
+ }
key.eddsa_priv = *eddsa_priv;
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
&salt,