summaryrefslogtreecommitdiff
path: root/src/mintdb
diff options
context:
space:
mode:
Diffstat (limited to 'src/mintdb')
-rw-r--r--src/mintdb/plugin_mintdb_postgres.c42
-rw-r--r--src/mintdb/test_mintdb.c13
2 files changed, 30 insertions, 25 deletions
diff --git a/src/mintdb/plugin_mintdb_postgres.c b/src/mintdb/plugin_mintdb_postgres.c
index fe2f2a49c..e4d0f4d50 100644
--- a/src/mintdb/plugin_mintdb_postgres.c
+++ b/src/mintdb/plugin_mintdb_postgres.c
@@ -510,8 +510,8 @@ postgres_prepare (PGconn *db_conn)
" balance_val"
",balance_frac"
",balance_curr"
- ",execution_date" /* NOTE: not used (yet), #3817 */
- ",details" /* NOTE: not used (yet), #3817 */
+ ",execution_date"
+ ",details"
" FROM reserves_in"
" WHERE reserve_pub=$1",
1, NULL);
@@ -1150,7 +1150,7 @@ postgres_reserves_in_insert (void *cls,
struct TALER_MINTDB_Session *session,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_Amount *balance,
- const char *details)
+ const json_t *details)
{
PGresult *result;
int reserve_exists;
@@ -1212,7 +1212,7 @@ postgres_reserves_in_insert (void *cls,
struct TALER_PQ_QueryParam params[] = {
TALER_PQ_query_param_auto_from_type (&reserve.pub),
TALER_PQ_query_param_amount (balance),
- TALER_PQ_query_param_fixed_size (details, strlen (details)),
+ TALER_PQ_query_param_json (details),
TALER_PQ_query_param_absolute_time (&now),
TALER_PQ_query_param_end
};
@@ -1490,29 +1490,29 @@ postgres_get_reserve_history (void *cls,
"Asked to fetch history for an unknown reserve.\n");
goto cleanup;
}
- /* FIXME: maybe also use the 'expiration_date' and 'details'
- values and return those as well? While right now they
- are unnecessary, the 'expiration_date' should become the
- original transfer date, and then it will be useful;
- similarly, 'details' might become useful for reserve refunds
- in the future. (#3817) */
while (0 < rows)
{
bt = GNUNET_new (struct TALER_MINTDB_BankTransfer);
- /* FIXME: use higher-level libtalerpq API here? */
- if (GNUNET_OK != TALER_PQ_extract_amount (result,
- --rows,
- "balance_val",
- "balance_frac",
- "balance_curr",
- &bt->amount))
{
- GNUNET_free (bt);
- GNUNET_break (0);
- goto cleanup;
+ struct TALER_PQ_ResultSpec rs[] = {
+ TALER_PQ_result_spec_amount ("balance",
+ &bt->amount),
+ TALER_PQ_result_spec_absolute_time ("execution_date",
+ &bt->execution_date),
+ TALER_PQ_result_spec_json ("details",
+ &bt->wire),
+ TALER_PQ_result_spec_end
+ };
+ if (GNUNET_YES !=
+ TALER_PQ_extract_result (result, rs, --rows))
+ {
+ GNUNET_break (0);
+ GNUNET_free (bt);
+ PQclear (result);
+ goto cleanup;
+ }
}
bt->reserve_pub = *reserve_pub;
- /* FIXME: bt->wire not initialized! (#3817) */
if (NULL != rh_tail)
{
rh_tail->next = GNUNET_new (struct TALER_MINTDB_ReserveHistory);
diff --git a/src/mintdb/test_mintdb.c b/src/mintdb/test_mintdb.c
index 74c1f66fe..56f5636d0 100644
--- a/src/mintdb/test_mintdb.c
+++ b/src/mintdb/test_mintdb.c
@@ -243,7 +243,8 @@ run (void *cls,
struct TALER_MINTDB_CollectableBlindcoin *withdraw;
struct TALER_MINTDB_Deposit deposit;
struct TALER_MINTDB_Deposit deposit2;
- struct json_t *wire;
+ json_t *wire;
+ json_t *just;
const char * const json_wire_str =
"{ \"type\":\"SEPA\", \
\"IBAN\":\"DE67830654080004822650\", \
@@ -285,24 +286,28 @@ run (void *cls,
amount.fraction = 1;
strcpy (amount.currency, CURRENCY);
result = 4;
+ just = json_loads ("{ \"justification\":\"1\" }", 0, NULL);
FAILIF (GNUNET_OK !=
plugin->reserves_in_insert (plugin->cls,
session,
&reserve_pub,
&amount,
- "justification 1"));
+ just));
+ json_decref (just);
FAILIF (GNUNET_OK !=
check_reserve (session,
&reserve_pub,
amount.value,
amount.fraction,
amount.currency));
+ just = json_loads ("{ \"justification\":\"2\" }", 0, NULL);
FAILIF (GNUNET_OK !=
plugin->reserves_in_insert (plugin->cls,
session,
&reserve_pub,
&amount,
- "justification 2"));
+ just));
+ json_decref (just);
FAILIF (GNUNET_OK !=
check_reserve (session,
&reserve_pub,
@@ -368,7 +373,7 @@ run (void *cls,
FAILIF (1 != bt->amount.value);
FAILIF (1 != bt->amount.fraction);
FAILIF (0 != strcmp (CURRENCY, bt->amount.currency));
- FAILIF (NULL != bt->wire); /* FIXME: write wire details to db */
+ FAILIF (NULL == bt->wire);
break;
case TALER_MINTDB_RO_WITHDRAW_COIN:
withdraw = rh_head->details.withdraw;