summaryrefslogtreecommitdiff
path: root/src/exchange-tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchange-tools')
-rw-r--r--src/exchange-tools/Makefile.am16
-rw-r--r--src/exchange-tools/exchange-offline.conf4
-rw-r--r--src/exchange-tools/taler-auditor-offline.c451
-rw-r--r--src/exchange-tools/taler-crypto-worker.c459
-rw-r--r--src/exchange-tools/taler-exchange-dbinit.c93
-rw-r--r--src/exchange-tools/taler-exchange-offline.c1428
6 files changed, 1433 insertions, 1018 deletions
diff --git a/src/exchange-tools/Makefile.am b/src/exchange-tools/Makefile.am
index 8e7790081..955544564 100644
--- a/src/exchange-tools/Makefile.am
+++ b/src/exchange-tools/Makefile.am
@@ -15,8 +15,7 @@ endif
bin_PROGRAMS = \
taler-auditor-offline \
taler-exchange-offline \
- taler-exchange-dbinit \
- taler-crypto-worker
+ taler-exchange-dbinit
taler_exchange_offline_SOURCES = \
taler-exchange-offline.c
@@ -60,19 +59,6 @@ taler_exchange_dbinit_CPPFLAGS = \
-I$(top_srcdir)/src/pq/ \
$(POSTGRESQL_CPPFLAGS)
-taler_crypto_worker_SOURCES = \
- taler-crypto-worker.c
-taler_crypto_worker_LDADD = \
- $(top_builddir)/src/util/libtalerutil.la \
- $(top_builddir)/src/json/libtalerjson.la \
- -lgnunetutil \
- -lgnunetjson \
- -ljansson \
- $(LIBGCRYPT_LIBS) \
- $(XLIB)
-
-
-
# Testcases
diff --git a/src/exchange-tools/exchange-offline.conf b/src/exchange-tools/exchange-offline.conf
index cfd5c98ef..020eb34ba 100644
--- a/src/exchange-tools/exchange-offline.conf
+++ b/src/exchange-tools/exchange-offline.conf
@@ -3,10 +3,10 @@
[exchange-offline]
# Where do we store the offline master private key of the exchange?
-MASTER_PRIV_FILE = ${TALER_DATA_HOME}/exchange-offline/master.priv
+MASTER_PRIV_FILE = ${TALER_DATA_HOME}exchange-offline/master.priv
# Where do we store the TOFU key material?
-SECM_TOFU_FILE = ${TALER_DATA_HOME}/exchange-offline/secm_tofus.pub
+SECM_TOFU_FILE = ${TALER_DATA_HOME}exchange-offline/secm_tofus.pub
# Base32-encoded public key of the RSA helper.
# SECM_DENOM_PUBKEY =
diff --git a/src/exchange-tools/taler-auditor-offline.c b/src/exchange-tools/taler-auditor-offline.c
index 53135d9fa..8c280d46b 100644
--- a/src/exchange-tools/taler-auditor-offline.c
+++ b/src/exchange-tools/taler-auditor-offline.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2020-2021 Taler Systems SA
+ Copyright (C) 2020-2023 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -174,7 +174,7 @@ static struct DenominationAddRequest *dar_tail;
/**
* Handle to the exchange, used to request /keys.
*/
-static struct TALER_EXCHANGE_Handle *exchange;
+static struct TALER_EXCHANGE_GetKeysHandle *exchange;
/**
@@ -219,7 +219,7 @@ do_shutdown (void *cls)
}
if (NULL != exchange)
{
- TALER_EXCHANGE_disconnect (exchange);
+ TALER_EXCHANGE_get_keys_cancel (exchange);
exchange = NULL;
}
if (NULL != nxt)
@@ -388,14 +388,15 @@ load_offline_key (int do_create)
* add operation result.
*
* @param cls closure with a `struct DenominationAddRequest`
- * @param hr HTTP response data
+ * @param adr response data
*/
static void
denomination_add_cb (
void *cls,
- const struct TALER_EXCHANGE_HttpResponse *hr)
+ const struct TALER_EXCHANGE_AuditorAddDenominationResponse *adr)
{
struct DenominationAddRequest *dar = cls;
+ const struct TALER_EXCHANGE_HttpResponse *hr = &adr->hr;
if (MHD_HTTP_NO_CONTENT != hr->http_status)
{
@@ -644,30 +645,24 @@ do_upload (char *const *args)
* a particular exchange and what keys the exchange is using.
*
* @param cls closure with the `char **` remaining args
- * @param hr HTTP response data
- * @param keys information about the various keys used
- * by the exchange, NULL if /keys failed
- * @param compat protocol compatibility information
+ * @param kr response data
+ * @param keys key data from the exchange
*/
static void
keys_cb (
void *cls,
- const struct TALER_EXCHANGE_HttpResponse *hr,
- const struct TALER_EXCHANGE_Keys *keys,
- enum TALER_EXCHANGE_VersionCompatibility compat)
+ const struct TALER_EXCHANGE_KeysResponse *kr,
+ struct TALER_EXCHANGE_Keys *keys)
{
char *const *args = cls;
- (void) keys;
- (void) compat;
- switch (hr->http_status)
+ exchange = NULL;
+ switch (kr->hr.http_status)
{
case MHD_HTTP_OK:
- if (! json_is_object (hr->reply))
+ if (NULL == kr->hr.reply)
{
GNUNET_break (0);
- TALER_EXCHANGE_disconnect (exchange);
- exchange = NULL;
test_shutdown ();
global_ret = EXIT_FAILURE;
return;
@@ -676,11 +671,9 @@ keys_cb (
default:
fprintf (stderr,
"Failed to download keys: %s (HTTP status: %u/%u)\n",
- hr->hint,
- hr->http_status,
- (unsigned int) hr->ec);
- TALER_EXCHANGE_disconnect (exchange);
- exchange = NULL;
+ kr->hr.hint,
+ kr->hr.http_status,
+ (unsigned int) kr->hr.ec);
test_shutdown ();
global_ret = EXIT_FAILURE;
return;
@@ -689,7 +682,7 @@ keys_cb (
GNUNET_JSON_pack_string ("operation",
OP_INPUT_KEYS),
GNUNET_JSON_pack_object_incref ("arguments",
- (json_t *) hr->reply));
+ (json_t *) kr->hr.reply));
if (NULL == args[0])
{
json_dumpf (in,
@@ -698,9 +691,8 @@ keys_cb (
json_decref (in);
in = NULL;
}
- TALER_EXCHANGE_disconnect (exchange);
- exchange = NULL;
next (args);
+ TALER_EXCHANGE_keys_decref (keys);
}
@@ -727,11 +719,11 @@ do_download (char *const *args)
global_ret = EXIT_NOTCONFIGURED;
return;
}
- exchange = TALER_EXCHANGE_connect (ctx,
- exchange_url,
- &keys_cb,
- (void *) args,
- TALER_EXCHANGE_OPTION_END);
+ exchange = TALER_EXCHANGE_get_keys (ctx,
+ exchange_url,
+ NULL,
+ &keys_cb,
+ (void *) args);
GNUNET_free (exchange_url);
}
@@ -742,46 +734,27 @@ do_download (char *const *args)
* @param denomkeys keys to output
* @return #GNUNET_OK on success
*/
-static int
+static enum GNUNET_GenericReturnValue
show_denomkeys (const json_t *denomkeys)
{
size_t index;
json_t *value;
json_array_foreach (denomkeys, index, value) {
+ struct TALER_DenominationGroup group;
+ const json_t *denoms;
const char *err_name;
unsigned int err_line;
- struct TALER_DenominationPublicKey denom_pub;
- struct GNUNET_TIME_Timestamp stamp_start;
- struct GNUNET_TIME_Timestamp stamp_expire_withdraw;
- struct GNUNET_TIME_Timestamp stamp_expire_deposit;
- struct GNUNET_TIME_Timestamp stamp_expire_legal;
- struct TALER_Amount coin_value;
- struct TALER_DenomFeeSet fees;
- struct TALER_MasterSignatureP master_sig;
struct GNUNET_JSON_Specification spec[] = {
- TALER_JSON_spec_denom_pub ("denom_pub",
- &denom_pub),
- TALER_JSON_spec_amount ("value",
- currency,
- &coin_value),
- TALER_JSON_SPEC_DENOM_FEES ("fee",
- currency,
- &fees),
- GNUNET_JSON_spec_timestamp ("stamp_start",
- &stamp_start),
- GNUNET_JSON_spec_timestamp ("stamp_expire_withdraw",
- &stamp_expire_withdraw),
- GNUNET_JSON_spec_timestamp ("stamp_expire_deposit",
- &stamp_expire_deposit),
- GNUNET_JSON_spec_timestamp ("stamp_expire_legal",
- &stamp_expire_legal),
- GNUNET_JSON_spec_fixed_auto ("master_sig",
- &master_sig),
+ TALER_JSON_spec_denomination_group (NULL,
+ currency,
+ &group),
+ GNUNET_JSON_spec_array_const ("denoms",
+ &denoms),
GNUNET_JSON_spec_end ()
};
- struct GNUNET_TIME_Relative duration;
- struct TALER_DenominationHashP h_denom_pub;
+ size_t index2;
+ json_t *value2;
if (GNUNET_OK !=
GNUNET_JSON_parse (value,
@@ -799,70 +772,116 @@ show_denomkeys (const json_t *denomkeys)
test_shutdown ();
return GNUNET_SYSERR;
}
- duration = GNUNET_TIME_absolute_get_difference (
- stamp_start.abs_time,
- stamp_expire_withdraw.abs_time);
- TALER_denom_pub_hash (&denom_pub,
- &h_denom_pub);
- if (GNUNET_OK !=
- TALER_exchange_offline_denom_validity_verify (
- &h_denom_pub,
- stamp_start,
- stamp_expire_withdraw,
- stamp_expire_deposit,
- stamp_expire_legal,
- &coin_value,
- &fees,
- &master_pub,
- &master_sig))
- {
- fprintf (stderr,
- "Invalid master signature for key %s (aborting)\n",
- TALER_B2S (&h_denom_pub));
- global_ret = EXIT_FAILURE;
- test_shutdown ();
- return GNUNET_SYSERR;
- }
+ json_array_foreach (denoms, index2, value2) {
+ struct GNUNET_TIME_Timestamp stamp_start;
+ struct GNUNET_TIME_Timestamp stamp_expire_withdraw;
+ struct GNUNET_TIME_Timestamp stamp_expire_deposit;
+ struct GNUNET_TIME_Timestamp stamp_expire_legal;
+ struct TALER_DenominationPublicKey denom_pub;
+ struct TALER_MasterSignatureP master_sig;
+ struct GNUNET_JSON_Specification ispec[] = {
+ TALER_JSON_spec_denom_pub_cipher (NULL,
+ group.cipher,
+ &denom_pub),
+ GNUNET_JSON_spec_timestamp ("stamp_start",
+ &stamp_start),
+ GNUNET_JSON_spec_timestamp ("stamp_expire_withdraw",
+ &stamp_expire_withdraw),
+ GNUNET_JSON_spec_timestamp ("stamp_expire_deposit",
+ &stamp_expire_deposit),
+ GNUNET_JSON_spec_timestamp ("stamp_expire_legal",
+ &stamp_expire_legal),
+ GNUNET_JSON_spec_fixed_auto ("master_sig",
+ &master_sig),
+ GNUNET_JSON_spec_end ()
+ };
+ struct GNUNET_TIME_Relative duration;
+ struct TALER_DenominationHashP h_denom_pub;
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (value2,
+ ispec,
+ &err_name,
+ &err_line))
+ {
+ fprintf (stderr,
+ "Invalid input for denomination key to 'show': %s#%u at %u/%u (skipping)\n",
+ err_name,
+ err_line,
+ (unsigned int) index,
+ (unsigned int) index2);
+ GNUNET_JSON_parse_free (spec);
+ global_ret = EXIT_FAILURE;
+ test_shutdown ();
+ return GNUNET_SYSERR;
+ }
+ duration = GNUNET_TIME_absolute_get_difference (
+ stamp_start.abs_time,
+ stamp_expire_withdraw.abs_time);
+ TALER_denom_pub_hash (&denom_pub,
+ &h_denom_pub);
+ if (GNUNET_OK !=
+ TALER_exchange_offline_denom_validity_verify (
+ &h_denom_pub,
+ stamp_start,
+ stamp_expire_withdraw,
+ stamp_expire_deposit,
+ stamp_expire_legal,
+ &group.value,
+ &group.fees,
+ &master_pub,
+ &master_sig))
+ {
+ fprintf (stderr,
+ "Invalid master signature for key %s (aborting)\n",
+ TALER_B2S (&h_denom_pub));
+ global_ret = EXIT_FAILURE;
+ GNUNET_JSON_parse_free (ispec);
+ GNUNET_JSON_parse_free (spec);
+ test_shutdown ();
+ return GNUNET_SYSERR;
+ }
- {
- char *withdraw_fee_s;
- char *deposit_fee_s;
- char *refresh_fee_s;
- char *refund_fee_s;
- char *deposit_s;
- char *legal_s;
-
- withdraw_fee_s = TALER_amount_to_string (&fees.withdraw);
- deposit_fee_s = TALER_amount_to_string (&fees.deposit);
- refresh_fee_s = TALER_amount_to_string (&fees.refresh);
- refund_fee_s = TALER_amount_to_string (&fees.refund);
- deposit_s = GNUNET_strdup (
- GNUNET_TIME_timestamp2s (stamp_expire_deposit));
- legal_s = GNUNET_strdup (
- GNUNET_TIME_timestamp2s (stamp_expire_legal));
-
- printf (
- "DENOMINATION-KEY %s of value %s starting at %s "
- "(used for: %s, deposit until: %s legal end: %s) with fees %s/%s/%s/%s\n",
- TALER_B2S (&h_denom_pub),
- TALER_amount2s (&coin_value),
- GNUNET_TIME_timestamp2s (stamp_start),
- GNUNET_TIME_relative2s (duration,
- false),
- deposit_s,
- legal_s,
- withdraw_fee_s,
- deposit_fee_s,
- refresh_fee_s,
- refund_fee_s);
- GNUNET_free (withdraw_fee_s);
- GNUNET_free (deposit_fee_s);
- GNUNET_free (refresh_fee_s);
- GNUNET_free (refund_fee_s);
- GNUNET_free (deposit_s);
- GNUNET_free (legal_s);
+ {
+ char *withdraw_fee_s;
+ char *deposit_fee_s;
+ char *refresh_fee_s;
+ char *refund_fee_s;
+ char *deposit_s;
+ char *legal_s;
+
+ withdraw_fee_s = TALER_amount_to_string (&group.fees.withdraw);
+ deposit_fee_s = TALER_amount_to_string (&group.fees.deposit);
+ refresh_fee_s = TALER_amount_to_string (&group.fees.refresh);
+ refund_fee_s = TALER_amount_to_string (&group.fees.refund);
+ deposit_s = GNUNET_strdup (
+ GNUNET_TIME_timestamp2s (stamp_expire_deposit));
+ legal_s = GNUNET_strdup (
+ GNUNET_TIME_timestamp2s (stamp_expire_legal));
+
+ printf (
+ "DENOMINATION-KEY %s of value %s starting at %s "
+ "(used for: %s, deposit until: %s legal end: %s) with fees %s/%s/%s/%s\n",
+ TALER_B2S (&h_denom_pub),
+ TALER_amount2s (&group.value),
+ GNUNET_TIME_timestamp2s (stamp_start),
+ GNUNET_TIME_relative2s (duration,
+ false),
+ deposit_s,
+ legal_s,
+ withdraw_fee_s,
+ deposit_fee_s,
+ refresh_fee_s,
+ refund_fee_s);
+ GNUNET_free (withdraw_fee_s);
+ GNUNET_free (deposit_fee_s);
+ GNUNET_free (refresh_fee_s);
+ GNUNET_free (refund_fee_s);
+ GNUNET_free (deposit_s);
+ GNUNET_free (legal_s);
+ }
+ GNUNET_JSON_parse_free (ispec);
}
-
GNUNET_JSON_parse_free (spec);
}
return GNUNET_OK;
@@ -956,11 +975,11 @@ do_show (char *const *args)
json_t *keys;
const char *err_name;
unsigned int err_line;
- json_t *denomkeys;
+ const json_t *denomkeys;
struct TALER_MasterPublicKeyP mpub;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_json ("denoms",
- &denomkeys),
+ GNUNET_JSON_spec_array_const ("denominations",
+ &denomkeys),
GNUNET_JSON_spec_fixed_auto ("master_public_key",
&mpub),
GNUNET_JSON_spec_end ()
@@ -1004,11 +1023,9 @@ do_show (char *const *args)
{
global_ret = EXIT_FAILURE;
test_shutdown ();
- GNUNET_JSON_parse_free (spec);
json_decref (keys);
return;
}
- GNUNET_JSON_parse_free (spec);
json_decref (keys);
/* do NOT consume input if next argument is '-' */
if ( (NULL != args[0]) &&
@@ -1028,45 +1045,27 @@ do_show (char *const *args)
* @param denomkeys keys to output
* @return #GNUNET_OK on success
*/
-static int
+static enum GNUNET_GenericReturnValue
sign_denomkeys (const json_t *denomkeys)
{
- size_t index;
+ size_t group_idx;
json_t *value;
- json_array_foreach (denomkeys, index, value) {
+ json_array_foreach (denomkeys, group_idx, value) {
+ struct TALER_DenominationGroup group = { 0 };
+ const json_t *denom_keys_array;
const char *err_name;
unsigned int err_line;
- struct TALER_DenominationPublicKey denom_pub;
- struct GNUNET_TIME_Timestamp stamp_start;
- struct GNUNET_TIME_Timestamp stamp_expire_withdraw;
- struct GNUNET_TIME_Timestamp stamp_expire_deposit;
- struct GNUNET_TIME_Timestamp stamp_expire_legal;
- struct TALER_Amount coin_value;
- struct TALER_DenomFeeSet fees;
- struct TALER_MasterSignatureP master_sig;
struct GNUNET_JSON_Specification spec[] = {
- TALER_JSON_spec_denom_pub ("denom_pub",
- &denom_pub),
- TALER_JSON_spec_amount ("value",
- currency,
- &coin_value),
- TALER_JSON_SPEC_DENOM_FEES ("fee",
- currency,
- &fees),
- GNUNET_JSON_spec_timestamp ("stamp_start",
- &stamp_start),
- GNUNET_JSON_spec_timestamp ("stamp_expire_withdraw",
- &stamp_expire_withdraw),
- GNUNET_JSON_spec_timestamp ("stamp_expire_deposit",
- &stamp_expire_deposit),
- GNUNET_JSON_spec_timestamp ("stamp_expire_legal",
- &stamp_expire_legal),
- GNUNET_JSON_spec_fixed_auto ("master_sig",
- &master_sig),
+ TALER_JSON_spec_denomination_group (NULL,
+ currency,
+ &group),
+ GNUNET_JSON_spec_array_const ("denoms",
+ &denom_keys_array),
GNUNET_JSON_spec_end ()
};
- struct TALER_DenominationHashP h_denom_pub;
+ size_t index;
+ json_t *denom_key_obj;
if (GNUNET_OK !=
GNUNET_JSON_parse (value,
@@ -1078,54 +1077,100 @@ sign_denomkeys (const json_t *denomkeys)
"Invalid input for denomination key to 'sign': %s#%u at %u (skipping)\n",
err_name,
err_line,
- (unsigned int) index);
+ (unsigned int) group_idx);
GNUNET_JSON_parse_free (spec);
global_ret = EXIT_FAILURE;
test_shutdown ();
return GNUNET_SYSERR;
}
- TALER_denom_pub_hash (&denom_pub,
- &h_denom_pub);
- if (GNUNET_OK !=
- TALER_exchange_offline_denom_validity_verify (
- &h_denom_pub,
- stamp_start,
- stamp_expire_withdraw,
- stamp_expire_deposit,
- stamp_expire_legal,
- &coin_value,
- &fees,
- &master_pub,
- &master_sig))
- {
- fprintf (stderr,
- "Invalid master signature for key %s (aborting)\n",
- TALER_B2S (&h_denom_pub));
- global_ret = EXIT_FAILURE;
- test_shutdown ();
- return GNUNET_SYSERR;
- }
+ json_array_foreach (denom_keys_array, index, denom_key_obj) {
+ struct GNUNET_TIME_Timestamp stamp_start;
+ struct GNUNET_TIME_Timestamp stamp_expire_withdraw;
+ struct GNUNET_TIME_Timestamp stamp_expire_deposit;
+ struct GNUNET_TIME_Timestamp stamp_expire_legal;
+ struct TALER_DenominationPublicKey denom_pub = {
+ .age_mask = group.age_mask
+ };
+ struct TALER_MasterSignatureP master_sig;
+ struct GNUNET_JSON_Specification ispec[] = {
+ TALER_JSON_spec_denom_pub_cipher (NULL,
+ group.cipher,
+ &denom_pub),
+ GNUNET_JSON_spec_timestamp ("stamp_start",
+ &stamp_start),
+ GNUNET_JSON_spec_timestamp ("stamp_expire_withdraw",
+ &stamp_expire_withdraw),
+ GNUNET_JSON_spec_timestamp ("stamp_expire_deposit",
+ &stamp_expire_deposit),
+ GNUNET_JSON_spec_timestamp ("stamp_expire_legal",
+ &stamp_expire_legal),
+ GNUNET_JSON_spec_fixed_auto ("master_sig",
+ &master_sig),
+ GNUNET_JSON_spec_end ()
+ };
+ struct TALER_DenominationHashP h_denom_pub;
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (denom_key_obj,
+ ispec,
+ &err_name,
+ &err_line))
+ {
+ fprintf (stderr,
+ "Invalid input for denomination key to 'show': %s#%u at %u/%u (skipping)\n",
+ err_name,
+ err_line,
+ (unsigned int) group_idx,
+ (unsigned int) index);
+ GNUNET_JSON_parse_free (spec);
+ global_ret = EXIT_FAILURE;
+ test_shutdown ();
+ return GNUNET_SYSERR;
+ }
+ TALER_denom_pub_hash (&denom_pub,
+ &h_denom_pub);
+ if (GNUNET_OK !=
+ TALER_exchange_offline_denom_validity_verify (
+ &h_denom_pub,
+ stamp_start,
+ stamp_expire_withdraw,
+ stamp_expire_deposit,
+ stamp_expire_legal,
+ &group.value,
+ &group.fees,
+ &master_pub,
+ &master_sig))
+ {
+ fprintf (stderr,
+ "Invalid master signature for key %s (aborting)\n",
+ TALER_B2S (&h_denom_pub));
+ global_ret = EXIT_FAILURE;
+ test_shutdown ();
+ return GNUNET_SYSERR;
+ }
- {
- struct TALER_AuditorSignatureP auditor_sig;
-
- TALER_auditor_denom_validity_sign (auditor_url,
- &h_denom_pub,
- &master_pub,
- stamp_start,
- stamp_expire_withdraw,
- stamp_expire_deposit,
- stamp_expire_legal,
- &coin_value,
- &fees,
- &auditor_priv,
- &auditor_sig);
- output_operation (OP_SIGN_DENOMINATION,
- GNUNET_JSON_PACK (
- GNUNET_JSON_pack_data_auto ("h_denom_pub",
- &h_denom_pub),
- GNUNET_JSON_pack_data_auto ("auditor_sig",
- &auditor_sig)));
+ {
+ struct TALER_AuditorSignatureP auditor_sig;
+
+ TALER_auditor_denom_validity_sign (auditor_url,
+ &h_denom_pub,
+ &master_pub,
+ stamp_start,
+ stamp_expire_withdraw,
+ stamp_expire_deposit,
+ stamp_expire_legal,
+ &group.value,
+ &group.fees,
+ &auditor_priv,
+ &auditor_sig);
+ output_operation (OP_SIGN_DENOMINATION,
+ GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_data_auto ("h_denom_pub",
+ &h_denom_pub),
+ GNUNET_JSON_pack_data_auto ("auditor_sig",
+ &auditor_sig)));
+ }
+ GNUNET_JSON_parse_free (ispec);
}
GNUNET_JSON_parse_free (spec);
}
@@ -1145,10 +1190,10 @@ do_sign (char *const *args)
const char *err_name;
unsigned int err_line;
struct TALER_MasterPublicKeyP mpub;
- json_t *denomkeys;
+ const json_t *denomkeys;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_json ("denoms",
- &denomkeys),
+ GNUNET_JSON_spec_array_const ("denominations",
+ &denomkeys),
GNUNET_JSON_spec_fixed_auto ("master_public_key",
&mpub),
GNUNET_JSON_spec_end ()
@@ -1203,11 +1248,9 @@ do_sign (char *const *args)
{
global_ret = EXIT_FAILURE;
test_shutdown ();
- GNUNET_JSON_parse_free (spec);
json_decref (keys);
return;
}
- GNUNET_JSON_parse_free (spec);
json_decref (keys);
next (args);
}
diff --git a/src/exchange-tools/taler-crypto-worker.c b/src/exchange-tools/taler-crypto-worker.c
deleted file mode 100644
index 8c3a123c3..000000000
--- a/src/exchange-tools/taler-crypto-worker.c
+++ /dev/null
@@ -1,459 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2014-2021 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-*/
-/**
- * @file exchange-tools/taler-crypto-worker.c
- * @brief Standalone process to perform various cryptographic operations.
- * @author Florian Dold
- */
-#include "platform.h"
-#include "taler_util.h"
-#include <gnunet/gnunet_json_lib.h>
-#include <gnunet/gnunet_crypto_lib.h>
-#include "taler_error_codes.h"
-#include "taler_json_lib.h"
-#include "taler_signatures.h"
-
-
-/**
- * Return value from main().
- */
-static int global_ret;
-
-
-/**
- * Main function that will be run under the GNUnet scheduler.
- *
- * @param cls closure
- * @param args remaining command-line arguments
- * @param cfgfile name of the configuration file used (for saving, can be NULL!)
- * @param cfg configuration
- */
-static void
-run (void *cls,
- char *const *args,
- const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- (void) cls;
- (void) args;
- (void) cfgfile;
- (void) cfg;
-
- json_t *req;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "started crypto worker\n");
-
- for (;;)
- {
- const char *op;
- const json_t *args;
- req = json_loadf (stdin, JSON_DISABLE_EOF_CHECK, NULL);
- if (NULL == req)
- {
- if (feof (stdin))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "end of input\n");
- global_ret = 0;
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "invalid JSON\n");
- global_ret = 1;
- return;
- }
- op = json_string_value (json_object_get (req,
- "op"));
- if (! op)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "no op specified\n");
- global_ret = 1;
- return;
- }
- args = json_object_get (req, "args");
- if (! args)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "no args specified\n");
- global_ret = 1;
- return;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "got request\n");
- if (0 == strcmp ("eddsa_get_public",
- op))
- {
- struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub;
- struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv;
- json_t *resp;
- struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_fixed_auto ("eddsa_priv",
- &eddsa_priv),
- GNUNET_JSON_spec_end ()
- };
- if (GNUNET_OK != GNUNET_JSON_parse (args,
- spec,
- NULL,
- NULL))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "malformed op args\n");
- global_ret = 1;
- return;
- }
- GNUNET_CRYPTO_eddsa_key_get_public (&eddsa_priv,
- &eddsa_pub);
- resp = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_data_auto ("eddsa_pub",
- &eddsa_pub)
- );
- json_dumpf (resp, stdout, JSON_COMPACT);
- printf ("\n");
- fflush (stdout);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "sent response\n");
- GNUNET_JSON_parse_free (spec);
- continue;
- }
- if (0 == strcmp ("ecdhe_get_public",
- op))
- {
- struct GNUNET_CRYPTO_EcdhePublicKey ecdhe_pub;
- struct GNUNET_CRYPTO_EcdhePrivateKey ecdhe_priv;
- json_t *resp;
- struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_fixed_auto ("ecdhe_priv",
- &ecdhe_priv),
- GNUNET_JSON_spec_end ()
- };
- if (GNUNET_OK != GNUNET_JSON_parse (args,
- spec,
- NULL,
- NULL))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "malformed op args\n");
- global_ret = 1;
- return;
- }
- GNUNET_CRYPTO_ecdhe_key_get_public (&ecdhe_priv,
- &ecdhe_pub);
- resp = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_data_auto ("ecdhe_pub",
- &ecdhe_pub)
- );
- json_dumpf (resp, stdout, JSON_COMPACT);
- printf ("\n");
- fflush (stdout);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "sent response\n");
- GNUNET_JSON_parse_free (spec);
- continue;
- }
- if (0 == strcmp ("eddsa_verify",
- op))
- {
- struct GNUNET_CRYPTO_EddsaPublicKey pub;
- struct GNUNET_CRYPTO_EddsaSignature sig;
- struct GNUNET_CRYPTO_EccSignaturePurpose *msg;
- size_t msg_size;
- enum GNUNET_GenericReturnValue verify_ret;
- json_t *resp;
- struct GNUNET_JSON_Specification eddsa_verify_spec[] = {
- GNUNET_JSON_spec_fixed_auto ("pub",
- &pub),
- GNUNET_JSON_spec_fixed_auto ("sig",
- &sig),
- GNUNET_JSON_spec_varsize ("msg",
- (void **) &msg,
- &msg_size),
- GNUNET_JSON_spec_end ()
- };
- if (GNUNET_OK != GNUNET_JSON_parse (args,
- eddsa_verify_spec,
- NULL,
- NULL))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "malformed op args\n");
- global_ret = 1;
- return;
- }
- verify_ret = GNUNET_CRYPTO_eddsa_verify_ (
- ntohl (msg->purpose),
- msg,
- &sig,
- &pub);
- resp = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_bool ("valid",
- GNUNET_OK == verify_ret));
- json_dumpf (resp, stdout, JSON_COMPACT);
- printf ("\n");
- fflush (stdout);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "sent response\n");
- GNUNET_JSON_parse_free (eddsa_verify_spec);
- continue;
- }
- if (0 == strcmp ("kx_ecdhe_eddsa",
- op))
- {
- struct GNUNET_CRYPTO_EcdhePrivateKey priv;
- struct GNUNET_CRYPTO_EddsaPublicKey pub;
- struct GNUNET_HashCode key_material;
- json_t *resp;
- struct GNUNET_JSON_Specification kx_spec[] = {
- GNUNET_JSON_spec_fixed_auto ("eddsa_pub",
- &pub),
- GNUNET_JSON_spec_fixed_auto ("ecdhe_priv",
- &priv),
- GNUNET_JSON_spec_end ()
- };
- if (GNUNET_OK !=
- GNUNET_JSON_parse (args,
- kx_spec,
- NULL,
- NULL))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "malformed op args\n");
- global_ret = 1;
- return;
- }
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CRYPTO_ecdh_eddsa (&priv,
- &pub,
- &key_material));
- resp = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_data_auto ("h",
- &key_material)
- );
- json_dumpf (resp,
- stdout,
- JSON_COMPACT);
- printf ("\n");
- fflush (stdout);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "sent response\n");
- GNUNET_JSON_parse_free (kx_spec);
- continue;
- }
- if (0 == strcmp ("eddsa_sign",
- op))
- {
- struct GNUNET_CRYPTO_EddsaSignature sig;
- struct GNUNET_CRYPTO_EccSignaturePurpose *msg;
- struct GNUNET_CRYPTO_EddsaPrivateKey priv;
- size_t msg_size;
- json_t *resp;
- struct GNUNET_JSON_Specification eddsa_sign_spec[] = {
- GNUNET_JSON_spec_fixed_auto ("priv",
- &priv),
- GNUNET_JSON_spec_varsize ("msg",
- (void **) &msg,
- &msg_size),
- GNUNET_JSON_spec_end ()
- };
- if (GNUNET_OK !=
- GNUNET_JSON_parse (args,
- eddsa_sign_spec,
- NULL,
- NULL))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "malformed op args\n");
- global_ret = 1;
- return;
- }
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CRYPTO_eddsa_sign_ (
- &priv,
- msg,
- &sig));
- resp = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_data_auto ("sig", &sig)
- );
- json_dumpf (resp, stdout,
- JSON_COMPACT);
- printf ("\n");
- fflush (stdout);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "sent response\n");
- GNUNET_JSON_parse_free (eddsa_sign_spec);
- continue;
- }
- if (0 == strcmp ("setup_refresh_planchet", op))
- {
- struct TALER_TransferSecretP transfer_secret;
- uint32_t coin_index;
- json_t *resp;
- struct GNUNET_JSON_Specification setup_refresh_planchet_spec[] = {
- GNUNET_JSON_spec_uint32 ("coin_index",
- &coin_index),
- GNUNET_JSON_spec_fixed_auto ("transfer_secret",
- &transfer_secret),
- GNUNET_JSON_spec_end ()
- };
- struct TALER_CoinSpendPublicKeyP coin_pub;
- struct TALER_CoinSpendPrivateKeyP coin_priv;
- struct TALER_PlanchetMasterSecretP ps;
- struct TALER_ExchangeWithdrawValues alg_values = {
- // FIXME: also allow CS
- .cipher = TALER_DENOMINATION_RSA,
- };
- union TALER_DenominationBlindingKeyP dbk;
-
- if (GNUNET_OK !=
- GNUNET_JSON_parse (args,
- setup_refresh_planchet_spec,
- NULL,
- NULL))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "malformed op args\n");
- global_ret = 1;
- return;
- }
- TALER_transfer_secret_to_planchet_secret (&transfer_secret,
- coin_index,
- &ps);
- TALER_planchet_setup_coin_priv (&ps,
- &alg_values,
- &coin_priv);
- GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv.eddsa_priv,
- &coin_pub.eddsa_pub);
- TALER_planchet_blinding_secret_create (&ps,
- &alg_values,
- &dbk);
-
- resp = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_data_auto ("coin_priv", &coin_priv),
- GNUNET_JSON_pack_data_auto ("coin_pub", &coin_pub),
- GNUNET_JSON_pack_data_auto ("blinding_key", &dbk.rsa_bks)
- );
- json_dumpf (resp, stdout, JSON_COMPACT);
- printf ("\n");
- fflush (stdout);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "sent response\n");
- GNUNET_JSON_parse_free (setup_refresh_planchet_spec);
- continue;
- }
- if (0 == strcmp ("rsa_blind", op))
- {
- struct GNUNET_HashCode hm;
- struct GNUNET_CRYPTO_RsaBlindingKeySecret bks;
- void *pub_enc;
- size_t pub_enc_size;
- int success;
- struct GNUNET_CRYPTO_RsaPublicKey *pub;
- void *blinded_buf;
- size_t blinded_size;
- json_t *resp;
- struct GNUNET_JSON_Specification rsa_blind_spec[] = {
- GNUNET_JSON_spec_fixed_auto ("hm",
- &hm),
- GNUNET_JSON_spec_fixed_auto ("bks",
- &bks),
- GNUNET_JSON_spec_varsize ("pub",
- &pub_enc,
- &pub_enc_size),
- GNUNET_JSON_spec_end ()
- };
- if (GNUNET_OK !=
- GNUNET_JSON_parse (args,
- rsa_blind_spec,
- NULL,
- NULL))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "malformed op args\n");
- global_ret = 1;
- return;
- }
- pub = GNUNET_CRYPTO_rsa_public_key_decode (pub_enc,
- pub_enc_size);
- success = GNUNET_CRYPTO_rsa_blind (&hm,
- &bks,
- pub,
- &blinded_buf,
- &blinded_size);
-
- if (GNUNET_YES == success)
- {
- resp = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_data_varsize ("blinded", blinded_buf, blinded_size),
- GNUNET_JSON_pack_bool ("success", true)
- );
- }
- else
- {
- resp = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_bool ("success", false)
- );
- }
- json_dumpf (resp, stdout, JSON_COMPACT);
- printf ("\n");
- fflush (stdout);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "sent response\n");
- GNUNET_JSON_parse_free (rsa_blind_spec);
- GNUNET_free (blinded_buf);
- continue;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "unsupported operation '%s'\n",
- op);
- global_ret = 1;
- return;
- }
-
-}
-
-
-/**
- * The entry point.
- *
- * @param argc number of arguments in @a argv
- * @param argv command-line arguments
- * @return 0 on normal termination
- */
-int
-main (int argc,
- char **argv)
-{
- struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_OPTION_END
- };
- int ret;
-
- /* force linker to link against libtalerutil; if we do
- not do this, the linker may "optimize" libtalerutil
- away and skip #TALER_OS_init(), which we do need */
- TALER_OS_init ();
- ret = GNUNET_PROGRAM_run (argc, argv,
- "taler-crypto-worker",
- "Execute cryptographic operations read from stdin",
- options,
- &run,
- NULL);
- if (GNUNET_NO == ret)
- return 0;
- if (GNUNET_SYSERR == ret)
- return 1;
- return global_ret;
-}
diff --git a/src/exchange-tools/taler-exchange-dbinit.c b/src/exchange-tools/taler-exchange-dbinit.c
index 7dd5c0151..41ff2ab24 100644
--- a/src/exchange-tools/taler-exchange-dbinit.c
+++ b/src/exchange-tools/taler-exchange-dbinit.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014-2022 Taler Systems SA
+ Copyright (C) 2014-2024 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -30,6 +30,11 @@
static int global_ret;
/**
+ * -a option: inject auditor triggers
+ */
+static int inject_auditor;
+
+/**
* -r option: do full DB reset
*/
static int reset_db;
@@ -50,21 +55,11 @@ static int gc_db;
static uint32_t num_partitions;
/**
- * -F option: setup a sharded database, i.e. create foreign tables/server
- */
-static int shard_db;
-
-/**
* -f option: force partitions to be created when there is only one
*/
static int force_create_partitions;
/**
- * -S option: setup a database on a shard server, creates tables with suffix shard_idx
- */
-static uint32_t shard_idx;
-
-/**
* Main function that will be run.
*
* @param cls closure
@@ -83,6 +78,7 @@ run (void *cls,
(void) cls;
(void) args;
(void) cfgfile;
+
if (NULL ==
(plugin = TALER_EXCHANGEDB_plugin_load (cfg)))
{
@@ -100,23 +96,10 @@ run (void *cls,
"Could not drop tables as requested. Either database was not yet initialized, or permission denied. Consult the logs. Will still try to create new tables.\n");
}
}
- if (0 < shard_idx)
- {
- if (GNUNET_OK !=
- plugin->create_shard_tables (plugin->cls,
- shard_idx))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Could not create shard database\n");
- global_ret = EXIT_NOTINSTALLED;
- }
- /* We do not want to continue if we are on a shard */
- TALER_EXCHANGEDB_plugin_unload (plugin);
- plugin = NULL;
- return;
- }
if (GNUNET_OK !=
- plugin->create_tables (plugin->cls))
+ plugin->create_tables (plugin->cls,
+ force_create_partitions || num_partitions > 0,
+ num_partitions))
{
fprintf (stderr,
"Failed to initialize database.\n");
@@ -125,38 +108,6 @@ run (void *cls,
global_ret = EXIT_NOPERMISSION;
return;
}
- if (1 <
- num_partitions
- || (
- 1 == num_partitions
- && force_create_partitions))
- {
- enum GNUNET_GenericReturnValue r = GNUNET_OK;
- if (shard_db)
- {
- r = plugin->setup_foreign_servers (plugin->cls,
- num_partitions);
- }
- else
- {
- r = plugin->setup_partitions (plugin->cls,
- num_partitions);
- }
- if (GNUNET_OK != r)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Could not setup partitions. Dropping default ones again\n");
- if (GNUNET_OK != plugin->drop_tables (plugin->cls))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Could not drop tables after failed partitioning, please delete the DB manually\n");
- }
- TALER_EXCHANGEDB_plugin_unload (plugin);
- plugin = NULL;
- global_ret = EXIT_NOTINSTALLED;
- return;
- }
- }
if (gc_db || clear_shards)
{
if (GNUNET_OK !=
@@ -187,6 +138,15 @@ run (void *cls,
}
}
}
+ if (inject_auditor)
+ {
+ if (GNUNET_SYSERR == plugin->inject_auditor_triggers (plugin->cls))
+ {
+ fprintf (stderr,
+ "Injecting auditor triggers failed!\n");
+ global_ret = EXIT_FAILURE;
+ }
+ }
TALER_EXCHANGEDB_plugin_unload (plugin);
plugin = NULL;
}
@@ -205,6 +165,10 @@ main (int argc,
char *const *argv)
{
const struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_option_flag ('a',
+ "inject-auditor",
+ "inject auditor triggers",
+ &inject_auditor),
GNUNET_GETOPT_option_flag ('g',
"gc",
"garbage collect database",
@@ -220,17 +184,8 @@ main (int argc,
GNUNET_GETOPT_option_uint ('P',
"partition",
"NUMBER",
- "Setup a partitioned database where each table which can be partitioned holds NUMBER partitions on a single DB node (NOTE: sharding add -F for sharding)",
+ "Setup a partitioned database where each table which can be partitioned holds NUMBER partitions on a single DB node",
&num_partitions),
- GNUNET_GETOPT_option_flag ('F',
- "foreign",
- "Setup a sharded database with foreign servers (shards) / tables rather than a partitioned one, must be called as DB superuser.",
- &shard_db),
- GNUNET_GETOPT_option_uint ('S',
- "shard",
- "INDEX",
- "Setup a shard server, creates tables with INDEX as suffix",
- &shard_idx),
GNUNET_GETOPT_option_flag ('f',
"force",
"Force partitions to be created if there is only one partition",
diff --git a/src/exchange-tools/taler-exchange-offline.c b/src/exchange-tools/taler-exchange-offline.c
index 60a39df96..1f10c55e3 100644
--- a/src/exchange-tools/taler-exchange-offline.c
+++ b/src/exchange-tools/taler-exchange-offline.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2020, 2021, 2022 Taler Systems SA
+ Copyright (C) 2020-2024 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -24,6 +24,8 @@
#include "taler_json_lib.h"
#include "taler_exchange_service.h"
#include "taler_extensions.h"
+#include <regex.h>
+
/**
* Name of the input for the 'sign' and 'show' operation.
@@ -113,6 +115,16 @@
#define OP_DRAIN_PROFITS "exchange-drain-profits-0"
/**
+ * Setup AML staff.
+ */
+#define OP_UPDATE_AML_STAFF "exchange-add-aml-staff-0"
+
+/**
+ * Setup partner exchange for wad transfers.
+ */
+#define OP_ADD_PARTNER "exchange-add-partner-0"
+
+/**
* Our private key, initialized in #load_offline_key().
*/
static struct TALER_MasterPrivateKeyP master_priv;
@@ -138,6 +150,12 @@ static struct GNUNET_CURL_RescheduleContext *rc;
static const struct GNUNET_CONFIGURATION_Handle *kcfg;
/**
+ * Age restriction configuration
+ */
+static bool ar_enabled = false;
+static struct TALER_AgeRestrictionConfig ar_config = {0};
+
+/**
* Return value from main().
*/
static int global_ret;
@@ -164,11 +182,6 @@ static char *currency;
static char *CFG_exchange_url;
/**
- * If age restriction is enabled, the age mask to be used
- */
-static struct TALER_AgeMask age_mask = {0};
-
-/**
* A subcommand supported by this program.
*/
struct SubCommand
@@ -498,6 +511,62 @@ struct UploadExtensionsRequest
/**
+ * Data structure for AML staff requests.
+ */
+struct AmlStaffRequest
+{
+
+ /**
+ * Kept in a DLL.
+ */
+ struct AmlStaffRequest *next;
+
+ /**
+ * Kept in a DLL.
+ */
+ struct AmlStaffRequest *prev;
+
+ /**
+ * Operation handle.
+ */
+ struct TALER_EXCHANGE_ManagementUpdateAmlOfficer *h;
+
+ /**
+ * Array index of the associated command.
+ */
+ size_t idx;
+};
+
+
+/**
+ * Data structure for partner add requests.
+ */
+struct PartnerAddRequest
+{
+
+ /**
+ * Kept in a DLL.
+ */
+ struct PartnerAddRequest *next;
+
+ /**
+ * Kept in a DLL.
+ */
+ struct PartnerAddRequest *prev;
+
+ /**
+ * Operation handle.
+ */
+ struct TALER_EXCHANGE_ManagementAddPartner *h;
+
+ /**
+ * Array index of the associated command.
+ */
+ size_t idx;
+};
+
+
+/**
* Next work item to perform.
*/
static struct GNUNET_SCHEDULER_Task *nxt;
@@ -507,6 +576,27 @@ static struct GNUNET_SCHEDULER_Task *nxt;
*/
static struct TALER_EXCHANGE_ManagementGetKeysHandle *mgkh;
+
+/**
+ * Active AML staff change requests.
+ */
+static struct AmlStaffRequest *asr_head;
+
+/**
+ * Active AML staff change requests.
+ */
+static struct AmlStaffRequest *asr_tail;
+
+/**
+ * Active partner add requests.
+ */
+static struct PartnerAddRequest *par_head;
+
+/**
+ * Active partner add requests.
+ */
+static struct PartnerAddRequest *par_tail;
+
/**
* Active denomiantion revocation requests.
*/
@@ -629,6 +719,36 @@ do_shutdown (void *cls)
(void) cls;
{
+ struct AmlStaffRequest *asr;
+
+ while (NULL != (asr = asr_head))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Aborting incomplete AML staff update #%u\n",
+ (unsigned int) asr->idx);
+ TALER_EXCHANGE_management_update_aml_officer_cancel (asr->h);
+ GNUNET_CONTAINER_DLL_remove (asr_head,
+ asr_tail,
+ asr);
+ GNUNET_free (asr);
+ }
+ }
+ {
+ struct PartnerAddRequest *par;
+
+ while (NULL != (par = par_head))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Aborting incomplete partner add request #%u\n",
+ (unsigned int) par->idx);
+ TALER_EXCHANGE_management_add_partner_cancel (par->h);
+ GNUNET_CONTAINER_DLL_remove (par_head,
+ par_tail,
+ par);
+ GNUNET_free (par);
+ }
+ }
+ {
struct DenomRevocationRequest *drr;
while (NULL != (drr = drr_head))
@@ -798,9 +918,10 @@ do_shutdown (void *cls)
if (NULL != out)
{
- json_dumpf (out,
- stdout,
- JSON_INDENT (2));
+ if (EXIT_SUCCESS == global_ret)
+ json_dumpf (out,
+ stdout,
+ JSON_INDENT (2));
json_decref (out);
out = NULL;
}
@@ -841,6 +962,8 @@ static void
test_shutdown (void)
{
if ( (NULL == drr_head) &&
+ (NULL == par_head) &&
+ (NULL == asr_head) &&
(NULL == srr_head) &&
(NULL == aar_head) &&
(NULL == adr_head) &&
@@ -999,14 +1122,15 @@ load_offline_key (int do_create)
* Function called with information about the post revocation operation result.
*
* @param cls closure with a `struct DenomRevocationRequest`
- * @param hr HTTP response data
+ * @param dr response data
*/
static void
denom_revocation_cb (
void *cls,
- const struct TALER_EXCHANGE_HttpResponse *hr)
+ const struct TALER_EXCHANGE_ManagementRevokeDenominationResponse *dr)
{
struct DenomRevocationRequest *drr = cls;
+ const struct TALER_EXCHANGE_HttpResponse *hr = &dr->hr;
if (MHD_HTTP_NO_CONTENT != hr->http_status)
{
@@ -1066,7 +1190,7 @@ upload_denom_revocation (const char *exchange_url,
stderr,
JSON_INDENT (2));
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return;
}
drr = GNUNET_new (struct DenomRevocationRequest);
@@ -1088,14 +1212,15 @@ upload_denom_revocation (const char *exchange_url,
* Function called with information about the post revocation operation result.
*
* @param cls closure with a `struct SignkeyRevocationRequest`
- * @param hr HTTP response data
+ * @param sr response data
*/
static void
signkey_revocation_cb (
void *cls,
- const struct TALER_EXCHANGE_HttpResponse *hr)
+ const struct TALER_EXCHANGE_ManagementRevokeSigningKeyResponse *sr)
{
struct SignkeyRevocationRequest *srr = cls;
+ const struct TALER_EXCHANGE_HttpResponse *hr = &sr->hr;
if (MHD_HTTP_NO_CONTENT != hr->http_status)
{
@@ -1155,7 +1280,7 @@ upload_signkey_revocation (const char *exchange_url,
stderr,
JSON_INDENT (2));
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return;
}
srr = GNUNET_new (struct SignkeyRevocationRequest);
@@ -1177,13 +1302,15 @@ upload_signkey_revocation (const char *exchange_url,
* Function called with information about the post auditor add operation result.
*
* @param cls closure with a `struct AuditorAddRequest`
- * @param hr HTTP response data
+ * @param mer response data
*/
static void
-auditor_add_cb (void *cls,
- const struct TALER_EXCHANGE_HttpResponse *hr)
+auditor_add_cb (
+ void *cls,
+ const struct TALER_EXCHANGE_ManagementAuditorEnableResponse *mer)
{
struct AuditorAddRequest *aar = cls;
+ const struct TALER_EXCHANGE_HttpResponse *hr = &mer->hr;
if (MHD_HTTP_NO_CONTENT != hr->http_status)
{
@@ -1224,7 +1351,7 @@ upload_auditor_add (const char *exchange_url,
const char *err_name;
unsigned int err_line;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_string ("auditor_url",
+ TALER_JSON_spec_web_url ("auditor_url",
&auditor_url),
GNUNET_JSON_spec_string ("auditor_name",
&auditor_name),
@@ -1252,7 +1379,7 @@ upload_auditor_add (const char *exchange_url,
stderr,
JSON_INDENT (2));
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return;
}
aar = GNUNET_new (struct AuditorAddRequest);
@@ -1277,13 +1404,15 @@ upload_auditor_add (const char *exchange_url,
* Function called with information about the post auditor del operation result.
*
* @param cls closure with a `struct AuditorDelRequest`
- * @param hr HTTP response data
+ * @param mdr response data
*/
static void
auditor_del_cb (void *cls,
- const struct TALER_EXCHANGE_HttpResponse *hr)
+ const struct
+ TALER_EXCHANGE_ManagementAuditorDisableResponse *mdr)
{
struct AuditorDelRequest *adr = cls;
+ const struct TALER_EXCHANGE_HttpResponse *hr = &mdr->hr;
if (MHD_HTTP_NO_CONTENT != hr->http_status)
{
@@ -1346,7 +1475,7 @@ upload_auditor_del (const char *exchange_url,
stderr,
JSON_INDENT (2));
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return;
}
adr = GNUNET_new (struct AuditorDelRequest);
@@ -1369,13 +1498,14 @@ upload_auditor_del (const char *exchange_url,
* Function called with information about the post wire add operation result.
*
* @param cls closure with a `struct WireAddRequest`
- * @param hr HTTP response data
+ * @param wer response data
*/
static void
wire_add_cb (void *cls,
- const struct TALER_EXCHANGE_HttpResponse *hr)
+ const struct TALER_EXCHANGE_ManagementWireEnableResponse *wer)
{
struct WireAddRequest *war = cls;
+ const struct TALER_EXCHANGE_HttpResponse *hr = &wer->hr;
if (MHD_HTTP_NO_CONTENT != hr->http_status)
{
@@ -1413,10 +1543,29 @@ upload_wire_add (const char *exchange_url,
struct GNUNET_TIME_Timestamp start_time;
struct WireAddRequest *war;
const char *err_name;
+ const char *conversion_url = NULL;
+ const char *bank_label = NULL;
+ int64_t priority = 0;
+ const json_t *debit_restrictions;
+ const json_t *credit_restrictions;
unsigned int err_line;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_string ("payto_uri",
- &payto_uri),
+ TALER_JSON_spec_payto_uri ("payto_uri",
+ &payto_uri),
+ GNUNET_JSON_spec_mark_optional (
+ TALER_JSON_spec_web_url ("conversion_url",
+ &conversion_url),
+ NULL),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string ("bank_label",
+ &bank_label),
+ NULL),
+ GNUNET_JSON_spec_int64 ("priority",
+ &priority),
+ GNUNET_JSON_spec_array_const ("debit_restrictions",
+ &debit_restrictions),
+ GNUNET_JSON_spec_array_const ("credit_restrictions",
+ &credit_restrictions),
GNUNET_JSON_spec_timestamp ("validity_start",
&start_time),
GNUNET_JSON_spec_fixed_auto ("master_sig_add",
@@ -1441,7 +1590,7 @@ upload_wire_add (const char *exchange_url,
stderr,
JSON_INDENT (2));
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return;
}
{
@@ -1454,7 +1603,7 @@ upload_wire_add (const char *exchange_url,
"payto:// URI `%s' is malformed\n",
payto_uri);
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return;
}
GNUNET_free (wire_method);
@@ -1468,7 +1617,7 @@ upload_wire_add (const char *exchange_url,
"payto URI is malformed: %s\n",
msg);
GNUNET_free (msg);
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_INVALIDARGUMENT;
return;
}
@@ -1479,9 +1628,14 @@ upload_wire_add (const char *exchange_url,
TALER_EXCHANGE_management_enable_wire (ctx,
exchange_url,
payto_uri,
+ conversion_url,
+ debit_restrictions,
+ credit_restrictions,
start_time,
&master_sig_add,
&master_sig_wire,
+ bank_label,
+ priority,
&wire_add_cb,
war);
GNUNET_CONTAINER_DLL_insert (war_head,
@@ -1494,13 +1648,14 @@ upload_wire_add (const char *exchange_url,
* Function called with information about the post wire del operation result.
*
* @param cls closure with a `struct WireDelRequest`
- * @param hr HTTP response data
+ * @param wdres response data
*/
static void
wire_del_cb (void *cls,
- const struct TALER_EXCHANGE_HttpResponse *hr)
+ const struct TALER_EXCHANGE_ManagementWireDisableResponse *wdres)
{
struct WireDelRequest *wdr = cls;
+ const struct TALER_EXCHANGE_HttpResponse *hr = &wdres->hr;
if (MHD_HTTP_NO_CONTENT != hr->http_status)
{
@@ -1539,8 +1694,8 @@ upload_wire_del (const char *exchange_url,
const char *err_name;
unsigned int err_line;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_string ("payto_uri",
- &payto_uri),
+ TALER_JSON_spec_payto_uri ("payto_uri",
+ &payto_uri),
GNUNET_JSON_spec_timestamp ("validity_end",
&end_time),
GNUNET_JSON_spec_fixed_auto ("master_sig",
@@ -1563,7 +1718,7 @@ upload_wire_del (const char *exchange_url,
stderr,
JSON_INDENT (2));
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return;
}
wdr = GNUNET_new (struct WireDelRequest);
@@ -1586,14 +1741,15 @@ upload_wire_del (const char *exchange_url,
* Function called with information about the post wire fee operation result.
*
* @param cls closure with a `struct WireFeeRequest`
- * @param hr HTTP response data
+ * @param swr response data
*/
static void
wire_fee_cb (
void *cls,
- const struct TALER_EXCHANGE_HttpResponse *hr)
+ const struct TALER_EXCHANGE_ManagementSetWireFeeResponse *swr)
{
struct WireFeeRequest *wfr = cls;
+ const struct TALER_EXCHANGE_HttpResponse *hr = &swr->hr;
if (MHD_HTTP_NO_CONTENT != hr->http_status)
{
@@ -1639,9 +1795,6 @@ upload_wire_fee (const char *exchange_url,
TALER_JSON_spec_amount ("wire_fee",
currency,
&fees.wire),
- TALER_JSON_spec_amount ("wad_fee",
- currency,
- &fees.wad),
TALER_JSON_spec_amount ("closing_fee",
currency,
&fees.closing),
@@ -1669,7 +1822,7 @@ upload_wire_fee (const char *exchange_url,
stderr,
JSON_INDENT (2));
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return;
}
wfr = GNUNET_new (struct WireFeeRequest);
@@ -1694,14 +1847,15 @@ upload_wire_fee (const char *exchange_url,
* Function called with information about the post global fee operation result.
*
* @param cls closure with a `struct WireFeeRequest`
- * @param hr HTTP response data
+ * @param gr response data
*/
static void
global_fee_cb (
void *cls,
- const struct TALER_EXCHANGE_HttpResponse *hr)
+ const struct TALER_EXCHANGE_ManagementSetGlobalFeeResponse *gr)
{
struct GlobalFeeRequest *gfr = cls;
+ const struct TALER_EXCHANGE_HttpResponse *hr = &gr->hr;
if (MHD_HTTP_NO_CONTENT != hr->http_status)
{
@@ -1741,16 +1895,12 @@ upload_global_fee (const char *exchange_url,
struct GNUNET_TIME_Timestamp start_time;
struct GNUNET_TIME_Timestamp end_time;
struct GNUNET_TIME_Relative purse_timeout;
- struct GNUNET_TIME_Relative kyc_timeout;
struct GNUNET_TIME_Relative history_expiration;
uint32_t purse_account_limit;
struct GNUNET_JSON_Specification spec[] = {
TALER_JSON_spec_amount ("history_fee",
currency,
&fees.history),
- TALER_JSON_spec_amount ("kyc_fee",
- currency,
- &fees.kyc),
TALER_JSON_spec_amount ("account_fee",
currency,
&fees.account),
@@ -1759,8 +1909,6 @@ upload_global_fee (const char *exchange_url,
&fees.purse),
GNUNET_JSON_spec_relative_time ("purse_timeout",
&purse_timeout),
- GNUNET_JSON_spec_relative_time ("kyc_timeout",
- &kyc_timeout),
GNUNET_JSON_spec_relative_time ("history_expiration",
&history_expiration),
GNUNET_JSON_spec_uint32 ("purse_account_limit",
@@ -1789,7 +1937,7 @@ upload_global_fee (const char *exchange_url,
stderr,
JSON_INDENT (2));
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return;
}
gfr = GNUNET_new (struct GlobalFeeRequest);
@@ -1801,7 +1949,6 @@ upload_global_fee (const char *exchange_url,
end_time,
&fees,
purse_timeout,
- kyc_timeout,
history_expiration,
purse_account_limit,
&master_sig,
@@ -1817,14 +1964,15 @@ upload_global_fee (const char *exchange_url,
* Function called with information about the drain profits operation.
*
* @param cls closure with a `struct DrainProfitsRequest`
- * @param hr HTTP response data
+ * @param mdr response data
*/
static void
drain_profits_cb (
void *cls,
- const struct TALER_EXCHANGE_HttpResponse *hr)
+ const struct TALER_EXCHANGE_ManagementDrainResponse *mdr)
{
struct DrainProfitsRequest *dpr = cls;
+ const struct TALER_EXCHANGE_HttpResponse *hr = &mdr->hr;
if (MHD_HTTP_NO_CONTENT != hr->http_status)
{
@@ -1875,8 +2023,8 @@ upload_drain (const char *exchange_url,
&date),
GNUNET_JSON_spec_string ("account_section",
&account_section),
- GNUNET_JSON_spec_string ("payto_uri",
- &payto_uri),
+ TALER_JSON_spec_payto_uri ("payto_uri",
+ &payto_uri),
GNUNET_JSON_spec_fixed_auto ("master_sig",
&master_sig),
GNUNET_JSON_spec_end ()
@@ -1897,7 +2045,7 @@ upload_drain (const char *exchange_url,
stderr,
JSON_INDENT (2));
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return;
}
dpr = GNUNET_new (struct DrainProfitsRequest);
@@ -1923,14 +2071,15 @@ upload_drain (const char *exchange_url,
* Function called with information about the post upload keys operation result.
*
* @param cls closure with a `struct UploadKeysRequest`
- * @param hr HTTP response data
+ * @param mr response data
*/
static void
keys_cb (
void *cls,
- const struct TALER_EXCHANGE_HttpResponse *hr)
+ const struct TALER_EXCHANGE_ManagementPostKeysResponse *mr)
{
struct UploadKeysRequest *ukr = cls;
+ const struct TALER_EXCHANGE_HttpResponse *hr = &mr->hr;
if (MHD_HTTP_NO_CONTENT != hr->http_status)
{
@@ -1966,13 +2115,13 @@ upload_keys (const char *exchange_url,
struct UploadKeysRequest *ukr;
const char *err_name;
unsigned int err_line;
- json_t *denom_sigs;
- json_t *signkey_sigs;
+ const json_t *denom_sigs;
+ const json_t *signkey_sigs;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_json ("denom_sigs",
- &denom_sigs),
- GNUNET_JSON_spec_json ("signkey_sigs",
- &signkey_sigs),
+ GNUNET_JSON_spec_array_const ("denom_sigs",
+ &denom_sigs),
+ GNUNET_JSON_spec_array_const ("signkey_sigs",
+ &signkey_sigs),
GNUNET_JSON_spec_end ()
};
bool ok = true;
@@ -1991,7 +2140,7 @@ upload_keys (const char *exchange_url,
stderr,
JSON_INDENT (2));
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return;
}
pkd.num_sign_sigs = json_array_size (signkey_sigs);
@@ -2084,11 +2233,10 @@ upload_keys (const char *exchange_url,
else
{
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
}
GNUNET_free (pkd.sign_sigs);
GNUNET_free (pkd.denom_sigs);
- GNUNET_JSON_parse_free (spec);
}
@@ -2096,14 +2244,15 @@ upload_keys (const char *exchange_url,
* Function called with information about the post upload extensions operation result.
*
* @param cls closure with a `struct UploadExtensionsRequest`
- * @param hr HTTP response data
+ * @param er response data
*/
static void
extensions_cb (
void *cls,
- const struct TALER_EXCHANGE_HttpResponse *hr)
+ const struct TALER_EXCHANGE_ManagementPostExtensionsResponse *er)
{
struct UploadExtensionsRequest *uer = cls;
+ const struct TALER_EXCHANGE_HttpResponse *hr = &er->hr;
if (MHD_HTTP_NO_CONTENT != hr->http_status)
{
@@ -2135,13 +2284,13 @@ upload_extensions (const char *exchange_url,
size_t idx,
const json_t *value)
{
- json_t *extensions;
+ const json_t *extensions;
struct TALER_MasterSignatureP sig;
const char *err_name;
unsigned int err_line;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_json ("extensions",
- &extensions),
+ GNUNET_JSON_spec_object_const ("extensions",
+ &extensions),
GNUNET_JSON_spec_fixed_auto ("extensions_sig",
&sig),
GNUNET_JSON_spec_end ()
@@ -2163,22 +2312,22 @@ upload_extensions (const char *exchange_url,
stderr,
JSON_INDENT (2));
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return;
}
/* 2. Verify the signature */
{
- struct TALER_ExtensionConfigHashP h_config;
+ struct TALER_ExtensionManifestsHashP h_manifests;
if (GNUNET_OK !=
- TALER_JSON_extensions_config_hash (extensions, &h_config))
+ TALER_JSON_extensions_manifests_hash (extensions,
+ &h_manifests))
{
- GNUNET_JSON_parse_free (spec);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "couldn't hash extensions\n");
+ "couldn't hash extensions' manifests\n");
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return;
}
@@ -2186,16 +2335,15 @@ upload_extensions (const char *exchange_url,
load_offline_key (GNUNET_NO))
return;
- if (GNUNET_OK != TALER_exchange_offline_extension_config_hash_verify (
- &h_config,
+ if (GNUNET_OK != TALER_exchange_offline_extension_manifests_hash_verify (
+ &h_manifests,
&master_pub,
&sig))
{
- GNUNET_JSON_parse_free (spec);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"invalid signature for extensions\n");
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return;
}
}
@@ -2206,8 +2354,9 @@ upload_extensions (const char *exchange_url,
.extensions = extensions,
.extensions_sig = sig,
};
- struct UploadExtensionsRequest *uer = GNUNET_new (struct
- UploadExtensionsRequest);
+ struct UploadExtensionsRequest *uer
+ = GNUNET_new (struct UploadExtensionsRequest);
+
uer->idx = idx;
uer->h = TALER_EXCHANGE_management_post_extensions (
ctx,
@@ -2219,7 +2368,223 @@ upload_extensions (const char *exchange_url,
uer_tail,
uer);
}
- GNUNET_JSON_parse_free (spec);
+}
+
+
+/**
+ * Function called with information about the add partner operation.
+ *
+ * @param cls closure with a `struct PartnerAddRequest`
+ * @param apr response data
+ */
+static void
+add_partner_cb (
+ void *cls,
+ const struct TALER_EXCHANGE_ManagementAddPartnerResponse *apr)
+{
+ struct PartnerAddRequest *par = cls;
+ const struct TALER_EXCHANGE_HttpResponse *hr = &apr->hr;
+
+ if (MHD_HTTP_NO_CONTENT != hr->http_status)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Upload failed for command %u with status %u: %s (%s)\n",
+ (unsigned int) par->idx,
+ hr->http_status,
+ TALER_ErrorCode_get_hint (hr->ec),
+ hr->hint);
+ global_ret = EXIT_FAILURE;
+ }
+ GNUNET_CONTAINER_DLL_remove (par_head,
+ par_tail,
+ par);
+ GNUNET_free (par);
+ test_shutdown ();
+}
+
+
+/**
+ * Add partner action.
+ *
+ * @param exchange_url base URL of the exchange
+ * @param idx index of the operation we are performing (for logging)
+ * @param value arguments for add partner
+ */
+static void
+add_partner (const char *exchange_url,
+ size_t idx,
+ const json_t *value)
+{
+ struct TALER_MasterPublicKeyP partner_pub;
+ struct GNUNET_TIME_Timestamp start_date;
+ struct GNUNET_TIME_Timestamp end_date;
+ struct GNUNET_TIME_Relative wad_frequency;
+ struct TALER_Amount wad_fee;
+ const char *partner_base_url;
+ struct TALER_MasterSignatureP master_sig;
+ struct PartnerAddRequest *par;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_fixed_auto ("partner_pub",
+ &partner_pub),
+ TALER_JSON_spec_amount ("wad_fee",
+ currency,
+ &wad_fee),
+ GNUNET_JSON_spec_relative_time ("wad_frequency",
+ &wad_frequency),
+ GNUNET_JSON_spec_timestamp ("start_date",
+ &start_date),
+ GNUNET_JSON_spec_timestamp ("end_date",
+ &end_date),
+ TALER_JSON_spec_web_url ("partner_base_url",
+ &partner_base_url),
+ GNUNET_JSON_spec_fixed_auto ("master_sig",
+ &master_sig),
+ GNUNET_JSON_spec_end ()
+ };
+ const char *err_name;
+ unsigned int err_line;
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (value,
+ spec,
+ &err_name,
+ &err_line))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Invalid input to add partner: %s#%u at %u (skipping)\n",
+ err_name,
+ err_line,
+ (unsigned int) idx);
+ json_dumpf (value,
+ stderr,
+ JSON_INDENT (2));
+ global_ret = EXIT_FAILURE;
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ par = GNUNET_new (struct PartnerAddRequest);
+ par->idx = idx;
+ par->h =
+ TALER_EXCHANGE_management_add_partner (ctx,
+ exchange_url,
+ &partner_pub,
+ start_date,
+ end_date,
+ wad_frequency,
+ &wad_fee,
+ partner_base_url,
+ &master_sig,
+ &add_partner_cb,
+ par);
+ GNUNET_CONTAINER_DLL_insert (par_head,
+ par_tail,
+ par);
+}
+
+
+/**
+ * Function called with information about the AML officer update operation.
+ *
+ * @param cls closure with a `struct AmlStaffRequest`
+ * @param ar response data
+ */
+static void
+update_aml_officer_cb (
+ void *cls,
+ const struct TALER_EXCHANGE_ManagementUpdateAmlOfficerResponse *ar)
+{
+ struct AmlStaffRequest *asr = cls;
+ const struct TALER_EXCHANGE_HttpResponse *hr = &ar->hr;
+
+ if (MHD_HTTP_NO_CONTENT != hr->http_status)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Upload failed for command %u with status %u: %s (%s)\n",
+ (unsigned int) asr->idx,
+ hr->http_status,
+ TALER_ErrorCode_get_hint (hr->ec),
+ hr->hint);
+ global_ret = EXIT_FAILURE;
+ }
+ GNUNET_CONTAINER_DLL_remove (asr_head,
+ asr_tail,
+ asr);
+ GNUNET_free (asr);
+ test_shutdown ();
+}
+
+
+/**
+ * Upload AML staff action.
+ *
+ * @param exchange_url base URL of the exchange
+ * @param idx index of the operation we are performing (for logging)
+ * @param value arguments for AML staff change
+ */
+static void
+update_aml_staff (const char *exchange_url,
+ size_t idx,
+ const json_t *value)
+{
+ struct TALER_AmlOfficerPublicKeyP officer_pub;
+ const char *officer_name;
+ struct GNUNET_TIME_Timestamp change_date;
+ bool is_active;
+ bool read_only;
+ struct TALER_MasterSignatureP master_sig;
+ struct AmlStaffRequest *asr;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_fixed_auto ("officer_pub",
+ &officer_pub),
+ GNUNET_JSON_spec_timestamp ("change_date",
+ &change_date),
+ GNUNET_JSON_spec_bool ("is_active",
+ &is_active),
+ GNUNET_JSON_spec_bool ("read_only",
+ &read_only),
+ GNUNET_JSON_spec_string ("officer_name",
+ &officer_name),
+ GNUNET_JSON_spec_fixed_auto ("master_sig",
+ &master_sig),
+ GNUNET_JSON_spec_end ()
+ };
+ const char *err_name;
+ unsigned int err_line;
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (value,
+ spec,
+ &err_name,
+ &err_line))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Invalid input to AML staff update: %s#%u at %u (skipping)\n",
+ err_name,
+ err_line,
+ (unsigned int) idx);
+ json_dumpf (value,
+ stderr,
+ JSON_INDENT (2));
+ global_ret = EXIT_FAILURE;
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
+ asr = GNUNET_new (struct AmlStaffRequest);
+ asr->idx = idx;
+ asr->h =
+ TALER_EXCHANGE_management_update_aml_officer (ctx,
+ exchange_url,
+ &officer_pub,
+ officer_name,
+ change_date,
+ is_active,
+ read_only,
+ &master_sig,
+ &update_aml_officer_cb,
+ asr);
+ GNUNET_CONTAINER_DLL_insert (asr_head,
+ asr_tail,
+ asr);
}
@@ -2276,6 +2641,14 @@ trigger_upload (const char *exchange_url)
.key = OP_EXTENSIONS,
.cb = &upload_extensions
},
+ {
+ .key = OP_UPDATE_AML_STAFF,
+ .cb = &update_aml_staff
+ },
+ {
+ .key = OP_ADD_PARTNER,
+ .cb = &add_partner
+ },
/* array termination */
{
.key = NULL
@@ -2296,7 +2669,7 @@ trigger_upload (const char *exchange_url)
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Malformed JSON input\n");
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return;
}
/* block of code that uses key and value */
@@ -2319,7 +2692,7 @@ trigger_upload (const char *exchange_url)
"Upload does not know how to handle `%s'\n",
key);
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return;
}
}
@@ -2339,7 +2712,7 @@ do_upload (char *const *args)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Downloaded data was not consumed, refusing upload\n");
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_FAILURE;
return;
}
@@ -2358,7 +2731,7 @@ do_upload (char *const *args)
err.line,
err.source,
err.position);
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_FAILURE;
return;
}
@@ -2367,7 +2740,7 @@ do_upload (char *const *args)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Error: expected JSON array for `upload` command\n");
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_FAILURE;
return;
}
@@ -2382,7 +2755,7 @@ do_upload (char *const *args)
"exchange",
"BASE_URL");
global_ret = EXIT_NOTCONFIGURED;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return;
}
trigger_upload (CFG_exchange_url);
@@ -2407,7 +2780,7 @@ do_revoke_denomination_key (char *const *args)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Downloaded data was not consumed, refusing revocation\n");
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_FAILURE;
return;
}
@@ -2420,7 +2793,7 @@ do_revoke_denomination_key (char *const *args)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"You must specify a denomination key with this subcommand\n");
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_INVALIDARGUMENT;
return;
}
@@ -2456,7 +2829,7 @@ do_revoke_signkey (char *const *args)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Downloaded data was not consumed, refusing revocation\n");
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_FAILURE;
return;
}
@@ -2469,7 +2842,7 @@ do_revoke_signkey (char *const *args)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"You must specify an exchange signing key with this subcommand\n");
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_INVALIDARGUMENT;
return;
}
@@ -2507,7 +2880,7 @@ do_add_auditor (char *const *args)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Downloaded data was not consumed, not adding auditor\n");
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_FAILURE;
return;
}
@@ -2520,7 +2893,7 @@ do_add_auditor (char *const *args)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"You must specify an auditor public key as first argument for this subcommand\n");
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_INVALIDARGUMENT;
return;
}
@@ -2533,7 +2906,7 @@ do_add_auditor (char *const *args)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"You must specify an auditor URI and auditor name as 2nd and 3rd arguments to this subcommand\n");
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_INVALIDARGUMENT;
return;
}
@@ -2579,7 +2952,7 @@ do_del_auditor (char *const *args)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Downloaded data was not consumed, not deleting auditor account\n");
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_FAILURE;
return;
}
@@ -2592,7 +2965,7 @@ do_del_auditor (char *const *args)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"You must specify an auditor public key as first argument for this subcommand\n");
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_INVALIDARGUMENT;
return;
}
@@ -2617,6 +2990,96 @@ do_del_auditor (char *const *args)
/**
+ * Parse account restriction.
+ *
+ * @param args the array of command-line arguments to process next
+ * @param[in,out] restrictions JSON array to update
+ * @return -1 on error, otherwise number of arguments from @a args that were used
+ */
+static int
+parse_restriction (char *const *args,
+ json_t *restrictions)
+{
+ if (NULL == args[0])
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Restriction TYPE argument missing\n");
+ return -1;
+ }
+ if (0 == strcmp (args[0],
+ "deny"))
+ {
+ GNUNET_assert (0 ==
+ json_array_append_new (
+ restrictions,
+ GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("type",
+ "deny"))));
+ return 1;
+ }
+ if (0 == strcmp (args[0],
+ "regex"))
+ {
+ json_t *i18n;
+ json_error_t err;
+
+ if ( (NULL == args[1]) ||
+ (NULL == args[2]) ||
+ (NULL == args[3]) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Mandatory arguments for restriction of type `regex' missing (REGEX, HINT, HINT-I18 required)\n");
+ return -1;
+ }
+ {
+ regex_t ex;
+
+ if (0 != regcomp (&ex,
+ args[1],
+ REG_NOSUB | REG_EXTENDED))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Invalid regular expression `%s'\n",
+ args[1]);
+ return -1;
+ }
+ regfree (&ex);
+ }
+
+ i18n = json_loads (args[3],
+ JSON_REJECT_DUPLICATES,
+ &err);
+ if (NULL == i18n)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Invalid JSON for restriction of type `regex': `%s` at %d\n",
+ args[3],
+ err.position);
+ return -1;
+ }
+ GNUNET_assert (0 ==
+ json_array_append_new (
+ restrictions,
+ GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("type",
+ "regex"),
+ GNUNET_JSON_pack_string ("payto_regex",
+ args[1]),
+ GNUNET_JSON_pack_string ("human_hint",
+ args[2]),
+ GNUNET_JSON_pack_object_steal ("human_hint_i18n",
+ i18n)
+ )));
+ return 4;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Restriction TYPE `%s' unsupported\n",
+ args[0]);
+ return -1;
+}
+
+
+/**
* Add wire account.
*
* @param args the array of command-line arguments to process next;
@@ -2628,12 +3091,18 @@ do_add_wire (char *const *args)
struct TALER_MasterSignatureP master_sig_add;
struct TALER_MasterSignatureP master_sig_wire;
struct GNUNET_TIME_Timestamp now;
+ const char *conversion_url = NULL;
+ const char *bank_label = NULL;
+ int64_t priority = 0;
+ json_t *debit_restrictions;
+ json_t *credit_restrictions;
+ unsigned int num_args = 1;
if (NULL != in)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Downloaded data was not consumed, not adding wire account\n");
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_FAILURE;
return;
}
@@ -2641,7 +3110,7 @@ do_add_wire (char *const *args)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"You must specify a payto://-URI with this subcommand\n");
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_INVALIDARGUMENT;
return;
}
@@ -2657,7 +3126,7 @@ do_add_wire (char *const *args)
"payto URI is malformed: %s\n",
msg);
GNUNET_free (msg);
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_INVALIDARGUMENT;
return;
}
@@ -2673,29 +3142,160 @@ do_add_wire (char *const *args)
"payto:// URI `%s' is malformed\n",
args[0]);
global_ret = EXIT_INVALIDARGUMENT;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return;
}
GNUNET_free (wire_method);
}
+ debit_restrictions = json_array ();
+ GNUNET_assert (NULL != debit_restrictions);
+ credit_restrictions = json_array ();
+ GNUNET_assert (NULL != credit_restrictions);
+ while (NULL != args[num_args])
+ {
+ if (0 == strcmp (args[num_args],
+ "conversion-url"))
+ {
+ num_args++;
+ conversion_url = args[num_args];
+ if (NULL == conversion_url)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "'conversion-url' requires an argument\n");
+ global_ret = EXIT_INVALIDARGUMENT;
+ GNUNET_SCHEDULER_shutdown ();
+ json_decref (debit_restrictions);
+ json_decref (credit_restrictions);
+ return;
+ }
+ if (! TALER_is_web_url (conversion_url))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "'conversion-url' must refer to HTTP(S) endpoint, `%s' is invalid\n",
+ conversion_url);
+ global_ret = EXIT_INVALIDARGUMENT;
+ GNUNET_SCHEDULER_shutdown ();
+ json_decref (debit_restrictions);
+ json_decref (credit_restrictions);
+ return;
+ }
+ num_args++;
+ continue;
+ }
+ if (0 == strcmp (args[num_args],
+ "credit-restriction"))
+ {
+ int iret;
+
+ num_args++;
+ iret = parse_restriction (&args[num_args],
+ credit_restrictions);
+ if (iret <= 0)
+ {
+ global_ret = EXIT_INVALIDARGUMENT;
+ GNUNET_SCHEDULER_shutdown ();
+ json_decref (debit_restrictions);
+ json_decref (credit_restrictions);
+ return;
+ }
+ num_args += iret;
+ continue;
+ }
+ if (0 == strcmp (args[num_args],
+ "debit-restriction"))
+ {
+ int iret;
+
+ num_args++;
+ iret = parse_restriction (&args[num_args],
+ debit_restrictions);
+ if (iret <= 0)
+ {
+ global_ret = EXIT_INVALIDARGUMENT;
+ GNUNET_SCHEDULER_shutdown ();
+ json_decref (debit_restrictions);
+ json_decref (credit_restrictions);
+ return;
+ }
+ num_args += iret;
+ continue;
+ }
+ if (0 == strcmp (args[num_args],
+ "display-hint"))
+ {
+ long long p;
+ char dummy;
+
+ num_args++;
+ if ( (NULL == args[num_args]) ||
+ (NULL == args[num_args + 1]) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "'display-hint' requires at least two arguments (priority and label)\n");
+ global_ret = EXIT_INVALIDARGUMENT;
+ GNUNET_SCHEDULER_shutdown ();
+ json_decref (debit_restrictions);
+ json_decref (credit_restrictions);
+ return;
+ }
+ if (1 != sscanf (args[num_args],
+ "%lld%c",
+ &p,
+ &dummy))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Priority argument `%s' is not a number\n",
+ args[num_args]);
+ global_ret = EXIT_INVALIDARGUMENT;
+ GNUNET_SCHEDULER_shutdown ();
+ json_decref (debit_restrictions);
+ json_decref (credit_restrictions);
+ return;
+ }
+ priority = (int64_t) p;
+ num_args++;
+ bank_label = args[num_args];
+ num_args++;
+ continue;
+ }
+ break;
+ }
TALER_exchange_offline_wire_add_sign (args[0],
+ conversion_url,
+ debit_restrictions,
+ credit_restrictions,
now,
&master_priv,
&master_sig_add);
TALER_exchange_wire_signature_make (args[0],
+ conversion_url,
+ debit_restrictions,
+ credit_restrictions,
&master_priv,
&master_sig_wire);
output_operation (OP_ENABLE_WIRE,
GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("payto_uri",
args[0]),
+ GNUNET_JSON_pack_array_steal ("debit_restrictions",
+ debit_restrictions),
+ GNUNET_JSON_pack_array_steal ("credit_restrictions",
+ credit_restrictions),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_string ("conversion_url",
+ conversion_url)),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_string ("bank_label",
+ bank_label)),
+ GNUNET_JSON_pack_int64 ("priority",
+ priority),
GNUNET_JSON_pack_timestamp ("validity_start",
now),
GNUNET_JSON_pack_data_auto ("master_sig_add",
&master_sig_add),
GNUNET_JSON_pack_data_auto ("master_sig_wire",
&master_sig_wire)));
- next (args + 1);
+ next (args + num_args);
}
@@ -2715,7 +3315,7 @@ do_del_wire (char *const *args)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Downloaded data was not consumed, not deleting wire account\n");
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_FAILURE;
return;
}
@@ -2723,7 +3323,7 @@ do_del_wire (char *const *args)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"You must specify a payto://-URI with this subcommand\n");
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_INVALIDARGUMENT;
return;
}
@@ -2752,7 +3352,7 @@ do_del_wire (char *const *args)
*
* @param args the array of command-line arguments to process next;
* args[0] must be the year, args[1] the wire method, args[2] the wire fee and args[3]
- * the closing fee and args[4] the wad fee.
+ * the closing fee.
*/
static void
do_set_wire_fee (char *const *args)
@@ -2768,7 +3368,7 @@ do_set_wire_fee (char *const *args)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Downloaded data was not consumed, not setting wire fee\n");
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_FAILURE;
return;
}
@@ -2776,7 +3376,6 @@ do_set_wire_fee (char *const *args)
(NULL == args[1]) ||
(NULL == args[2]) ||
(NULL == args[3]) ||
- (NULL == args[4]) ||
( (1 != sscanf (args[0],
"%u%c",
&year,
@@ -2788,14 +3387,11 @@ do_set_wire_fee (char *const *args)
&fees.wire)) ||
(GNUNET_OK !=
TALER_string_to_amount (args[3],
- &fees.closing)) ||
- (GNUNET_OK !=
- TALER_string_to_amount (args[4],
- &fees.wad)) )
+ &fees.closing)) )
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "You must use YEAR, METHOD, WIRE-FEE, CLOSING-FEE and WAD-FEE as arguments for this subcommand\n");
- test_shutdown ();
+ "You must use YEAR, METHOD, WIRE-FEE, and CLOSING-FEE as arguments for this subcommand\n");
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_INVALIDARGUMENT;
return;
}
@@ -2826,13 +3422,11 @@ do_set_wire_fee (char *const *args)
end_time),
TALER_JSON_pack_amount ("wire_fee",
&fees.wire),
- TALER_JSON_pack_amount ("wad_fee",
- &fees.wad),
TALER_JSON_pack_amount ("closing_fee",
&fees.closing),
GNUNET_JSON_pack_data_auto ("master_sig",
&master_sig)));
- next (args + 5);
+ next (args + 4);
}
@@ -2840,9 +3434,9 @@ do_set_wire_fee (char *const *args)
* Set global fees for the given year.
*
* @param args the array of command-line arguments to process next;
- * args[0] must be the year, args[1] the history fee, args[2] the kyc fee, args[3]
- * the account fee and args[4] the purse fee. These are followed by args[5] purse timeout,
- * args[6] kyc timeout and args[7] history expiration. Last is args[8] the (free) purse account limit.
+ * args[0] must be the year, args[1] the history fee, args[2]
+ * the account fee and args[3] the purse fee. These are followed by args[4] purse timeout,
+ * args[5] history expiration. Last is args[6] the (free) purse account limit.
*/
static void
do_set_global_fee (char *const *args)
@@ -2852,7 +3446,6 @@ do_set_global_fee (char *const *args)
unsigned int year;
struct TALER_GlobalFeeSet fees;
struct GNUNET_TIME_Relative purse_timeout;
- struct GNUNET_TIME_Relative kyc_timeout;
struct GNUNET_TIME_Relative history_expiration;
unsigned int purse_account_limit;
struct GNUNET_TIME_Timestamp start_time;
@@ -2862,7 +3455,7 @@ do_set_global_fee (char *const *args)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Downloaded data was not consumed, not setting global fee\n");
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_FAILURE;
return;
}
@@ -2872,44 +3465,64 @@ do_set_global_fee (char *const *args)
(NULL == args[3]) ||
(NULL == args[4]) ||
(NULL == args[5]) ||
- (NULL == args[6]) ||
- (NULL == args[7]) ||
- (NULL == args[8]) ||
- ( (1 != sscanf (args[0],
- "%u%c",
- &year,
- &dummy)) &&
- (0 != strcasecmp ("now",
- args[0])) ) ||
- (GNUNET_OK !=
+ (NULL == args[6]) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "You must use YEAR, HISTORY-FEE, ACCOUNT-FEE, PURSE-FEE, PURSE-TIMEOUT, HISTORY-EXPIRATION and PURSE-ACCOUNT-LIMIT as arguments for this subcommand\n");
+ GNUNET_SCHEDULER_shutdown ();
+ global_ret = EXIT_INVALIDARGUMENT;
+ return;
+ }
+ if ( (1 != sscanf (args[0],
+ "%u%c",
+ &year,
+ &dummy)) &&
+ (0 != strcasecmp ("now",
+ args[0])) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Invalid YEAR given for 'global-fee' subcommand\n");
+ GNUNET_SCHEDULER_shutdown ();
+ global_ret = EXIT_INVALIDARGUMENT;
+ return;
+ }
+ if ( (GNUNET_OK !=
TALER_string_to_amount (args[1],
&fees.history)) ||
(GNUNET_OK !=
TALER_string_to_amount (args[2],
- &fees.kyc)) ||
- (GNUNET_OK !=
- TALER_string_to_amount (args[3],
&fees.account)) ||
(GNUNET_OK !=
- TALER_string_to_amount (args[4],
- &fees.purse)) ||
- (GNUNET_OK !=
- GNUNET_STRINGS_fancy_time_to_relative (args[5],
+ TALER_string_to_amount (args[3],
+ &fees.purse)) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Invalid amount given for 'global-fee' subcommand\n");
+ GNUNET_SCHEDULER_shutdown ();
+ global_ret = EXIT_INVALIDARGUMENT;
+ return;
+ }
+ if ( (GNUNET_OK !=
+ GNUNET_STRINGS_fancy_time_to_relative (args[4],
&purse_timeout)) ||
(GNUNET_OK !=
- GNUNET_STRINGS_fancy_time_to_relative (args[6],
- &kyc_timeout)) ||
- (GNUNET_OK !=
- GNUNET_STRINGS_fancy_time_to_relative (args[7],
- &history_expiration)) ||
- (1 != sscanf (args[8],
- "%u%c",
- &purse_account_limit,
- &dummy)) )
+ GNUNET_STRINGS_fancy_time_to_relative (args[5],
+ &history_expiration)) )
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "You must use YEAR, HISTORY-FEE, KYC-FEE, ACCOUNT-FEE, PURSE-FEE, PURSE-TIMEOUT, KYC-TIMEOUT, HISTORY-EXPIRATION and PURSE-ACCOUNT-LIMIT as arguments for this subcommand\n");
- test_shutdown ();
+ "Invalid delay given for 'global-fee' subcommand\n");
+ GNUNET_SCHEDULER_shutdown ();
+ global_ret = EXIT_INVALIDARGUMENT;
+ return;
+ }
+ if (1 != sscanf (args[6],
+ "%u%c",
+ &purse_account_limit,
+ &dummy))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Invalid purse account limit given for 'global-fee' subcommand\n");
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_INVALIDARGUMENT;
return;
}
@@ -2928,7 +3541,6 @@ do_set_global_fee (char *const *args)
end_time,
&fees,
purse_timeout,
- kyc_timeout,
history_expiration,
(uint32_t) purse_account_limit,
&master_priv,
@@ -2941,23 +3553,19 @@ do_set_global_fee (char *const *args)
end_time),
TALER_JSON_pack_amount ("history_fee",
&fees.history),
- TALER_JSON_pack_amount ("kyc_fee",
- &fees.kyc),
TALER_JSON_pack_amount ("account_fee",
&fees.account),
TALER_JSON_pack_amount ("purse_fee",
&fees.purse),
GNUNET_JSON_pack_time_rel ("purse_timeout",
purse_timeout),
- GNUNET_JSON_pack_time_rel ("kyc_timeout",
- kyc_timeout),
GNUNET_JSON_pack_time_rel ("history_expiration",
history_expiration),
GNUNET_JSON_pack_uint64 ("purse_account_limit",
(uint32_t) purse_account_limit),
GNUNET_JSON_pack_data_auto ("master_sig",
&master_sig)));
- next (args + 9);
+ next (args + 7);
}
@@ -2985,7 +3593,7 @@ do_drain (char *const *args)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Downloaded data was not consumed, refusing drain\n");
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_FAILURE;
return;
}
@@ -2998,7 +3606,7 @@ do_drain (char *const *args)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Drain requires an amount, section name and target payto://-URI as arguments\n");
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_INVALIDARGUMENT;
return;
}
@@ -3008,7 +3616,7 @@ do_drain (char *const *args)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Drain requires an amount, section name and target payto://-URI as arguments\n");
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_INVALIDARGUMENT;
return;
}
@@ -3019,7 +3627,7 @@ do_drain (char *const *args)
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Invalid amount `%s' specified for drain\n",
args[0]);
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_INVALIDARGUMENT;
return;
}
@@ -3033,7 +3641,7 @@ do_drain (char *const *args)
payto_uri,
err);
GNUNET_free (err);
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_INVALIDARGUMENT;
return;
}
@@ -3070,23 +3678,275 @@ do_drain (char *const *args)
/**
+ * Add partner.
+ *
+ * @param args the array of command-line arguments to process next;
+ * args[0] must be the partner's master public key, args[1] the partner's
+ * API base URL, args[2] the wad fee, args[3] the wad frequency, and
+ * args[4] the year (including possibly 'now')
+ */
+static void
+do_add_partner (char *const *args)
+{
+ struct TALER_MasterPublicKeyP partner_pub;
+ struct GNUNET_TIME_Timestamp start_date;
+ struct GNUNET_TIME_Timestamp end_date;
+ struct GNUNET_TIME_Relative wad_frequency;
+ struct TALER_Amount wad_fee;
+ const char *partner_base_url;
+ struct TALER_MasterSignatureP master_sig;
+ char dummy;
+ unsigned int year;
+
+ if (NULL != in)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Downloaded data was not consumed, not adding partner\n");
+ GNUNET_SCHEDULER_shutdown ();
+ global_ret = EXIT_FAILURE;
+ return;
+ }
+ if ( (NULL == args[0]) ||
+ (GNUNET_OK !=
+ GNUNET_STRINGS_string_to_data (args[0],
+ strlen (args[0]),
+ &partner_pub,
+ sizeof (partner_pub))) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "You must specify the partner master public key as first argument for this subcommand\n");
+ GNUNET_SCHEDULER_shutdown ();
+ global_ret = EXIT_INVALIDARGUMENT;
+ return;
+ }
+ if ( (NULL == args[1]) ||
+ (0 != strncmp ("http",
+ args[1],
+ strlen ("http"))) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "You must specify the partner's base URL as the 2nd argument to this subcommand\n");
+ GNUNET_SCHEDULER_shutdown ();
+ global_ret = EXIT_INVALIDARGUMENT;
+ return;
+ }
+ partner_base_url = args[1];
+ if ( (NULL == args[2]) ||
+ (GNUNET_OK !=
+ TALER_string_to_amount (args[2],
+ &wad_fee)) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Invalid amount `%s' specified for wad fee of partner\n",
+ args[2]);
+ GNUNET_SCHEDULER_shutdown ();
+ global_ret = EXIT_INVALIDARGUMENT;
+ return;
+ }
+ if ( (NULL == args[3]) ||
+ (GNUNET_OK !=
+ GNUNET_STRINGS_fancy_time_to_relative (args[3],
+ &wad_frequency)) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Invalid wad frequency `%s' specified for add partner\n",
+ args[3]);
+ GNUNET_SCHEDULER_shutdown ();
+ global_ret = EXIT_INVALIDARGUMENT;
+ return;
+ }
+ if ( (NULL == args[4]) ||
+ ( (1 != sscanf (args[4],
+ "%u%c",
+ &year,
+ &dummy)) &&
+ (0 != strcasecmp ("now",
+ args[4])) ) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Invalid year `%s' specified for add partner\n",
+ args[4]);
+ GNUNET_SCHEDULER_shutdown ();
+ global_ret = EXIT_INVALIDARGUMENT;
+ return;
+ }
+ if (0 == strcasecmp ("now",
+ args[4]))
+ year = GNUNET_TIME_get_current_year ();
+ start_date = GNUNET_TIME_absolute_to_timestamp (
+ GNUNET_TIME_year_to_time (year));
+ end_date = GNUNET_TIME_absolute_to_timestamp (
+ GNUNET_TIME_year_to_time (year + 1));
+
+ if (GNUNET_OK !=
+ load_offline_key (GNUNET_NO))
+ return;
+ TALER_exchange_offline_partner_details_sign (&partner_pub,
+ start_date,
+ end_date,
+ wad_frequency,
+ &wad_fee,
+ partner_base_url,
+ &master_priv,
+ &master_sig);
+ output_operation (OP_ADD_PARTNER,
+ GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("partner_base_url",
+ partner_base_url),
+ GNUNET_JSON_pack_time_rel ("wad_frequency",
+ wad_frequency),
+ GNUNET_JSON_pack_timestamp ("start_date",
+ start_date),
+ GNUNET_JSON_pack_timestamp ("end_date",
+ end_date),
+ GNUNET_JSON_pack_data_auto ("partner_pub",
+ &partner_pub),
+ GNUNET_JSON_pack_data_auto ("master_sig",
+ &master_sig)));
+ next (args + 5);
+}
+
+
+/**
+ * Enable or disable AML staff.
+ *
+ * @param is_active true to enable, false to disable
+ * @param args the array of command-line arguments to process next; args[0] must be the AML staff's public key, args[1] the AML staff's legal name, and if @a is_active then args[2] rw (read write) or ro (read only)
+ */
+static void
+do_set_aml_staff (bool is_active,
+ char *const *args)
+{
+ struct TALER_AmlOfficerPublicKeyP officer_pub;
+ const char *officer_name;
+ bool read_only;
+ struct TALER_MasterSignatureP master_sig;
+ struct GNUNET_TIME_Timestamp now
+ = GNUNET_TIME_timestamp_get ();
+
+ if (NULL != in)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Downloaded data was not consumed, not updating AML staff status\n");
+ GNUNET_SCHEDULER_shutdown ();
+ global_ret = EXIT_FAILURE;
+ return;
+ }
+ if ( (NULL == args[0]) ||
+ (GNUNET_OK !=
+ GNUNET_STRINGS_string_to_data (args[0],
+ strlen (args[0]),
+ &officer_pub,
+ sizeof (officer_pub))) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "You must specify the AML officer's public key as first argument for this subcommand\n");
+ GNUNET_SCHEDULER_shutdown ();
+ global_ret = EXIT_INVALIDARGUMENT;
+ return;
+ }
+ if (NULL == args[1])
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "You must specify the officer's legal name as the 2nd argument to this subcommand\n");
+ GNUNET_SCHEDULER_shutdown ();
+ global_ret = EXIT_INVALIDARGUMENT;
+ return;
+ }
+ officer_name = args[1];
+ if (is_active)
+ {
+ if ( (NULL == args[2]) ||
+ ( (0 != strcmp (args[2],
+ "ro")) &&
+ (0 != strcmp (args[2],
+ "rw")) ) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "You must specify 'ro' or 'rw' (and not `%s') for the access level\n",
+ args[2]);
+ GNUNET_SCHEDULER_shutdown ();
+ global_ret = EXIT_INVALIDARGUMENT;
+ return;
+ }
+ read_only = (0 == strcmp (args[2],
+ "ro"));
+ }
+ else
+ {
+ read_only = true;
+ }
+ if (GNUNET_OK !=
+ load_offline_key (GNUNET_NO))
+ return;
+ TALER_exchange_offline_aml_officer_status_sign (&officer_pub,
+ officer_name,
+ now,
+ is_active,
+ read_only,
+ &master_priv,
+ &master_sig);
+ output_operation (OP_UPDATE_AML_STAFF,
+ GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("officer_name",
+ officer_name),
+ GNUNET_JSON_pack_timestamp ("change_date",
+ now),
+ GNUNET_JSON_pack_bool ("is_active",
+ is_active),
+ GNUNET_JSON_pack_bool ("read_only",
+ read_only),
+ GNUNET_JSON_pack_data_auto ("officer_pub",
+ &officer_pub),
+ GNUNET_JSON_pack_data_auto ("master_sig",
+ &master_sig)));
+ next (args + (is_active ? 3 : 2));
+}
+
+
+/**
+ * Disable AML staff.
+ *
+ * @param args the array of command-line arguments to process next;
+ * args[0] must be the AML staff's public key, args[1] the AML staff's legal name, args[2] rw (read write) or ro (read only)
+ */
+static void
+disable_aml_staff (char *const *args)
+{
+ do_set_aml_staff (false,
+ args);
+}
+
+
+/**
+ * Enable AML staff.
+ *
+ * @param args the array of command-line arguments to process next;
+ * args[0] must be the AML staff's public key, args[1] the AML staff's legal name, args[2] rw (read write) or ro (read only)
+ */
+static void
+enable_aml_staff (char *const *args)
+{
+ do_set_aml_staff (true,
+ args);
+}
+
+
+/**
* Function called with information about future keys. Dumps the JSON output
* (on success), either into an internal buffer or to stdout (depending on
* whether there are subsequent commands).
*
* @param cls closure with the `char **` remaining args
- * @param hr HTTP response data
- * @param keys information about the various keys used
- * by the exchange, NULL if /management/keys failed
+ * @param mgr response data
*/
static void
download_cb (void *cls,
- const struct TALER_EXCHANGE_HttpResponse *hr,
- const struct TALER_EXCHANGE_FutureKeys *keys)
+ const struct TALER_EXCHANGE_ManagementGetKeysResponse *mgr)
{
char *const *args = cls;
+ const struct TALER_EXCHANGE_HttpResponse *hr = &mgr->hr;
- (void) keys;
mgkh = NULL;
switch (hr->http_status)
{
@@ -3104,7 +3964,7 @@ download_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to download keys from `%s' (no HTTP response)\n",
CFG_exchange_url);
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_FAILURE;
return;
}
@@ -3143,7 +4003,7 @@ do_download (char *const *args)
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange",
"BASE_URL");
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_NOTCONFIGURED;
return;
}
@@ -3351,7 +4211,7 @@ tofu_check (const struct TALER_SecurityModulePublicKeySetP *secmset)
* @param signkeys keys to output
* @return #GNUNET_OK on success
*/
-static int
+static enum GNUNET_GenericReturnValue
show_signkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub,
const json_t *signkeys)
{
@@ -3396,7 +4256,7 @@ show_signkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub,
stderr,
JSON_INDENT (2));
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return GNUNET_SYSERR;
}
duration = GNUNET_TIME_absolute_get_difference (start_time.abs_time,
@@ -3412,7 +4272,7 @@ show_signkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub,
"Invalid security module signature for signing key %s (aborting)\n",
TALER_B2S (&exchange_pub));
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return GNUNET_SYSERR;
}
{
@@ -3504,7 +4364,7 @@ show_denomkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub_rsa,
JSON_INDENT (2));
GNUNET_JSON_parse_free (spec);
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return GNUNET_SYSERR;
}
duration = GNUNET_TIME_absolute_get_difference (
@@ -3512,13 +4372,13 @@ show_denomkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub_rsa,
stamp_expire_withdraw.abs_time);
TALER_denom_pub_hash (&denom_pub,
&h_denom_pub);
- switch (denom_pub.cipher)
+ switch (denom_pub.bsign_pub_key->cipher)
{
- case TALER_DENOMINATION_RSA:
+ case GNUNET_CRYPTO_BSA_RSA:
{
struct TALER_RsaPubHashP h_rsa;
- TALER_rsa_pub_hash (denom_pub.details.rsa_public_key,
+ TALER_rsa_pub_hash (denom_pub.bsign_pub_key->details.rsa_public_key,
&h_rsa);
ok = TALER_exchange_secmod_rsa_verify (&h_rsa,
section_name,
@@ -3528,11 +4388,11 @@ show_denomkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub_rsa,
&secm_sig);
}
break;
- case TALER_DENOMINATION_CS:
+ case GNUNET_CRYPTO_BSA_CS:
{
struct TALER_CsPubHashP h_cs;
- TALER_cs_pub_hash (&denom_pub.details.cs_public_key,
+ TALER_cs_pub_hash (&denom_pub.bsign_pub_key->details.cs_public_key,
&h_cs);
ok = TALER_exchange_secmod_cs_verify (&h_cs,
section_name,
@@ -3553,7 +4413,7 @@ show_denomkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub_rsa,
"Invalid security module signature for denomination key %s (aborting)\n",
GNUNET_h2s (&h_denom_pub.hash));
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return GNUNET_SYSERR;
}
@@ -3640,7 +4500,7 @@ parse_keys_input (const char *command_name)
err.source,
err.position);
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return NULL;
}
}
@@ -3659,7 +4519,7 @@ parse_keys_input (const char *command_name)
stderr,
JSON_INDENT (2));
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return NULL;
}
if (0 != strcmp (op_str,
@@ -3690,15 +4550,15 @@ do_show (char *const *args)
json_t *keys;
const char *err_name;
unsigned int err_line;
- json_t *denomkeys;
- json_t *signkeys;
+ const json_t *denomkeys;
+ const json_t *signkeys;
struct TALER_MasterPublicKeyP mpub;
struct TALER_SecurityModulePublicKeySetP secmset;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_json ("future_denoms",
- &denomkeys),
- GNUNET_JSON_spec_json ("future_signkeys",
- &signkeys),
+ GNUNET_JSON_spec_array_const ("future_denoms",
+ &denomkeys),
+ GNUNET_JSON_spec_array_const ("future_signkeys",
+ &signkeys),
GNUNET_JSON_spec_fixed_auto ("master_pub",
&mpub),
GNUNET_JSON_spec_fixed_auto ("denom_secmod_public_key",
@@ -3731,7 +4591,7 @@ do_show (char *const *args)
stderr,
JSON_INDENT (2));
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
json_decref (keys);
return;
}
@@ -3742,8 +4602,7 @@ do_show (char *const *args)
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Fatal: exchange uses different master key!\n");
global_ret = EXIT_FAILURE;
- test_shutdown ();
- GNUNET_JSON_parse_free (spec);
+ GNUNET_SCHEDULER_shutdown ();
json_decref (keys);
return;
}
@@ -3751,8 +4610,7 @@ do_show (char *const *args)
tofu_check (&secmset))
{
global_ret = EXIT_FAILURE;
- test_shutdown ();
- GNUNET_JSON_parse_free (spec);
+ GNUNET_SCHEDULER_shutdown ();
json_decref (keys);
return;
}
@@ -3765,13 +4623,11 @@ do_show (char *const *args)
denomkeys)) )
{
global_ret = EXIT_FAILURE;
- test_shutdown ();
- GNUNET_JSON_parse_free (spec);
+ GNUNET_SCHEDULER_shutdown ();
json_decref (keys);
return;
}
json_decref (keys);
- GNUNET_JSON_parse_free (spec);
next (args);
}
@@ -3830,7 +4686,7 @@ sign_signkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub,
stderr,
JSON_INDENT (2));
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return GNUNET_SYSERR;
}
@@ -3847,7 +4703,7 @@ sign_signkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub,
"Invalid security module signature for signing key %s (aborting)\n",
TALER_B2S (&exchange_pub));
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
@@ -3888,7 +4744,7 @@ load_age_mask (const char*section_name)
static const struct TALER_AgeMask null_mask = {0};
enum GNUNET_GenericReturnValue ret;
- if (age_mask.bits == 0)
+ if (! ar_enabled)
return null_mask;
if (GNUNET_OK != (GNUNET_CONFIGURATION_have_value (
@@ -3900,14 +4756,14 @@ load_age_mask (const char*section_name)
ret = GNUNET_CONFIGURATION_get_value_yesno (kcfg,
section_name,
"AGE_RESTRICTED");
- if (GNUNET_YES == ret)
- return age_mask;
-
if (GNUNET_SYSERR == ret)
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
section_name,
"AGE_RESTRICTED",
"Value must be YES or NO\n");
+ if (GNUNET_YES == ret)
+ return ar_config.mask;
+
return null_mask;
}
@@ -3984,7 +4840,7 @@ sign_denomkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub_rsa,
JSON_INDENT (2));
GNUNET_JSON_parse_free (spec);
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
return GNUNET_SYSERR;
}
duration = GNUNET_TIME_absolute_get_difference (
@@ -3996,13 +4852,14 @@ sign_denomkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub_rsa,
TALER_denom_pub_hash (&denom_pub,
&h_denom_pub);
- switch (denom_pub.cipher)
+
+ switch (denom_pub.bsign_pub_key->cipher)
{
- case TALER_DENOMINATION_RSA:
+ case GNUNET_CRYPTO_BSA_RSA:
{
struct TALER_RsaPubHashP h_rsa;
- TALER_rsa_pub_hash (denom_pub.details.rsa_public_key,
+ TALER_rsa_pub_hash (denom_pub.bsign_pub_key->details.rsa_public_key,
&h_rsa);
if (GNUNET_OK !=
TALER_exchange_secmod_rsa_verify (&h_rsa,
@@ -4016,17 +4873,17 @@ sign_denomkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub_rsa,
"Invalid security module signature for denomination key %s (aborting)\n",
GNUNET_h2s (&h_denom_pub.hash));
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
}
break;
- case TALER_DENOMINATION_CS:
+ case GNUNET_CRYPTO_BSA_CS:
{
struct TALER_CsPubHashP h_cs;
- TALER_cs_pub_hash (&denom_pub.details.cs_public_key,
+ TALER_cs_pub_hash (&denom_pub.bsign_pub_key->details.cs_public_key,
&h_cs);
if (GNUNET_OK !=
TALER_exchange_secmod_cs_verify (&h_cs,
@@ -4040,7 +4897,7 @@ sign_denomkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub_rsa,
"Invalid security module signature for denomination key %s (aborting)\n",
GNUNET_h2s (&h_denom_pub.hash));
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
@@ -4048,7 +4905,7 @@ sign_denomkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub_rsa,
break;
default:
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
@@ -4091,15 +4948,15 @@ do_sign (char *const *args)
json_t *keys;
const char *err_name;
unsigned int err_line;
- json_t *denomkeys;
- json_t *signkeys;
+ const json_t *denomkeys;
+ const json_t *signkeys;
struct TALER_MasterPublicKeyP mpub;
struct TALER_SecurityModulePublicKeySetP secmset;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_json ("future_denoms",
- &denomkeys),
- GNUNET_JSON_spec_json ("future_signkeys",
- &signkeys),
+ GNUNET_JSON_spec_array_const ("future_denoms",
+ &denomkeys),
+ GNUNET_JSON_spec_array_const ("future_signkeys",
+ &signkeys),
GNUNET_JSON_spec_fixed_auto ("master_pub",
&mpub),
GNUNET_JSON_spec_fixed_auto ("denom_secmod_public_key",
@@ -4134,7 +4991,7 @@ do_sign (char *const *args)
stderr,
JSON_INDENT (2));
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
json_decref (keys);
return;
}
@@ -4145,8 +5002,7 @@ do_sign (char *const *args)
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Fatal: exchange uses different master key!\n");
global_ret = EXIT_FAILURE;
- test_shutdown ();
- GNUNET_JSON_parse_free (spec);
+ GNUNET_SCHEDULER_shutdown ();
json_decref (keys);
return;
}
@@ -4156,8 +5012,7 @@ do_sign (char *const *args)
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Fatal: security module keys changed!\n");
global_ret = EXIT_FAILURE;
- test_shutdown ();
- GNUNET_JSON_parse_free (spec);
+ GNUNET_SCHEDULER_shutdown ();
json_decref (keys);
return;
}
@@ -4178,10 +5033,9 @@ do_sign (char *const *args)
denomkey_sig_array)) )
{
global_ret = EXIT_FAILURE;
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
json_decref (signkey_sig_array);
json_decref (denomkey_sig_array);
- GNUNET_JSON_parse_free (spec);
json_decref (keys);
return;
}
@@ -4193,7 +5047,6 @@ do_sign (char *const *args)
GNUNET_JSON_pack_array_steal ("signkey_sigs",
signkey_sig_array)));
}
- GNUNET_JSON_parse_free (spec);
json_decref (keys);
next (args);
}
@@ -4248,18 +5101,24 @@ do_setup (char *const *args)
static void
do_extensions_show (char *const *args)
{
- const struct TALER_Extension *it;
+ const struct TALER_Extensions *it;
json_t *exts = json_object ();
json_t *obj;
GNUNET_assert (NULL != exts);
for (it = TALER_extensions_get_head ();
- NULL != it;
+ NULL != it && NULL != it->extension;
it = it->next)
- GNUNET_assert (0 ==
- json_object_set_new (exts,
- it->name,
- it->config_to_json (it)));
+ {
+ const struct TALER_Extension *extension = it->extension;
+ int ret;
+
+ ret = json_object_set_new (exts,
+ extension->name,
+ extension->manifest (extension));
+ GNUNET_assert (-1 != ret);
+ }
+
obj = GNUNET_JSON_PACK (
GNUNET_JSON_pack_object_steal ("extensions",
exts));
@@ -4268,7 +5127,7 @@ do_extensions_show (char *const *args)
json_dumps (obj,
JSON_INDENT (2)));
json_decref (obj);
- next (args + 1);
+ next (args);
}
@@ -4279,35 +5138,38 @@ static void
do_extensions_sign (char *const *args)
{
json_t *extensions = json_object ();
- struct TALER_ExtensionConfigHashP h_config;
+ struct TALER_ExtensionManifestsHashP h_manifests;
struct TALER_MasterSignatureP sig;
- const struct TALER_Extension *it;
+ const struct TALER_Extensions *it;
+ bool found = false;
json_t *obj;
GNUNET_assert (NULL != extensions);
- if (GNUNET_OK !=
- TALER_extensions_load_taler_config (kcfg))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "error while loading taler config for extensions\n");
- json_decref (extensions);
- return;
- }
for (it = TALER_extensions_get_head ();
- NULL != it;
+ NULL != it && NULL != it->extension;
it = it->next)
+ {
+ const struct TALER_Extension *ext = it->extension;
+ GNUNET_assert (ext);
+
+ found = true;
+
GNUNET_assert (0 ==
json_object_set_new (extensions,
- it->name,
- it->config_to_json (it)));
+ ext->name,
+ ext->manifest (ext)));
+ }
+
+ if (! found)
+ return;
if (GNUNET_OK !=
- TALER_JSON_extensions_config_hash (extensions,
- &h_config))
+ TALER_JSON_extensions_manifests_hash (extensions,
+ &h_manifests))
{
json_decref (extensions);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "error while hashing config for extensions\n");
+ "error while hashing manifest for extensions\n");
return;
}
@@ -4318,18 +5180,19 @@ do_extensions_sign (char *const *args)
return;
}
- TALER_exchange_offline_extension_config_hash_sign (&h_config,
- &master_priv,
- &sig);
+ TALER_exchange_offline_extension_manifests_hash_sign (&h_manifests,
+ &master_priv,
+ &sig);
obj = GNUNET_JSON_PACK (
GNUNET_JSON_pack_object_steal ("extensions",
extensions),
GNUNET_JSON_pack_data_auto (
"extensions_sig",
&sig));
+
output_operation (OP_EXTENSIONS,
obj);
- next (args + 1);
+ next (args);
}
@@ -4372,6 +5235,9 @@ cmd_handler (char *const *args,
cmds[i].name,
cmds[i].help);
}
+ json_decref (out);
+ out = NULL;
+ GNUNET_SCHEDULER_shutdown ();
}
@@ -4400,7 +5266,7 @@ do_work_extensions (char *const *args)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"You must provide a subcommand: `show` or `sign`.\n");
- test_shutdown ();
+ GNUNET_SCHEDULER_shutdown ();
global_ret = EXIT_INVALIDARGUMENT;
return;
}
@@ -4464,7 +5330,7 @@ work (void *cls)
{
.name = "enable-account",
.help =
- "enable wire account of the exchange (payto-URI must be given as argument)",
+ "enable wire account of the exchange (payto-URI must be given as argument; for optional arguments see man page)",
.cb = &do_add_wire
},
{
@@ -4476,13 +5342,13 @@ work (void *cls)
{
.name = "wire-fee",
.help =
- "sign wire fees for the given year (year, wire method, wire fee, closing fee and wad fee must be given as arguments)",
+ "sign wire fees for the given year (year, wire method, wire fee, and closing fee must be given as arguments)",
.cb = &do_set_wire_fee
},
{
.name = "global-fee",
.help =
- "sign global fees for the given year (year, history fee, kyc fee, account fee, purse fee, purse timeout, kyc timeout, history expiration and the maximum number of free purses per account must be given as arguments)",
+ "sign global fees for the given year (year, history fee, account fee, purse fee, purse timeout, history expiration and the maximum number of free purses per account must be given as arguments)",
.cb = &do_set_global_fee
},
{
@@ -4492,6 +5358,24 @@ work (void *cls)
.cb = &do_drain
},
{
+ .name = "add-partner",
+ .help =
+ "add partner exchange for P2P wad transfers (partner master public key, partner base URL, wad fee, wad frequency and validity year must be given as arguments)",
+ .cb = &do_add_partner
+ },
+ {
+ .name = "aml-enable",
+ .help =
+ "enable AML staff member (staff member public key, legal name and rw (read write) or ro (read only) must be given as arguments)",
+ .cb = &enable_aml_staff
+ },
+ {
+ .name = "aml-disable",
+ .help =
+ "disable AML staff member (staff member public key and legal name must be given as arguments)",
+ .cb = &disable_aml_staff
+ },
+ {
.name = "upload",
.help =
"upload operation result to exchange (to be performed online!)",
@@ -4530,25 +5414,31 @@ run (void *cls,
(void) cls;
(void) cfgfile;
kcfg = cfg;
- if (GNUNET_OK !=
- TALER_config_get_currency (kcfg,
- &currency))
+
+ /* load extensions */
+ GNUNET_assert (GNUNET_OK ==
+ TALER_extensions_init (kcfg));
+
+ /* setup age restriction, if applicable */
{
- global_ret = EXIT_NOTCONFIGURED;
- return;
+ const struct TALER_AgeRestrictionConfig *arc;
+
+ if (NULL !=
+ (arc = TALER_extensions_get_age_restriction_config ()))
+ {
+ ar_config = *arc;
+ ar_enabled = true;
+ }
}
- /* load age mask, if age restriction is enabled */
- GNUNET_assert (GNUNET_OK ==
- TALER_extension_age_restriction_register ());
- if (GNUNET_OK != TALER_extensions_load_taler_config (kcfg))
+ if (GNUNET_OK !=
+ TALER_config_get_currency (kcfg,
+ &currency))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "error while loading taler config for extensions\n");
+ global_ret = EXIT_NOTCONFIGURED;
return;
}
- age_mask = TALER_extensions_age_restriction_ageMask ();
ctx = GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule,
&rc);