summaryrefslogtreecommitdiff
path: root/src/exchange
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-03-02 06:26:12 +0100
committerChristian Grothoff <christian@grothoff.org>2017-03-02 06:26:12 +0100
commit397c718809f2f53f3e0714ea6433083ea7379124 (patch)
tree1a16c756aa9c43c6d1f49c9ae4366b3342a3cacd /src/exchange
parent4d8942b8188e5d2ddd6d3d8a31b141e59a82f771 (diff)
downloadexchange-397c718809f2f53f3e0714ea6433083ea7379124.tar.gz
exchange-397c718809f2f53f3e0714ea6433083ea7379124.tar.bz2
exchange-397c718809f2f53f3e0714ea6433083ea7379124.zip
implementing #4921: add base URL to wire transfers
Diffstat (limited to 'src/exchange')
-rw-r--r--src/exchange/exchange.conf8
-rw-r--r--src/exchange/taler-exchange-aggregator.c20
-rw-r--r--src/exchange/test-taler-exchange-aggregator-postgres.conf34
-rw-r--r--src/exchange/test_taler_exchange_aggregator.c46
4 files changed, 94 insertions, 14 deletions
diff --git a/src/exchange/exchange.conf b/src/exchange/exchange.conf
index 39151ea67..a226d4149 100644
--- a/src/exchange/exchange.conf
+++ b/src/exchange/exchange.conf
@@ -33,6 +33,14 @@ UNIXPATH_MODE = 660
# HTTP port the exchange listens to
PORT = 8081
+# Base URL of the exchange (public-facing). Due to reverse proxies,
+# this may or may not match our port or hostname at all and can thus
+# not be determined automatically. Note that a globally reachable name
+# is required, so 'localhost' will not work except for testing.
+# Required for wire transfers as we need to include it in the wire
+# transfers to enable tracking.
+BASE_URL = http://localhost:8081/
+
[exchange-admin]
# Network configuration for the /admin HTTP server
diff --git a/src/exchange/taler-exchange-aggregator.c b/src/exchange/taler-exchange-aggregator.c
index d692fe396..96ec7627f 100644
--- a/src/exchange/taler-exchange-aggregator.c
+++ b/src/exchange/taler-exchange-aggregator.c
@@ -29,8 +29,6 @@
#include "taler_wire_lib.h"
-
-
/**
* Information we keep for each loaded wire plugin.
*/
@@ -169,6 +167,11 @@ struct AggregationUnit
static char *exchange_currency_string;
/**
+ * What is the base URL of this exchange?
+ */
+static char *exchange_base_url;
+
+/**
* The exchange's configuration (global)
*/
static struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -763,6 +766,7 @@ run_aggregation (void *cls)
au->ph = wp->wire_plugin->prepare_wire_transfer (wp->wire_plugin->cls,
au->wire,
&au->total_amount,
+ exchange_base_url,
&au->wtid,
&prepare_cb,
au);
@@ -1061,6 +1065,18 @@ run (void *cls,
const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *c)
{
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (c,
+ "exchange",
+ "BASE_URL",
+ &exchange_base_url))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ "exchange",
+ "BASE_URL");
+ global_ret = 1;
+ return;
+ }
cfg = GNUNET_CONFIGURATION_dup (c);
if (GNUNET_OK != exchange_serve_process_config ())
{
diff --git a/src/exchange/test-taler-exchange-aggregator-postgres.conf b/src/exchange/test-taler-exchange-aggregator-postgres.conf
index 0822bab44..7bcadc157 100644
--- a/src/exchange/test-taler-exchange-aggregator-postgres.conf
+++ b/src/exchange/test-taler-exchange-aggregator-postgres.conf
@@ -1,8 +1,40 @@
+[PATHS]
+# Persistant data storage for the testcase
+TALER_TEST_HOME = test_taler_exchange_httpd_home/
+
+[taler]
+# Currency supported by the exchange (can only be one)
+CURRENCY = EUR
+
[exchange]
-#The DB plugin to use
+# The DB plugin to use
DB = postgres
+# Wire format supported by the exchange
+# We use 'test' for testing of the actual
+# coin operations.
+WIREFORMAT = test
+
+# HTTP port the exchange listens to
+PORT = 8081
+
+# Master public key used to sign the exchange's various keys
+MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
+
+# Expected base URL of the exchange.
+BASE_URL = "https://exchange.taler.net/"
+
[exchangedb-postgres]
#The connection string the plugin has to use for connecting to the database
DB_CONN_STR = postgres:///talercheck
+
+
+
+[exchange-wire-outgoing-test]
+# What is the main website of the bank?
+BANK_URI = "http://localhost:8082/"
+
+# From which account at the 'bank' should outgoing
+# wire transfers be made?
+EXCHANGE_ACCOUNT_NUMBER = 3
diff --git a/src/exchange/test_taler_exchange_aggregator.c b/src/exchange/test_taler_exchange_aggregator.c
index aa998712d..6bd0d709b 100644
--- a/src/exchange/test_taler_exchange_aggregator.c
+++ b/src/exchange/test_taler_exchange_aggregator.c
@@ -111,6 +111,11 @@ struct Command
uint64_t credit_account;
/**
+ * Base URL of the exchange.
+ */
+ const char *exchange_base_url;
+
+ /**
* Subject of the transfer, set by the command.
*/
struct TALER_WireTransferIdentifierRawP wtid;
@@ -512,7 +517,7 @@ interpreter (void *cls)
NULL, NULL, NULL,
"taler-exchange-aggregator",
"taler-exchange-aggregator",
- "-c", "test_taler_exchange_httpd.conf",
+ "-c", config_filename,
"-t", /* enable temporary tables */
NULL);
if (NULL == aggregator_proc)
@@ -556,10 +561,11 @@ interpreter (void *cls)
}
if (GNUNET_OK !=
TALER_FAKEBANK_check (fb,
- &want_amount,
- cmd->details.expect_transaction.debit_account,
- cmd->details.expect_transaction.credit_account,
- &cmd->details.expect_transaction.wtid))
+ &want_amount,
+ cmd->details.expect_transaction.debit_account,
+ cmd->details.expect_transaction.credit_account,
+ cmd->details.expect_transaction.exchange_base_url,
+ &cmd->details.expect_transaction.wtid))
{
fail (cmd);
return;
@@ -614,6 +620,7 @@ run_test ()
.label = "expect-deposit-1",
.details.expect_transaction.debit_account = 3,
.details.expect_transaction.credit_account = 4,
+ .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
.details.expect_transaction.amount = "EUR:0.9"
},
@@ -660,6 +667,7 @@ run_test ()
.label = "expect-deposit-2",
.details.expect_transaction.debit_account = 3,
.details.expect_transaction.credit_account = 4,
+ .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
.details.expect_transaction.amount = "EUR:1.8"
},
@@ -705,6 +713,7 @@ run_test ()
.label = "expect-deposit-3a",
.details.expect_transaction.debit_account = 3,
.details.expect_transaction.credit_account = 4,
+ .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
.details.expect_transaction.amount = "EUR:0.9"
},
{
@@ -712,6 +721,7 @@ run_test ()
.label = "expect-deposit-3b",
.details.expect_transaction.debit_account = 3,
.details.expect_transaction.credit_account = 4,
+ .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
.details.expect_transaction.amount = "EUR:0.9"
},
{
@@ -719,6 +729,7 @@ run_test ()
.label = "expect-deposit-3c",
.details.expect_transaction.debit_account = 3,
.details.expect_transaction.credit_account = 5,
+ .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
.details.expect_transaction.amount = "EUR:0.9"
},
{
@@ -767,6 +778,7 @@ run_test ()
.label = "expect-deposit-4",
.details.expect_transaction.debit_account = 3,
.details.expect_transaction.credit_account = 4,
+ .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
.details.expect_transaction.amount = "EUR:0.2"
},
@@ -811,6 +823,7 @@ run_test ()
.label = "expect-deposit-5",
.details.expect_transaction.debit_account = 3,
.details.expect_transaction.credit_account = 4,
+ .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
.details.expect_transaction.amount = "EUR:0.2"
},
@@ -893,6 +906,7 @@ run_test ()
.label = "expect-deposit-6",
.details.expect_transaction.debit_account = 3,
.details.expect_transaction.credit_account = 4,
+ .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
.details.expect_transaction.amount = "EUR:0.01"
},
@@ -932,6 +946,7 @@ run_test ()
.label = "expect-deposit-7",
.details.expect_transaction.debit_account = 3,
.details.expect_transaction.credit_account = 4,
+ .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
.details.expect_transaction.amount = "EUR:0.01"
},
/* Now check profit was actually taken */
@@ -953,6 +968,7 @@ run_test ()
.label = "expect-deposit-7",
.details.expect_transaction.debit_account = 3,
.details.expect_transaction.credit_account = 4,
+ .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
.details.expect_transaction.amount = "EUR:0.02"
},
@@ -1010,6 +1026,7 @@ run_test ()
.label = "expect-deposit-8",
.details.expect_transaction.debit_account = 3,
.details.expect_transaction.credit_account = 4,
+ .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
.details.expect_transaction.amount = "EUR:0.04"
},
@@ -1069,6 +1086,7 @@ run_test ()
.label = "expect-deposit-9",
.details.expect_transaction.debit_account = 3,
.details.expect_transaction.credit_account = 4,
+ .details.expect_transaction.exchange_base_url = "https://exchange.taler.net/",
.details.expect_transaction.amount = "EUR:0.02"
},
@@ -1142,7 +1160,8 @@ run (void *cls)
GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
GNUNET_DISK_pipe_handle (sigpipe,
GNUNET_DISK_PIPE_END_READ),
- &maint_child_death, NULL);
+ &maint_child_death,
+ NULL);
GNUNET_SCHEDULER_add_shutdown (&shutdown_action,
NULL);
timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
@@ -1195,9 +1214,11 @@ main (int argc,
}
plugin_name++;
(void) GNUNET_asprintf (&testname,
- "test-taler-exchange-aggregator-%s", plugin_name);
+ "test-taler-exchange-aggregator-%s",
+ plugin_name);
(void) GNUNET_asprintf (&config_filename,
- "%s.conf", testname);
+ "%s.conf",
+ testname);
/* these might get in the way */
unsetenv ("XDG_DATA_HOME");
unsetenv ("XDG_CONFIG_HOME");
@@ -1214,13 +1235,16 @@ main (int argc,
GNUNET_free (testname);
return 2;
}
- sigpipe = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, GNUNET_NO, GNUNET_NO);
+ sigpipe = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO,
+ GNUNET_NO, GNUNET_NO);
GNUNET_assert (NULL != sigpipe);
shc_chld =
- GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, &sighandler_child_death);
+ GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD,
+ &sighandler_child_death);
coin_pk = GNUNET_CRYPTO_rsa_private_key_create (1024);
coin_pub = GNUNET_CRYPTO_rsa_private_key_get_public (coin_pk);
- GNUNET_SCHEDULER_run (&run, cfg);
+ GNUNET_SCHEDULER_run (&run,
+ cfg);
GNUNET_CRYPTO_rsa_private_key_free (coin_pk);
GNUNET_CRYPTO_rsa_public_key_free (coin_pub);
GNUNET_SIGNAL_handler_uninstall (shc_chld);