aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bank-lib/fakebank.c66
-rw-r--r--src/include/taler_util.h11
-rw-r--r--src/lib/testing_api_cmd_bank_check.c7
-rw-r--r--src/util/test_payto.c8
-rw-r--r--src/util/util.c31
5 files changed, 76 insertions, 47 deletions
diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c
index b12b04378..8f0306870 100644
--- a/src/bank-lib/fakebank.c
+++ b/src/bank-lib/fakebank.c
@@ -54,12 +54,12 @@ struct Transaction
struct TALER_Amount amount;
/**
- * Account to debit.
+ * Account to debit (string, not payto!)
*/
char *debit_account;
/**
- * Account to credit.
+ * Account to credit (string, not payto!)
*/
char *credit_account;
@@ -198,27 +198,6 @@ struct TALER_FAKEBANK_Handle
/**
- * Return account string from an x-taler-bank payto:// URL.
- *
- * @param payto:// URL of method x-taler-bank
- * @return account_name the account name
- */
-char *
-get_xtalerbank_payto_account (const char *payto_url)
-{
- const char *beg;
-
- GNUNET_assert (0 == strncasecmp (payto_url,
- "payto://x-taler-bank/",
- strlen ("payto://x-taler-bank/")));
- beg = strchr (&payto_url[strlen ("payto://x-taler-bank/")],
- '/');
- GNUNET_assert (NULL != beg);
- return GNUNET_strdup (&beg[1]);
-}
-
-
-/**
* Generate log messages for failed check operation.
*
* @param h handle to output transaction log for
@@ -346,8 +325,8 @@ TALER_FAKEBANK_check_credit (struct TALER_FAKEBANK_Handle *h,
* Tell the fakebank to create another wire transfer.
*
* @param h fake bank handle
- * @param debit_account account to debit
- * @param credit_account account to credit
+ * @param debit_account account to debit, not payto://!
+ * @param credit_account account to credit, not payto://!
* @param amount amount to transfer
* @param subject wire transfer subject to use
* @param exchange_base_url exchange URL
@@ -366,6 +345,12 @@ TALER_FAKEBANK_make_transfer (struct TALER_FAKEBANK_Handle *h,
{
struct Transaction *t;
+ GNUNET_break (0 != strncasecmp ("payto://",
+ debit_account,
+ strlen ("payto://")));
+ GNUNET_break (0 != strncasecmp ("payto://",
+ credit_account,
+ strlen ("payto://")));
if (NULL != request_uid)
{
for (struct Transaction *t = h->transactions_head; NULL != t; t = t->next)
@@ -431,6 +416,12 @@ TALER_FAKEBANK_make_admin_transfer (struct TALER_FAKEBANK_Handle *h,
{
struct Transaction *t;
+ GNUNET_break (0 != strncasecmp ("payto://",
+ debit_account,
+ strlen ("payto://")));
+ GNUNET_break (0 != strncasecmp ("payto://",
+ credit_account,
+ strlen ("payto://")));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Making transfer from %s to %s over %s and subject %s\n",
debit_account,
@@ -616,7 +607,7 @@ handle_admin_add_incoming (struct TALER_FAKEBANK_Handle *h,
json_decref (json);
return MHD_NO;
}
- debit = get_xtalerbank_payto_account (debit_account);
+ debit = TALER_xtalerbank_account_from_payto (debit_account);
row_id = TALER_FAKEBANK_make_admin_transfer (h,
debit,
account,
@@ -692,6 +683,7 @@ handle_transfer (struct TALER_FAKEBANK_Handle *h,
struct GNUNET_HashCode uuid;
struct TALER_WireTransferIdentifierRawP wtid;
const char *credit_account;
+ char *credit;
const char *base_url;
struct TALER_Amount amount;
struct GNUNET_JSON_Specification spec[] = {
@@ -718,9 +710,10 @@ handle_transfer (struct TALER_FAKEBANK_Handle *h,
return MHD_NO;
}
{
+ credit = TALER_xtalerbank_account_from_payto (credit_account);
row_id = TALER_FAKEBANK_make_transfer (h,
account,
- credit_account,
+ credit,
&amount,
&wtid,
base_url,
@@ -728,10 +721,11 @@ handle_transfer (struct TALER_FAKEBANK_Handle *h,
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Receiving incoming wire transfer: %s->%s, subject: %s, amount: %s, from %s\n",
account,
- credit_account,
+ credit,
TALER_B2S (&wtid),
TALER_amount2s (&amount),
base_url);
+ GNUNET_free (credit);
}
}
json_decref (json);
@@ -972,14 +966,6 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
else
ha.delta++;
}
- else
- {
- fprintf (stderr,
- "Skipping transaction %s->%s: only care about %s\n",
- pos->debit_account,
- pos->credit_account,
- account);
- }
if (ha.delta > 0)
pos = pos->prev;
else
@@ -1088,14 +1074,6 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
else
ha.delta++;
}
- else
- {
- fprintf (stderr,
- "Skipping transaction %s->%s: only care about %s\n",
- pos->debit_account,
- pos->credit_account,
- account);
- }
if (ha.delta > 0)
pos = pos->prev;
else
diff --git a/src/include/taler_util.h b/src/include/taler_util.h
index da5017949..0f4eaab66 100644
--- a/src/include/taler_util.h
+++ b/src/include/taler_util.h
@@ -280,4 +280,15 @@ char *
TALER_xtalerbank_account_url_from_payto (const char *payto);
+/**
+ * Obtain the account name from a payto URL.
+ *
+ * @param payto an x-taler-bank payto URL
+ * @return only the account name from the @a payto URL, NULL if not an x-taler-bank
+ * payto URL
+ */
+char *
+TALER_xtalerbank_account_from_payto (const char *payto);
+
+
#endif
diff --git a/src/lib/testing_api_cmd_bank_check.c b/src/lib/testing_api_cmd_bank_check.c
index a7c4341c5..e443833a4 100644
--- a/src/lib/testing_api_cmd_bank_check.c
+++ b/src/lib/testing_api_cmd_bank_check.c
@@ -129,9 +129,10 @@ check_bank_transfer_run (void *cls,
if (NULL == deposit_cmd)
TALER_TESTING_FAIL (is);
- GNUNET_assert
- (GNUNET_OK == TALER_TESTING_get_trait_amount_obj
- (deposit_cmd, 0, &amount_ptr));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_TESTING_get_trait_amount_obj (deposit_cmd,
+ 0,
+ &amount_ptr));
amount = *amount_ptr;
GNUNET_assert
diff --git a/src/util/test_payto.c b/src/util/test_payto.c
index 0a570ee5a..f0247f19b 100644
--- a/src/util/test_payto.c
+++ b/src/util/test_payto.c
@@ -78,6 +78,14 @@ main (int argc,
"payto://x-taler-bank/localhost:1080/alice");
CHECK ("http://localhost:1080/alice",
r);
+ r = TALER_xtalerbank_account_from_payto (
+ "payto://x-taler-bank/localhost:1080/alice");
+ CHECK ("alice",
+ r);
+ r = TALER_xtalerbank_account_from_payto (
+ "payto://x-taler-bank/localhost:1080/alice?subject=hello&amount=EUR:1");
+ CHECK ("alice",
+ r);
return 0;
}
diff --git a/src/util/util.c b/src/util/util.c
index 531bd27f5..7f5e60e4d 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -710,4 +710,35 @@ TALER_xtalerbank_account_url_from_payto (const char *payto)
}
+/**
+ * Obtain the account name from a payto URL.
+ *
+ * @param payto an x-taler-bank payto URL
+ * @return only the account name from the @a payto URL, NULL if not an x-taler-bank
+ * payto URL
+ */
+char *
+TALER_xtalerbank_account_from_payto (const char *payto)
+{
+ const char *beg;
+ const char *end;
+
+ if (0 != strncasecmp (payto,
+ "payto://x-taler-bank/",
+ strlen ("payto://x-taler-bank/")))
+ return NULL;
+ beg = strchr (&payto[strlen ("payto://x-taler-bank/")],
+ '/');
+ if (NULL == beg)
+ return NULL;
+ beg++;
+ end = strchr (beg,
+ '?');
+ if (NULL == end)
+ return GNUNET_strdup (beg);
+ return GNUNET_strndup (beg,
+ end - beg);
+}
+
+
/* end of util.c */