aboutsummaryrefslogtreecommitdiff
path: root/src/wire
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-04-01 16:15:35 +0200
committerChristian Grothoff <christian@grothoff.org>2016-04-01 16:15:35 +0200
commitde3e26303e0069614d4a5aa425e4fa5ddb088b8b (patch)
tree982ba3095d80ec48a910dad15e3d886b36c6be24 /src/wire
parent92907bee45681b1273172a3c88461a60bcae8589 (diff)
implementing #4356, tests still failing, but main logic should now be updated
Diffstat (limited to 'src/wire')
-rw-r--r--src/wire/plugin_wire_sepa.c60
-rw-r--r--src/wire/plugin_wire_template.c20
-rw-r--r--src/wire/plugin_wire_test.c53
3 files changed, 132 insertions, 1 deletions
diff --git a/src/wire/plugin_wire_sepa.c b/src/wire/plugin_wire_sepa.c
index 904afa9bf..995436725 100644
--- a/src/wire/plugin_wire_sepa.c
+++ b/src/wire/plugin_wire_sepa.c
@@ -380,7 +380,7 @@ verify_wire_sepa_signature_ok (const json_t *json,
if (NULL == master_pub)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Skipping signature check as master public key not given\n");
return GNUNET_OK;
}
@@ -492,6 +492,63 @@ sepa_wire_validate (void *cls,
/**
+ * Obtain wire transfer details in the plugin-specific format
+ * from the configuration.
+ *
+ * @param cls closure
+ * @param cfg configuration with details about wire accounts
+ * @param account_name which section in the configuration should we parse
+ * @return NULL if @a cfg fails to have valid wire details for @a account_name
+ */
+static json_t *
+sepa_get_wire_details (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *account_name)
+{
+ char *sepa_wire_file;
+ json_error_t err;
+ json_t *ret;
+
+ /* Fetch reply */
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_filename (cfg,
+ account_name,
+ "SEPA_RESPONSE_FILE",
+ &sepa_wire_file))
+ {
+ return NULL;
+ }
+ ret = json_load_file (sepa_wire_file,
+ JSON_REJECT_DUPLICATES,
+ &err);
+ if (NULL == ret)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to parse JSON in %s: %s (%s:%u)\n",
+ sepa_wire_file,
+ err.text,
+ err.source,
+ err.line);
+ GNUNET_free (sepa_wire_file);
+ return NULL;
+ }
+ if (GNUNET_YES != sepa_wire_validate (cls,
+ ret,
+ NULL))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to validate SEPA data in %s\n",
+ sepa_wire_file);
+ GNUNET_free (sepa_wire_file);
+ json_decref (ret);
+ return NULL;
+ }
+ GNUNET_free (sepa_wire_file);
+ return ret;
+}
+
+
+/**
* Prepare for exeuction of a wire transfer.
*
* @param cls the @e cls of this struct with the plugin-specific state
@@ -604,6 +661,7 @@ libtaler_plugin_wire_sepa_init (void *cls)
plugin = GNUNET_new (struct TALER_WIRE_Plugin);
plugin->cls = sc;
plugin->amount_round = &sepa_amount_round;
+ plugin->get_wire_details = &sepa_get_wire_details;
plugin->wire_validate = &sepa_wire_validate;
plugin->prepare_wire_transfer = &sepa_prepare_wire_transfer;
plugin->prepare_wire_transfer_cancel = &sepa_prepare_wire_transfer_cancel;
diff --git a/src/wire/plugin_wire_template.c b/src/wire/plugin_wire_template.c
index 91b380c38..fd6fbfbe9 100644
--- a/src/wire/plugin_wire_template.c
+++ b/src/wire/plugin_wire_template.c
@@ -74,6 +74,25 @@ template_amount_round (void *cls,
/**
+ * Obtain wire transfer details in the plugin-specific format
+ * from the configuration.
+ *
+ * @param cls closure
+ * @param cfg configuration with details about wire accounts
+ * @param account_name which section in the configuration should we parse
+ * @return NULL if @a cfg fails to have valid wire details for @a account_name
+ */
+static json_t *
+template_get_wire_details (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *account_name)
+{
+ GNUNET_break (0);
+ return NULL;
+}
+
+
+/**
* Check if the given wire format JSON object is correctly formatted
*
* @param cls the @e cls of this struct with the plugin-specific state
@@ -216,6 +235,7 @@ libtaler_plugin_wire_template_init (void *cls)
plugin = GNUNET_new (struct TALER_WIRE_Plugin);
plugin->cls = tc;
plugin->amount_round = &template_amount_round;
+ plugin->get_wire_details = &template_get_wire_details;
plugin->wire_validate = &template_wire_validate;
plugin->prepare_wire_transfer = &template_prepare_wire_transfer;
plugin->prepare_wire_transfer_cancel = &template_prepare_wire_transfer_cancel;
diff --git a/src/wire/plugin_wire_test.c b/src/wire/plugin_wire_test.c
index 3ef76aa6b..a03f8127d 100644
--- a/src/wire/plugin_wire_test.c
+++ b/src/wire/plugin_wire_test.c
@@ -233,6 +233,58 @@ test_amount_round (void *cls,
/**
+ * Obtain wire transfer details in the plugin-specific format
+ * from the configuration.
+ *
+ * @param cls closure
+ * @param cfg configuration with details about wire accounts
+ * @param account_name which section in the configuration should we parse
+ * @return NULL if @a cfg fails to have valid wire details for @a account_name
+ */
+static json_t *
+test_get_wire_details (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *account_name)
+{
+ json_t *ret;
+ char *bank_uri;
+ unsigned long long account_number;
+
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ account_name,
+ "BANK_URI",
+ &bank_uri))
+ {
+ /* oopsie, configuration error */
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ account_name,
+ "BANK_URI");
+ return NULL;
+ }
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (cfg,
+ account_name,
+ "BANK_ACCOUNT_NUMBER",
+ &account_number))
+ {
+ /* oopsie, configuration error */
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ account_name,
+ "BANK_URI");
+ GNUNET_free (bank_uri);
+ return NULL;
+ }
+ ret = json_pack ("{s:s, s:I, s:s}",
+ "type", "test",
+ "account_number", (json_int_t) account_number,
+ "bank_uri", bank_uri);
+ GNUNET_free (bank_uri);
+ return ret;
+}
+
+
+/**
* Check if the given wire format JSON object is correctly formatted.
* Right now, the only thing we require is a field
* "account_number" which must contain a positive 53-bit integer.
@@ -628,6 +680,7 @@ libtaler_plugin_wire_test_init (void *cls)
plugin = GNUNET_new (struct TALER_WIRE_Plugin);
plugin->cls = tc;
plugin->amount_round = &test_amount_round;
+ plugin->get_wire_details = &test_get_wire_details;
plugin->wire_validate = &test_wire_validate;
plugin->prepare_wire_transfer = &test_prepare_wire_transfer;
plugin->prepare_wire_transfer_cancel = &test_prepare_wire_transfer_cancel;