diff options
author | Marcello Stanisci <marcello.stanisci@inria.fr> | 2016-03-04 15:29:43 +0100 |
---|---|---|
committer | Marcello Stanisci <marcello.stanisci@inria.fr> | 2016-03-04 15:29:43 +0100 |
commit | 1eedc6b595ee29eca60595510303ca28b4fce24d (patch) | |
tree | 24f2ad8dc534f0804780415c86ae59e484a701df /src | |
parent | 1879165d18319901b1cea3f1760a3ce7deda0902 (diff) |
adding TEST as possible wiretransfer types (backend)
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/merchant.conf | 55 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd.c | 54 |
2 files changed, 51 insertions, 58 deletions
diff --git a/src/backend/merchant.conf b/src/backend/merchant.conf deleted file mode 100644 index 0861593e..00000000 --- a/src/backend/merchant.conf +++ /dev/null @@ -1,55 +0,0 @@ -# Sample configuration file for a merchant. -[merchant] - -# Which port do we run the backend on? (HTTP server) -PORT = 9966 - -# FIXME: is this one used? -HOSTNAME = localhost - -# Where is our private key? -KEYFILE = merchant.priv - -# What currency does this backend accept? -CURRENCY = EUR - -# FIXME: to be revised -TRUSTED_EXCHANGES = taler - -# How quickly do we want the exchange to send us our money? -# Used only if the frontend does not specify a value. -# FIXME: EDATE is a bit short, 'execution_delay'? -EDATE = 3 week - -# Which plugin (backend) do we use for the DB. -DB = postgres - -[exchange-taler] -URI = http://exchange.test.taler.net/ -MASTER_KEY = Q1WVGRGC1F4W7RYC6M23AEGFEXQEHQ730K3GG0B67VPHQSRR75H0 - -# Auditors must be in sections "auditor-", the rest of the section -# name could be anything. -[auditor-ezb] -# Informal name of the auditor. Just for the user. -NAME = European Central Bank - -# URI of the auditor (especially for in the future, when the -# auditor offers an automated issue reporting system). -# Not really used today. -URI = http://taler.ezb.eu/ - -# This is the important bit: the signing key of the auditor. -PUBLIC_KEY = 9QXF7XY7E9VPV47B5Z806NDFSX2VJ79SVHHD29QEQ3BG31ANHZ60 - -# This specifies which database we use. -[merchantdb-postgres] -CONFIG = postgres:///talerdemo - -# "wire-" sections include wire details, here for SEPA. -[wire-sepa] -IBAN = DE67830654080004822650 -NAME = GNUNET E.V -BIC = GENODEF1SRL -ADDRESS = "Garching" -SALT = 12345 diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c index 72e3cdd4..ccd3381d 100644 --- a/src/backend/taler-merchant-httpd.c +++ b/src/backend/taler-merchant-httpd.c @@ -326,6 +326,34 @@ TMH_trigger_daemon () run_daemon (NULL, NULL); } +/** + * Parse the TEST wireformat information from the configuration. + * If any of the required fields is missing return an error. + * + * @param cfg the configuration + * @return #GNUNET_OK on success, #GNUNET_SYSERR on error + */ +static int +parse_wireformat_test (const struct GNUNET_CONFIGURATION_Handle *cfg) +{ + char *account_number; + + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string(cfg, + "wire-test", + "ACCOUNT_NUMBER", + &account_number)) + return GNUNET_SYSERR; + j_wire = json_pack("{s:s, s:s}", + "type", "TEST", + "account_number", account_number); + GNUNET_free (account_number); + if (NULL == j_wire) + return GNUNET_SYSERR; + return GNUNET_OK; + +} + /** * Parse the SEPA information from the configuration. If any of the @@ -516,6 +544,8 @@ run (void *cls, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *config) { + char *wireformat; + result = GNUNET_SYSERR; shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, @@ -527,9 +557,27 @@ run (void *cls, TMH_AUDITORS_init (config)); /* FIXME: for now, we just support SEPA here: */ EXITIF (GNUNET_OK != - parse_wireformat_sepa (config)); - EXITIF (GNUNET_OK != - validate_and_hash_wireformat ("SEPA")); + GNUNET_CONFIGURATION_get_value_string (config, + "merchant", + "WIREFORMAT", + &wireformat)); + + if (0 == strcmp("SEPA", wireformat)) + { + EXITIF (GNUNET_OK != + parse_wireformat_sepa (config)); + EXITIF (GNUNET_OK != + validate_and_hash_wireformat ("SEPA")); + } + else if (0 == strcmp("TEST", wireformat)) + { + EXITIF (GNUNET_OK != + parse_wireformat_test (config)); + EXITIF (GNUNET_OK != + validate_and_hash_wireformat ("TEST")); + } + GNUNET_free (wireformat); + EXITIF (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (config, "merchant", |