commit dbffac740680e26e6a310ec7100e6bc0ae45af61
parent d2ad8e7990975509a95471ca6f83c32e714df70b
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date: Thu, 31 Jan 2019 15:13:43 +0100
Proposal logic.
Checking if the instance(s) given by the frontend when
it creates the proposal are the same.
Diffstat:
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c
@@ -1052,7 +1052,9 @@ TMH_lookup_instance (const char *name)
/**
- * Extract merchant instance from the given JSON
+ * Extract merchant instance from the given JSON; if not
+ * 'instance' field was found, then "default" instance is
+ * returned.
*
* @param json the JSON to inspect; it is not required to
* comply with any particular format. It will only be checked
diff --git a/src/backend/taler-merchant-httpd_proposal.c b/src/backend/taler-merchant-httpd_proposal.c
@@ -447,6 +447,20 @@ proposal_put (struct MHD_Connection *connection,
}
mi = TMH_lookup_instance_json (merchant);
+
+ /* The outer instance field, and the one included
+ * in the merchant object are different */
+ if (0 != strcmp (mi->id,
+ instance))
+ {
+ TALER_LOG_ERROR
+ ("Inconsistent instance specified by merchant\n");
+ return TMH_RESPONSE_reply_not_found
+ (connection,
+ TALER_EC_CONTRACT_INSTANCE_INCONSISTENT,
+ "Inconsistent instance given");
+ }
+
if (NULL == mi)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,