aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-05-08 13:18:36 +0200
committerChristian Grothoff <christian@grothoff.org>2017-05-08 13:18:36 +0200
commit20aad54c3e010020185c76d9e0727f3f497c2f73 (patch)
tree37013453e198452b30710fb9165a2f5389cb6af9
parent2dcaffe4510410e568d637c1e251e230e2df41d9 (diff)
remove dead transfer details field from reserves_in (API, exchangedb, etc.)
-rw-r--r--src/auditor/taler-auditor.c2
-rw-r--r--src/exchange-lib/exchange_api_reserve.c40
-rw-r--r--src/exchange-tools/taler-exchange-reservemod.c14
-rw-r--r--src/exchange/taler-exchange-httpd_db.c15
-rw-r--r--src/exchange/taler-exchange-httpd_responses.c3
-rw-r--r--src/exchange/taler-exchange-wirewatch.c4
-rw-r--r--src/exchangedb/perf_taler_exchangedb_interpreter.c17
-rw-r--r--src/exchangedb/plugin_exchangedb_common.c2
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c25
-rw-r--r--src/exchangedb/test_exchangedb.c15
-rw-r--r--src/include/taler_exchange_service.h9
-rw-r--r--src/include/taler_exchangedb_plugin.h16
12 files changed, 67 insertions, 95 deletions
diff --git a/src/auditor/taler-auditor.c b/src/auditor/taler-auditor.c
index aad4cea6e..56712a3ab 100644
--- a/src/auditor/taler-auditor.c
+++ b/src/auditor/taler-auditor.c
@@ -614,7 +614,6 @@ struct ReserveContext
* @param reserve_pub public key of the reserve (also the WTID)
* @param credit amount that was received
* @param sender_account_details information about the sender's bank account
- * @param transfer_details information that uniquely identifies the wire transfer
* @param wire_reference unique reference identifying the wire transfer (binary blob)
* @param wire_reference_size number of bytes in @a wire_reference
* @param execution_date when did we receive the funds
@@ -626,7 +625,6 @@ handle_reserve_in (void *cls,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_Amount *credit,
const json_t *sender_account_details,
- const json_t *transfer_details,
const void *wire_reference,
size_t wire_reference_size,
struct GNUNET_TIME_Absolute execution_date)
diff --git a/src/exchange-lib/exchange_api_reserve.c b/src/exchange-lib/exchange_api_reserve.c
index 716be641d..7649cccda 100644
--- a/src/exchange-lib/exchange_api_reserve.c
+++ b/src/exchange-lib/exchange_api_reserve.c
@@ -138,7 +138,17 @@ parse_reserve_history (struct TALER_EXCHANGE_Handle *exchange,
"DEPOSIT"))
{
json_t *wire_account;
- json_t *transfer;
+ void *wire_reference;
+ size_t wire_reference_size;
+
+ struct GNUNET_JSON_Specification withdraw_spec[] = {
+ GNUNET_JSON_spec_varsize ("wire_reference",
+ &wire_reference,
+ &wire_reference_size),
+ GNUNET_JSON_spec_json ("sender_account_details",
+ &wire_account),
+ GNUNET_JSON_spec_end()
+ };
rhistory[off].type = TALER_EXCHANGE_RTT_DEPOSIT;
if (GNUNET_OK !=
@@ -150,33 +160,17 @@ parse_reserve_history (struct TALER_EXCHANGE_Handle *exchange,
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
- wire_account = json_object_get (transaction,
- "sender_account_details");
- /* check 'wire_account' is a JSON object (no need to check wireformat,
- but we do at least expect "some" JSON object here) */
- if ( (NULL == wire_account) ||
- (! json_is_object (wire_account)) )
- {
- /* not even a JSON 'wire' specification, not acceptable */
- GNUNET_break_op (0);
- if (NULL != wire_account)
- json_decref (wire_account);
- return GNUNET_SYSERR;
- }
- transfer = json_object_get (transaction,
- "transfer_details");
- /* check 'transfer' is a JSON object */
- if ( (NULL == transfer) ||
- (! json_is_object (transfer)) )
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (transaction,
+ withdraw_spec,
+ NULL, NULL))
{
GNUNET_break_op (0);
- json_decref (wire_account);
- if (NULL != transfer)
- json_decref (transfer);
return GNUNET_SYSERR;
}
rhistory[off].details.in_details.sender_account_details = wire_account;
- rhistory[off].details.in_details.transfer_details = transfer;
+ rhistory[off].details.in_details.wire_reference = wire_reference;
+ rhistory[off].details.in_details.wire_reference_size = wire_reference_size;
/* end type==DEPOSIT */
}
else if (0 == strcasecmp (type,
diff --git a/src/exchange-tools/taler-exchange-reservemod.c b/src/exchange-tools/taler-exchange-reservemod.c
index 626499056..84595d199 100644
--- a/src/exchange-tools/taler-exchange-reservemod.c
+++ b/src/exchange-tools/taler-exchange-reservemod.c
@@ -80,6 +80,7 @@ run_transaction (const struct TALER_ReservePublicKeyP *reserve_pub,
{
int ret;
struct TALER_EXCHANGEDB_Session *session;
+ void *json_str;
session = plugin->get_session (plugin->cls);
if (NULL == session)
@@ -89,15 +90,22 @@ run_transaction (const struct TALER_ReservePublicKeyP *reserve_pub,
return GNUNET_SYSERR;
}
/* FIXME: maybe allow passing timestamp via command-line? */
+ json_str = json_dumps (tdetails,
+ JSON_INDENT(2));
+ if (NULL == json_str)
+ {
+ GNUNET_break (0); /* out of memory? */
+ return GNUNET_SYSERR;
+ }
ret = plugin->reserves_in_insert (plugin->cls,
session,
reserve_pub,
add_value,
GNUNET_TIME_absolute_get (),
jdetails,
- "FIXME",
- 5,
- tdetails);
+ json_str,
+ strlen (json_str));
+ free (json_str);
if (GNUNET_SYSERR == ret)
{
fprintf (stderr,
diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c
index 085438d60..0634e34f6 100644
--- a/src/exchange/taler-exchange-httpd_db.c
+++ b/src/exchange/taler-exchange-httpd_db.c
@@ -1867,6 +1867,7 @@ TEH_DB_execute_admin_add_incoming (struct MHD_Connection *connection,
{
struct TALER_EXCHANGEDB_Session *session;
int ret;
+ void *json_str;
if (NULL == (session = TEH_plugin->get_session (TEH_plugin->cls)))
{
@@ -1874,15 +1875,23 @@ TEH_DB_execute_admin_add_incoming (struct MHD_Connection *connection,
return TEH_RESPONSE_reply_internal_db_error (connection,
TALER_EC_DB_SETUP_FAILED);
}
+ json_str = json_dumps (transfer_details,
+ JSON_INDENT(2));
+ if (NULL == json_str)
+ {
+ GNUNET_break (0);
+ return TEH_RESPONSE_reply_internal_db_error (connection,
+ TALER_EC_PARSER_OUT_OF_MEMORY);
+ }
ret = TEH_plugin->reserves_in_insert (TEH_plugin->cls,
session,
reserve_pub,
amount,
execution_time,
sender_account_details,
- "FIXME",
- 5,
- transfer_details);
+ json_str,
+ strlen (json_str));
+ free (json_str);
if (GNUNET_SYSERR == ret)
{
GNUNET_break (0);
diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c
index a839413b7..f9051f0b4 100644
--- a/src/exchange/taler-exchange-httpd_responses.c
+++ b/src/exchange/taler-exchange-httpd_responses.c
@@ -772,7 +772,8 @@ compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHistory *rh,
json_pack ("{s:s, s:O, s:O, s:o}",
"type", "DEPOSIT",
"sender_account_details", pos->details.bank->sender_account_details,
- "transfer_details", pos->details.bank->transfer_details,
+ "wire_reference", GNUNET_JSON_from_data (pos->details.bank->wire_reference,
+ pos->details.bank->wire_reference_size),
"amount", TALER_JSON_from_amount (&pos->details.bank->amount))));
break;
case TALER_EXCHANGEDB_RO_WITHDRAW_COIN:
diff --git a/src/exchange/taler-exchange-wirewatch.c b/src/exchange/taler-exchange-wirewatch.c
index 918eb597a..6daf5caca 100644
--- a/src/exchange/taler-exchange-wirewatch.c
+++ b/src/exchange/taler-exchange-wirewatch.c
@@ -238,7 +238,6 @@ history_cb (void *cls,
NULL);
return GNUNET_OK; /* will be ignored anyway */
}
- // FIXME: create json!
ret = db_plugin->reserves_in_insert (db_plugin->cls,
session,
&details->reserve_pub,
@@ -246,8 +245,7 @@ history_cb (void *cls,
details->execution_date,
details->account_details,
row_off,
- row_off_size,
- NULL /* FIXME */);
+ row_off_size);
if (GNUNET_OK != ret)
{
GNUNET_break (0);
diff --git a/src/exchangedb/perf_taler_exchangedb_interpreter.c b/src/exchangedb/perf_taler_exchangedb_interpreter.c
index 06078cfe7..9c4eb367a 100644
--- a/src/exchangedb/perf_taler_exchangedb_interpreter.c
+++ b/src/exchangedb/perf_taler_exchangedb_interpreter.c
@@ -1374,7 +1374,7 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state)
int ret;
struct PERF_TALER_EXCHANGEDB_Reserve *reserve;
json_t *sndr;
- json_t *just;
+ uint32_t uid;
reserve_index = state->cmd[state->i].details.insert_reserve.index_reserve;
reserve = state->cmd[reserve_index].exposed.data.reserve;
@@ -1382,11 +1382,8 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state)
"account",
(int) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
UINT32_MAX));
- just = json_pack ("{s:i}",
- "justification",
- (int) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- UINT32_MAX));
- GNUNET_assert (NULL != just);
+ uid = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
+ UINT32_MAX);
GNUNET_assert (NULL != sndr);
ret = state->plugin->reserves_in_insert (state->plugin->cls,
state->session,
@@ -1394,12 +1391,10 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state)
&reserve->reserve.balance,
GNUNET_TIME_absolute_get (),
sndr,
- "PERF",
- 4,
- just);
+ &uid,
+ sizeof (uid));
GNUNET_assert (GNUNET_SYSERR != ret);
json_decref (sndr);
- json_decref (just);
}
break;
@@ -1486,7 +1481,7 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state)
dki_index = state->cmd[state->i].details.create_withdraw.index_dki;
reserve_index = state->cmd[state->i].details.create_withdraw.index_reserve;
coin = PERF_TALER_EXCHANGEDB_coin_init (state->cmd[dki_index].exposed.data.dki,
- state->cmd[reserve_index].exposed.data.reserve);
+ state->cmd[reserve_index].exposed.data.reserve);
GNUNET_assert (NULL != coin);
state->cmd[state->i].exposed.data.coin = coin;
}
diff --git a/src/exchangedb/plugin_exchangedb_common.c b/src/exchangedb/plugin_exchangedb_common.c
index 0f7d2fe76..61c00c14d 100644
--- a/src/exchangedb/plugin_exchangedb_common.c
+++ b/src/exchangedb/plugin_exchangedb_common.c
@@ -44,8 +44,6 @@ common_free_reserve_history (void *cls,
bt = rh->details.bank;
if (NULL != bt->sender_account_details)
json_decref (bt->sender_account_details);
- if (NULL != bt->transfer_details)
- json_decref (bt->transfer_details);
GNUNET_free_non_null (bt->wire_reference);
GNUNET_free (bt);
break;
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index 6a59b9f58..0bf82f048 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -357,7 +357,6 @@ postgres_create_tables (void *cls)
",credit_frac INT4 NOT NULL"
",credit_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
",sender_account_details TEXT NOT NULL"
- ",transfer_details TEXT NOT NULL"
",execution_date INT8 NOT NULL"
",PRIMARY KEY (reserve_pub, wire_reference)"
");");
@@ -764,11 +763,10 @@ postgres_prepare (PGconn *db_conn)
",credit_frac"
",credit_curr"
",sender_account_details"
- ",transfer_details"
",execution_date"
") VALUES "
- "($1, $2, $3, $4, $5, $6, $7, $8);",
- 8, NULL);
+ "($1, $2, $3, $4, $5, $6, $7);",
+ 7, NULL);
/* Used in postgres_select_reserves_in_above_serial_id() to obtain inbound
@@ -782,7 +780,6 @@ postgres_prepare (PGconn *db_conn)
",credit_curr"
",execution_date"
",sender_account_details"
- ",transfer_details"
",reserve_in_serial_id"
" FROM reserves_in"
" WHERE reserve_in_serial_id>=$1"
@@ -799,7 +796,6 @@ postgres_prepare (PGconn *db_conn)
",credit_curr"
",execution_date"
",sender_account_details"
- ",transfer_details"
" FROM reserves_in"
" WHERE reserve_pub=$1",
1, NULL);
@@ -2080,7 +2076,6 @@ reserves_update (void *cls,
* @param sender_account_details account information for the sender
* @param wire_reference unique reference identifying the wire transfer (binary blob)
* @param wire_reference_size number of bytes in @a wire_reference
- * @param transfer_details information that uniquely identifies the transfer
* @return #GNUNET_OK upon success; #GNUNET_NO if the given
* @a details are already known for this @a reserve_pub,
* #GNUNET_SYSERR upon failures (DB error, incompatible currency)
@@ -2093,8 +2088,7 @@ postgres_reserves_in_insert (void *cls,
struct GNUNET_TIME_Absolute execution_time,
const json_t *sender_account_details,
const void *wire_reference,
- size_t wire_reference_size,
- const json_t *transfer_details)
+ size_t wire_reference_size)
{
struct PostgresClosure *pg = cls;
PGresult *result;
@@ -2178,7 +2172,6 @@ postgres_reserves_in_insert (void *cls,
wire_reference_size),
TALER_PQ_query_param_amount (balance),
TALER_PQ_query_param_json (sender_account_details),
- TALER_PQ_query_param_json (transfer_details),
GNUNET_PQ_query_param_absolute_time (&execution_time),
GNUNET_PQ_query_param_end
};
@@ -2479,8 +2472,6 @@ postgres_get_reserve_history (void *cls,
&bt->execution_date),
TALER_PQ_result_spec_json ("sender_account_details",
&bt->sender_account_details),
- TALER_PQ_result_spec_json ("transfer_details",
- &bt->transfer_details),
GNUNET_PQ_result_spec_end
};
if (GNUNET_OK !=
@@ -5369,7 +5360,7 @@ postgres_start_deferred_wire_out (void *cls,
* @param session database connection
* @param date time of the wire transfer
* @param wtid subject of the wire transfer
- * @param wire details about the receiver account of the wire transfer
+ * @param wire_account details about the receiver account of the wire transfer
* @param amount amount that was transmitted
* @return #GNUNET_OK on success
* #GNUNET_SYSERR on DB errors
@@ -5379,14 +5370,14 @@ postgres_store_wire_transfer_out (void *cls,
struct TALER_EXCHANGEDB_Session *session,
struct GNUNET_TIME_Absolute date,
const struct TALER_WireTransferIdentifierRawP *wtid,
- const json_t *wire,
+ const json_t *wire_account,
const struct TALER_Amount *amount)
{
PGresult *result;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_absolute_time (&date),
GNUNET_PQ_query_param_auto_from_type (wtid),
- TALER_PQ_query_param_json (wire),
+ TALER_PQ_query_param_json (wire_account),
TALER_PQ_query_param_amount (amount),
GNUNET_PQ_query_param_end
};
@@ -5840,7 +5831,6 @@ postgres_select_reserves_in_above_serial_id (void *cls,
struct TALER_ReservePublicKeyP reserve_pub;
struct TALER_Amount credit;
json_t *sender_account_details;
- json_t *transfer_details;
struct GNUNET_TIME_Absolute execution_date;
uint64_t rowid;
void *wire_reference;
@@ -5858,8 +5848,6 @@ postgres_select_reserves_in_above_serial_id (void *cls,
&execution_date),
TALER_PQ_result_spec_json ("sender_account_details",
&sender_account_details),
- TALER_PQ_result_spec_json ("transfer_details",
- &transfer_details),
GNUNET_PQ_result_spec_uint64 ("reserve_in_serial_id",
&rowid),
GNUNET_PQ_result_spec_end
@@ -5879,7 +5867,6 @@ postgres_select_reserves_in_above_serial_id (void *cls,
&reserve_pub,
&credit,
sender_account_details,
- transfer_details,
wire_reference,
wire_reference_size,
execution_date);
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index 7c6c362db..9b399233b 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -1032,7 +1032,6 @@ audit_refund_cb (void *cls,
* @param reserve_pub public key of the reserve (also the WTID)
* @param credit amount that was received
* @param sender_account_details information about the sender's bank account
- * @param transfer_details information that uniquely identifies the wire transfer
* @param wire_reference unique reference identifying the wire transfer (binary blob)
* @param wire_reference_size number of bytes in @a wire_reference
* @param execution_date when did we receive the funds
@@ -1044,7 +1043,6 @@ audit_reserve_in_cb (void *cls,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_Amount *credit,
const json_t *sender_account_details,
- const json_t *transfer_details,
const void *wire_reference,
size_t wire_reference_size,
struct GNUNET_TIME_Absolute execution_date)
@@ -1436,7 +1434,6 @@ run (void *cls)
struct TALER_EXCHANGEDB_TransactionList *tl;
struct TALER_EXCHANGEDB_TransactionList *tlp;
json_t *wire;
- json_t *just;
json_t *sndr;
unsigned int matched;
const char * const json_wire_str =
@@ -1506,8 +1503,6 @@ run (void *cls)
result = 4;
sndr = json_loads ("{ \"account\":\"1\" }", 0, NULL);
GNUNET_assert (NULL != sndr);
- just = json_loads ("{ \"justification\":\"1\" }", 0, NULL);
- GNUNET_assert (NULL != just);
FAILIF (GNUNET_OK !=
plugin->reserves_in_insert (plugin->cls,
session,
@@ -1516,16 +1511,13 @@ run (void *cls)
GNUNET_TIME_absolute_get (),
sndr,
"TEST",
- 4,
- just));
- json_decref (just);
+ 4));
FAILIF (GNUNET_OK !=
check_reserve (session,
&reserve_pub,
value.value,
value.fraction,
value.currency));
- just = json_loads ("{ \"justification\":\"2\" }", 0, NULL);
FAILIF (GNUNET_OK !=
plugin->reserves_in_insert (plugin->cls,
session,
@@ -1534,9 +1526,7 @@ run (void *cls)
GNUNET_TIME_absolute_get (),
sndr,
"TEST2",
- 5,
- just));
- json_decref (just);
+ 5));
json_decref (sndr);
FAILIF (GNUNET_OK !=
check_reserve (session,
@@ -1672,7 +1662,6 @@ run (void *cls)
FAILIF (1000 != bt->amount.fraction);
FAILIF (0 != strcmp (CURRENCY, bt->amount.currency));
FAILIF (NULL == bt->sender_account_details);
- FAILIF (NULL == bt->transfer_details);
break;
case TALER_EXCHANGEDB_RO_WITHDRAW_COIN:
withdraw = rh_head->details.withdraw;
diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h
index d1d6f3bda..f65cf2a01 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -711,9 +711,14 @@ struct TALER_EXCHANGE_ReserveHistory
json_t *sender_account_details;
/**
- * Wire transfer details for the incoming transfer.
+ * Information that uniquely identifies the wire transfer.
*/
- json_t *transfer_details;
+ void *wire_reference;
+
+ /**
+ * Number of bytes stored in @e wire_reference.
+ */
+ size_t wire_reference_size;
} in_details;
diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h
index a8df8c859..e4277b462 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -56,12 +56,6 @@ struct TALER_EXCHANGEDB_BankTransfer
json_t *sender_account_details;
/**
- * Detailed wire transfer information that uniquely identifies the
- * wire transfer.
- */
- json_t *transfer_details;
-
- /**
* Data uniquely identifying the wire transfer (wire transfer-type specific)
*/
void *wire_reference;
@@ -809,7 +803,6 @@ typedef int
* @param reserve_pub public key of the reserve (also the WTID)
* @param credit amount that was received
* @param sender_account_details information about the sender's bank account
- * @param transfer_details information that uniquely identifies the wire transfer
* @param wire_reference unique identifier for the wire transfer (plugin-specific format)
* @param wire_reference_size number of bytes in @a wire_reference
* @param execution_date when did we receive the funds
@@ -821,7 +814,6 @@ typedef int
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_Amount *credit,
const json_t *sender_account_details,
- const json_t *transfer_details,
const void *wire_reference,
size_t wire_reference_size,
struct GNUNET_TIME_Absolute execution_date);
@@ -1197,7 +1189,6 @@ struct TALER_EXCHANGEDB_Plugin
* @param sender_account_details information about the sender's bank account
* @param wire_reference unique reference identifying the wire transfer (binary blob)
* @param wire_reference_size number of bytes in @a wire_reference
- * @param transfer_details information that uniquely identifies the wire transfer
* @return #GNUNET_OK upon success; #GNUNET_NO if the given
* @a details are already known for this @a reserve_pub,
* #GNUNET_SYSERR upon failures (DB error, incompatible currency)
@@ -1210,8 +1201,7 @@ struct TALER_EXCHANGEDB_Plugin
struct GNUNET_TIME_Absolute execution_time,
const json_t *sender_account_details,
const void *wire_reference,
- size_t wire_reference_size,
- const json_t *transfer_details);
+ size_t wire_reference_size);
/**
@@ -1938,7 +1928,7 @@ struct TALER_EXCHANGEDB_Plugin
* @param session database connection
* @param date time of the wire transfer
* @param wtid subject of the wire transfer
- * @param wire details about the receiver account of the wire transfer
+ * @param wire_account details about the receiver account of the wire transfer
* @param amount amount that was transmitted
* @return #GNUNET_OK on success
* #GNUNET_SYSERR on DB errors
@@ -1948,7 +1938,7 @@ struct TALER_EXCHANGEDB_Plugin
struct TALER_EXCHANGEDB_Session *session,
struct GNUNET_TIME_Absolute date,
const struct TALER_WireTransferIdentifierRawP *wtid,
- const json_t *wire,
+ const json_t *wire_account,
const struct TALER_Amount *amount);