aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchangedb')
-rw-r--r--src/exchangedb/perf_taler_exchangedb_init.c6
-rw-r--r--src/exchangedb/perf_taler_exchangedb_interpreter.c24
-rw-r--r--src/exchangedb/plugin_exchangedb_common.c8
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c45
-rw-r--r--src/exchangedb/test_exchangedb.c15
5 files changed, 59 insertions, 39 deletions
diff --git a/src/exchangedb/perf_taler_exchangedb_init.c b/src/exchangedb/perf_taler_exchangedb_init.c
index 5e98c4f5a..5183074bb 100644
--- a/src/exchangedb/perf_taler_exchangedb_init.c
+++ b/src/exchangedb/perf_taler_exchangedb_init.c
@@ -276,7 +276,7 @@ PERF_TALER_EXCHANGEDB_deposit_init (const struct PERF_TALER_EXCHANGEDB_Coin *coi
deposit->csig = csig;
deposit->h_contract = h_contract;
deposit->h_wire = h_wire;
- deposit->wire = json_loads (wire, 0, NULL);
+ deposit->receiver_wire_account = json_loads (wire, 0, NULL);
deposit->transaction_id = transaction_id++;
deposit->timestamp = timestamp;
deposit->refund_deadline = refund_deadline;
@@ -298,7 +298,7 @@ PERF_TALER_EXCHANGEDB_deposit_copy (const struct TALER_EXCHANGEDB_Deposit *depos
copy = GNUNET_new (struct TALER_EXCHANGEDB_Deposit);
*copy = *deposit;
- json_incref (copy->wire);
+ json_incref (copy->receiver_wire_account);
copy->coin.denom_pub.rsa_public_key =
GNUNET_CRYPTO_rsa_public_key_dup (deposit->coin.denom_pub.rsa_public_key);
copy->coin.denom_sig.rsa_signature =
@@ -318,7 +318,7 @@ PERF_TALER_EXCHANGEDB_deposit_free (struct TALER_EXCHANGEDB_Deposit *deposit)
return GNUNET_OK;
GNUNET_CRYPTO_rsa_public_key_free (deposit->coin.denom_pub.rsa_public_key);
GNUNET_CRYPTO_rsa_signature_free (deposit->coin.denom_sig.rsa_signature);
- json_decref (deposit->wire);
+ json_decref (deposit->receiver_wire_account);
GNUNET_free (deposit);
return GNUNET_OK;
}
diff --git a/src/exchangedb/perf_taler_exchangedb_interpreter.c b/src/exchangedb/perf_taler_exchangedb_interpreter.c
index 5a2eed95f..e6268ebbc 100644
--- a/src/exchangedb/perf_taler_exchangedb_interpreter.c
+++ b/src/exchangedb/perf_taler_exchangedb_interpreter.c
@@ -1373,23 +1373,31 @@ interpret (struct PERF_TALER_EXCHANGEDB_interpreter_state *state)
unsigned int reserve_index;
int ret;
struct PERF_TALER_EXCHANGEDB_Reserve *reserve;
- json_t *details = NULL;
+ json_t *sndr;
+ json_t *just;
reserve_index = state->cmd[state->i].details.insert_reserve.index_reserve;
reserve = state->cmd[reserve_index].exposed.data.reserve;
- details = json_pack ("{s:i}","justification",
- GNUNET_CRYPTO_random_u32 (
- GNUNET_CRYPTO_QUALITY_WEAK,
- UINT32_MAX));
- GNUNET_assert (NULL != details);
+ sndr = json_pack ("{s:i}",
+ "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);
+ GNUNET_assert (NULL != sndr);
ret = state->plugin->reserves_in_insert (state->plugin->cls,
state->session,
&reserve->reserve.pub,
&reserve->reserve.balance,
GNUNET_TIME_absolute_get (),
- details);
+ sndr,
+ just);
GNUNET_assert (GNUNET_SYSERR != ret);
- json_decref (details);
+ json_decref (sndr);
+ json_decref (just);
}
break;
diff --git a/src/exchangedb/plugin_exchangedb_common.c b/src/exchangedb/plugin_exchangedb_common.c
index 16396f0f3..3bf9bda32 100644
--- a/src/exchangedb/plugin_exchangedb_common.c
+++ b/src/exchangedb/plugin_exchangedb_common.c
@@ -40,8 +40,10 @@ common_free_reserve_history (void *cls,
{
case TALER_EXCHANGEDB_RO_BANK_TO_EXCHANGE:
bt = rh->details.bank;
- if (NULL != bt->wire)
- json_decref (bt->wire);
+ if (NULL != bt->sender_account_details)
+ json_decref (bt->sender_account_details);
+ if (NULL != bt->transfer_details)
+ json_decref (bt->transfer_details);
GNUNET_free (bt);
break;
case TALER_EXCHANGEDB_RO_WITHDRAW_COIN:
@@ -98,7 +100,7 @@ common_free_coin_transaction_list (void *cls,
switch (list->type)
{
case TALER_EXCHANGEDB_TT_DEPOSIT:
- json_decref (list->details.deposit->wire);
+ json_decref (list->details.deposit->receiver_wire_account);
if (NULL != list->details.deposit->coin.denom_pub.rsa_public_key)
GNUNET_CRYPTO_rsa_public_key_free (list->details.deposit->coin.denom_pub.rsa_public_key);
if (NULL != list->details.deposit->coin.denom_sig.rsa_signature)
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index 8465e4de0..34cffa0f5 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -305,9 +305,10 @@ postgres_create_tables (void *cls)
",balance_val INT8 NOT NULL"
",balance_frac INT4 NOT NULL"
",balance_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
- ",details TEXT NOT NULL "
+ ",sender_account_details TEXT NOT NULL "
+ ",transfer_details TEXT NOT NULL "
",execution_date INT8 NOT NULL"
- ",PRIMARY KEY (reserve_pub,details)"
+ ",PRIMARY KEY (reserve_pub,transfer_details)"
");");
/* Create indices on reserves_in */
SQLEXEC_INDEX ("CREATE INDEX reserves_in_reserve_pub_index"
@@ -627,11 +628,12 @@ postgres_prepare (PGconn *db_conn)
",balance_val"
",balance_frac"
",balance_curr"
- ",details"
+ ",sender_account_details"
+ ",transfer_details"
",execution_date"
") VALUES "
- "($1, $2, $3, $4, $5, $6);",
- 6, NULL);
+ "($1, $2, $3, $4, $5, $6, $7);",
+ 7, NULL);
/* Used in #postgres_get_reserve_history() to obtain inbound transactions
for a reserve */
@@ -641,7 +643,8 @@ postgres_prepare (PGconn *db_conn)
",balance_frac"
",balance_curr"
",execution_date"
- ",details"
+ ",sender_account_details"
+ ",transfer_details"
" FROM reserves_in"
" WHERE reserve_pub=$1",
1, NULL);
@@ -1634,8 +1637,8 @@ reserves_update (void *cls,
* @param reserve_pub public key of the reserve
* @param balance the amount that has to be added to the reserve
* @param execution_time when was the amount added
- * @param details bank transaction details justifying the increment,
- * must be unique for each incoming transaction
+ * @param sender_account_details account information for the sender
+ * @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)
@@ -1646,7 +1649,8 @@ postgres_reserves_in_insert (void *cls,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_Amount *balance,
struct GNUNET_TIME_Absolute execution_time,
- const json_t *details)
+ const json_t *sender_account_details,
+ const json_t *transfer_details)
{
PGresult *result;
int reserve_exists;
@@ -1688,8 +1692,8 @@ postgres_reserves_in_insert (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Reserve does not exist; creating a new one\n");
result = GNUNET_PQ_exec_prepared (session->conn,
- "reserve_create",
- params);
+ "reserve_create",
+ params);
if (PGRES_COMMAND_OK != PQresultStatus(result))
{
QUERY_ERR (result);
@@ -1707,14 +1711,15 @@ postgres_reserves_in_insert (void *cls,
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (&reserve.pub),
TALER_PQ_query_param_amount (balance),
- TALER_PQ_query_param_json (details),
+ 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
};
result = GNUNET_PQ_exec_prepared (session->conn,
- "reserves_in_add_transaction",
- params);
+ "reserves_in_add_transaction",
+ params);
}
if (PGRES_COMMAND_OK != PQresultStatus(result))
{
@@ -1989,8 +1994,10 @@ postgres_get_reserve_history (void *cls,
&bt->amount),
GNUNET_PQ_result_spec_absolute_time ("execution_date",
&bt->execution_date),
- TALER_PQ_result_spec_json ("details",
- &bt->wire),
+ 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 !=
@@ -2647,7 +2654,7 @@ postgres_insert_deposit (void *cls,
GNUNET_PQ_query_param_auto_from_type (&deposit->h_contract),
GNUNET_PQ_query_param_auto_from_type (&deposit->h_wire),
GNUNET_PQ_query_param_auto_from_type (&deposit->csig),
- TALER_PQ_query_param_json (deposit->wire),
+ TALER_PQ_query_param_json (deposit->receiver_wire_account),
GNUNET_PQ_query_param_end
};
@@ -3484,7 +3491,7 @@ postgres_get_link_data_list (void *cls,
&denom_pub),
GNUNET_PQ_result_spec_end
};
-
+
if (GNUNET_OK !=
GNUNET_PQ_extract_result (result, rs, i))
{
@@ -3643,7 +3650,7 @@ postgres_get_coin_transactions (void *cls,
GNUNET_PQ_result_spec_auto_from_type ("h_wire",
&deposit->h_wire),
TALER_PQ_result_spec_json ("wire",
- &deposit->wire),
+ &deposit->receiver_wire_account),
GNUNET_PQ_result_spec_auto_from_type ("coin_sig",
&deposit->csig),
GNUNET_PQ_result_spec_end
diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c
index 355ef6a87..6d624f407 100644
--- a/src/exchangedb/test_exchangedb.c
+++ b/src/exchangedb/test_exchangedb.c
@@ -974,9 +974,6 @@ deposit_cb (void *cls,
}
-
-
-
/**
* Main function that will be run by the scheduler.
*
@@ -1003,6 +1000,7 @@ run (void *cls)
struct TALER_WireTransferIdentifierRawP wtid;
json_t *wire;
json_t *just;
+ json_t *sndr;
unsigned int matched;
const char * const json_wire_str =
"{ \"type\":\"SEPA\", \
@@ -1060,6 +1058,7 @@ run (void *cls)
&amount_with_fee));
result = 4;
+ sndr = json_loads ("{ \"account\":\"1\" }", 0, NULL);
just = json_loads ("{ \"justification\":\"1\" }", 0, NULL);
FAILIF (GNUNET_OK !=
plugin->reserves_in_insert (plugin->cls,
@@ -1067,6 +1066,7 @@ run (void *cls)
&reserve_pub,
&value,
GNUNET_TIME_absolute_get (),
+ sndr,
just));
json_decref (just);
FAILIF (GNUNET_OK !=
@@ -1082,8 +1082,10 @@ run (void *cls)
&reserve_pub,
&value,
GNUNET_TIME_absolute_get (),
- just));
+ sndr,
+ just));
json_decref (just);
+ json_decref (sndr);
FAILIF (GNUNET_OK !=
check_reserve (session,
&reserve_pub,
@@ -1153,7 +1155,8 @@ run (void *cls)
FAILIF (1 != bt->amount.value);
FAILIF (10 != bt->amount.fraction);
FAILIF (0 != strcmp (CURRENCY, bt->amount.currency));
- FAILIF (NULL == bt->wire);
+ FAILIF (NULL == bt->sender_account_details);
+ FAILIF (NULL == bt->transfer_details);
break;
case TALER_EXCHANGEDB_RO_WITHDRAW_COIN:
withdraw = rh_head->details.withdraw;
@@ -1178,7 +1181,7 @@ run (void *cls)
wire = json_loads (json_wire_str, 0, NULL);
TALER_JSON_hash (wire,
&deposit.h_wire);
- deposit.wire = wire;
+ deposit.receiver_wire_account = wire;
deposit.transaction_id =
GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
deposit.amount_with_fee = value;