aboutsummaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/taler-merchant-httpd.c')
-rw-r--r--src/backend/taler-merchant-httpd.c60
1 files changed, 29 insertions, 31 deletions
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c
index 25de5e45..d259d5cb 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -53,36 +53,11 @@
struct MerchantInstance **instances;
/**
- * Our wire format details in JSON format (with salt).
- */
-struct json_t *j_wire;
-
-/**
- * Hash of our wire format details as given in #j_wire.
- */
-struct GNUNET_HashCode h_wire;
-
-/**
- * Merchant's private key
- */
-struct TALER_MerchantPrivateKeyP privkey;
-
-/**
- * Merchant's public key
- */
-struct TALER_MerchantPublicKeyP pubkey;
-
-/**
* The port we are running on
*/
static long long unsigned port;
/**
- * File holding the merchant's private key
- */
-static char *keyfile;
-
-/**
* This value tells the exchange by which date this merchant would like
* to receive the funds for a deposited payment
*/
@@ -276,11 +251,6 @@ do_shutdown (void *cls)
}
TMH_EXCHANGES_done ();
TMH_AUDITORS_done ();
- if (NULL != j_wire)
- {
- json_decref (j_wire);
- j_wire = NULL;
- }
if (NULL != instances)
{
unsigned int i;
@@ -471,7 +441,7 @@ instances_iterator_cb (void *cls,
if (GNUNET_YES != GNUNET_DISK_file_test (mi->keyfile))
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Merchant private key `%s' does not exist yet, creating it!\n",
- keyfile);
+ mi->keyfile);
if (NULL ==
(pk = GNUNET_CRYPTO_eddsa_key_create_from_file (mi->keyfile)))
{
@@ -526,6 +496,34 @@ instances_iterator_cb (void *cls,
}
/**
+ * Extract merchant instance from the given JSON
+ *
+ * @param json the JSON to inspect; it is not required to
+ * comply with any particular format. It will only be checked
+ * if the field "receiver" is there.
+ * @return a pointer to a #struct MerchantInstance. This will be
+ * the 'default' merchant if the frontend did not specif any
+ * "receiver" field. The user should not care to free the returned
+ * value, as it is taken from a global array that will be freed
+ * by the general shutdown routine. NULL if the frontend specified
+ * a wrong instance
+ */
+struct MerchantInstance *
+get_instance (struct json_t *json)
+{
+ unsigned int i;
+ struct json_t *receiver;
+ /*FIXME who decrefs receiver?*/
+ if (NULL == (receiver = json_object_get (json, "receiver")))
+ receiver = json_string ("default");
+
+ for (i=0; NULL != instances[i]; i++)
+ if (0 == strcmp (json_string_value (receiver), instances[i]->id))
+ return instances[i];
+ return NULL;
+}
+
+/**
* Iterate over each merchant instance, in order to populate
* each instance's own data
*