-finish reveal_cb
This commit is contained in:
parent
2da8705c96
commit
bbeb913dc2
@ -18,6 +18,11 @@
|
|||||||
* @brief testcase to test mint's HTTP API interface
|
* @brief testcase to test mint's HTTP API interface
|
||||||
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
|
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
|
||||||
* @author Christian Grothoff
|
* @author Christian Grothoff
|
||||||
|
*
|
||||||
|
* TODO:
|
||||||
|
* - support depositing coins from /refresh/reveal result
|
||||||
|
* - test /refresh/-operations
|
||||||
|
* - check coins returned by link_cb
|
||||||
*/
|
*/
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "taler_util.h"
|
#include "taler_util.h"
|
||||||
@ -124,6 +129,33 @@ struct MeltDetails
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Information about a fresh coin generated by the refresh operation.
|
||||||
|
*/
|
||||||
|
struct FreshCoin
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If @e amount is NULL, this specifies the denomination key to
|
||||||
|
* use. Otherwise, this will be set (by the interpreter) to the
|
||||||
|
* denomination PK matching @e amount.
|
||||||
|
*/
|
||||||
|
const struct TALER_MINT_DenomPublicKey *pk;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set (by the interpreter) to the mint's signature over the
|
||||||
|
* coin's public key.
|
||||||
|
*/
|
||||||
|
struct TALER_DenominationSignature sig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set (by the interpreter) to the coin's private key.
|
||||||
|
*/
|
||||||
|
struct TALER_CoinSpendPrivateKeyP coin_priv;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Details for a mint operation to execute.
|
* Details for a mint operation to execute.
|
||||||
*/
|
*/
|
||||||
@ -331,6 +363,12 @@ struct Command
|
|||||||
*/
|
*/
|
||||||
const char **fresh_amounts;
|
const char **fresh_amounts;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of the public keys corresponding to
|
||||||
|
* the @e fresh_amounts, set by the interpreter.
|
||||||
|
*/
|
||||||
|
const struct TALER_MINT_DenomPublicKey **fresh_pks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Melt handle while operation is running.
|
* Melt handle while operation is running.
|
||||||
*/
|
*/
|
||||||
@ -379,28 +417,7 @@ struct Command
|
|||||||
/**
|
/**
|
||||||
* Information about coins withdrawn, set by the interpreter.
|
* Information about coins withdrawn, set by the interpreter.
|
||||||
*/
|
*/
|
||||||
struct
|
struct FreshCoin *fresh_coins;
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If @e amount is NULL, this specifies the denomination key to
|
|
||||||
* use. Otherwise, this will be set (by the interpreter) to the
|
|
||||||
* denomination PK matching @e amount.
|
|
||||||
*/
|
|
||||||
const struct TALER_MINT_DenomPublicKey *pk;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set (by the interpreter) to the mint's signature over the
|
|
||||||
* coin's public key.
|
|
||||||
*/
|
|
||||||
struct TALER_DenominationSignature sig;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set (by the interpreter) to the coin's private key.
|
|
||||||
*/
|
|
||||||
struct TALER_CoinSpendPrivateKeyP coin_priv;
|
|
||||||
|
|
||||||
} *fresh_coins;
|
|
||||||
|
|
||||||
} refresh_reveal;
|
} refresh_reveal;
|
||||||
|
|
||||||
@ -900,6 +917,7 @@ reveal_cb (void *cls,
|
|||||||
{
|
{
|
||||||
struct InterpreterState *is = cls;
|
struct InterpreterState *is = cls;
|
||||||
struct Command *cmd = &is->commands[is->ip];
|
struct Command *cmd = &is->commands[is->ip];
|
||||||
|
const struct Command *ref;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
cmd->details.refresh_reveal.rrh = NULL;
|
cmd->details.refresh_reveal.rrh = NULL;
|
||||||
@ -912,11 +930,24 @@ reveal_cb (void *cls,
|
|||||||
fail (is);
|
fail (is);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ref = find_command (is,
|
||||||
|
cmd->details.refresh_reveal.melt_ref);
|
||||||
cmd->details.refresh_reveal.num_fresh_coins = num_coins;
|
cmd->details.refresh_reveal.num_fresh_coins = num_coins;
|
||||||
switch (http_status)
|
switch (http_status)
|
||||||
{
|
{
|
||||||
case MHD_HTTP_OK:
|
case MHD_HTTP_OK:
|
||||||
// FIXME: store returned coin keys...
|
cmd->details.refresh_reveal.fresh_coins
|
||||||
|
= GNUNET_new_array (num_coins,
|
||||||
|
struct FreshCoin);
|
||||||
|
for (i=0;i<num_coins;i++)
|
||||||
|
{
|
||||||
|
struct FreshCoin *fc = &cmd->details.refresh_reveal.fresh_coins[i];
|
||||||
|
|
||||||
|
fc->pk = ref->details.refresh_melt.fresh_pks[i];
|
||||||
|
fc->coin_priv = coin_privs[i];
|
||||||
|
fc->sig.rsa_signature
|
||||||
|
= GNUNET_CRYPTO_rsa_signature_dup (sigs[i].rsa_signature);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -1324,6 +1355,9 @@ interpreter_run (void *cls,
|
|||||||
NULL != cmd->details.refresh_melt.fresh_amounts[num_fresh_coins];
|
NULL != cmd->details.refresh_melt.fresh_amounts[num_fresh_coins];
|
||||||
num_fresh_coins++) ;
|
num_fresh_coins++) ;
|
||||||
|
|
||||||
|
cmd->details.refresh_melt.fresh_pks
|
||||||
|
= GNUNET_new_array (num_fresh_coins,
|
||||||
|
const struct TALER_MINT_DenomPublicKey *);
|
||||||
{
|
{
|
||||||
struct TALER_CoinSpendPrivateKeyP melt_privs[num_melted_coins];
|
struct TALER_CoinSpendPrivateKeyP melt_privs[num_melted_coins];
|
||||||
struct TALER_Amount melt_amounts[num_melted_coins];
|
struct TALER_Amount melt_amounts[num_melted_coins];
|
||||||
@ -1368,8 +1402,10 @@ interpreter_run (void *cls,
|
|||||||
fail (is);
|
fail (is);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fresh_pks[i] = *find_pk (is->keys,
|
cmd->details.refresh_melt.fresh_pks[i]
|
||||||
|
= find_pk (is->keys,
|
||||||
&amount);
|
&amount);
|
||||||
|
fresh_pks[i] = *cmd->details.refresh_melt.fresh_pks[i];
|
||||||
}
|
}
|
||||||
cmd->details.refresh_melt.refresh_data
|
cmd->details.refresh_melt.refresh_data
|
||||||
= TALER_MINT_refresh_prepare (num_melted_coins,
|
= TALER_MINT_refresh_prepare (num_melted_coins,
|
||||||
@ -1558,6 +1594,8 @@ do_shutdown (void *cls,
|
|||||||
TALER_MINT_refresh_melt_cancel (cmd->details.refresh_melt.rmh);
|
TALER_MINT_refresh_melt_cancel (cmd->details.refresh_melt.rmh);
|
||||||
cmd->details.refresh_melt.rmh = NULL;
|
cmd->details.refresh_melt.rmh = NULL;
|
||||||
}
|
}
|
||||||
|
GNUNET_free_non_null (cmd->details.refresh_melt.fresh_pks);
|
||||||
|
cmd->details.refresh_melt.fresh_pks = NULL;
|
||||||
GNUNET_free_non_null (cmd->details.refresh_melt.refresh_data);
|
GNUNET_free_non_null (cmd->details.refresh_melt.refresh_data);
|
||||||
cmd->details.refresh_melt.refresh_data = NULL;
|
cmd->details.refresh_melt.refresh_data = NULL;
|
||||||
cmd->details.refresh_melt.refresh_data_length = 0;
|
cmd->details.refresh_melt.refresh_data_length = 0;
|
||||||
@ -1572,6 +1610,17 @@ do_shutdown (void *cls,
|
|||||||
TALER_MINT_refresh_reveal_cancel (cmd->details.refresh_reveal.rrh);
|
TALER_MINT_refresh_reveal_cancel (cmd->details.refresh_reveal.rrh);
|
||||||
cmd->details.refresh_reveal.rrh = NULL;
|
cmd->details.refresh_reveal.rrh = NULL;
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
unsigned int j;
|
||||||
|
struct FreshCoin *fresh_coins;
|
||||||
|
|
||||||
|
fresh_coins = cmd->details.refresh_reveal.fresh_coins;
|
||||||
|
for (j=0;j<cmd->details.refresh_reveal.num_fresh_coins;j++)
|
||||||
|
GNUNET_CRYPTO_rsa_signature_free (fresh_coins[j].sig.rsa_signature);
|
||||||
|
}
|
||||||
|
GNUNET_free_non_null (cmd->details.refresh_reveal.fresh_coins);
|
||||||
|
cmd->details.refresh_reveal.fresh_coins = NULL;
|
||||||
|
cmd->details.refresh_reveal.num_fresh_coins = 0;
|
||||||
break;
|
break;
|
||||||
case OC_REFRESH_LINK:
|
case OC_REFRESH_LINK:
|
||||||
if (NULL != cmd->details.refresh_link.rlh)
|
if (NULL != cmd->details.refresh_link.rlh)
|
||||||
|
Loading…
Reference in New Issue
Block a user