summaryrefslogtreecommitdiff
path: root/src/bank-lib
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2018-06-12 19:16:43 +0200
committerMarcello Stanisci <stanisci.m@gmail.com>2018-06-12 19:16:43 +0200
commit6f579eb833be396b56903ff7252c3023ef46a92d (patch)
tree449e83b49c02c88d72d91396c3dfb186412d511c /src/bank-lib
parent01f933bbdc69388eb6e0c7a476292a9b667d9027 (diff)
downloadexchange-6f579eb833be396b56903ff7252c3023ef46a92d.tar.gz
exchange-6f579eb833be396b56903ff7252c3023ef46a92d.tar.bz2
exchange-6f579eb833be396b56903ff7252c3023ef46a92d.zip
From payto:// to base url.
The conversion prepends http// or https:// depending on the port given beside the hostname. If port is 433, then prepends https://, otherwise prepends http://. For now, the conversion was only necessary at the /history bank lib.
Diffstat (limited to 'src/bank-lib')
-rw-r--r--src/bank-lib/bank_api_history.c11
-rw-r--r--src/bank-lib/fakebank.c2
-rw-r--r--src/bank-lib/test_bank_interpreter.c4
-rw-r--r--src/bank-lib/testing_api_cmd_history.c17
4 files changed, 24 insertions, 10 deletions
diff --git a/src/bank-lib/bank_api_history.c b/src/bank-lib/bank_api_history.c
index 902165de..fa53a5bb 100644
--- a/src/bank-lib/bank_api_history.c
+++ b/src/bank-lib/bank_api_history.c
@@ -78,6 +78,7 @@ parse_account_history (struct TALER_BANK_HistoryHandle *hh,
const json_t *history)
{
json_t *history_array;
+ char *bank_hostname;
if (NULL == (history_array = json_object_get (history, "data")))
{
@@ -136,11 +137,17 @@ parse_account_history (struct TALER_BANK_HistoryHandle *hh,
GNUNET_JSON_parse_free (hist_spec);
return GNUNET_SYSERR;
}
+ /* Note, bank_base_url has _always_ the protocol scheme
+ * and it proved to be good at this point. */
+ bank_hostname = strchr (hh->bank_base_url, ':');
+ GNUNET_assert (NULL != bank_hostname);
+ bank_hostname += 3;
+
GNUNET_asprintf (&td.account_url,
- ('/' == hh->bank_base_url[strlen(hh->bank_base_url)-1])
+ ('/' == bank_hostname[strlen(bank_hostname)-1])
? "payto://x-taler-bank/%s%llu"
: "payto://x-taler-bank/%s/%llu",
- hh->bank_base_url,
+ bank_hostname,
(unsigned long long) other_account);
hh->hcb (hh->hcb_cls,
MHD_HTTP_OK,
diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c
index 6761cb51..2a816468 100644
--- a/src/bank-lib/fakebank.c
+++ b/src/bank-lib/fakebank.c
@@ -960,6 +960,8 @@ handle_mhd_request (void *cls,
/* Unexpected URL path, just close the connection. */
/* we're rather impolite here, but it's a testcase. */
+ TALER_LOG_ERROR ("Breaking URL: %s\n",
+ url);
GNUNET_break_op (0);
return MHD_NO;
}
diff --git a/src/bank-lib/test_bank_interpreter.c b/src/bank-lib/test_bank_interpreter.c
index e503bd8d..fe6b4e1a 100644
--- a/src/bank-lib/test_bank_interpreter.c
+++ b/src/bank-lib/test_bank_interpreter.c
@@ -328,7 +328,7 @@ build_history (struct InterpreterState *is,
h[total].direction |= TALER_BANK_DIRECTION_CANCEL;
GNUNET_asprintf (&h[total].details.account_url,
"payto://x-taler-bank/%s/%llu",
- "http://localhost:8080",
+ "localhost:8080",
(unsigned long long) pos->details.admin_add_incoming.debit_account_no);
}
if ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_DEBIT)) &&
@@ -340,7 +340,7 @@ build_history (struct InterpreterState *is,
h[total].direction |= TALER_BANK_DIRECTION_CANCEL;
GNUNET_asprintf (&h[total].details.account_url,
"payto://x-taler-bank/%s/%llu",
- "http://localhost:8080",
+ "localhost:8080",
(unsigned long long) pos->details.admin_add_incoming.credit_account_no);
}
if ( ( (0 != (cmd->details.history.direction & TALER_BANK_DIRECTION_CREDIT)) &&
diff --git a/src/bank-lib/testing_api_cmd_history.c b/src/bank-lib/testing_api_cmd_history.c
index fa5e8739..c9f4960e 100644
--- a/src/bank-lib/testing_api_cmd_history.c
+++ b/src/bank-lib/testing_api_cmd_history.c
@@ -380,6 +380,9 @@ build_history (struct TALER_TESTING_Interpreter *is,
const struct TALER_TESTING_Command *pos = &is->commands[off];
int cancelled;
const uint64_t *row_id;
+ char *bank_hostname;
+ const uint64_t *credit_account_no;
+ const uint64_t *debit_account_no;
if (GNUNET_OK != TALER_TESTING_GET_TRAIT_ROW_ID
(pos, &row_id))
@@ -408,8 +411,6 @@ build_history (struct TALER_TESTING_Interpreter *is,
TALER_LOG_INFO ("hit limit specified by command\n");
break;
}
- const uint64_t *credit_account_no;
- const uint64_t *debit_account_no;
GNUNET_assert
(GNUNET_OK == TALER_TESTING_GET_TRAIT_CREDIT_ACCOUNT
@@ -444,6 +445,10 @@ build_history (struct TALER_TESTING_Interpreter *is,
continue;
}
+ bank_hostname = strchr (hs->bank_url, ':');
+ GNUNET_assert (NULL != bank_hostname);
+ bank_hostname += 3;
+
if ( (0 != (hs->direction & TALER_BANK_DIRECTION_CREDIT)) &&
(hs->account_no == *credit_account_no))
{
@@ -453,10 +458,10 @@ build_history (struct TALER_TESTING_Interpreter *is,
GNUNET_asprintf
(&h[total].details.account_url,
- ('/' == hs->bank_url[strlen(hs->bank_url) -1])
+ ('/' == bank_hostname[strlen(bank_hostname) -1])
? "payto://x-taler-bank/%s%llu"
: "payto://x-taler-bank/%s/%llu",
- hs->bank_url,
+ bank_hostname,
(unsigned long long) *debit_account_no);
}
if ( (0 != (hs->direction & TALER_BANK_DIRECTION_DEBIT)) &&
@@ -468,10 +473,10 @@ build_history (struct TALER_TESTING_Interpreter *is,
GNUNET_asprintf
(&h[total].details.account_url,
- ('/' == hs->bank_url[strlen(hs->bank_url) -1])
+ ('/' == bank_hostname[strlen(bank_hostname) -1])
? "payto://x-taler-bank/%s%llu"
: "payto://x-taler-bank/%s/%llu",
- hs->bank_url,
+ bank_hostname,
(unsigned long long) *credit_account_no);
}
if ( ( (0 != (hs->direction & TALER_BANK_DIRECTION_CREDIT)) &&