aboutsummaryrefslogtreecommitdiff
path: root/src/wire
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/wire
parent4d8942b8188e5d2ddd6d3d8a31b141e59a82f771 (diff)
implementing #4921: add base URL to wire transfers
Diffstat (limited to 'src/wire')
-rw-r--r--src/wire/plugin_wire_sepa.c4
-rw-r--r--src/wire/plugin_wire_template.c2
-rw-r--r--src/wire/plugin_wire_test.c40
3 files changed, 38 insertions, 8 deletions
diff --git a/src/wire/plugin_wire_sepa.c b/src/wire/plugin_wire_sepa.c
index 4f1d50414..e15eabbf9 100644
--- a/src/wire/plugin_wire_sepa.c
+++ b/src/wire/plugin_wire_sepa.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2016 GNUnet e.V. & Inria
+ Copyright (C) 2016, 2017 GNUnet e.V. & Inria
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -658,6 +658,7 @@ sepa_sign_wire_details (void *cls,
* @param cls the @e cls of this struct with the plugin-specific state
* @param wire valid wire account information
* @param amount amount to transfer, already rounded
+ * @param exchange_base_url base URL of the exchange (for tracking)
* @param wtid wire transfer identifier to use
* @param psc function to call with the prepared data to persist
* @param psc_cls closure for @a psc
@@ -667,6 +668,7 @@ static struct TALER_WIRE_PrepareHandle *
sepa_prepare_wire_transfer (void *cls,
const json_t *wire,
const struct TALER_Amount *amount,
+ const char *exchange_base_url,
const struct TALER_WireTransferIdentifierRawP *wtid,
TALER_WIRE_PrepareTransactionCallback psc,
void *psc_cls)
diff --git a/src/wire/plugin_wire_template.c b/src/wire/plugin_wire_template.c
index 416eb9c58..aa4e1a3b3 100644
--- a/src/wire/plugin_wire_template.c
+++ b/src/wire/plugin_wire_template.c
@@ -120,6 +120,7 @@ template_wire_validate (void *cls,
* @param cls the @e cls of this struct with the plugin-specific state
* @param wire valid wire account information
* @param amount amount to transfer, already rounded
+ * @param exchange_base_url base URL of the exchange (for tracking)
* @param wtid wire transfer identifier to use
* @param ptc function to call with the prepared data to persist
* @param ptc_cls closure for @a ptc
@@ -129,6 +130,7 @@ static struct TALER_WIRE_PrepareHandle *
template_prepare_wire_transfer (void *cls,
const json_t *wire,
const struct TALER_Amount *amount,
+ const char *exchange_base_url,
const struct TALER_WireTransferIdentifierRawP *wtid,
TALER_WIRE_PrepareTransactionCallback ptc,
void *ptc_cls)
diff --git a/src/wire/plugin_wire_test.c b/src/wire/plugin_wire_test.c
index 7b52dee40..84bff98bd 100644
--- a/src/wire/plugin_wire_test.c
+++ b/src/wire/plugin_wire_test.c
@@ -86,6 +86,11 @@ struct TALER_WIRE_PrepareHandle
json_t *wire;
/**
+ * Base URL to use for the exchange.
+ */
+ char *exchange_base_url;
+
+ /**
* Function to call with the serialized data.
*/
TALER_WIRE_PrepareTransactionCallback ptc;
@@ -397,7 +402,9 @@ struct BufFormatP
*/
struct TALER_AmountNBO amount;
- /* followed by serialized 'wire' JSON data */
+ /* followed by serialized 'wire' JSON data (0-terminated) */
+
+ /* followed by 0-terminated base URL */
};
GNUNET_NETWORK_STRUCT_END
@@ -417,6 +424,7 @@ test_prepare_wire_transfer_cancel (void *cls,
if (NULL != pth->task)
GNUNET_SCHEDULER_cancel (pth->task);
json_decref (pth->wire);
+ GNUNET_free (pth->exchange_base_url);
GNUNET_free (pth);
}
@@ -432,7 +440,8 @@ do_prepare (void *cls)
{
struct TALER_WIRE_PrepareHandle *pth = cls;
char *wire_enc;
- size_t len;
+ size_t len_w;
+ size_t len_b;
struct BufFormatP bf;
pth->task = NULL;
@@ -449,19 +458,23 @@ do_prepare (void *cls)
pth);
return;
}
- len = strlen (wire_enc) + 1;
+ len_w = strlen (wire_enc) + 1;
+ len_b = strlen (pth->exchange_base_url) + 1;
bf.wtid = pth->wtid;
TALER_amount_hton (&bf.amount,
&pth->amount);
{
- char buf[sizeof (struct BufFormatP) + len];
+ char buf[sizeof (struct BufFormatP) + len_w + len_b];
memcpy (buf,
&bf,
sizeof (struct BufFormatP));
memcpy (&buf[sizeof (struct BufFormatP)],
wire_enc,
- len);
+ len_w);
+ memcpy (&buf[sizeof (struct BufFormatP) + len_w],
+ pth->exchange_base_url,
+ len_b);
/* finally give the state back */
pth->ptc (pth->ptc_cls,
@@ -485,6 +498,7 @@ do_prepare (void *cls)
* @param cls the @e cls of this struct with the plugin-specific state
* @param wire valid wire account information
* @param amount amount to transfer, already rounded
+ * @param exchange_base_url base URL of this exchange
* @param wtid wire transfer identifier to use
* @param ptc function to call with the prepared data to persist
* @param ptc_cls closure for @a ptc
@@ -494,6 +508,7 @@ static struct TALER_WIRE_PrepareHandle *
test_prepare_wire_transfer (void *cls,
const json_t *wire,
const struct TALER_Amount *amount,
+ const char *exchange_base_url,
const struct TALER_WireTransferIdentifierRawP *wtid,
TALER_WIRE_PrepareTransactionCallback ptc,
void *ptc_cls)
@@ -515,6 +530,7 @@ test_prepare_wire_transfer (void *cls,
pth = GNUNET_new (struct TALER_WIRE_PrepareHandle);
pth->tc = tc;
pth->wire = json_incref ((json_t *) wire);
+ pth->exchange_base_url = GNUNET_strdup (exchange_base_url);
pth->wtid = *wtid;
pth->ptc = ptc;
pth->ptc_cls = ptc_cls;
@@ -650,6 +666,8 @@ test_execute_wire_transfer (void *cls,
json_int_t account_no;
struct BufFormatP bf;
char *emsg;
+ const char *json_s;
+ const char *exchange_base_url;
if (NULL == tc->ctx)
{
@@ -658,7 +676,14 @@ test_execute_wire_transfer (void *cls,
return NULL; /* not initialized with configuration, cannot do transfers */
}
if ( (buf_size <= sizeof (struct BufFormatP)) ||
- ('\0' != buf[buf_size -1]) )
+ ('\0' != buf[buf_size - 1]) )
+ {
+ GNUNET_break (0);
+ return NULL;
+ }
+ json_s = &buf[sizeof (struct BufFormatP)];
+ exchange_base_url = &json_s[strlen (json_s) + 1];
+ if (exchange_base_url > &buf[buf_size - 1])
{
GNUNET_break (0);
return NULL;
@@ -668,7 +693,7 @@ test_execute_wire_transfer (void *cls,
sizeof (bf));
TALER_amount_ntoh (&amount,
&bf.amount);
- wire = json_loads (&buf[sizeof (struct BufFormatP)],
+ wire = json_loads (json_s,
JSON_REJECT_DUPLICATES,
NULL);
if (NULL == wire)
@@ -697,6 +722,7 @@ test_execute_wire_transfer (void *cls,
eh->cc_cls = cc_cls;
eh->aaih = TALER_BANK_admin_add_incoming (tc->ctx,
tc->bank_uri,
+ exchange_base_url,
&bf.wtid,
&amount,
(uint64_t) tc->exchange_account_outgoing_no,