implementing #4932
This commit is contained in:
parent
e3dcc27b68
commit
1c84b3d4af
@ -878,15 +878,18 @@ exchange_keys_update_denomkeys ()
|
||||
* Sign @a af with @a priv
|
||||
*
|
||||
* @param[in|out] af fee structure to sign
|
||||
* @param wireplugin name of the plugin for which we sign
|
||||
* @param priv private key to use for signing
|
||||
*/
|
||||
static void
|
||||
sign_af (struct TALER_EXCHANGEDB_AggregateFees *af,
|
||||
const char *wireplugin,
|
||||
const struct GNUNET_CRYPTO_EddsaPrivateKey *priv)
|
||||
{
|
||||
struct TALER_MasterWireFeePS wf;
|
||||
|
||||
TALER_EXCHANGEDB_fees_2_wf (af,
|
||||
TALER_EXCHANGEDB_fees_2_wf (wireplugin,
|
||||
af,
|
||||
&wf);
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
GNUNET_CRYPTO_eddsa_sign (priv,
|
||||
@ -980,6 +983,7 @@ create_wire_fee_for_method (void *cls,
|
||||
GNUNET_free (amounts);
|
||||
GNUNET_free (opt);
|
||||
sign_af (af,
|
||||
wiremethod,
|
||||
&master_priv.eddsa_priv);
|
||||
if (NULL == af_tail)
|
||||
af_head = af;
|
||||
@ -992,6 +996,7 @@ create_wire_fee_for_method (void *cls,
|
||||
if ( (GNUNET_OK == *ret) &&
|
||||
(GNUNET_OK !=
|
||||
TALER_EXCHANGEDB_fees_write (fn,
|
||||
wiremethod,
|
||||
af_head)) )
|
||||
*ret = GNUNET_SYSERR;
|
||||
GNUNET_free (section);
|
||||
|
@ -142,17 +142,22 @@ TALER_EXCHANGEDB_fees_read (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
||||
/**
|
||||
* Convert @a af to @a wf.
|
||||
*
|
||||
* @param wireplugin name of the wire plugin the fees are for
|
||||
* @param[in,out] af aggregate fees, host format (updated to round time)
|
||||
* @param[out] wf aggregate fees, disk / signature format
|
||||
*/
|
||||
void
|
||||
TALER_EXCHANGEDB_fees_2_wf (struct TALER_EXCHANGEDB_AggregateFees *af,
|
||||
TALER_EXCHANGEDB_fees_2_wf (const char *wireplugin,
|
||||
struct TALER_EXCHANGEDB_AggregateFees *af,
|
||||
struct TALER_MasterWireFeePS *wf)
|
||||
{
|
||||
(void) GNUNET_TIME_round_abs (&af->start_date);
|
||||
(void) GNUNET_TIME_round_abs (&af->end_date);
|
||||
wf->purpose.size = htonl (sizeof (*wf));
|
||||
wf->purpose.purpose = htonl (TALER_SIGNATURE_MASTER_WIRE_FEES);
|
||||
GNUNET_CRYPTO_hash (wireplugin,
|
||||
strlen (wireplugin) + 1,
|
||||
&wf->h_wire_method);
|
||||
wf->start_date = GNUNET_TIME_absolute_hton (af->start_date);
|
||||
wf->end_date = GNUNET_TIME_absolute_hton (af->end_date);
|
||||
TALER_amount_hton (&wf->wire_fee,
|
||||
@ -164,11 +169,13 @@ TALER_EXCHANGEDB_fees_2_wf (struct TALER_EXCHANGEDB_AggregateFees *af,
|
||||
* Write given fee structure to disk.
|
||||
*
|
||||
* @param filename where to write the fees
|
||||
* @param wireplugin which plugin the fees are about
|
||||
* @param af fee structure to write
|
||||
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
|
||||
*/
|
||||
int
|
||||
TALER_EXCHANGEDB_fees_write (const char *filename,
|
||||
const char *wireplugin,
|
||||
struct TALER_EXCHANGEDB_AggregateFees *af)
|
||||
{
|
||||
struct GNUNET_DISK_FileHandle *fh;
|
||||
@ -201,7 +208,8 @@ TALER_EXCHANGEDB_fees_write (const char *filename,
|
||||
GNUNET_DISK_file_close (fh));
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
TALER_EXCHANGEDB_fees_2_wf (af,
|
||||
TALER_EXCHANGEDB_fees_2_wf (wireplugin,
|
||||
af,
|
||||
&wd.wf);
|
||||
wd.master_sig = af->master_sig;
|
||||
af = af->next;
|
||||
|
@ -36,7 +36,8 @@ sign_af (struct TALER_EXCHANGEDB_AggregateFees *af,
|
||||
{
|
||||
struct TALER_MasterWireFeePS wf;
|
||||
|
||||
TALER_EXCHANGEDB_fees_2_wf (af,
|
||||
TALER_EXCHANGEDB_fees_2_wf ("test",
|
||||
af,
|
||||
&wf);
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
GNUNET_CRYPTO_eddsa_sign (priv,
|
||||
@ -99,6 +100,7 @@ main (int argc,
|
||||
|
||||
if (GNUNET_OK !=
|
||||
TALER_EXCHANGEDB_fees_write (tmpfile,
|
||||
"test",
|
||||
af))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
@ -121,7 +123,8 @@ main (int argc,
|
||||
{
|
||||
struct TALER_MasterWireFeePS wf;
|
||||
|
||||
TALER_EXCHANGEDB_fees_2_wf (p,
|
||||
TALER_EXCHANGEDB_fees_2_wf ("test",
|
||||
p,
|
||||
&wf);
|
||||
if (GNUNET_OK !=
|
||||
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_WIRE_FEES,
|
||||
|
@ -345,11 +345,13 @@ TALER_EXCHANGEDB_fees_read (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
||||
/**
|
||||
* Convert @a af to @a wf.
|
||||
*
|
||||
* @param wireplugin name of the wire plugin the fees are for
|
||||
* @param[in,out] af aggregate fees, host format (updated to round time)
|
||||
* @param[out] wf aggregate fees, disk / signature format
|
||||
*/
|
||||
void
|
||||
TALER_EXCHANGEDB_fees_2_wf (struct TALER_EXCHANGEDB_AggregateFees *af,
|
||||
TALER_EXCHANGEDB_fees_2_wf (const char *wireplugin,
|
||||
struct TALER_EXCHANGEDB_AggregateFees *af,
|
||||
struct TALER_MasterWireFeePS *wf);
|
||||
|
||||
|
||||
@ -357,11 +359,13 @@ TALER_EXCHANGEDB_fees_2_wf (struct TALER_EXCHANGEDB_AggregateFees *af,
|
||||
* Write given fee structure to disk.
|
||||
*
|
||||
* @param filename where to write the fees
|
||||
* @param wireplugin name of the plugin for which we write the fees
|
||||
* @param af fee structure to write
|
||||
* @return #GNUNET_OK on success, #GNUNET_SYSERR on error
|
||||
*/
|
||||
int
|
||||
TALER_EXCHANGEDB_fees_write (const char *filename,
|
||||
const char *wireplugin,
|
||||
struct TALER_EXCHANGEDB_AggregateFees *af);
|
||||
|
||||
|
||||
|
@ -897,6 +897,13 @@ struct TALER_MasterWireFeePS
|
||||
*/
|
||||
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
||||
|
||||
/**
|
||||
* Hash over the wire method (yes, H("test") or H("sepa")), in lower
|
||||
* case, including 0-terminator. Used to uniquely identify which
|
||||
* wire method these fees apply to.
|
||||
*/
|
||||
struct GNUNET_HashCode h_wire_method;
|
||||
|
||||
/**
|
||||
* Start date when the fee goes into effect.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user