Getting transaction history 60% fixed.

This commit is contained in:
Marcello Stanisci 2019-02-12 17:13:08 +01:00
parent 8aa66c6023
commit 82f01f111b
No known key found for this signature in database
GPG Key ID: 8D526861953F4C0F
2 changed files with 30 additions and 28 deletions

View File

@ -71,11 +71,6 @@ char *since_when;
*/ */
char *account_section; char *account_section;
/**
* Binary version of the 'since-when' CLI option.
*/
void *since_when_bin;
/** /**
* URL identifying the account that is going to receive the * URL identifying the account that is going to receive the
* wire transfer. * wire transfer.
@ -96,6 +91,7 @@ struct TALER_WIRE_Plugin *plugin_handle;
/** /**
* Callback used to process ONE entry in the transaction * Callback used to process ONE entry in the transaction
* history returned by the bank. * history returned by the bank.
*
* @param cls closure * @param cls closure
* @param ec taler error code * @param ec taler error code
* @param dir direction of the transfer * @param dir direction of the transfer
@ -107,21 +103,17 @@ struct TALER_WIRE_Plugin *plugin_handle;
* abort iteration * abort iteration
*/ */
int int
cb (void *cls, history_cb (void *cls,
enum TALER_ErrorCode ec, enum TALER_ErrorCode ec,
enum TALER_BANK_Direction dir, enum TALER_BANK_Direction dir,
const void *row_off, const void *row_off,
size_t row_off_size, size_t row_off_size,
const struct TALER_WIRE_TransferDetails *details) const struct TALER_WIRE_TransferDetails *details)
{ {
char *row_off_enc; char *row_off_enc;
row_off_enc = GNUNET_STRINGS_data_to_string_alloc (row_off, row_off_enc = GNUNET_STRINGS_data_to_string_alloc (row_off,
row_off_size); row_off_size);
fprintf (stdout,
"History of transactions:\n");
/* Give more details on screen (??) */ /* Give more details on screen (??) */
fprintf (stdout, fprintf (stdout,
"%s\n", "%s\n",
@ -249,23 +241,21 @@ execute_wire_transfer ()
void void
execute_history () execute_history ()
{ {
size_t bin_len = (strlen (since_when) * 5) / 8; size_t bin_len = 0;
void *since_when_bin = NULL;
if (NULL == since_when) if (NULL != since_when)
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, bin_len = (strlen (since_when) * 5) / 8;
"Missing since-when option\n");
GNUNET_SCHEDULER_shutdown ();
return;
}
since_when_bin = GNUNET_malloc (bin_len); since_when_bin = GNUNET_malloc (bin_len);
GNUNET_assert GNUNET_assert
(GNUNET_OK == GNUNET_STRINGS_string_to_data (GNUNET_OK == GNUNET_STRINGS_string_to_data
(since_when, (since_when,
strlen (since_when), strlen (since_when),
since_when_bin, since_when_bin,
bin_len)); bin_len));
}
if (NULL == plugin_handle->get_history if (NULL == plugin_handle->get_history
(plugin_handle->cls, (plugin_handle->cls,
@ -274,15 +264,14 @@ execute_history ()
since_when_bin, since_when_bin,
bin_len, bin_len,
10, 10,
cb, history_cb,
NULL)); NULL))
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not request the transaction history.\n"); "Could not request the transaction history.\n");
GNUNET_SCHEDULER_shutdown (); GNUNET_SCHEDULER_shutdown ();
return; return;
} }
} }
/** /**
@ -370,7 +359,7 @@ main (int argc,
GNUNET_GETOPT_option_flag ('H', GNUNET_GETOPT_option_flag ('H',
"history", "history",
"Ask to get the list of" "Ask to get a list of 10"
" transactions.", " transactions.",
&history), &history),
@ -386,7 +375,9 @@ main (int argc,
" transactions history, this" " transactions history, this"
" option commands that all the" " option commands that all the"
" results should have IDs settled" " results should have IDs settled"
" after SW", " after SW. If not given, then"
" the 10 youngest transactions"
" are returned.",
&since_when), &since_when),
GNUNET_GETOPT_option_string ('s', GNUNET_GETOPT_option_string ('s',

View File

@ -1073,7 +1073,12 @@ taler_bank_get_history (void *cls,
parse_account_cfg (tc->cfg, parse_account_cfg (tc->cfg,
account_section, account_section,
&account)) &account))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not parse the config section '%s'\n",
account_section);
return NULL; return NULL;
}
whh = GNUNET_new (struct TALER_WIRE_HistoryHandle); whh = GNUNET_new (struct TALER_WIRE_HistoryHandle);
if (GNUNET_OK != if (GNUNET_OK !=
@ -1081,6 +1086,9 @@ taler_bank_get_history (void *cls,
account_section, account_section,
&whh->auth)) &whh->auth))
{ {
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not parse the auth values from '%s'\n",
account_section);
GNUNET_free (whh); GNUNET_free (whh);
return NULL; return NULL;
} }
@ -1088,6 +1096,8 @@ taler_bank_get_history (void *cls,
whh->hres_cb = hres_cb; whh->hres_cb = hres_cb;
whh->hres_cb_cls = hres_cb_cls; whh->hres_cb_cls = hres_cb_cls;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Requesting the transaction history.\n");
whh->hh = TALER_BANK_history (tc->ctx, whh->hh = TALER_BANK_history (tc->ctx,
account.bank_base_url, account.bank_base_url,
&whh->auth, &whh->auth,
@ -1110,6 +1120,7 @@ taler_bank_get_history (void *cls,
} }
GNUNET_free (account.hostname); GNUNET_free (account.hostname);
GNUNET_free (account.bank_base_url); GNUNET_free (account.bank_base_url);
GNUNET_assert (NULL != whh);
return whh; return whh;
} }