fixing #3817
This commit is contained in:
parent
edc6d38082
commit
dc23f290ee
@ -42,6 +42,13 @@ struct TALER_MINTDB_BankTransfer
|
||||
*/
|
||||
struct TALER_Amount amount;
|
||||
|
||||
/**
|
||||
* When did the mint receive the incoming transaction?
|
||||
* (This is the execution date of the mint's database,
|
||||
* the execution date of the bank should be in @e wire).
|
||||
*/
|
||||
struct GNUNET_TIME_Absolute execution_date;
|
||||
|
||||
/**
|
||||
* Detailed wire information about the transaction.
|
||||
*/
|
||||
@ -724,7 +731,7 @@ struct TALER_MINTDB_Plugin
|
||||
struct TALER_MINTDB_Session *db,
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
const struct TALER_Amount *balance,
|
||||
const char *details);
|
||||
const json_t *details);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -41,7 +41,7 @@ taler_mint_reservemod_LDADD = \
|
||||
$(top_builddir)/src/util/libtalerutil.la \
|
||||
$(top_builddir)/src/pq/libtalerpq.la \
|
||||
$(top_builddir)/src/mintdb/libtalermintdb.la \
|
||||
-lgnunetutil $(XLIB)
|
||||
-lgnunetutil -ljansson $(XLIB)
|
||||
taler_mint_reservemod_LDFLAGS = \
|
||||
$(POSTGRESQL_LDFLAGS)
|
||||
taler_mint_reservemod_CPPFLAGS = \
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "platform.h"
|
||||
#include <gnunet/gnunet_util_lib.h>
|
||||
#include <libpq-fe.h>
|
||||
#include <jansson.h>
|
||||
#include "taler_mintdb_plugin.h"
|
||||
|
||||
/**
|
||||
@ -54,6 +55,8 @@ main (int argc, char *const *argv)
|
||||
char *add_str = NULL;
|
||||
struct TALER_Amount add_value;
|
||||
char *details = NULL;
|
||||
json_t *jdetails;
|
||||
json_error_t error;
|
||||
struct TALER_ReservePublicKeyP reserve_pub;
|
||||
struct TALER_MINTDB_Session *session;
|
||||
const struct GNUNET_GETOPT_CommandLineOption options[] = {
|
||||
@ -157,11 +160,24 @@ main (int argc, char *const *argv)
|
||||
"Failed to initialize DB session\n");
|
||||
goto cleanup;
|
||||
}
|
||||
jdetails = json_loads (details,
|
||||
JSON_REJECT_DUPLICATES,
|
||||
&error);
|
||||
if (NULL == jdetails)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"Failed to parse JSON transaction details `%s': %s (%s)\n",
|
||||
details,
|
||||
error.text,
|
||||
error.source);
|
||||
goto cleanup;
|
||||
}
|
||||
ret = plugin->reserves_in_insert (plugin->cls,
|
||||
session,
|
||||
&reserve_pub,
|
||||
&add_value,
|
||||
details);
|
||||
jdetails);
|
||||
json_decref (jdetails);
|
||||
if (GNUNET_SYSERR == ret)
|
||||
{
|
||||
fprintf (stderr,
|
||||
|
@ -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);
|
||||
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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user