aboutsummaryrefslogtreecommitdiff
path: root/src/exchange-tools/taler-wire.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchange-tools/taler-wire.c')
-rw-r--r--src/exchange-tools/taler-wire.c70
1 files changed, 41 insertions, 29 deletions
diff --git a/src/exchange-tools/taler-wire.c b/src/exchange-tools/taler-wire.c
index 213c1eff3..f9c4a3579 100644
--- a/src/exchange-tools/taler-wire.c
+++ b/src/exchange-tools/taler-wire.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of TALER 2 This file is part of TALER
3 Copyright (C) 2014-2018 Taler Systems SA 3 Copyright (C) 2014--2019 Taler Systems SA
4 4
5 TALER is free software; you can redistribute it and/or modify 5 TALER is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as 6 it under the terms of the GNU General Public License as
@@ -29,62 +29,67 @@
29#include "taler_wire_lib.h" 29#include "taler_wire_lib.h"
30 30
31/** 31/**
32 * If set to GNUNET_YES, then we'll ask the bank for a list 32 * If set to #GNUNET_YES, then we'll ask the bank for a list
33 * of transactions from the account mentioned in the config 33 * of transactions from the account mentioned in the config
34 * section. 34 * section.
35 */ 35 */
36int history; 36static int history;
37 37
38/** 38/**
39 * If set to GNUNET_YES, then we'll ask the bank to execute a 39 * If set to GNUNET_YES, then we'll ask the bank to execute a
40 * wire transfer. 40 * wire transfer.
41 */ 41 */
42int transfer; 42static int transfer;
43 43
44/** 44/**
45 * Name of the wire plugin to use with the bank. 45 * Name of the wire plugin to use with the bank.
46 */ 46 */
47char *plugin_name; 47static char *plugin_name;
48 48
49/** 49/**
50 * Global return code. 50 * Global return code.
51 */ 51 */
52unsigned int global_ret = 1; 52static unsigned int global_ret = 1;
53 53
54/** 54/**
55 * When a wire transfer is being performed, this value 55 * When a wire transfer is being performed, this value
56 * specifies the amount to wire-transfer. It's given in 56 * specifies the amount to wire-transfer. It's given in
57 * the usual CURRENCY:X[.Y] format. 57 * the usual CURRENCY:X[.Y] format.
58 */ 58 */
59char *amount; 59static char *amount;
60 60
61/** 61/**
62 * Base32 encoding of a transaction ID. When asking the 62 * Base32 encoding of a transaction ID. When asking the
63 * bank for a transaction history, all the results will 63 * bank for a transaction history, all the results will
64 * have a transaction ID settled *after* this one. 64 * have a transaction ID settled *after* this one.
65 */ 65 */
66char *since_when; 66static char *since_when;
67 67
68/** 68/**
69 * Which config section has the credentials to access the bank. 69 * Which config section has the credentials to access the bank.
70 */ 70 */
71char *account_section; 71static char *account_section;
72 72
73/** 73/**
74 * URL identifying the account that is going to receive the 74 * URL identifying the account that is going to receive the
75 * wire transfer. 75 * wire transfer.
76 */ 76 */
77char *destination_account_url; 77static char *destination_account_url;
78 78
79/** 79/**
80 * Handle for the wire transfer preparation task. 80 * Handle for the wire transfer preparation task.
81 */ 81 */
82struct TALER_WIRE_PrepareHandle *ph; 82static struct TALER_WIRE_PrepareHandle *ph;
83 83
84/** 84/**
85 * Wire plugin handle. 85 * Wire plugin handle.
86 */ 86 */
87struct TALER_WIRE_Plugin *plugin_handle; 87static struct TALER_WIRE_Plugin *plugin_handle;
88
89/**
90 * Handle to ongoing history operation.
91 */
92static struct TALER_WIRE_HistoryHandle *hh;
88 93
89 94
90/** 95/**
@@ -274,15 +279,14 @@ execute_history ()
274 bin_len)); 279 bin_len));
275 } 280 }
276 281
277 if (NULL == plugin_handle->get_history 282 if (NULL == (hh = plugin_handle->get_history (plugin_handle->cls,
278 (plugin_handle->cls, 283 account_section,
279 account_section, 284 TALER_BANK_DIRECTION_BOTH,
280 TALER_BANK_DIRECTION_BOTH, 285 since_when_bin,
281 since_when_bin, 286 bin_len,
282 bin_len, 287 -10,
283 -10, 288 &history_cb,
284 history_cb, 289 NULL)))
285 NULL))
286 { 290 {
287 fprintf (stderr, 291 fprintf (stderr,
288 "Could not request the transaction history.\n"); 292 "Could not request the transaction history.\n");
@@ -297,9 +301,21 @@ execute_history ()
297 * 301 *
298 * @param cls closure. 302 * @param cls closure.
299 */ 303 */
300void 304static void
301do_shutdown (void *cls) 305do_shutdown (void *cls)
302{ 306{
307 if (NULL != hh)
308 {
309 plugin_handle->get_history_cancel (plugin_handle->cls,
310 hh);
311 hh = NULL;
312 }
313 if (NULL != ph)
314 {
315 plugin_handle->prepare_wire_transfer_cancel (plugin_handle->cls,
316 ph);
317 ph = NULL;
318 }
303 TALER_WIRE_plugin_unload (plugin_handle); 319 TALER_WIRE_plugin_unload (plugin_handle);
304} 320}
305 321
@@ -377,8 +393,7 @@ main (int argc,
377 struct GNUNET_GETOPT_CommandLineOption options[] = { 393 struct GNUNET_GETOPT_CommandLineOption options[] = {
378 GNUNET_GETOPT_option_flag ('H', 394 GNUNET_GETOPT_option_flag ('H',
379 "history", 395 "history",
380 "Ask to get a list of 10" 396 "Ask to get a list of 10 transactions.",
381 " transactions.",
382 &history), 397 &history),
383 GNUNET_GETOPT_option_flag ('t', 398 GNUNET_GETOPT_option_flag ('t',
384 "transfer", 399 "transfer",
@@ -398,9 +413,7 @@ main (int argc,
398 GNUNET_GETOPT_option_string ('s', 413 GNUNET_GETOPT_option_string ('s',
399 "section", 414 "section",
400 "ACCOUNT-SECTION", 415 "ACCOUNT-SECTION",
401 "Which config section has the" 416 "Which config section has the credentials to access the bank. Mandatory.\n",
402 " credentials to access the"
403 " bank. Mandatory.\n",
404 &account_section), 417 &account_section),
405 GNUNET_GETOPT_option_string ('a', 418 GNUNET_GETOPT_option_string ('a',
406 "amount", 419 "amount",
@@ -410,8 +423,7 @@ main (int argc,
410 GNUNET_GETOPT_option_string ('d', 423 GNUNET_GETOPT_option_string ('d',
411 "destination", 424 "destination",
412 "PAYTO-URL", 425 "PAYTO-URL",
413 "Destination account for the" 426 "Destination account for the wire transfer.",
414 " wire transfer.",
415 &destination_account_url), 427 &destination_account_url),
416 GNUNET_GETOPT_OPTION_END 428 GNUNET_GETOPT_OPTION_END
417 }; 429 };