Initial work for more commands
This commit is contained in:
parent
00fb066842
commit
663fa898f5
@ -484,47 +484,6 @@ PERF_TALER_MINTDB_refresh_session_free (struct TALER_MINTDB_RefreshSession *refr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate a random CoinPublicInfo
|
|
||||||
*/
|
|
||||||
struct TALER_CoinPublicInfo *
|
|
||||||
PERF_TALER_MINTDB_coin_public_info_init ()
|
|
||||||
{
|
|
||||||
struct GNUNET_CRYPTO_EddsaPrivateKey *coin_spent_prv;
|
|
||||||
struct GNUNET_CRYPTO_rsa_PrivateKey *denom_prv;
|
|
||||||
struct TALER_CoinPublicInfo *cpi;
|
|
||||||
|
|
||||||
GNUNET_assert (NULL !=
|
|
||||||
(denom_prv = GNUNET_CRYPTO_rsa_private_key_create (PERF_TALER_MINTDB_RSA_SIZE)));
|
|
||||||
GNUNET_assert (NULL !=
|
|
||||||
(coin_spent_prv = GNUNET_CRYPTO_eddsa_key_create ()));
|
|
||||||
GNUNET_assert (NULL !=
|
|
||||||
(cpi = GNUNET_new (struct TALER_CoinPublicInfo)));
|
|
||||||
GNUNET_CRYPTO_eddsa_key_get_public (coin_spent_prv, &cpi->coin_pub.eddsa_pub);
|
|
||||||
GNUNET_assert (NULL !=
|
|
||||||
(cpi->denom_pub.rsa_public_key = GNUNET_CRYPTO_rsa_private_key_get_public (denom_prv)));
|
|
||||||
GNUNET_assert (NULL !=
|
|
||||||
(cpi->denom_sig.rsa_signature = GNUNET_CRYPTO_rsa_sign (denom_prv,
|
|
||||||
&cpi->coin_pub,
|
|
||||||
sizeof (struct TALER_CoinSpendPublicKeyP))));
|
|
||||||
GNUNET_free (coin_spent_prv);
|
|
||||||
GNUNET_CRYPTO_rsa_private_key_free (denom_prv);
|
|
||||||
return cpi;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Free a CoinPublicInfo
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
PERF_TALER_MINTDB_coin_public_info_free (struct TALER_CoinPublicInfo *cpi)
|
|
||||||
{
|
|
||||||
|
|
||||||
GNUNET_CRYPTO_rsa_signature_free (cpi->denom_sig.rsa_signature);
|
|
||||||
GNUNET_CRYPTO_rsa_public_key_free (cpi->denom_pub.rsa_public_key);
|
|
||||||
return GNUNET_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a melt operation
|
* Create a melt operation
|
||||||
*
|
*
|
||||||
@ -560,12 +519,17 @@ PERF_TALER_MINTDB_refresh_melt_init (struct GNUNET_HashCode *session,
|
|||||||
GNUNET_assert (GNUNET_OK == TALER_string_to_amount (CURRENCY ":0.1",
|
GNUNET_assert (GNUNET_OK == TALER_string_to_amount (CURRENCY ":0.1",
|
||||||
&amount_with_fee));
|
&amount_with_fee));
|
||||||
melt = GNUNET_new (struct TALER_MINTDB_RefreshMelt);
|
melt = GNUNET_new (struct TALER_MINTDB_RefreshMelt);
|
||||||
melt->coin = coin->public_info;
|
melt->coin.coin_pub = coin->public_info.coin_pub;
|
||||||
|
melt->coin.denom_sig.rsa_signature =
|
||||||
|
GNUNET_CRYPTO_rsa_signature_dup (coin->public_info.denom_sig.rsa_signature);
|
||||||
|
melt->coin.denom_pub.rsa_public_key =
|
||||||
|
GNUNET_CRYPTO_rsa_public_key_dup (coin->public_info.denom_pub.rsa_public_key);
|
||||||
|
GNUNET_assert (NULL != melt->coin.denom_pub.rsa_public_key);
|
||||||
|
GNUNET_assert (NULL != melt->coin.denom_sig.rsa_signature);
|
||||||
melt->coin_sig = coin_sig;
|
melt->coin_sig = coin_sig;
|
||||||
melt->session_hash = *session;
|
melt->session_hash = *session;
|
||||||
melt->amount_with_fee = amount;
|
melt->amount_with_fee = amount;
|
||||||
melt->melt_fee = amount_with_fee;
|
melt->melt_fee = amount_with_fee;
|
||||||
|
|
||||||
return melt;
|
return melt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -770,6 +770,93 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PERF_TALER_MINTDB_CMD_INSERT_REFRESH_ORDER:
|
||||||
|
{
|
||||||
|
int hash_index;
|
||||||
|
int denom_index;
|
||||||
|
struct GNUNET_HashCode session_hash;
|
||||||
|
struct TALER_MINTDB_DenominationKeyIssueInformation *denom;
|
||||||
|
|
||||||
|
hash_index = cmd_find (state->cmd,
|
||||||
|
state->cmd[state->i].details.insert_refresh_order.label_hash);
|
||||||
|
GNUNET_assert (GNUNET_SYSERR != hash_index);
|
||||||
|
denom_index = cmd_find (state->cmd,
|
||||||
|
state->cmd[state->i].details.insert_refresh_order.label_denom);
|
||||||
|
GNUNET_assert (GNUNET_SYSERR != denom_index);
|
||||||
|
session_hash = state->cmd[hash_index].exposed.data.session_hash;
|
||||||
|
denom = state->cmd[denom_index].exposed.data.dki;
|
||||||
|
state->plugin->insert_refresh_order (state->plugin->cls,
|
||||||
|
state->session,
|
||||||
|
&session_hash,
|
||||||
|
1,
|
||||||
|
&denom->denom_pub);
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PERF_TALER_MINTDB_CMD_GET_REFRESH_ORDER:
|
||||||
|
{
|
||||||
|
int hash_index;
|
||||||
|
struct GNUNET_HashCode hash;
|
||||||
|
struct TALER_DenominationPublicKey denom_pub;
|
||||||
|
|
||||||
|
hash_index = cmd_find (state->cmd,
|
||||||
|
state->cmd[state->i].details.get_refresh_order.label_hash);
|
||||||
|
GNUNET_assert (GNUNET_SYSERR != hash_index);
|
||||||
|
hash = state->cmd[hash_index].exposed.data.session_hash;
|
||||||
|
state->plugin->get_refresh_order (state->plugin->cls,
|
||||||
|
state->session,
|
||||||
|
&hash,
|
||||||
|
1,
|
||||||
|
&denom_pub);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PERF_TALER_MINTDB_CMD_INSERT_REFRESH_COMMIT_COIN:
|
||||||
|
{
|
||||||
|
int hash_index;
|
||||||
|
|
||||||
|
hash_index = cmd_find (state->cmd,
|
||||||
|
state->cmd[state->i].details.insert_refresh_commit_coin.label_hash);
|
||||||
|
GNUNET_assert (GNUNET_SYSERR != hash_index);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PERF_TALER_MINTDB_CMD_GET_REFRESH_COMMIT_COIN:
|
||||||
|
{
|
||||||
|
int hash_index;
|
||||||
|
|
||||||
|
hash_index = cmd_find (state->cmd,
|
||||||
|
state->cmd[state->i].details.insert_refresh_commit_coin.label_hash);
|
||||||
|
GNUNET_assert (GNUNET_SYSERR != hash_index);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PERF_TALER_MINTDB_CMD_INSERT_REFRESH_COMMIT_LINK:
|
||||||
|
{
|
||||||
|
int hash_index;
|
||||||
|
|
||||||
|
hash_index = cmd_find (state->cmd,
|
||||||
|
state->cmd[state->i].details.insert_refresh_commit_link.label_hash);
|
||||||
|
GNUNET_assert (GNUNET_SYSERR != hash_index);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PERF_TALER_MINTDB_CMD_GET_REFRESH_COMMIT_LINK:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PERF_TALER_MINTDB_CMD_GET_MELT_COMMITMENT:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PERF_TALER_MINTDB_CMD_INSERT_REFRESH_OUT:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PERF_TALER_MINTDB_CMD_GET_LINK_DATA_LIST:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PERF_TALER_MINTDB_CMD_GET_TRANSFER:
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -321,6 +321,21 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Access the transactioj history of a coin
|
||||||
|
*
|
||||||
|
* @param _label the label of the command
|
||||||
|
* @param _label_coin the coin which history is checked
|
||||||
|
*/
|
||||||
|
#define PERF_TALER_MINTDB_INIT_CMD_GET_COIN_TRANSACTION(_label, _label_coin) \
|
||||||
|
{ \
|
||||||
|
.command = PERF_TALER_MINTDB_CMD_GET_COIN_TRANSACTION, \
|
||||||
|
.label = _label, \
|
||||||
|
.exposed.type = PERF_TALER_MINTDB_NONE, \
|
||||||
|
.details.get_coin_trancaction.label_coin = _label_coin \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts informations about a withdrawal in the database
|
* Inserts informations about a withdrawal in the database
|
||||||
*
|
*
|
||||||
@ -367,8 +382,24 @@
|
|||||||
* @param _label_reserve the reserve used to provide currency
|
* @param _label_reserve the reserve used to provide currency
|
||||||
*/
|
*/
|
||||||
#define PERF_TALER_MINTDB_INIT_CMD_WITHDRAW_SIGN(_label, _label_dki, _label_reserve) \
|
#define PERF_TALER_MINTDB_INIT_CMD_WITHDRAW_SIGN(_label, _label_dki, _label_reserve) \
|
||||||
PERF_TALER_MINTDB_CMD_GET_RESERVE_HISTORY("", _label_reserve), \
|
PERF_TALER_MINTDB_INIT_CMD_GET_RESERVE_HISTORY(_label "reserve_history", \
|
||||||
PERF_TALER_MINTDB_CMD_INSERT_WITHDRAW(_label, _label_dki, _label_reserve),
|
_label_reserve), \
|
||||||
|
PERF_TALER_MINTDB_INIT_CMD_INSERT_WITHDRAW(_label "insert withdraw", \
|
||||||
|
_label_dki, \
|
||||||
|
_label_reserve),
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The /deposit api call
|
||||||
|
*
|
||||||
|
* @param _label the label of the command
|
||||||
|
* @param _label_coin the coin used for the deposit
|
||||||
|
*/
|
||||||
|
#define PERF_TALER_MINTDB_INIT_CMD_deposit(_label, _label_coin) \
|
||||||
|
PERF_TALER_MINTDB_INIT_CMD_GET_COIN_TRANSACTION (_label "coin history", \
|
||||||
|
_label_coin), \
|
||||||
|
PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT (_label "deposit", \
|
||||||
|
_label_coin),
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -570,12 +601,12 @@ enum PERF_TALER_MINTDB_CMD_Name
|
|||||||
/**
|
/**
|
||||||
* Insert refresh commit coin
|
* Insert refresh commit coin
|
||||||
*/
|
*/
|
||||||
PERF_TALER_MINTDB_CMD_INSERT_COMMIT_COIN,
|
PERF_TALER_MINTDB_CMD_INSERT_REFRESH_COMMIT_COIN,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get refresh commit coin
|
* Get refresh commit coin
|
||||||
*/
|
*/
|
||||||
PERF_TALER_MINTDB_CMD_GET_COMMIT_COIN,
|
PERF_TALER_MINTDB_CMD_GET_REFRESH_COMMIT_COIN,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert refresh commit link
|
* Insert refresh commit link
|
||||||
@ -593,9 +624,20 @@ enum PERF_TALER_MINTDB_CMD_Name
|
|||||||
PERF_TALER_MINTDB_CMD_GET_MELT_COMMITMENT,
|
PERF_TALER_MINTDB_CMD_GET_MELT_COMMITMENT,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Insert a new coin into the database after a melt operation
|
||||||
*/
|
*/
|
||||||
PERF_TALER_MINTDB_CMD_INSERT_REFRESH_OUT
|
PERF_TALER_MINTDB_CMD_INSERT_REFRESH_OUT,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the link data list of a coin
|
||||||
|
*/
|
||||||
|
PERF_TALER_MINTDB_CMD_GET_LINK_DATA_LIST,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the shared secret and the transfere public key
|
||||||
|
*/
|
||||||
|
PERF_TALER_MINTDB_CMD_GET_TRANSFER
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -876,7 +918,103 @@ union PERF_TALER_MINTDB_CMD_Details
|
|||||||
* The refresh session hash
|
* The refresh session hash
|
||||||
*/
|
*/
|
||||||
const char *label_hash;
|
const char *label_hash;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The new coin denomination
|
||||||
|
*/
|
||||||
|
const char *label_denom;
|
||||||
} insert_refresh_order;
|
} insert_refresh_order;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data requiered for the #PERF_TALER_MINTDB_CMD_GET_REFRESH_ORDER command
|
||||||
|
*/
|
||||||
|
struct PERF_TALER_MINTDB_CMD_getRefreshOrderDetails
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The session hash
|
||||||
|
*/
|
||||||
|
const char *label_hash;
|
||||||
|
|
||||||
|
} get_refresh_order;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data requiered for the #PERF_TALER_MINTDB_CMD_INSERT_REFRESH_COMMIT_COIN command
|
||||||
|
*/
|
||||||
|
struct PERF_TALER_MINTDB_CMD_insertRefreshCommitCoinDetails
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The refresh session hash
|
||||||
|
*/
|
||||||
|
const char *label_hash;
|
||||||
|
} insert_refresh_commit_coin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data requiered for the #PERF_TALER_MINTDB_CMD_INSERT_REFRESH_COMMIT_LINK command
|
||||||
|
*/
|
||||||
|
struct PERF_TALER_MINTDB_CMD_insertRefreshCommitLinkDetails
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The refresh session hash
|
||||||
|
*/
|
||||||
|
const char *label_hash;
|
||||||
|
|
||||||
|
} insert_refresh_commit_link;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data requiered by the #PERF_TALER_MINTDB_CMD_GET_REFRESH_COMMIT_LINK command
|
||||||
|
*/
|
||||||
|
struct PERF_TALER_MINTB_CMD_getRefreshCommitLinkDetails
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The refresh session hash
|
||||||
|
*/
|
||||||
|
const char *label_hash;
|
||||||
|
} get_refresh_commit_link;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data requiered for the #PERF_TALER_MINTDB_CMD_GET_MELT_COMMITMENT command
|
||||||
|
*/
|
||||||
|
struct PERF_TALER_MINTDB_CMD_getMeltCommitmentDaetails
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The refresh session hash
|
||||||
|
*/
|
||||||
|
const char *label_hash;
|
||||||
|
} get_melt_commitment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data requiered by the #PERF_TALER_MINTDB_CMD_INSERT_REFRESH_OUT command
|
||||||
|
*/
|
||||||
|
struct PERF_TALER_MINTDB_CMD_insertRefreshOutDetails
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The refresh session hash
|
||||||
|
*/
|
||||||
|
const char *label_hash;
|
||||||
|
} insert_refresh_out;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data requiered by the #PERF_TALER_MINTDB_CMD_GET_LINK_DATA_LIST command
|
||||||
|
*/
|
||||||
|
struct PERF_TALER_MINTDB_CMD_getLinkDataListDetails
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The refresh session hash
|
||||||
|
*/
|
||||||
|
const char *label_hash;
|
||||||
|
} get_link_datat_list;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data requiered by the #PERF_TALER_MINTDB_CMD_GET_TRANSFER command
|
||||||
|
*/
|
||||||
|
struct PERF_TALER_MINTDB_CMD_getTransferDetails
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The refresh session hash
|
||||||
|
*/
|
||||||
|
const char *label_hash;
|
||||||
|
} get_transfer;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -908,6 +1046,7 @@ struct PERF_TALER_MINTDB_Cmd
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Run a benchmark
|
||||||
*
|
*
|
||||||
* @param benchmark_name the name of the benchmark, displayed in the logs
|
* @param benchmark_name the name of the benchmark, displayed in the logs
|
||||||
* @param configuration_file path to the taler configuration file to use
|
* @param configuration_file path to the taler configuration file to use
|
||||||
|
Loading…
Reference in New Issue
Block a user