diff options
Diffstat (limited to 'src/exchange-tools/taler-exchange-offline.c')
-rw-r--r-- | src/exchange-tools/taler-exchange-offline.c | 665 |
1 files changed, 475 insertions, 190 deletions
diff --git a/src/exchange-tools/taler-exchange-offline.c b/src/exchange-tools/taler-exchange-offline.c index 660864b77..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-2023 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. @@ -916,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; } @@ -1119,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) { @@ -1186,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); @@ -1208,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) { @@ -1275,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); @@ -1297,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) { @@ -1344,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), @@ -1372,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); @@ -1397,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) { @@ -1466,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); @@ -1489,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) { @@ -1533,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", @@ -1561,7 +1590,7 @@ upload_wire_add (const char *exchange_url, stderr, JSON_INDENT (2)); global_ret = EXIT_FAILURE; - test_shutdown (); + GNUNET_SCHEDULER_shutdown (); return; } { @@ -1574,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); @@ -1588,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; } @@ -1599,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, @@ -1614,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) { @@ -1659,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", @@ -1683,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); @@ -1706,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) { @@ -1786,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); @@ -1811,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) { @@ -1900,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); @@ -1927,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) { @@ -1985,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 () @@ -2007,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); @@ -2033,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) { @@ -2076,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; @@ -2101,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); @@ -2194,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); } @@ -2206,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) { @@ -2245,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 () @@ -2273,7 +2312,7 @@ upload_extensions (const char *exchange_url, stderr, JSON_INDENT (2)); global_ret = EXIT_FAILURE; - test_shutdown (); + GNUNET_SCHEDULER_shutdown (); return; } @@ -2282,13 +2321,13 @@ upload_extensions (const char *exchange_url, struct TALER_ExtensionManifestsHashP h_manifests; if (GNUNET_OK != - TALER_JSON_extensions_manifests_hash (extensions, &h_manifests)) + TALER_JSON_extensions_manifests_hash (extensions, + &h_manifests)) { - GNUNET_JSON_parse_free (spec); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "couldn't hash extensions' manifests\n"); global_ret = EXIT_FAILURE; - test_shutdown (); + GNUNET_SCHEDULER_shutdown (); return; } @@ -2301,11 +2340,10 @@ upload_extensions (const char *exchange_url, &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; } } @@ -2316,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, @@ -2329,7 +2368,6 @@ upload_extensions (const char *exchange_url, uer_tail, uer); } - GNUNET_JSON_parse_free (spec); } @@ -2337,14 +2375,15 @@ upload_extensions (const char *exchange_url, * Function called with information about the add partner operation. * * @param cls closure with a `struct PartnerAddRequest` - * @param hr HTTP response data + * @param apr response data */ static void add_partner_cb ( void *cls, - const struct TALER_EXCHANGE_HttpResponse *hr) + 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) { @@ -2396,7 +2435,7 @@ add_partner (const char *exchange_url, &start_date), GNUNET_JSON_spec_timestamp ("end_date", &end_date), - GNUNET_JSON_spec_string ("partner_base_url", + TALER_JSON_spec_web_url ("partner_base_url", &partner_base_url), GNUNET_JSON_spec_fixed_auto ("master_sig", &master_sig), @@ -2420,7 +2459,7 @@ add_partner (const char *exchange_url, stderr, JSON_INDENT (2)); global_ret = EXIT_FAILURE; - test_shutdown (); + GNUNET_SCHEDULER_shutdown (); return; } par = GNUNET_new (struct PartnerAddRequest); @@ -2447,14 +2486,15 @@ add_partner (const char *exchange_url, * Function called with information about the AML officer update operation. * * @param cls closure with a `struct AmlStaffRequest` - * @param hr HTTP response data + * @param ar response data */ static void update_aml_officer_cb ( void *cls, - const struct TALER_EXCHANGE_HttpResponse *hr) + 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) { @@ -2526,7 +2566,7 @@ update_aml_staff (const char *exchange_url, stderr, JSON_INDENT (2)); global_ret = EXIT_FAILURE; - test_shutdown (); + GNUNET_SCHEDULER_shutdown (); return; } asr = GNUNET_new (struct AmlStaffRequest); @@ -2629,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 */ @@ -2652,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; } } @@ -2672,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; } @@ -2691,7 +2731,7 @@ do_upload (char *const *args) err.line, err.source, err.position); - test_shutdown (); + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_FAILURE; return; } @@ -2700,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; } @@ -2715,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); @@ -2740,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; } @@ -2753,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; } @@ -2789,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; } @@ -2802,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; } @@ -2840,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; } @@ -2853,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; } @@ -2866,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; } @@ -2912,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; } @@ -2925,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; } @@ -2950,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; @@ -2961,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; } @@ -2974,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; } @@ -2990,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; } @@ -3006,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); } @@ -3048,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; } @@ -3056,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; } @@ -3101,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; } @@ -3124,7 +3391,7 @@ do_set_wire_fee (char *const *args) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "You must use YEAR, METHOD, WIRE-FEE, and CLOSING-FEE as arguments for this subcommand\n"); - test_shutdown (); + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_INVALIDARGUMENT; return; } @@ -3188,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; } @@ -3198,14 +3465,28 @@ do_set_global_fee (char *const *args) (NULL == args[3]) || (NULL == args[4]) || (NULL == args[5]) || - (NULL == args[6]) || - ( (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 != @@ -3213,21 +3494,35 @@ do_set_global_fee (char *const *args) &fees.account)) || (GNUNET_OK != TALER_string_to_amount (args[3], - &fees.purse)) || - (GNUNET_OK != + &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[5], - &history_expiration)) || - (1 != sscanf (args[6], - "%u%c", - &purse_account_limit, - &dummy)) ) + &history_expiration)) ) { 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"); - 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; } @@ -3298,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; } @@ -3311,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; } @@ -3321,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; } @@ -3332,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; } @@ -3346,7 +3641,7 @@ do_drain (char *const *args) payto_uri, err); GNUNET_free (err); - test_shutdown (); + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_INVALIDARGUMENT; return; } @@ -3407,7 +3702,7 @@ do_add_partner (char *const *args) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Downloaded data was not consumed, not adding partner\n"); - test_shutdown (); + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_FAILURE; return; } @@ -3420,7 +3715,7 @@ do_add_partner (char *const *args) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "You must specify the partner master public key as first argument for this subcommand\n"); - test_shutdown (); + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_INVALIDARGUMENT; return; } @@ -3431,7 +3726,7 @@ do_add_partner (char *const *args) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "You must specify the partner's base URL as the 2nd argument to this subcommand\n"); - test_shutdown (); + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_INVALIDARGUMENT; return; } @@ -3444,7 +3739,7 @@ do_add_partner (char *const *args) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid amount `%s' specified for wad fee of partner\n", args[2]); - test_shutdown (); + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_INVALIDARGUMENT; return; } @@ -3456,7 +3751,7 @@ do_add_partner (char *const *args) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid wad frequency `%s' specified for add partner\n", args[3]); - test_shutdown (); + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_INVALIDARGUMENT; return; } @@ -3471,7 +3766,7 @@ do_add_partner (char *const *args) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid year `%s' specified for add partner\n", args[4]); - test_shutdown (); + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_INVALIDARGUMENT; return; } @@ -3533,7 +3828,7 @@ do_set_aml_staff (bool is_active, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Downloaded data was not consumed, not updating AML staff status\n"); - test_shutdown (); + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_FAILURE; return; } @@ -3546,7 +3841,7 @@ do_set_aml_staff (bool is_active, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "You must specify the AML officer's public key as first argument for this subcommand\n"); - test_shutdown (); + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_INVALIDARGUMENT; return; } @@ -3554,7 +3849,7 @@ do_set_aml_staff (bool is_active, { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "You must specify the officer's legal name as the 2nd argument to this subcommand\n"); - test_shutdown (); + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_INVALIDARGUMENT; return; } @@ -3570,7 +3865,7 @@ do_set_aml_staff (bool is_active, GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "You must specify 'ro' or 'rw' (and not `%s') for the access level\n", args[2]); - test_shutdown (); + GNUNET_SCHEDULER_shutdown (); global_ret = EXIT_INVALIDARGUMENT; return; } @@ -3643,18 +3938,15 @@ enable_aml_staff (char *const *args) * 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) { @@ -3672,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; } @@ -3711,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; } @@ -3964,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, @@ -3980,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; } { @@ -4072,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 ( @@ -4080,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, @@ -4096,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, @@ -4121,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; } @@ -4208,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; } } @@ -4227,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, @@ -4258,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", @@ -4299,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; } @@ -4310,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; } @@ -4319,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; } @@ -4333,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); } @@ -4398,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; } @@ -4415,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; } @@ -4552,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 ( @@ -4564,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, @@ -4584,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, @@ -4608,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; } @@ -4616,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; } @@ -4659,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", @@ -4702,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; } @@ -4713,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; } @@ -4724,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; } @@ -4746,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; } @@ -4761,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); } @@ -4981,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; } @@ -5045,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 }, { |