fix #6662: add versioning information to JSON exchanged between taler-exchange-offline invocations
This commit is contained in:
parent
b1e305fb05
commit
0ad6cb0a86
@ -23,6 +23,24 @@
|
|||||||
#include "taler_json_lib.h"
|
#include "taler_json_lib.h"
|
||||||
#include "taler_exchange_service.h"
|
#include "taler_exchange_service.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the input of a denomination key signature for the 'upload' operation.
|
||||||
|
* The "auditor-" prefix ensures that there is no ambiguity between
|
||||||
|
* taler-exchange-offline and taler-auditor-offline JSON formats.
|
||||||
|
* The last component --by convention-- identifies the protocol version
|
||||||
|
* and should be incremented whenever the JSON format of the 'argument' changes.
|
||||||
|
*/
|
||||||
|
#define OP_SIGN_DENOMINATION "auditor-sign-denomination-0"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the input for the 'sign' and 'show' operations.
|
||||||
|
* The "auditor-" prefix ensures that there is no ambiguity between
|
||||||
|
* taler-exchange-offline and taler-auditor-offline JSON formats.
|
||||||
|
* The last component --by convention-- identifies the protocol version
|
||||||
|
* and should be incremented whenever the JSON format of the 'argument' changes.
|
||||||
|
*/
|
||||||
|
#define OP_INPUT_KEYS "auditor-keys-0"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Our private key, initialized in #load_offline_key().
|
* Our private key, initialized in #load_offline_key().
|
||||||
@ -452,7 +470,7 @@ trigger_upload (const char *exchange_url)
|
|||||||
{
|
{
|
||||||
struct UploadHandler uhs[] = {
|
struct UploadHandler uhs[] = {
|
||||||
{
|
{
|
||||||
.key = "sign-denomination",
|
.key = OP_SIGN_DENOMINATION,
|
||||||
.cb = &upload_denomination_add
|
.cb = &upload_denomination_add
|
||||||
},
|
},
|
||||||
/* array termination */
|
/* array termination */
|
||||||
@ -605,15 +623,18 @@ keys_cb (
|
|||||||
global_ret = 4;
|
global_ret = 4;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
in = json_pack ("{s:s,s:O}",
|
||||||
|
"operation",
|
||||||
|
OP_INPUT_KEYS,
|
||||||
|
"arguments",
|
||||||
|
hr->reply);
|
||||||
if (NULL == args[0])
|
if (NULL == args[0])
|
||||||
{
|
{
|
||||||
json_dumpf (hr->reply,
|
json_dumpf (in,
|
||||||
stdout,
|
stdout,
|
||||||
JSON_INDENT (2));
|
JSON_INDENT (2));
|
||||||
}
|
json_decref (in);
|
||||||
else
|
in = NULL;
|
||||||
{
|
|
||||||
in = json_incref ((json_t*) hr->reply);
|
|
||||||
}
|
}
|
||||||
TALER_EXCHANGE_disconnect (exchange);
|
TALER_EXCHANGE_disconnect (exchange);
|
||||||
exchange = NULL;
|
exchange = NULL;
|
||||||
@ -796,13 +817,26 @@ show_denomkeys (const json_t *denomkeys)
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show exchange denomination keys.
|
* Parse the '/keys' input for operation called @a command_name.
|
||||||
*
|
*
|
||||||
* @param args the array of command-line arguments to process next
|
* @param command_name name of the command, for logging errors
|
||||||
|
* @return NULL if the input is malformed
|
||||||
*/
|
*/
|
||||||
static void
|
static json_t *
|
||||||
do_show (char *const *args)
|
parse_keys (const char *command_name)
|
||||||
{
|
{
|
||||||
|
json_t *keys;
|
||||||
|
const char *op_str;
|
||||||
|
struct GNUNET_JSON_Specification spec[] = {
|
||||||
|
GNUNET_JSON_spec_json ("arguments",
|
||||||
|
&keys),
|
||||||
|
GNUNET_JSON_spec_string ("operation",
|
||||||
|
&op_str),
|
||||||
|
GNUNET_JSON_spec_end ()
|
||||||
|
};
|
||||||
|
const char *err_name;
|
||||||
|
unsigned int err_line;
|
||||||
|
|
||||||
if (NULL == in)
|
if (NULL == in)
|
||||||
{
|
{
|
||||||
json_error_t err;
|
json_error_t err;
|
||||||
@ -820,11 +854,53 @@ do_show (char *const *args)
|
|||||||
err.position);
|
err.position);
|
||||||
global_ret = 2;
|
global_ret = 2;
|
||||||
test_shutdown ();
|
test_shutdown ();
|
||||||
return;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
GNUNET_JSON_parse (in,
|
||||||
|
spec,
|
||||||
|
&err_name,
|
||||||
|
&err_line))
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"Invalid input to '%s': %s#%u (skipping)\n",
|
||||||
|
command_name,
|
||||||
|
err_name,
|
||||||
|
err_line);
|
||||||
|
json_dumpf (in,
|
||||||
|
stderr,
|
||||||
|
JSON_INDENT (2));
|
||||||
|
global_ret = 7;
|
||||||
|
test_shutdown ();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (0 != strcmp (op_str,
|
||||||
|
OP_INPUT_KEYS))
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"Invalid input to '%s' : operation is `%s', expected `%s'\n",
|
||||||
|
command_name,
|
||||||
|
op_str,
|
||||||
|
OP_INPUT_KEYS);
|
||||||
|
GNUNET_JSON_parse_free (spec);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
json_decref (in);
|
||||||
|
in = NULL;
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show exchange denomination keys.
|
||||||
|
*
|
||||||
|
* @param args the array of command-line arguments to process next
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
do_show (char *const *args)
|
||||||
{
|
{
|
||||||
|
json_t *keys;
|
||||||
const char *err_name;
|
const char *err_name;
|
||||||
unsigned int err_line;
|
unsigned int err_line;
|
||||||
json_t *denomkeys;
|
json_t *denomkeys;
|
||||||
@ -837,8 +913,11 @@ do_show (char *const *args)
|
|||||||
GNUNET_JSON_spec_end ()
|
GNUNET_JSON_spec_end ()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
keys = parse_keys ("show");
|
||||||
|
if (NULL == keys)
|
||||||
|
return;
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_JSON_parse (in,
|
GNUNET_JSON_parse (keys,
|
||||||
spec,
|
spec,
|
||||||
&err_name,
|
&err_name,
|
||||||
&err_line))
|
&err_line))
|
||||||
@ -849,6 +928,7 @@ do_show (char *const *args)
|
|||||||
err_line);
|
err_line);
|
||||||
global_ret = 7;
|
global_ret = 7;
|
||||||
test_shutdown ();
|
test_shutdown ();
|
||||||
|
json_decref (keys);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (0 !=
|
if (0 !=
|
||||||
@ -859,6 +939,7 @@ do_show (char *const *args)
|
|||||||
"Exchange master public key does not match key we have configured (aborting)\n");
|
"Exchange master public key does not match key we have configured (aborting)\n");
|
||||||
global_ret = 7;
|
global_ret = 7;
|
||||||
test_shutdown ();
|
test_shutdown ();
|
||||||
|
json_decref (keys);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
@ -867,10 +948,11 @@ do_show (char *const *args)
|
|||||||
global_ret = 8;
|
global_ret = 8;
|
||||||
test_shutdown ();
|
test_shutdown ();
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
|
json_decref (keys);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
}
|
json_decref (keys);
|
||||||
/* do NOT consume input if next argument is '-' */
|
/* do NOT consume input if next argument is '-' */
|
||||||
if ( (NULL != args[0]) &&
|
if ( (NULL != args[0]) &&
|
||||||
(0 == strcmp ("-",
|
(0 == strcmp ("-",
|
||||||
@ -879,8 +961,6 @@ do_show (char *const *args)
|
|||||||
next (args + 1);
|
next (args + 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
json_decref (in);
|
|
||||||
in = NULL;
|
|
||||||
next (args);
|
next (args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -996,7 +1076,7 @@ sign_denomkeys (const json_t *denomkeys)
|
|||||||
&fee_refund,
|
&fee_refund,
|
||||||
&auditor_priv,
|
&auditor_priv,
|
||||||
&auditor_sig);
|
&auditor_sig);
|
||||||
output_operation ("sign-denomination",
|
output_operation (OP_SIGN_DENOMINATION,
|
||||||
json_pack ("{s:o, s:o}",
|
json_pack ("{s:o, s:o}",
|
||||||
"h_denom_pub",
|
"h_denom_pub",
|
||||||
GNUNET_JSON_from_data_auto (&h_denom_pub),
|
GNUNET_JSON_from_data_auto (&h_denom_pub),
|
||||||
@ -1017,31 +1097,7 @@ sign_denomkeys (const json_t *denomkeys)
|
|||||||
static void
|
static void
|
||||||
do_sign (char *const *args)
|
do_sign (char *const *args)
|
||||||
{
|
{
|
||||||
if (NULL == in)
|
json_t *keys;
|
||||||
{
|
|
||||||
json_error_t err;
|
|
||||||
|
|
||||||
out = json_loadf (stdin,
|
|
||||||
JSON_REJECT_DUPLICATES,
|
|
||||||
&err);
|
|
||||||
if (NULL == in)
|
|
||||||
{
|
|
||||||
fprintf (stderr,
|
|
||||||
"Failed to read JSON input: %s at %d:%s (offset: %d)\n",
|
|
||||||
err.text,
|
|
||||||
err.line,
|
|
||||||
err.source,
|
|
||||||
err.position);
|
|
||||||
global_ret = 2;
|
|
||||||
test_shutdown ();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (GNUNET_OK !=
|
|
||||||
load_offline_key ())
|
|
||||||
return;
|
|
||||||
|
|
||||||
{
|
|
||||||
const char *err_name;
|
const char *err_name;
|
||||||
unsigned int err_line;
|
unsigned int err_line;
|
||||||
struct TALER_MasterPublicKeyP mpub;
|
struct TALER_MasterPublicKeyP mpub;
|
||||||
@ -1054,8 +1110,19 @@ do_sign (char *const *args)
|
|||||||
GNUNET_JSON_spec_end ()
|
GNUNET_JSON_spec_end ()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
keys = parse_keys ("sign");
|
||||||
|
if (NULL == keys)
|
||||||
|
return;
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_JSON_parse (in,
|
load_offline_key ())
|
||||||
|
{
|
||||||
|
json_decref (keys);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
GNUNET_JSON_parse (keys,
|
||||||
spec,
|
spec,
|
||||||
&err_name,
|
&err_name,
|
||||||
&err_line))
|
&err_line))
|
||||||
@ -1066,6 +1133,7 @@ do_sign (char *const *args)
|
|||||||
err_line);
|
err_line);
|
||||||
global_ret = 7;
|
global_ret = 7;
|
||||||
test_shutdown ();
|
test_shutdown ();
|
||||||
|
json_decref (keys);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (0 !=
|
if (0 !=
|
||||||
@ -1076,6 +1144,7 @@ do_sign (char *const *args)
|
|||||||
"Exchange master public key does not match key we have configured (aborting)\n");
|
"Exchange master public key does not match key we have configured (aborting)\n");
|
||||||
global_ret = 7;
|
global_ret = 7;
|
||||||
test_shutdown ();
|
test_shutdown ();
|
||||||
|
json_decref (keys);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
@ -1084,12 +1153,11 @@ do_sign (char *const *args)
|
|||||||
global_ret = 8;
|
global_ret = 8;
|
||||||
test_shutdown ();
|
test_shutdown ();
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
|
json_decref (keys);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
}
|
json_decref (keys);
|
||||||
json_decref (in);
|
|
||||||
in = NULL;
|
|
||||||
next (args);
|
next (args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,69 @@
|
|||||||
#include "taler_json_lib.h"
|
#include "taler_json_lib.h"
|
||||||
#include "taler_exchange_service.h"
|
#include "taler_exchange_service.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the input for the 'sign' and 'show' operation.
|
||||||
|
* The last component --by convention-- identifies the protocol version
|
||||||
|
* and should be incremented whenever the JSON format of the 'argument' changes.
|
||||||
|
*/
|
||||||
|
#define OP_INPUT_KEYS "exchange-input-keys-0"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the operation to 'disable auditor'
|
||||||
|
* The last component --by convention-- identifies the protocol version
|
||||||
|
* and should be incremented whenever the JSON format of the 'argument' changes.
|
||||||
|
*/
|
||||||
|
#define OP_DISABLE_AUDITOR "exchange-disable-auditor-0"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the operation to 'enable auditor'
|
||||||
|
* The last component --by convention-- identifies the protocol version
|
||||||
|
* and should be incremented whenever the JSON format of the 'argument' changes.
|
||||||
|
*/
|
||||||
|
#define OP_ENABLE_AUDITOR "exchange-enable-auditor-0"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the operation to 'enable wire'
|
||||||
|
* The last component --by convention-- identifies the protocol version
|
||||||
|
* and should be incremented whenever the JSON format of the 'argument' changes.
|
||||||
|
*/
|
||||||
|
#define OP_ENABLE_WIRE "exchange-enable-wire-0"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the operation to 'disable wire'
|
||||||
|
* The last component --by convention-- identifies the protocol version
|
||||||
|
* and should be incremented whenever the JSON format of the 'argument' changes.
|
||||||
|
*/
|
||||||
|
#define OP_DISABLE_WIRE "exchange-disable-wire-0"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the operation to set a 'wire-fee'
|
||||||
|
* The last component --by convention-- identifies the protocol version
|
||||||
|
* and should be incremented whenever the JSON format of the 'argument' changes.
|
||||||
|
*/
|
||||||
|
#define OP_SET_WIRE_FEE "exchange-set-wire-fee-0"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the operation to 'upload' key signatures
|
||||||
|
* The last component --by convention-- identifies the protocol version
|
||||||
|
* and should be incremented whenever the JSON format of the 'argument' changes.
|
||||||
|
*/
|
||||||
|
#define OP_UPLOAD_SIGS "exchange-upload-sigs-0"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the operation to 'revoke-denomination' key
|
||||||
|
* The last component --by convention-- identifies the protocol version
|
||||||
|
* and should be incremented whenever the JSON format of the 'argument' changes.
|
||||||
|
*/
|
||||||
|
#define OP_REVOKE_DENOMINATION "exchange-revoke-denomination-0"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the operation to 'revoke-signkey'
|
||||||
|
* The last component --by convention-- identifies the protocol version
|
||||||
|
* and should be incremented whenever the JSON format of the 'argument' changes.
|
||||||
|
*/
|
||||||
|
#define OP_REVOKE_SIGNKEY "exchange-revoke-signkey-0"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Our private key, initialized in #load_offline_key().
|
* Our private key, initialized in #load_offline_key().
|
||||||
@ -1570,35 +1633,35 @@ trigger_upload (const char *exchange_url)
|
|||||||
{
|
{
|
||||||
struct UploadHandler uhs[] = {
|
struct UploadHandler uhs[] = {
|
||||||
{
|
{
|
||||||
.key = "revoke-denomination",
|
.key = OP_REVOKE_DENOMINATION,
|
||||||
.cb = &upload_denom_revocation
|
.cb = &upload_denom_revocation
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.key = "revoke-signkey",
|
.key = OP_REVOKE_SIGNKEY,
|
||||||
.cb = &upload_signkey_revocation
|
.cb = &upload_signkey_revocation
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.key = "enable-auditor",
|
.key = OP_ENABLE_AUDITOR,
|
||||||
.cb = &upload_auditor_add
|
.cb = &upload_auditor_add
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.key = "disable-auditor",
|
.key = OP_DISABLE_AUDITOR,
|
||||||
.cb = &upload_auditor_del
|
.cb = &upload_auditor_del
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.key = "enable-wire",
|
.key = OP_ENABLE_WIRE,
|
||||||
.cb = &upload_wire_add
|
.cb = &upload_wire_add
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.key = "disable-wire",
|
.key = OP_DISABLE_WIRE,
|
||||||
.cb = &upload_wire_del
|
.cb = &upload_wire_del
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.key = "set-wire-fee",
|
.key = OP_SET_WIRE_FEE,
|
||||||
.cb = &upload_wire_fee
|
.cb = &upload_wire_fee
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.key = "upload-keys",
|
.key = OP_UPLOAD_SIGS,
|
||||||
.cb = &upload_keys
|
.cb = &upload_keys
|
||||||
},
|
},
|
||||||
/* array termination */
|
/* array termination */
|
||||||
@ -1755,7 +1818,7 @@ do_revoke_denomination_key (char *const *args)
|
|||||||
TALER_exchange_offline_denomination_revoke_sign (&h_denom_pub,
|
TALER_exchange_offline_denomination_revoke_sign (&h_denom_pub,
|
||||||
&master_priv,
|
&master_priv,
|
||||||
&master_sig);
|
&master_sig);
|
||||||
output_operation ("revoke-denomination",
|
output_operation (OP_REVOKE_DENOMINATION,
|
||||||
json_pack ("{s:o, s:o}",
|
json_pack ("{s:o, s:o}",
|
||||||
"h_denom_pub",
|
"h_denom_pub",
|
||||||
GNUNET_JSON_from_data_auto (&h_denom_pub),
|
GNUNET_JSON_from_data_auto (&h_denom_pub),
|
||||||
@ -1804,7 +1867,7 @@ do_revoke_signkey (char *const *args)
|
|||||||
TALER_exchange_offline_signkey_revoke_sign (&exchange_pub,
|
TALER_exchange_offline_signkey_revoke_sign (&exchange_pub,
|
||||||
&master_priv,
|
&master_priv,
|
||||||
&master_sig);
|
&master_sig);
|
||||||
output_operation ("revoke-signkey",
|
output_operation (OP_REVOKE_SIGNKEY,
|
||||||
json_pack ("{s:o, s:o}",
|
json_pack ("{s:o, s:o}",
|
||||||
"exchange_pub",
|
"exchange_pub",
|
||||||
GNUNET_JSON_from_data_auto (&exchange_pub),
|
GNUNET_JSON_from_data_auto (&exchange_pub),
|
||||||
@ -1873,7 +1936,7 @@ do_add_auditor (char *const *args)
|
|||||||
now,
|
now,
|
||||||
&master_priv,
|
&master_priv,
|
||||||
&master_sig);
|
&master_sig);
|
||||||
output_operation ("enable-auditor",
|
output_operation (OP_ENABLE_AUDITOR,
|
||||||
json_pack ("{s:s, s:s, s:o, s:o, s:o}",
|
json_pack ("{s:s, s:s, s:o, s:o, s:o}",
|
||||||
"auditor_url",
|
"auditor_url",
|
||||||
args[1],
|
args[1],
|
||||||
@ -1933,7 +1996,7 @@ do_del_auditor (char *const *args)
|
|||||||
now,
|
now,
|
||||||
&master_priv,
|
&master_priv,
|
||||||
&master_sig);
|
&master_sig);
|
||||||
output_operation ("disable-auditor",
|
output_operation (OP_DISABLE_AUDITOR,
|
||||||
json_pack ("{s:o, s:o, s:o}",
|
json_pack ("{s:o, s:o, s:o}",
|
||||||
"auditor_pub",
|
"auditor_pub",
|
||||||
GNUNET_JSON_from_data_auto (&auditor_pub),
|
GNUNET_JSON_from_data_auto (&auditor_pub),
|
||||||
@ -1987,7 +2050,7 @@ do_add_wire (char *const *args)
|
|||||||
TALER_exchange_wire_signature_make (args[0],
|
TALER_exchange_wire_signature_make (args[0],
|
||||||
&master_priv,
|
&master_priv,
|
||||||
&master_sig_wire);
|
&master_sig_wire);
|
||||||
output_operation ("enable-wire",
|
output_operation (OP_ENABLE_WIRE,
|
||||||
json_pack ("{s:s, s:o, s:o, s:o}",
|
json_pack ("{s:s, s:o, s:o, s:o}",
|
||||||
"payto_uri",
|
"payto_uri",
|
||||||
args[0],
|
args[0],
|
||||||
@ -2039,7 +2102,7 @@ do_del_wire (char *const *args)
|
|||||||
now,
|
now,
|
||||||
&master_priv,
|
&master_priv,
|
||||||
&master_sig);
|
&master_sig);
|
||||||
output_operation ("disable-wire",
|
output_operation (OP_DISABLE_WIRE,
|
||||||
json_pack ("{s:s, s:o, s:o}",
|
json_pack ("{s:s, s:o, s:o}",
|
||||||
"payto_uri",
|
"payto_uri",
|
||||||
args[0],
|
args[0],
|
||||||
@ -2116,7 +2179,7 @@ do_set_wire_fee (char *const *args)
|
|||||||
&closing_fee,
|
&closing_fee,
|
||||||
&master_priv,
|
&master_priv,
|
||||||
&master_sig);
|
&master_sig);
|
||||||
output_operation ("set-wire-fee",
|
output_operation (OP_SET_WIRE_FEE,
|
||||||
json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}",
|
json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}",
|
||||||
"wire_method",
|
"wire_method",
|
||||||
args[1],
|
args[1],
|
||||||
@ -2166,15 +2229,18 @@ download_cb (void *cls,
|
|||||||
global_ret = 4;
|
global_ret = 4;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
in = json_pack ("{s:s,s:O}",
|
||||||
|
"operation",
|
||||||
|
OP_INPUT_KEYS,
|
||||||
|
"arguments",
|
||||||
|
hr->reply);
|
||||||
if (NULL == args[0])
|
if (NULL == args[0])
|
||||||
{
|
{
|
||||||
json_dumpf (hr->reply,
|
json_dumpf (in,
|
||||||
stdout,
|
stdout,
|
||||||
JSON_INDENT (2));
|
JSON_INDENT (2));
|
||||||
}
|
json_decref (in);
|
||||||
else
|
in = NULL;
|
||||||
{
|
|
||||||
in = json_incref ((json_t*) hr->reply);
|
|
||||||
}
|
}
|
||||||
next (args);
|
next (args);
|
||||||
}
|
}
|
||||||
@ -2516,13 +2582,26 @@ show_denomkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub,
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show future keys.
|
* Parse the input of exchange keys for the 'show' and 'sign' commands.
|
||||||
*
|
*
|
||||||
* @param args the array of command-line arguments to process next
|
* @param command_name name of the command, for logging
|
||||||
|
* @return NULL on error, otherwise the keys details to be free'd by caller
|
||||||
*/
|
*/
|
||||||
static void
|
static json_t *
|
||||||
do_show (char *const *args)
|
parse_keys_input (const char *command_name)
|
||||||
{
|
{
|
||||||
|
const char *op_str;
|
||||||
|
json_t *keys;
|
||||||
|
struct GNUNET_JSON_Specification spec[] = {
|
||||||
|
GNUNET_JSON_spec_json ("arguments",
|
||||||
|
&keys),
|
||||||
|
GNUNET_JSON_spec_string ("operation",
|
||||||
|
&op_str),
|
||||||
|
GNUNET_JSON_spec_end ()
|
||||||
|
};
|
||||||
|
const char *err_name;
|
||||||
|
unsigned int err_line;
|
||||||
|
|
||||||
if (NULL == in)
|
if (NULL == in)
|
||||||
{
|
{
|
||||||
json_error_t err;
|
json_error_t err;
|
||||||
@ -2540,14 +2619,53 @@ do_show (char *const *args)
|
|||||||
err.position);
|
err.position);
|
||||||
global_ret = 2;
|
global_ret = 2;
|
||||||
test_shutdown ();
|
test_shutdown ();
|
||||||
return;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
load_offline_key ())
|
GNUNET_JSON_parse (in,
|
||||||
return;
|
spec,
|
||||||
|
&err_name,
|
||||||
|
&err_line))
|
||||||
{
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"Invalid input to '%s': %s#%u (skipping)\n",
|
||||||
|
command_name,
|
||||||
|
err_name,
|
||||||
|
err_line);
|
||||||
|
json_dumpf (in,
|
||||||
|
stderr,
|
||||||
|
JSON_INDENT (2));
|
||||||
|
global_ret = 7;
|
||||||
|
test_shutdown ();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (0 != strcmp (op_str,
|
||||||
|
OP_INPUT_KEYS))
|
||||||
|
{
|
||||||
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"Invalid input to '%s' : operation is `%s', expected `%s'\n",
|
||||||
|
command_name,
|
||||||
|
op_str,
|
||||||
|
OP_INPUT_KEYS);
|
||||||
|
GNUNET_JSON_parse_free (spec);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
json_decref (in);
|
||||||
|
in = NULL;
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show future keys.
|
||||||
|
*
|
||||||
|
* @param args the array of command-line arguments to process next
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
do_show (char *const *args)
|
||||||
|
{
|
||||||
|
json_t *keys;
|
||||||
const char *err_name;
|
const char *err_name;
|
||||||
unsigned int err_line;
|
unsigned int err_line;
|
||||||
json_t *denomkeys;
|
json_t *denomkeys;
|
||||||
@ -2568,8 +2686,13 @@ do_show (char *const *args)
|
|||||||
GNUNET_JSON_spec_end ()
|
GNUNET_JSON_spec_end ()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
keys = parse_keys_input ("show");
|
||||||
|
if (NULL == keys)
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_JSON_parse (in,
|
GNUNET_JSON_parse (keys,
|
||||||
spec,
|
spec,
|
||||||
&err_name,
|
&err_name,
|
||||||
&err_line))
|
&err_line))
|
||||||
@ -2583,6 +2706,7 @@ do_show (char *const *args)
|
|||||||
JSON_INDENT (2));
|
JSON_INDENT (2));
|
||||||
global_ret = 7;
|
global_ret = 7;
|
||||||
test_shutdown ();
|
test_shutdown ();
|
||||||
|
json_decref (keys);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (0 !=
|
if (0 !=
|
||||||
@ -2594,6 +2718,7 @@ do_show (char *const *args)
|
|||||||
global_ret = 6;
|
global_ret = 6;
|
||||||
test_shutdown ();
|
test_shutdown ();
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
|
json_decref (keys);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (GNUNET_SYSERR ==
|
if (GNUNET_SYSERR ==
|
||||||
@ -2602,6 +2727,7 @@ do_show (char *const *args)
|
|||||||
global_ret = 8;
|
global_ret = 8;
|
||||||
test_shutdown ();
|
test_shutdown ();
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
|
json_decref (keys);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( (GNUNET_OK !=
|
if ( (GNUNET_OK !=
|
||||||
@ -2614,12 +2740,11 @@ do_show (char *const *args)
|
|||||||
global_ret = 8;
|
global_ret = 8;
|
||||||
test_shutdown ();
|
test_shutdown ();
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
|
json_decref (keys);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
json_decref (keys);
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
}
|
|
||||||
json_decref (in);
|
|
||||||
in = NULL;
|
|
||||||
next (args);
|
next (args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2842,7 +2967,8 @@ sign_denomkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub,
|
|||||||
GNUNET_assert (0 ==
|
GNUNET_assert (0 ==
|
||||||
json_array_append_new (
|
json_array_append_new (
|
||||||
result,
|
result,
|
||||||
json_pack ("{s:o, s:o}",
|
json_pack (
|
||||||
|
"{s:o,s:o}",
|
||||||
"h_denom_pub",
|
"h_denom_pub",
|
||||||
GNUNET_JSON_from_data_auto (&h_denom_pub),
|
GNUNET_JSON_from_data_auto (&h_denom_pub),
|
||||||
"master_sig",
|
"master_sig",
|
||||||
@ -2862,31 +2988,7 @@ sign_denomkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub,
|
|||||||
static void
|
static void
|
||||||
do_sign (char *const *args)
|
do_sign (char *const *args)
|
||||||
{
|
{
|
||||||
if (NULL == in)
|
json_t *keys;
|
||||||
{
|
|
||||||
json_error_t err;
|
|
||||||
|
|
||||||
in = json_loadf (stdin,
|
|
||||||
JSON_REJECT_DUPLICATES,
|
|
||||||
&err);
|
|
||||||
if (NULL == in)
|
|
||||||
{
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"Failed to read JSON input: %s at %d:%s (offset: %d)\n",
|
|
||||||
err.text,
|
|
||||||
err.line,
|
|
||||||
err.source,
|
|
||||||
err.position);
|
|
||||||
global_ret = 2;
|
|
||||||
test_shutdown ();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (GNUNET_OK !=
|
|
||||||
load_offline_key ())
|
|
||||||
return;
|
|
||||||
|
|
||||||
{
|
|
||||||
const char *err_name;
|
const char *err_name;
|
||||||
unsigned int err_line;
|
unsigned int err_line;
|
||||||
json_t *denomkeys;
|
json_t *denomkeys;
|
||||||
@ -2907,8 +3009,17 @@ do_sign (char *const *args)
|
|||||||
GNUNET_JSON_spec_end ()
|
GNUNET_JSON_spec_end ()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
keys = parse_keys_input ("sign");
|
||||||
|
if (NULL == keys)
|
||||||
|
return;
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_JSON_parse (in,
|
load_offline_key ())
|
||||||
|
{
|
||||||
|
json_decref (keys);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
GNUNET_JSON_parse (keys,
|
||||||
spec,
|
spec,
|
||||||
&err_name,
|
&err_name,
|
||||||
&err_line))
|
&err_line))
|
||||||
@ -2922,6 +3033,7 @@ do_sign (char *const *args)
|
|||||||
JSON_INDENT (2));
|
JSON_INDENT (2));
|
||||||
global_ret = 7;
|
global_ret = 7;
|
||||||
test_shutdown ();
|
test_shutdown ();
|
||||||
|
json_decref (keys);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (0 !=
|
if (0 !=
|
||||||
@ -2933,6 +3045,7 @@ do_sign (char *const *args)
|
|||||||
global_ret = 6;
|
global_ret = 6;
|
||||||
test_shutdown ();
|
test_shutdown ();
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
|
json_decref (keys);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (GNUNET_SYSERR ==
|
if (GNUNET_SYSERR ==
|
||||||
@ -2943,6 +3056,7 @@ do_sign (char *const *args)
|
|||||||
global_ret = 8;
|
global_ret = 8;
|
||||||
test_shutdown ();
|
test_shutdown ();
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
|
json_decref (keys);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -2965,10 +3079,11 @@ do_sign (char *const *args)
|
|||||||
json_decref (signkey_sig_array);
|
json_decref (signkey_sig_array);
|
||||||
json_decref (denomkey_sig_array);
|
json_decref (denomkey_sig_array);
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
|
json_decref (keys);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
output_operation ("upload-keys",
|
output_operation (OP_UPLOAD_SIGS,
|
||||||
json_pack ("{s:o,s:o}",
|
json_pack ("{s:o,s:o}",
|
||||||
"denom_sigs",
|
"denom_sigs",
|
||||||
denomkey_sig_array,
|
denomkey_sig_array,
|
||||||
@ -2976,9 +3091,7 @@ do_sign (char *const *args)
|
|||||||
signkey_sig_array));
|
signkey_sig_array));
|
||||||
}
|
}
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
}
|
json_decref (keys);
|
||||||
json_decref (in);
|
|
||||||
in = NULL;
|
|
||||||
next (args);
|
next (args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3002,8 +3115,7 @@ work (void *cls)
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "sign",
|
.name = "sign",
|
||||||
.help =
|
.help = "sign all future public keys from the input",
|
||||||
"sing all future public keys from the input",
|
|
||||||
.cb = &do_sign
|
.cb = &do_sign
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -3021,7 +3133,7 @@ work (void *cls)
|
|||||||
{
|
{
|
||||||
.name = "enable-auditor",
|
.name = "enable-auditor",
|
||||||
.help =
|
.help =
|
||||||
"enable auditor for the exchange (auditor-public key, auditor-URI and auditor name must given as arguments)",
|
"enable auditor for the exchange (auditor-public key, auditor-URI and auditor-name must be given as arguments)",
|
||||||
.cb = &do_add_auditor
|
.cb = &do_add_auditor
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -3081,12 +3193,11 @@ work (void *cls)
|
|||||||
global_ret = 3;
|
global_ret = 3;
|
||||||
}
|
}
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
|
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
|
||||||
|
|
||||||
"Supported subcommands:\n");
|
"Supported subcommands:\n");
|
||||||
for (unsigned int i = 0; NULL != cmds[i].name; i++)
|
for (unsigned int i = 0; NULL != cmds[i].name; i++)
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
|
GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
|
||||||
"\t%s - %s\n",
|
"- %s: %s\n",
|
||||||
cmds[i].name,
|
cmds[i].name,
|
||||||
cmds[i].help);
|
cmds[i].help);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user