summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcello Stanisci <marcello.stanisci@inria.fr>2017-06-20 11:41:30 +0200
committerMarcello Stanisci <marcello.stanisci@inria.fr>2017-06-20 11:41:30 +0200
commitf48df598cf421374130beecaa0485c2ff2a2d70e (patch)
tree603eda8ca944a17ad4fc951faa24b175cb1d6675
parent870ca3f8ec04d1d4c5be3a25bd72c9ee6bc5e3d5 (diff)
downloadmerchant-f48df598cf421374130beecaa0485c2ff2a2d70e.tar.gz
merchant-f48df598cf421374130beecaa0485c2ff2a2d70e.tar.bz2
merchant-f48df598cf421374130beecaa0485c2ff2a2d70e.zip
Return a signed confirmation of the refund
-rw-r--r--src/backend/taler-merchant-httpd_refund.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/src/backend/taler-merchant-httpd_refund.c b/src/backend/taler-merchant-httpd_refund.c
index 2149df1b..f8f40aff 100644
--- a/src/backend/taler-merchant-httpd_refund.c
+++ b/src/backend/taler-merchant-httpd_refund.c
@@ -26,6 +26,28 @@
#include "taler-merchant-httpd_parsing.h"
#include "taler-merchant-httpd_responses.h"
+#define REFUND_CONFIRMATION 0
+
+/**
+ * We confirm with a signature that the refund has been successfully
+ * done. Even though the frontend doesn't usually do crypto, this signature
+ * may turn useful in court.
+ */
+struct RefundConfirmationP
+{
+
+ /**
+ * Purpose is simply set to zero, see macro REFUND_CONFIRMATION above
+ */
+ struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
+
+ /**
+ * Hashing the order id, as frontends don't handle contract terms
+ */
+ struct GNUNET_HashCode h_order_id GNUNET_PACKED;
+
+};
+
struct ProcessRefundData
{
/**
@@ -116,6 +138,8 @@ MH_handler_refund_increase (struct TMH_RequestHandler *rh,
const char *merchant;
struct MerchantInstance *mi;
struct GNUNET_HashCode h_contract_terms;
+ struct RefundConfirmationP confirmation;
+ struct GNUNET_CRYPTO_EddsaSignature sig;
struct GNUNET_JSON_Specification spec[] = {
TALER_JSON_spec_amount ("refund", &refund),
@@ -239,7 +263,26 @@ MH_handler_refund_increase (struct TMH_RequestHandler *rh,
json_decref (contract_terms);
json_decref (root);
GNUNET_JSON_parse_free (spec);
- return MHD_YES;
+
+ confirmation.purpose.purpose = REFUND_CONFIRMATION;
+ confirmation.purpose.size = htonl (sizeof (struct RefundConfirmationP));
+
+ if (GNUNET_OK != GNUNET_CRYPTO_eddsa_sign (&mi->privkey.eddsa_priv,
+ &confirmation.purpose,
+ &sig))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to sign successful refund confirmation\n");
+ return TMH_RESPONSE_reply_internal_error (connection,
+ TALER_EC_NONE,
+ "Refund done, but failed to sign confirmation");
+
+ }
+
+ return TMH_RESPONSE_reply_json_pack (connection,
+ MHD_HTTP_OK,
+ "{s:s}",
+ "sig", GNUNET_JSON_from_data_auto (&sig));
}