major rename-fest for more constent symbol names
This commit is contained in:
parent
7730a08349
commit
eae1896a4b
@ -1,6 +1,6 @@
|
|||||||
[mint]
|
[mint]
|
||||||
db = postgres:///taler
|
db = postgres:///taler
|
||||||
port = 4241
|
port = 4241
|
||||||
master_pub = ...
|
TMH_master_public_key = ...
|
||||||
refresh_security_parameter = 3
|
refresh_security_parameter = 3
|
||||||
|
|
||||||
|
@ -43,13 +43,17 @@ Naming conventions:
|
|||||||
+ must start with TALER_[SUBSYSTEMNAME]_ where SUBSYSTEMNAME
|
+ must start with TALER_[SUBSYSTEMNAME]_ where SUBSYSTEMNAME
|
||||||
MUST match the subdirectory of src/ in which the symbol is defined
|
MUST match the subdirectory of src/ in which the symbol is defined
|
||||||
+ from libtalerutil start just with TALER_, without subsystemname
|
+ from libtalerutil start just with TALER_, without subsystemname
|
||||||
|
+ if scope is ONE binary and symbols are not in a shared library,
|
||||||
|
use binary-specific prefix (such as TMH = taler-mint-httpd) for
|
||||||
|
globals, possibly followed by the subsystem (TMH_DB_xxx).
|
||||||
|
|
||||||
* structs:
|
* structs:
|
||||||
+ structs that are 'packed' and do not contain pointers and are
|
+ structs that are 'packed' and do not contain pointers and are
|
||||||
thus suitable for hashing or similar operations are distinguished
|
thus suitable for hashing or similar operations are distinguished
|
||||||
by adding a "P" at the end of the name. (NEW) Note that this
|
by adding a "P" at the end of the name. (NEW) Note that this
|
||||||
convention does not hold for the GNUnet-structs (yet).
|
convention does not hold for the GNUnet-structs (yet).
|
||||||
|
+ structs that are used with a purpose for signatures, additionally
|
||||||
|
get an "S" at the end of the name.
|
||||||
|
|
||||||
* private (library-internal) symbols (including structs and macros)
|
* private (library-internal) symbols (including structs and macros)
|
||||||
+ must not start with TALER_ or any other prefix
|
+ must not start with TALER_ or any other prefix
|
||||||
|
@ -8,4 +8,6 @@ talerinclude_HEADERS = \
|
|||||||
taler_json_lib.h \
|
taler_json_lib.h \
|
||||||
taler_util.h \
|
taler_util.h \
|
||||||
taler_mint_service.h \
|
taler_mint_service.h \
|
||||||
|
taler_mintdb_plugin.h \
|
||||||
|
taler_pq_lib.h \
|
||||||
taler_signatures.h
|
taler_signatures.h
|
||||||
|
@ -32,7 +32,7 @@ GNUNET_NETWORK_STRUCT_BEGIN
|
|||||||
/**
|
/**
|
||||||
* Type of public keys for Taler reserves.
|
* Type of public keys for Taler reserves.
|
||||||
*/
|
*/
|
||||||
struct TALER_ReservePublicKey
|
struct TALER_ReservePublicKeyP
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Taler uses EdDSA for reserves.
|
* Taler uses EdDSA for reserves.
|
||||||
@ -44,7 +44,7 @@ struct TALER_ReservePublicKey
|
|||||||
/**
|
/**
|
||||||
* Type of private keys for Taler reserves.
|
* Type of private keys for Taler reserves.
|
||||||
*/
|
*/
|
||||||
struct TALER_ReservePrivateKey
|
struct TALER_ReservePrivateKeyP
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Taler uses EdDSA for reserves.
|
* Taler uses EdDSA for reserves.
|
||||||
@ -56,7 +56,7 @@ struct TALER_ReservePrivateKey
|
|||||||
/**
|
/**
|
||||||
* Type of signatures used with Taler reserves.
|
* Type of signatures used with Taler reserves.
|
||||||
*/
|
*/
|
||||||
struct TALER_ReserveSignature
|
struct TALER_ReserveSignatureP
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Taler uses EdDSA for reserves.
|
* Taler uses EdDSA for reserves.
|
||||||
@ -70,7 +70,7 @@ struct TALER_ReserveSignature
|
|||||||
* Merchants can issue refunds using the corresponding
|
* Merchants can issue refunds using the corresponding
|
||||||
* private key.
|
* private key.
|
||||||
*/
|
*/
|
||||||
struct TALER_MerchantPublicKey
|
struct TALER_MerchantPublicKeyP
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Taler uses EdDSA for merchants.
|
* Taler uses EdDSA for merchants.
|
||||||
@ -84,7 +84,7 @@ struct TALER_MerchantPublicKey
|
|||||||
* Merchants can issue refunds using the corresponding
|
* Merchants can issue refunds using the corresponding
|
||||||
* private key.
|
* private key.
|
||||||
*/
|
*/
|
||||||
struct TALER_MerchantPrivateKey
|
struct TALER_MerchantPrivateKeyP
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Taler uses EdDSA for merchants.
|
* Taler uses EdDSA for merchants.
|
||||||
@ -97,7 +97,7 @@ struct TALER_MerchantPrivateKey
|
|||||||
* Type of transfer public keys used during refresh
|
* Type of transfer public keys used during refresh
|
||||||
* operations.
|
* operations.
|
||||||
*/
|
*/
|
||||||
struct TALER_TransferPublicKey
|
struct TALER_TransferPublicKeyP
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Taler uses ECDSA for transfer keys.
|
* Taler uses ECDSA for transfer keys.
|
||||||
@ -111,7 +111,7 @@ struct TALER_TransferPublicKey
|
|||||||
* Type of transfer public keys used during refresh
|
* Type of transfer public keys used during refresh
|
||||||
* operations.
|
* operations.
|
||||||
*/
|
*/
|
||||||
struct TALER_TransferPrivateKey
|
struct TALER_TransferPrivateKeyP
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Taler uses ECDSA for melting session keys.
|
* Taler uses ECDSA for melting session keys.
|
||||||
@ -125,7 +125,7 @@ struct TALER_TransferPrivateKey
|
|||||||
* Type of online public keys used by the mint to sign
|
* Type of online public keys used by the mint to sign
|
||||||
* messages.
|
* messages.
|
||||||
*/
|
*/
|
||||||
struct TALER_MintPublicKey
|
struct TALER_MintPublicKeyP
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Taler uses EdDSA for online mint message signing.
|
* Taler uses EdDSA for online mint message signing.
|
||||||
@ -138,7 +138,7 @@ struct TALER_MintPublicKey
|
|||||||
* Type of online public keys used by the mint to
|
* Type of online public keys used by the mint to
|
||||||
* sign messages.
|
* sign messages.
|
||||||
*/
|
*/
|
||||||
struct TALER_MintPrivateKey
|
struct TALER_MintPrivateKeyP
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Taler uses EdDSA for online signatures sessions.
|
* Taler uses EdDSA for online signatures sessions.
|
||||||
@ -150,7 +150,7 @@ struct TALER_MintPrivateKey
|
|||||||
/**
|
/**
|
||||||
* Type of signatures used by the mint to sign messages online.
|
* Type of signatures used by the mint to sign messages online.
|
||||||
*/
|
*/
|
||||||
struct TALER_MintSignature
|
struct TALER_MintSignatureP
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Taler uses EdDSA for online signatures sessions.
|
* Taler uses EdDSA for online signatures sessions.
|
||||||
@ -162,7 +162,7 @@ struct TALER_MintSignature
|
|||||||
/**
|
/**
|
||||||
* Type of the offline master public key used by the mint.
|
* Type of the offline master public key used by the mint.
|
||||||
*/
|
*/
|
||||||
struct TALER_MasterPublicKey
|
struct TALER_MasterPublicKeyP
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Taler uses EdDSA for the long-term offline master key.
|
* Taler uses EdDSA for the long-term offline master key.
|
||||||
@ -174,7 +174,7 @@ struct TALER_MasterPublicKey
|
|||||||
/**
|
/**
|
||||||
* Type of the offline master public keys used by the mint.
|
* Type of the offline master public keys used by the mint.
|
||||||
*/
|
*/
|
||||||
struct TALER_MasterPrivateKey
|
struct TALER_MasterPrivateKeyP
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Taler uses EdDSA for the long-term offline master key.
|
* Taler uses EdDSA for the long-term offline master key.
|
||||||
@ -186,7 +186,7 @@ struct TALER_MasterPrivateKey
|
|||||||
/**
|
/**
|
||||||
* Type of signatures by the offline master public key used by the mint.
|
* Type of signatures by the offline master public key used by the mint.
|
||||||
*/
|
*/
|
||||||
struct TALER_MasterSignature
|
struct TALER_MasterSignatureP
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Taler uses EdDSA for the long-term offline master key.
|
* Taler uses EdDSA for the long-term offline master key.
|
||||||
@ -199,7 +199,7 @@ struct TALER_MasterSignature
|
|||||||
/**
|
/**
|
||||||
* Type of public keys for Taler coins.
|
* Type of public keys for Taler coins.
|
||||||
*/
|
*/
|
||||||
struct TALER_CoinSpendPublicKey
|
union TALER_CoinSpendPublicKeyP
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Taler uses ECDSA for coins.
|
* Taler uses ECDSA for coins.
|
||||||
@ -211,7 +211,7 @@ struct TALER_CoinSpendPublicKey
|
|||||||
/**
|
/**
|
||||||
* Type of private keys for Taler coins.
|
* Type of private keys for Taler coins.
|
||||||
*/
|
*/
|
||||||
struct TALER_CoinSpendPrivateKey
|
union TALER_CoinSpendPrivateKeyP
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Taler uses ECDSA for coins.
|
* Taler uses ECDSA for coins.
|
||||||
@ -223,7 +223,7 @@ struct TALER_CoinSpendPrivateKey
|
|||||||
/**
|
/**
|
||||||
* Type of signatures made with Taler coins.
|
* Type of signatures made with Taler coins.
|
||||||
*/
|
*/
|
||||||
struct TALER_CoinSpendSignature
|
union TALER_CoinSpendSignatureP
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Taler uses ECDSA for coins.
|
* Taler uses ECDSA for coins.
|
||||||
@ -294,7 +294,7 @@ struct TALER_CoinPublicInfo
|
|||||||
/**
|
/**
|
||||||
* The coin's public key.
|
* The coin's public key.
|
||||||
*/
|
*/
|
||||||
struct TALER_CoinSpendPublicKey coin_pub;
|
union TALER_CoinSpendPublicKeyP coin_pub;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public key representing the denomination of the coin
|
* Public key representing the denomination of the coin
|
||||||
@ -331,10 +331,10 @@ GNUNET_NETWORK_STRUCT_BEGIN
|
|||||||
/**
|
/**
|
||||||
* Secret used to decrypt the key to decrypt link secrets.
|
* Secret used to decrypt the key to decrypt link secrets.
|
||||||
*/
|
*/
|
||||||
struct TALER_TransferSecret
|
struct TALER_TransferSecretP
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Secret used to encrypt/decrypt the `struct TALER_LinkSecret`.
|
* Secret used to encrypt/decrypt the `struct TALER_LinkSecretP`.
|
||||||
* Must be (currently) a hash as this is what
|
* Must be (currently) a hash as this is what
|
||||||
* #GNUNET_CRYPTO_ecc_ecdh() returns to us.
|
* #GNUNET_CRYPTO_ecc_ecdh() returns to us.
|
||||||
*/
|
*/
|
||||||
@ -345,7 +345,7 @@ struct TALER_TransferSecret
|
|||||||
/**
|
/**
|
||||||
* Secret used to decrypt refresh links.
|
* Secret used to decrypt refresh links.
|
||||||
*/
|
*/
|
||||||
struct TALER_LinkSecret
|
struct TALER_LinkSecretP
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Secret used to decrypt the refresh link data.
|
* Secret used to decrypt the refresh link data.
|
||||||
@ -357,25 +357,25 @@ struct TALER_LinkSecret
|
|||||||
/**
|
/**
|
||||||
* Encrypted secret used to decrypt refresh links.
|
* Encrypted secret used to decrypt refresh links.
|
||||||
*/
|
*/
|
||||||
struct TALER_EncryptedLinkSecret
|
struct TALER_EncryptedLinkSecretP
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Encrypted secret, must be the given size!
|
* Encrypted secret, must be the given size!
|
||||||
*/
|
*/
|
||||||
char enc[sizeof (struct TALER_LinkSecret)];
|
char enc[sizeof (struct TALER_LinkSecretP)];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Representation of an refresh link in cleartext.
|
* Representation of an refresh link in cleartext.
|
||||||
*/
|
*/
|
||||||
struct TALER_RefreshLinkDecrypted
|
struct TALER_RefreshLinkDecryptedP
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private key of the coin.
|
* Private key of the coin.
|
||||||
*/
|
*/
|
||||||
struct TALER_CoinSpendPrivateKey coin_priv;
|
union TALER_CoinSpendPrivateKeyP coin_priv;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blinding key.
|
* Blinding key.
|
||||||
@ -408,7 +408,7 @@ struct TALER_RefreshLinkEncrypted
|
|||||||
/**
|
/**
|
||||||
* Encrypted private key of the coin.
|
* Encrypted private key of the coin.
|
||||||
*/
|
*/
|
||||||
char coin_priv_enc[sizeof (struct TALER_CoinSpendPrivateKey)];
|
char coin_priv_enc[sizeof (union TALER_CoinSpendPrivateKeyP)];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -423,9 +423,9 @@ struct TALER_RefreshLinkEncrypted
|
|||||||
* @return #GNUNET_OK on success
|
* @return #GNUNET_OK on success
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_transfer_decrypt (const struct TALER_EncryptedLinkSecret *secret_enc,
|
TALER_transfer_decrypt (const struct TALER_EncryptedLinkSecretP *secret_enc,
|
||||||
const struct TALER_TransferSecret *trans_sec,
|
const struct TALER_TransferSecretP *trans_sec,
|
||||||
struct TALER_LinkSecret *secret);
|
struct TALER_LinkSecretP *secret);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -438,9 +438,9 @@ TALER_transfer_decrypt (const struct TALER_EncryptedLinkSecret *secret_enc,
|
|||||||
* @return #GNUNET_OK on success
|
* @return #GNUNET_OK on success
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_transfer_encrypt (const struct TALER_LinkSecret *secret,
|
TALER_transfer_encrypt (const struct TALER_LinkSecretP *secret,
|
||||||
const struct TALER_TransferSecret *trans_sec,
|
const struct TALER_TransferSecretP *trans_sec,
|
||||||
struct TALER_EncryptedLinkSecret *secret_enc);
|
struct TALER_EncryptedLinkSecretP *secret_enc);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -450,9 +450,9 @@ TALER_transfer_encrypt (const struct TALER_LinkSecret *secret,
|
|||||||
* @param secret shared secret to use for decryption
|
* @param secret shared secret to use for decryption
|
||||||
* @return NULL on error
|
* @return NULL on error
|
||||||
*/
|
*/
|
||||||
struct TALER_RefreshLinkDecrypted *
|
struct TALER_RefreshLinkDecryptedP *
|
||||||
TALER_refresh_decrypt (const struct TALER_RefreshLinkEncrypted *input,
|
TALER_refresh_decrypt (const struct TALER_RefreshLinkEncrypted *input,
|
||||||
const struct TALER_LinkSecret *secret);
|
const struct TALER_LinkSecretP *secret);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -463,8 +463,8 @@ TALER_refresh_decrypt (const struct TALER_RefreshLinkEncrypted *input,
|
|||||||
* @return NULL on error (should never happen)
|
* @return NULL on error (should never happen)
|
||||||
*/
|
*/
|
||||||
struct TALER_RefreshLinkEncrypted *
|
struct TALER_RefreshLinkEncrypted *
|
||||||
TALER_refresh_encrypt (const struct TALER_RefreshLinkDecrypted *input,
|
TALER_refresh_encrypt (const struct TALER_RefreshLinkDecryptedP *input,
|
||||||
const struct TALER_LinkSecret *secret);
|
const struct TALER_LinkSecretP *secret);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,15 +18,15 @@
|
|||||||
* @brief helper functions for JSON processing using libjansson
|
* @brief helper functions for JSON processing using libjansson
|
||||||
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
|
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
|
||||||
*/
|
*/
|
||||||
#ifndef TALER_JSON_LIB_H_
|
#ifndef TALER_json_LIB_H_
|
||||||
#define TALER_JSON_LIB_H_
|
#define TALER_json_LIB_H_
|
||||||
|
|
||||||
#include <jansson.h>
|
#include <jansson.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print JSON parsing related error information
|
* Print JSON parsing related error information
|
||||||
*/
|
*/
|
||||||
#define TALER_JSON_warn(error) \
|
#define TALER_json_warn(error) \
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, \
|
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, \
|
||||||
"JSON parsing failed at %s:%u: %s (%s)\n", \
|
"JSON parsing failed at %s:%u: %s (%s)\n", \
|
||||||
__FILE__, __LINE__, error.text, error.source)
|
__FILE__, __LINE__, error.text, error.source)
|
||||||
@ -39,7 +39,7 @@
|
|||||||
* @return a json object describing the amount
|
* @return a json object describing the amount
|
||||||
*/
|
*/
|
||||||
json_t *
|
json_t *
|
||||||
TALER_JSON_from_amount (const struct TALER_Amount *amount);
|
TALER_json_from_amount (const struct TALER_Amount *amount);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -49,7 +49,7 @@ TALER_JSON_from_amount (const struct TALER_Amount *amount);
|
|||||||
* @return a json string with the timestamp in @a stamp
|
* @return a json string with the timestamp in @a stamp
|
||||||
*/
|
*/
|
||||||
json_t *
|
json_t *
|
||||||
TALER_JSON_from_abs (struct GNUNET_TIME_Absolute stamp);
|
TALER_json_from_abs (struct GNUNET_TIME_Absolute stamp);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,7 +60,7 @@ TALER_JSON_from_abs (struct GNUNET_TIME_Absolute stamp);
|
|||||||
* @return the JSON reporesentation of the signature with purpose
|
* @return the JSON reporesentation of the signature with purpose
|
||||||
*/
|
*/
|
||||||
json_t *
|
json_t *
|
||||||
TALER_JSON_from_eddsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
|
TALER_json_from_eddsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
|
||||||
const struct GNUNET_CRYPTO_EddsaSignature *signature);
|
const struct GNUNET_CRYPTO_EddsaSignature *signature);
|
||||||
|
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ TALER_JSON_from_eddsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpo
|
|||||||
* @return the JSON reporesentation of the signature with purpose
|
* @return the JSON reporesentation of the signature with purpose
|
||||||
*/
|
*/
|
||||||
json_t *
|
json_t *
|
||||||
TALER_JSON_from_ecdsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
|
TALER_json_from_ecdsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
|
||||||
const struct GNUNET_CRYPTO_EcdsaSignature *signature);
|
const struct GNUNET_CRYPTO_EcdsaSignature *signature);
|
||||||
|
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ TALER_JSON_from_ecdsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpo
|
|||||||
* @return corresponding JSON encoding
|
* @return corresponding JSON encoding
|
||||||
*/
|
*/
|
||||||
json_t *
|
json_t *
|
||||||
TALER_JSON_from_rsa_public_key (struct GNUNET_CRYPTO_rsa_PublicKey *pk);
|
TALER_json_from_rsa_public_key (struct GNUNET_CRYPTO_rsa_PublicKey *pk);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -93,7 +93,7 @@ TALER_JSON_from_rsa_public_key (struct GNUNET_CRYPTO_rsa_PublicKey *pk);
|
|||||||
* @return corresponding JSON encoding
|
* @return corresponding JSON encoding
|
||||||
*/
|
*/
|
||||||
json_t *
|
json_t *
|
||||||
TALER_JSON_from_rsa_signature (struct GNUNET_CRYPTO_rsa_Signature *sig);
|
TALER_json_from_rsa_signature (struct GNUNET_CRYPTO_rsa_Signature *sig);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,7 +105,7 @@ TALER_JSON_from_rsa_signature (struct GNUNET_CRYPTO_rsa_Signature *sig);
|
|||||||
* @return json string that encodes @a data
|
* @return json string that encodes @a data
|
||||||
*/
|
*/
|
||||||
json_t *
|
json_t *
|
||||||
TALER_JSON_from_data (const void *data, size_t size);
|
TALER_json_from_data (const void *data, size_t size);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,7 +116,7 @@ TALER_JSON_from_data (const void *data, size_t size);
|
|||||||
* @return json string that encodes @a hc
|
* @return json string that encodes @a hc
|
||||||
*/
|
*/
|
||||||
json_t *
|
json_t *
|
||||||
TALER_JSON_from_hash (const struct GNUNET_HashCode *hc);
|
TALER_json_from_hash (const struct GNUNET_HashCode *hc);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -127,7 +127,7 @@ TALER_JSON_from_hash (const struct GNUNET_HashCode *hc);
|
|||||||
* @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
|
* @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_JSON_to_amount (json_t *json,
|
TALER_json_to_amount (json_t *json,
|
||||||
struct TALER_Amount *r_amount);
|
struct TALER_Amount *r_amount);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -138,7 +138,7 @@ TALER_JSON_to_amount (json_t *json,
|
|||||||
* @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
|
* @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_JSON_to_abs (json_t *json,
|
TALER_json_to_abs (json_t *json,
|
||||||
struct GNUNET_TIME_Absolute *r_abs);
|
struct GNUNET_TIME_Absolute *r_abs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,7 +150,7 @@ TALER_JSON_to_abs (json_t *json,
|
|||||||
* @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
|
* @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_JSON_to_data (json_t *json,
|
TALER_json_to_data (json_t *json,
|
||||||
void *out,
|
void *out,
|
||||||
size_t out_size);
|
size_t out_size);
|
||||||
|
|
||||||
@ -162,10 +162,10 @@ TALER_JSON_to_data (json_t *json,
|
|||||||
* @return #GNUNET_YES if correctly formatted; #GNUNET_NO if not
|
* @return #GNUNET_YES if correctly formatted; #GNUNET_NO if not
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_JSON_validate_wireformat (const char *type,
|
TALER_json_validate_wireformat (const char *type,
|
||||||
const json_t *wire);
|
const json_t *wire);
|
||||||
|
|
||||||
|
|
||||||
#endif /* TALER_JSON_LIB_H_ */
|
#endif /* TALER_json_LIB_H_ */
|
||||||
|
|
||||||
/* End of taler_json_lib.h */
|
/* End of taler_json_lib.h */
|
||||||
|
@ -42,7 +42,7 @@ struct TALER_MINT_SigningPublicKey
|
|||||||
/**
|
/**
|
||||||
* The signing public key
|
* The signing public key
|
||||||
*/
|
*/
|
||||||
struct TALER_MintPublicKey key;
|
struct TALER_MintPublicKeyP key;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validity start time
|
* Validity start time
|
||||||
@ -140,7 +140,7 @@ struct TALER_MINT_Handle *
|
|||||||
TALER_MINT_connect (struct TALER_MINT_Context *ctx,
|
TALER_MINT_connect (struct TALER_MINT_Context *ctx,
|
||||||
const char *hostname,
|
const char *hostname,
|
||||||
uint16_t port,
|
uint16_t port,
|
||||||
const struct TALER_MasterPublicKey *master_key);
|
const struct TALER_MasterPublicKeyP *master_key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnect from the mint
|
* Disconnect from the mint
|
||||||
@ -287,7 +287,7 @@ TALER_MINT_deposit_submit_json_ (struct TALER_MINT_Handle *mint,
|
|||||||
struct TALER_BLIND_Signature *ubsig,
|
struct TALER_BLIND_Signature *ubsig,
|
||||||
uint64_t transaction_id,
|
uint64_t transaction_id,
|
||||||
struct TALER_Amount *amount,
|
struct TALER_Amount *amount,
|
||||||
const struct TALER_MerchantPublicKey *merchant_pub,
|
const struct TALER_MerchantPublicKeyP *merchant_pub,
|
||||||
const struct GNUNET_HashCode *h_contract,
|
const struct GNUNET_HashCode *h_contract,
|
||||||
const struct GNUNET_HashCode *h_wire,
|
const struct GNUNET_HashCode *h_wire,
|
||||||
const struct TALER_CoinSignature *csig,
|
const struct TALER_CoinSignature *csig,
|
||||||
|
@ -35,7 +35,7 @@ struct BankTransfer
|
|||||||
/**
|
/**
|
||||||
* Public key of the reserve that was filled.
|
* Public key of the reserve that was filled.
|
||||||
*/
|
*/
|
||||||
struct TALER_ReservePublicKey reserve_pub;
|
struct TALER_ReservePublicKeyP reserve_pub;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Amount that was transferred to the mint.
|
* Amount that was transferred to the mint.
|
||||||
@ -58,7 +58,7 @@ struct Reserve
|
|||||||
/**
|
/**
|
||||||
* The reserve's public key. This uniquely identifies the reserve
|
* The reserve's public key. This uniquely identifies the reserve
|
||||||
*/
|
*/
|
||||||
struct TALER_ReservePublicKey pub;
|
struct TALER_ReservePublicKeyP pub;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The balance amount existing in the reserve
|
* The balance amount existing in the reserve
|
||||||
@ -96,7 +96,7 @@ struct CollectableBlindcoin
|
|||||||
/**
|
/**
|
||||||
* Public key of the reserve that was drained.
|
* Public key of the reserve that was drained.
|
||||||
*/
|
*/
|
||||||
struct TALER_ReservePublicKey reserve_pub;
|
struct TALER_ReservePublicKeyP reserve_pub;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hash over the blinded message, needed to verify
|
* Hash over the blinded message, needed to verify
|
||||||
@ -108,7 +108,7 @@ struct CollectableBlindcoin
|
|||||||
* Signature confirming the withdrawl, matching @e reserve_pub,
|
* Signature confirming the withdrawl, matching @e reserve_pub,
|
||||||
* @e denom_pub and @e h_coin_envelope.
|
* @e denom_pub and @e h_coin_envelope.
|
||||||
*/
|
*/
|
||||||
struct TALER_ReserveSignature reserve_sig;
|
struct TALER_ReserveSignatureP reserve_sig;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -186,13 +186,13 @@ struct Deposit
|
|||||||
* by @e h_wire in relation to the contract identified
|
* by @e h_wire in relation to the contract identified
|
||||||
* by @e h_contract.
|
* by @e h_contract.
|
||||||
*/
|
*/
|
||||||
struct TALER_CoinSpendSignature csig;
|
union TALER_CoinSpendSignatureP csig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public key of the merchant. Enables later identification
|
* Public key of the merchant. Enables later identification
|
||||||
* of the merchant in case of a need to rollback transactions.
|
* of the merchant in case of a need to rollback transactions.
|
||||||
*/
|
*/
|
||||||
struct TALER_MerchantPublicKey merchant_pub;
|
struct TALER_MerchantPublicKeyP merchant_pub;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hash over the contract between merchant and customer
|
* Hash over the contract between merchant and customer
|
||||||
@ -247,7 +247,7 @@ struct RefreshSession
|
|||||||
uint16_t num_newcoins;
|
uint16_t num_newcoins;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index (smaller #KAPPA) which the mint has chosen to not
|
* Index (smaller #TALER_CNC_KAPPA) which the mint has chosen to not
|
||||||
* have revealed during cut and choose.
|
* have revealed during cut and choose.
|
||||||
*/
|
*/
|
||||||
uint16_t noreveal_index;
|
uint16_t noreveal_index;
|
||||||
@ -268,7 +268,7 @@ struct RefreshMelt
|
|||||||
/**
|
/**
|
||||||
* Signature over the melting operation.
|
* Signature over the melting operation.
|
||||||
*/
|
*/
|
||||||
struct TALER_CoinSpendSignature coin_sig;
|
union TALER_CoinSpendSignatureP coin_sig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hash of the refresh session this coin is melted into.
|
* Hash of the refresh session this coin is melted into.
|
||||||
@ -290,7 +290,7 @@ struct RefreshMelt
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* We have as many `struct RefreshCommitCoin` as there are new
|
* We have as many `struct RefreshCommitCoin` as there are new
|
||||||
* coins being created by the refresh (for each of the #KAPPA
|
* coins being created by the refresh (for each of the #TALER_CNC_KAPPA
|
||||||
* sets). These are the coins we ask the mint to sign if the
|
* sets). These are the coins we ask the mint to sign if the
|
||||||
* respective set is selected.
|
* respective set is selected.
|
||||||
*/
|
*/
|
||||||
@ -331,12 +331,12 @@ struct RefreshCommitLink
|
|||||||
* in combintation with the corresponding private key of the
|
* in combintation with the corresponding private key of the
|
||||||
* coin.
|
* coin.
|
||||||
*/
|
*/
|
||||||
struct TALER_TransferPublicKey transfer_pub;
|
struct TALER_TransferPublicKeyP transfer_pub;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypted shared secret to decrypt the link.
|
* Encrypted shared secret to decrypt the link.
|
||||||
*/
|
*/
|
||||||
struct TALER_EncryptedLinkSecret shared_secret_enc;
|
struct TALER_EncryptedLinkSecretP shared_secret_enc;
|
||||||
};
|
};
|
||||||
|
|
||||||
GNUNET_NETWORK_STRUCT_END
|
GNUNET_NETWORK_STRUCT_END
|
||||||
@ -384,7 +384,7 @@ struct Lock
|
|||||||
/**
|
/**
|
||||||
* Signature over the locking operation.
|
* Signature over the locking operation.
|
||||||
*/
|
*/
|
||||||
struct TALER_CoinSpendSignature coin_sig;
|
union TALER_CoinSpendSignatureP coin_sig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How much value is being locked?
|
* How much value is being locked?
|
||||||
@ -650,7 +650,7 @@ struct TALER_MINTDB_Plugin
|
|||||||
struct ReserveHistory *
|
struct ReserveHistory *
|
||||||
(*get_reserve_history) (void *cls,
|
(*get_reserve_history) (void *cls,
|
||||||
struct TALER_MINTDB_Session *sesssion,
|
struct TALER_MINTDB_Session *sesssion,
|
||||||
const struct TALER_ReservePublicKey *reserve_pub);
|
const struct TALER_ReservePublicKeyP *reserve_pub);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -814,7 +814,7 @@ struct TALER_MINTDB_Plugin
|
|||||||
* @param cls the @e cls of this struct with the plugin-specific state
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
* @param sesssion database connection to use
|
* @param sesssion database connection to use
|
||||||
* @param session_hash hash to identify refresh session
|
* @param session_hash hash to identify refresh session
|
||||||
* @param i set index (1st dimension), relating to #KAPPA
|
* @param i set index (1st dimension), relating to #TALER_CNC_KAPPA
|
||||||
* @param num_newcoins coin index size of the @a commit_coins array
|
* @param num_newcoins coin index size of the @a commit_coins array
|
||||||
* @param commit_coin array of coin commitments to store
|
* @param commit_coin array of coin commitments to store
|
||||||
* @return #GNUNET_OK on success
|
* @return #GNUNET_OK on success
|
||||||
@ -859,7 +859,7 @@ struct TALER_MINTDB_Plugin
|
|||||||
* @param cls the @e cls of this struct with the plugin-specific state
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
* @param sesssion database connection to use
|
* @param sesssion database connection to use
|
||||||
* @param session_hash hash to identify refresh session
|
* @param session_hash hash to identify refresh session
|
||||||
* @param i set index (1st dimension), relating to #KAPPA
|
* @param i set index (1st dimension), relating to #TALER_CNC_KAPPA
|
||||||
* @param num_links size of the @a commit_link array
|
* @param num_links size of the @a commit_link array
|
||||||
* @param commit_links array of link information to store
|
* @param commit_links array of link information to store
|
||||||
* @return #GNUNET_SYSERR on internal error, #GNUNET_OK on success
|
* @return #GNUNET_SYSERR on internal error, #GNUNET_OK on success
|
||||||
@ -928,7 +928,7 @@ struct TALER_MINTDB_Plugin
|
|||||||
struct LinkDataList *
|
struct LinkDataList *
|
||||||
(*get_link_data_list) (void *cls,
|
(*get_link_data_list) (void *cls,
|
||||||
struct TALER_MINTDB_Session *sesssion,
|
struct TALER_MINTDB_Session *sesssion,
|
||||||
const struct TALER_CoinSpendPublicKey *coin_pub);
|
const union TALER_CoinSpendPublicKeyP *coin_pub);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -961,9 +961,9 @@ struct TALER_MINTDB_Plugin
|
|||||||
int
|
int
|
||||||
(*get_transfer) (void *cls,
|
(*get_transfer) (void *cls,
|
||||||
struct TALER_MINTDB_Session *sesssion,
|
struct TALER_MINTDB_Session *sesssion,
|
||||||
const struct TALER_CoinSpendPublicKey *coin_pub,
|
const union TALER_CoinSpendPublicKeyP *coin_pub,
|
||||||
struct TALER_TransferPublicKey *transfer_pub,
|
struct TALER_TransferPublicKeyP *transfer_pub,
|
||||||
struct TALER_EncryptedLinkSecret *shared_secret_enc);
|
struct TALER_EncryptedLinkSecretP *shared_secret_enc);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1009,7 +1009,7 @@ struct TALER_MINTDB_Plugin
|
|||||||
struct TALER_MINT_DB_TransactionList *
|
struct TALER_MINT_DB_TransactionList *
|
||||||
(*get_coin_transactions) (void *cls,
|
(*get_coin_transactions) (void *cls,
|
||||||
struct TALER_MINTDB_Session *sesssion,
|
struct TALER_MINTDB_Session *sesssion,
|
||||||
const struct TALER_CoinSpendPublicKey *coin_pub);
|
const union TALER_CoinSpendPublicKeyP *coin_pub);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
@ -14,15 +14,14 @@
|
|||||||
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
|
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @file pq/db_pq.h
|
* @file pq/taler_pq_lib.h
|
||||||
* @brief helper functions for DB interactions
|
* @brief helper functions for DB interactions
|
||||||
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
|
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
|
||||||
* @author Florian Dold
|
* @author Florian Dold
|
||||||
* @author Christian Grothoff
|
* @author Christian Grothoff
|
||||||
*/
|
*/
|
||||||
|
#ifndef TALER_PQ_LIB_H_
|
||||||
#ifndef TALER_DB_LIB_H_
|
#define TALER_PQ_LIB_H_
|
||||||
#define TALER_DB_LIB_H_
|
|
||||||
|
|
||||||
#include <libpq-fe.h>
|
#include <libpq-fe.h>
|
||||||
#include "taler_util.h"
|
#include "taler_util.h"
|
||||||
@ -30,7 +29,7 @@
|
|||||||
/**
|
/**
|
||||||
* Description of a DB query parameter.
|
* Description of a DB query parameter.
|
||||||
*/
|
*/
|
||||||
struct TALER_DB_QueryParam
|
struct TALER_PQ_QueryParam
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Data or NULL
|
* Data or NULL
|
||||||
@ -52,7 +51,7 @@ struct TALER_DB_QueryParam
|
|||||||
/**
|
/**
|
||||||
* End of query parameter specification.
|
* End of query parameter specification.
|
||||||
*/
|
*/
|
||||||
#define TALER_DB_QUERY_PARAM_END { NULL, 0, 0 }
|
#define TALER_PQ_QUERY_PARAM_END { NULL, 0, 0 }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate fixed-size query parameter with size given explicitly.
|
* Generate fixed-size query parameter with size given explicitly.
|
||||||
@ -60,7 +59,7 @@ struct TALER_DB_QueryParam
|
|||||||
* @param x pointer to the query parameter to pass
|
* @param x pointer to the query parameter to pass
|
||||||
* @param s number of bytes of @a x to use for the query
|
* @param s number of bytes of @a x to use for the query
|
||||||
*/
|
*/
|
||||||
#define TALER_DB_QUERY_PARAM_PTR_SIZED(x, s) { (x), (s), 1 }
|
#define TALER_PQ_QUERY_PARAM_PTR_SIZED(x, s) { (x), (s), 1 }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate fixed-size query parameter with size determined
|
* Generate fixed-size query parameter with size determined
|
||||||
@ -68,13 +67,13 @@ struct TALER_DB_QueryParam
|
|||||||
*
|
*
|
||||||
* @param x pointer to the query parameter to pass.
|
* @param x pointer to the query parameter to pass.
|
||||||
*/
|
*/
|
||||||
#define TALER_DB_QUERY_PARAM_PTR(x) TALER_DB_QUERY_PARAM_PTR_SIZED(x, sizeof (*(x)))
|
#define TALER_PQ_QUERY_PARAM_PTR(x) TALER_PQ_QUERY_PARAM_PTR_SIZED(x, sizeof (*(x)))
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of a DB result cell.
|
* Description of a DB result cell.
|
||||||
*/
|
*/
|
||||||
struct TALER_DB_ResultSpec
|
struct TALER_PQ_ResultSpec
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Destination for the data.
|
* Destination for the data.
|
||||||
@ -104,7 +103,7 @@ struct TALER_DB_ResultSpec
|
|||||||
/**
|
/**
|
||||||
* End of result parameter specification.
|
* End of result parameter specification.
|
||||||
*/
|
*/
|
||||||
#define TALER_DB_RESULT_SPEC_END { NULL, 0, NULL, NULL }
|
#define TALER_PQ_RESULT_SPEC_END { NULL, 0, NULL, NULL }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We expect a fixed-size result, with size given explicitly
|
* We expect a fixed-size result, with size given explicitly
|
||||||
@ -113,7 +112,7 @@ struct TALER_DB_ResultSpec
|
|||||||
* @param dst point to where to store the result
|
* @param dst point to where to store the result
|
||||||
* @param s number of bytes we should use in @a dst
|
* @param s number of bytes we should use in @a dst
|
||||||
*/
|
*/
|
||||||
#define TALER_DB_RESULT_SPEC_SIZED(name, dst, s) { (void *) (dst), (s), (name), NULL }
|
#define TALER_PQ_RESULT_SPEC_SIZED(name, dst, s) { (void *) (dst), (s), (name), NULL }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We expect a fixed-size result, with size determined by the type of `* dst`
|
* We expect a fixed-size result, with size determined by the type of `* dst`
|
||||||
@ -121,7 +120,7 @@ struct TALER_DB_ResultSpec
|
|||||||
* @param name name of the field in the table
|
* @param name name of the field in the table
|
||||||
* @param dst point to where to store the result, type fits expected result size
|
* @param dst point to where to store the result, type fits expected result size
|
||||||
*/
|
*/
|
||||||
#define TALER_DB_RESULT_SPEC(name, dst) TALER_DB_RESULT_SPEC_SIZED(name, dst, sizeof (*(dst)))
|
#define TALER_PQ_RESULT_SPEC(name, dst) TALER_PQ_RESULT_SPEC_SIZED(name, dst, sizeof (*(dst)))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Variable-size result expected.
|
* Variable-size result expected.
|
||||||
@ -130,16 +129,16 @@ struct TALER_DB_ResultSpec
|
|||||||
* @param dst where to store the result (of type void **), to be allocated
|
* @param dst where to store the result (of type void **), to be allocated
|
||||||
* @param sptr pointer to a `size_t` for where to store the size of @a dst
|
* @param sptr pointer to a `size_t` for where to store the size of @a dst
|
||||||
*/
|
*/
|
||||||
#define TALER_DB_RESULT_SPEC_VAR(name, dst, sptr) { (void *) (dst), 0, (name), sptr }
|
#define TALER_PQ_RESULT_SPEC_VAR(name, dst, sptr) { (void *) (dst), 0, (name), sptr }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute a prepared statement.
|
* Execute a prepared statement.
|
||||||
*/
|
*/
|
||||||
PGresult *
|
PGresult *
|
||||||
TALER_DB_exec_prepared (PGconn *db_conn,
|
TALER_PQ_exec_prepared (PGconn *db_conn,
|
||||||
const char *name,
|
const char *name,
|
||||||
const struct TALER_DB_QueryParam *params);
|
const struct TALER_PQ_QueryParam *params);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -153,19 +152,19 @@ TALER_DB_exec_prepared (PGconn *db_conn,
|
|||||||
* #GNUNET_SYSERR if a result was invalid (non-existing field)
|
* #GNUNET_SYSERR if a result was invalid (non-existing field)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_DB_extract_result (PGresult *result,
|
TALER_PQ_extract_result (PGresult *result,
|
||||||
struct TALER_DB_ResultSpec *rs,
|
struct TALER_PQ_ResultSpec *rs,
|
||||||
int row);
|
int row);
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
TALER_DB_field_isnull (PGresult *result,
|
TALER_PQ_field_isnull (PGresult *result,
|
||||||
int row,
|
int row,
|
||||||
const char *fname);
|
const char *fname);
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
TALER_DB_extract_amount_nbo (PGresult *result,
|
TALER_PQ_extract_amount_nbo (PGresult *result,
|
||||||
int row,
|
int row,
|
||||||
const char *val_name,
|
const char *val_name,
|
||||||
const char *frac_name,
|
const char *frac_name,
|
||||||
@ -174,7 +173,7 @@ TALER_DB_extract_amount_nbo (PGresult *result,
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
TALER_DB_extract_amount (PGresult *result,
|
TALER_PQ_extract_amount (PGresult *result,
|
||||||
int row,
|
int row,
|
||||||
const char *val_name,
|
const char *val_name,
|
||||||
const char *frac_name,
|
const char *frac_name,
|
||||||
@ -184,6 +183,6 @@ TALER_DB_extract_amount (PGresult *result,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* TALER_DB_LIB_H_ */
|
#endif /* TALER_PQ_LIB_H_ */
|
||||||
|
|
||||||
/* end of db/db_pq.h */
|
/* end of db/taler_pq_lib.h */
|
@ -32,61 +32,61 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Cut-and-choose size for refreshing. Client looses the gamble (of
|
* Cut-and-choose size for refreshing. Client looses the gamble (of
|
||||||
* unaccountable transfers) with probability 1/KAPPA. Refresh cost
|
* unaccountable transfers) with probability 1/TALER_CNC_KAPPA. Refresh cost
|
||||||
* increases linearly with KAPPA, and 3 is sufficient up to a
|
* increases linearly with TALER_CNC_KAPPA, and 3 is sufficient up to a
|
||||||
* income/sales tax of 66% of total transaction value. As there is
|
* income/sales tax of 66% of total transaction value. As there is
|
||||||
* no good reason to change this security parameter, we declare it
|
* no good reason to change this security parameter, we declare it
|
||||||
* fixed and part of the protocol.
|
* fixed and part of the protocol.
|
||||||
*/
|
*/
|
||||||
#define KAPPA 3
|
#define TALER_CNC_KAPPA 3
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose for signing public keys signed
|
* Purpose for signing public keys signed
|
||||||
* by the mint master key.
|
* by the mint master key.
|
||||||
*/
|
*/
|
||||||
#define TALER_SIGNATURE_MASTER_SIGNKEY 1
|
#define TALER_SIGNATURE_MINT_SIGNING_KEY_VALIDITY 1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose for denomination keys signed
|
* Purpose for denomination keys signed
|
||||||
* by the mint master key.
|
* by the mint master key.
|
||||||
*/
|
*/
|
||||||
#define TALER_SIGNATURE_MASTER_DENOM 2
|
#define TALER_SIGNATURE_MINT_DENOMINATION_KEY_VALIDITY 2
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose for the state of a reserve,
|
* Purpose for the state of a reserve,
|
||||||
* signed by the mint's signing key.
|
* signed by the mint's signing key.
|
||||||
*/
|
*/
|
||||||
#define TALER_SIGNATURE_RESERVE_STATUS 3
|
#define TALER_SIGNATURE_MINT_RESERVE_STATUS 3
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signature where the reserve key
|
* Signature where the reserve key
|
||||||
* confirms a withdraw request.
|
* confirms a withdraw request.
|
||||||
*/
|
*/
|
||||||
#define TALER_SIGNATURE_WITHDRAW 4
|
#define TALER_SIGNATURE_RESERVE_WITHDRAW_REQUEST 4
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signature using a coin key confirming the melting of
|
* Signature using a coin key confirming the melting of
|
||||||
* a coin.
|
* a coin.
|
||||||
*/
|
*/
|
||||||
#define TALER_SIGNATURE_REFRESH_MELT_COIN 5
|
#define TALER_SIGNATURE_COIN_MELT 5
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signature where the mint (current signing key)
|
* Signature where the mint (current signing key)
|
||||||
* confirms the no-reveal index for cut-and-choose and
|
* confirms the no-reveal index for cut-and-choose and
|
||||||
* the validity of the melted coins.
|
* the validity of the melted coins.
|
||||||
*/
|
*/
|
||||||
#define TALER_SIGNATURE_REFRESH_MELT_RESPONSE 6
|
#define TALER_SIGNATURE_MINT_MELT_RESPONSE 6
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signature where the Mint confirms a deposit request.
|
* Signature where the Mint confirms a deposit request.
|
||||||
*/
|
*/
|
||||||
#define TALER_SIGNATURE_MINT_DEPOSIT 7
|
#define TALER_SIGNATURE_COIN_DEPOSIT 7
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signature where the Mint confirms the full /keys response set.
|
* Signature where the Mint confirms the full /keys response set.
|
||||||
*/
|
*/
|
||||||
#define TALER_SIGNATURE_KEYS_SET 8
|
#define TALER_SIGNATURE_MINT_KEY_SET 8
|
||||||
|
|
||||||
|
|
||||||
/***********************/
|
/***********************/
|
||||||
@ -104,11 +104,14 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Signature made by the wallet of a user to confirm a deposit permission
|
* Signature made by the wallet of a user to confirm a deposit permission
|
||||||
|
* FIXME: this is #TALER_SIGNATURE_COIN_DEPOSIT already!
|
||||||
*/
|
*/
|
||||||
#define TALER_SIGNATURE_WALLET_DEPOSIT 201
|
#define TALER_SIGNATURE_WALLET_DEPOSIT 201
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signature made by the wallet of a user to confirm a incremental deposit permission
|
* Signature made by the wallet of a user to confirm a incremental
|
||||||
|
* deposit permission.
|
||||||
|
* FIXME: this MIGHT also be #TALER_SIGNATURE_COIN_DEPOSIT already!
|
||||||
*/
|
*/
|
||||||
#define TALER_SIGNATURE_INCREMENTAL_WALLET_DEPOSIT 202
|
#define TALER_SIGNATURE_INCREMENTAL_WALLET_DEPOSIT 202
|
||||||
|
|
||||||
@ -120,11 +123,11 @@ GNUNET_NETWORK_STRUCT_BEGIN
|
|||||||
* Format used for to generate the signature on a request to withdraw
|
* Format used for to generate the signature on a request to withdraw
|
||||||
* coins from a reserve.
|
* coins from a reserve.
|
||||||
*/
|
*/
|
||||||
struct TALER_WithdrawRequest
|
struct TALER_WithdrawRequestPS
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose must be #TALER_SIGNATURE_WITHDRAW.
|
* Purpose must be #TALER_SIGNATURE_RESERVE_WITHDRAW_REQUEST.
|
||||||
*/
|
*/
|
||||||
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
||||||
|
|
||||||
@ -132,7 +135,7 @@ struct TALER_WithdrawRequest
|
|||||||
* Reserve public key (which reserve to withdraw from). This is
|
* Reserve public key (which reserve to withdraw from). This is
|
||||||
* the public key which must match the signature.
|
* the public key which must match the signature.
|
||||||
*/
|
*/
|
||||||
struct TALER_ReservePublicKey reserve_pub;
|
struct TALER_ReservePublicKeyP reserve_pub;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value of the coin being minted (matching the denomination key)
|
* Value of the coin being minted (matching the denomination key)
|
||||||
@ -159,7 +162,7 @@ struct TALER_WithdrawRequest
|
|||||||
* Format used to generate the signature on a request to deposit
|
* Format used to generate the signature on a request to deposit
|
||||||
* a coin into the account of a merchant.
|
* a coin into the account of a merchant.
|
||||||
*/
|
*/
|
||||||
struct TALER_DepositRequest
|
struct TALER_DepositRequestPS
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Purpose must be #TALER_SIGNATURE_WALLET_DEPOSIT
|
* Purpose must be #TALER_SIGNATURE_WALLET_DEPOSIT
|
||||||
@ -192,7 +195,7 @@ struct TALER_DepositRequest
|
|||||||
/**
|
/**
|
||||||
* The coin's public key.
|
* The coin's public key.
|
||||||
*/
|
*/
|
||||||
struct TALER_CoinSpendPublicKey coin_pub;
|
union TALER_CoinSpendPublicKeyP coin_pub;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -201,10 +204,10 @@ struct TALER_DepositRequest
|
|||||||
* Format used to generate the signature on a confirmation
|
* Format used to generate the signature on a confirmation
|
||||||
* from the mint that a deposit request succeeded.
|
* from the mint that a deposit request succeeded.
|
||||||
*/
|
*/
|
||||||
struct TALER_DepositConfirmation
|
struct TALER_DepositConfirmationPS
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Purpose must be #TALER_SIGNATURE_MINT_DEPOSIT
|
* Purpose must be #TALER_SIGNATURE_COIN_DEPOSIT
|
||||||
*/
|
*/
|
||||||
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
||||||
|
|
||||||
@ -235,12 +238,12 @@ struct TALER_DepositConfirmation
|
|||||||
/**
|
/**
|
||||||
* The coin's public key.
|
* The coin's public key.
|
||||||
*/
|
*/
|
||||||
struct TALER_CoinSpendPublicKey coin_pub;
|
union TALER_CoinSpendPublicKeyP coin_pub;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Merchant's public key.
|
* The Merchant's public key.
|
||||||
*/
|
*/
|
||||||
struct TALER_MerchantPublicKey merchant;
|
struct TALER_MerchantPublicKeyP merchant;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -249,10 +252,10 @@ struct TALER_DepositConfirmation
|
|||||||
* Message signed by a coin to indicate that the coin should
|
* Message signed by a coin to indicate that the coin should
|
||||||
* be melted.
|
* be melted.
|
||||||
*/
|
*/
|
||||||
struct RefreshMeltCoinSignature
|
struct TALER_RefreshMeltCoinAffirmationPS
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Purpose is #TALER_SIGNATURE_REFRESH_MELT_COIN.
|
* Purpose is #TALER_SIGNATURE_COIN_MELT.
|
||||||
*/
|
*/
|
||||||
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
||||||
|
|
||||||
@ -277,7 +280,7 @@ struct RefreshMeltCoinSignature
|
|||||||
/**
|
/**
|
||||||
* The coin's public key.
|
* The coin's public key.
|
||||||
*/
|
*/
|
||||||
struct TALER_CoinSpendPublicKey coin_pub;
|
union TALER_CoinSpendPublicKeyP coin_pub;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -287,10 +290,10 @@ struct RefreshMeltCoinSignature
|
|||||||
* coins were successfully melted. This also commits the mint to a
|
* coins were successfully melted. This also commits the mint to a
|
||||||
* particular index to not be revealed during the refresh.
|
* particular index to not be revealed during the refresh.
|
||||||
*/
|
*/
|
||||||
struct RefreshMeltResponseSignatureBody
|
struct TALER_RefreshMeltConfirmationPS
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Purpose is #TALER_SIGNATURE_REFRESH_MELT_RESPONSE.
|
* Purpose is #TALER_SIGNATURE_MINT_MELT_RESPONSE.
|
||||||
*/
|
*/
|
||||||
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
||||||
|
|
||||||
@ -311,15 +314,15 @@ struct RefreshMeltResponseSignatureBody
|
|||||||
* to sign mint messages other than coins, i.e. to confirm that a
|
* to sign mint messages other than coins, i.e. to confirm that a
|
||||||
* deposit was successful or that a refresh was accepted.
|
* deposit was successful or that a refresh was accepted.
|
||||||
*/
|
*/
|
||||||
struct TALER_MINT_SignKeyIssue
|
struct TALER_MintSigningKeyValidityPS
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Signature over the signing key (by the master key of the mint).
|
* Signature over the signing key (by the master key of the mint).
|
||||||
*/
|
*/
|
||||||
struct TALER_MasterSignature signature;
|
struct TALER_MasterSignatureP signature;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose is #TALER_SIGNATURE_MASTER_SIGNKEY.
|
* Purpose is #TALER_SIGNATURE_MINT_SIGNING_KEY_VALIDITY.
|
||||||
*/
|
*/
|
||||||
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
||||||
|
|
||||||
@ -327,7 +330,7 @@ struct TALER_MINT_SignKeyIssue
|
|||||||
* Master public key of the mint corresponding to @e signature.
|
* Master public key of the mint corresponding to @e signature.
|
||||||
* This is the long-term offline master key of the mint.
|
* This is the long-term offline master key of the mint.
|
||||||
*/
|
*/
|
||||||
struct TALER_MasterPublicKey master_pub;
|
struct TALER_MasterPublicKeyP master_public_key;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When does this signing key begin to be valid?
|
* When does this signing key begin to be valid?
|
||||||
@ -346,7 +349,7 @@ struct TALER_MINT_SignKeyIssue
|
|||||||
* The public online signing key that the mint will use
|
* The public online signing key that the mint will use
|
||||||
* between @e start and @e expire.
|
* between @e start and @e expire.
|
||||||
*/
|
*/
|
||||||
struct TALER_MintPublicKey signkey_pub;
|
struct TALER_MintPublicKeyP signkey_pub;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -355,11 +358,11 @@ struct TALER_MINT_SignKeyIssue
|
|||||||
* to detect cheating mints that give out different sets to
|
* to detect cheating mints that give out different sets to
|
||||||
* different users.
|
* different users.
|
||||||
*/
|
*/
|
||||||
struct TALER_MINT_KeySetSignature
|
struct TALER_MintKeySetPS
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose is #TALER_SIGNATURE_KEYS_SET
|
* Purpose is #TALER_SIGNATURE_MINT_KEY_SET
|
||||||
*/
|
*/
|
||||||
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
||||||
|
|
||||||
@ -379,16 +382,16 @@ struct TALER_MINT_KeySetSignature
|
|||||||
* Information about a denomination key. Denomination keys
|
* Information about a denomination key. Denomination keys
|
||||||
* are used to sign coins of a certain value into existence.
|
* are used to sign coins of a certain value into existence.
|
||||||
*/
|
*/
|
||||||
struct TALER_MINT_DenomKeyIssue
|
struct TALER_DenominationKeyValidityPS
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Signature over this struct to affirm the validity
|
* Signature over this struct to affirm the validity
|
||||||
* of the key.
|
* of the key.
|
||||||
*/
|
*/
|
||||||
struct TALER_MasterSignature signature;
|
struct TALER_MasterSignatureP signature;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purpose is #TALER_SIGNATURE_MASTER_DENOM.
|
* Purpose is #TALER_SIGNATURE_MINT_DENOMINATION_KEY_VALIDITY.
|
||||||
*/
|
*/
|
||||||
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
|
||||||
|
|
||||||
@ -396,7 +399,7 @@ struct TALER_MINT_DenomKeyIssue
|
|||||||
* The long-term offline master key of the mint that was
|
* The long-term offline master key of the mint that was
|
||||||
* used to create @e signature.
|
* used to create @e signature.
|
||||||
*/
|
*/
|
||||||
struct TALER_MasterPublicKey master;
|
struct TALER_MasterPublicKeyP master;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start time of the validity period for this key.
|
* Start time of the validity period for this key.
|
||||||
|
@ -29,13 +29,13 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Define logging functions */
|
/* Define logging functions */
|
||||||
#define LOG_DEBUG(...) \
|
#define TALER_LOG_DEBUG(...) \
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
|
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
|
||||||
|
|
||||||
#define LOG_WARNING(...) \
|
#define TALER_LOG_WARNING(...) \
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, __VA_ARGS__)
|
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, __VA_ARGS__)
|
||||||
|
|
||||||
#define LOG_ERROR(...) \
|
#define TALER_LOG_ERROR(...) \
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, __VA_ARGS__)
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, __VA_ARGS__)
|
||||||
|
|
||||||
|
|
||||||
@ -49,7 +49,7 @@
|
|||||||
#define TALER_assert_as(EXP, reason) \
|
#define TALER_assert_as(EXP, reason) \
|
||||||
do { \
|
do { \
|
||||||
if (EXP) break; \
|
if (EXP) break; \
|
||||||
LOG_ERROR("%s at %s:%d\n", reason, __FILE__, __LINE__); \
|
TALER_LOG_ERROR("%s at %s:%d\n", reason, __FILE__, __LINE__); \
|
||||||
abort(); \
|
abort(); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
@ -59,11 +59,11 @@
|
|||||||
* a failure of the command 'cmd' with the message given
|
* a failure of the command 'cmd' with the message given
|
||||||
* by gcry_strerror(rc).
|
* by gcry_strerror(rc).
|
||||||
*/
|
*/
|
||||||
#define LOG_GCRY_ERROR(cmd, rc) do { LOG_ERROR("`%s' failed at %s:%d with error: %s\n", cmd, __FILE__, __LINE__, gcry_strerror(rc)); } while(0)
|
#define TALER_LOG_GCRY_ERROR(cmd, rc) do { TALER_LOG_ERROR("`%s' failed at %s:%d with error: %s\n", cmd, __FILE__, __LINE__, gcry_strerror(rc)); } while(0)
|
||||||
|
|
||||||
|
|
||||||
#define TALER_gcry_ok(cmd) \
|
#define TALER_gcry_ok(cmd) \
|
||||||
do {int rc; rc = cmd; if (!rc) break; LOG_ERROR("A Gcrypt call failed at %s:%d with error: %s\n", __FILE__, __LINE__, gcry_strerror(rc)); abort(); } while (0)
|
do {int rc; rc = cmd; if (!rc) break; TALER_LOG_ERROR("A Gcrypt call failed at %s:%d with error: %s\n", __FILE__, __LINE__, gcry_strerror(rc)); abort(); } while (0)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,7 +108,7 @@ TALER_config_get_denom (struct GNUNET_CONFIGURATION_Handle *cfg,
|
|||||||
* @return a pointer to the dir path (to be freed by the caller)
|
* @return a pointer to the dir path (to be freed by the caller)
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
TALER_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind);
|
TALER_os_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -246,7 +246,7 @@ parse_timestamp (struct GNUNET_TIME_Absolute *abs,
|
|||||||
static int
|
static int
|
||||||
parse_json_signkey (struct TALER_MINT_SigningPublicKey **_sign_key,
|
parse_json_signkey (struct TALER_MINT_SigningPublicKey **_sign_key,
|
||||||
json_t *sign_key_obj,
|
json_t *sign_key_obj,
|
||||||
struct TALER_MasterPublicKey *master_key)
|
struct TALER_MasterPublicKeyP *master_key)
|
||||||
{
|
{
|
||||||
json_t *valid_from_obj;
|
json_t *valid_from_obj;
|
||||||
json_t *valid_until_obj;
|
json_t *valid_until_obj;
|
||||||
@ -257,7 +257,7 @@ parse_json_signkey (struct TALER_MINT_SigningPublicKey **_sign_key,
|
|||||||
const char *key_enc;
|
const char *key_enc;
|
||||||
const char *sig_enc;
|
const char *sig_enc;
|
||||||
struct TALER_MINT_SigningPublicKey *sign_key;
|
struct TALER_MINT_SigningPublicKey *sign_key;
|
||||||
struct TALER_MINT_SignKeyIssue sign_key_issue;
|
struct TALER_MintSigningKeyValidityPS sign_key_issue;
|
||||||
struct GNUNET_CRYPTO_EddsaSignature sig;
|
struct GNUNET_CRYPTO_EddsaSignature sig;
|
||||||
struct GNUNET_TIME_Absolute valid_from;
|
struct GNUNET_TIME_Absolute valid_from;
|
||||||
struct GNUNET_TIME_Absolute valid_until;
|
struct GNUNET_TIME_Absolute valid_until;
|
||||||
@ -286,15 +286,15 @@ parse_json_signkey (struct TALER_MINT_SigningPublicKey **_sign_key,
|
|||||||
GNUNET_CRYPTO_eddsa_public_key_from_string (key_enc,
|
GNUNET_CRYPTO_eddsa_public_key_from_string (key_enc,
|
||||||
52,
|
52,
|
||||||
&sign_key_issue.signkey_pub.eddsa_pub));
|
&sign_key_issue.signkey_pub.eddsa_pub));
|
||||||
sign_key_issue.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SIGNKEY);
|
sign_key_issue.purpose.purpose = htonl (TALER_SIGNATURE_MINT_SIGNING_KEY_VALIDITY);
|
||||||
sign_key_issue.purpose.size =
|
sign_key_issue.purpose.size =
|
||||||
htonl (sizeof (sign_key_issue)
|
htonl (sizeof (sign_key_issue)
|
||||||
- offsetof (struct TALER_MINT_SignKeyIssue, purpose));
|
- offsetof (struct TALER_MintSigningKeyValidityPS, purpose));
|
||||||
sign_key_issue.master_pub = *master_key;
|
sign_key_issue.master_public_key = *master_key;
|
||||||
sign_key_issue.start = GNUNET_TIME_absolute_hton (valid_from);
|
sign_key_issue.start = GNUNET_TIME_absolute_hton (valid_from);
|
||||||
sign_key_issue.expire = GNUNET_TIME_absolute_hton (valid_until);
|
sign_key_issue.expire = GNUNET_TIME_absolute_hton (valid_until);
|
||||||
EXITIF (GNUNET_OK !=
|
EXITIF (GNUNET_OK !=
|
||||||
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_SIGNKEY,
|
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MINT_SIGNING_KEY_VALIDITY,
|
||||||
&sign_key_issue.purpose,
|
&sign_key_issue.purpose,
|
||||||
&sig,
|
&sig,
|
||||||
&master_key->eddsa_pub));
|
&master_key->eddsa_pub));
|
||||||
@ -341,7 +341,7 @@ parse_json_amount (json_t *amount_obj, struct TALER_Amount *amt)
|
|||||||
static int
|
static int
|
||||||
parse_json_denomkey (struct TALER_MINT_DenomPublicKey **_denom_key,
|
parse_json_denomkey (struct TALER_MINT_DenomPublicKey **_denom_key,
|
||||||
json_t *denom_key_obj,
|
json_t *denom_key_obj,
|
||||||
struct TALER_MasterPublicKey *master_key)
|
struct TALER_MasterPublicKeyP *master_key)
|
||||||
{
|
{
|
||||||
json_t *obj;
|
json_t *obj;
|
||||||
const char *sig_enc;
|
const char *sig_enc;
|
||||||
@ -359,7 +359,7 @@ parse_json_denomkey (struct TALER_MINT_DenomPublicKey **_denom_key,
|
|||||||
struct TALER_Amount fee_withdraw;
|
struct TALER_Amount fee_withdraw;
|
||||||
struct TALER_Amount fee_deposit;
|
struct TALER_Amount fee_deposit;
|
||||||
struct TALER_Amount fee_refresh;
|
struct TALER_Amount fee_refresh;
|
||||||
struct TALER_MINT_DenomKeyIssue denom_key_issue;
|
struct TALER_DenominationKeyValidityPS denom_key_issue;
|
||||||
struct GNUNET_CRYPTO_rsa_PublicKey *pk;
|
struct GNUNET_CRYPTO_rsa_PublicKey *pk;
|
||||||
struct GNUNET_CRYPTO_EddsaSignature sig;
|
struct GNUNET_CRYPTO_EddsaSignature sig;
|
||||||
|
|
||||||
@ -408,10 +408,10 @@ parse_json_denomkey (struct TALER_MINT_DenomPublicKey **_denom_key,
|
|||||||
EXITIF (GNUNET_SYSERR == parse_json_amount (obj, &fee_deposit));
|
EXITIF (GNUNET_SYSERR == parse_json_amount (obj, &fee_deposit));
|
||||||
EXITIF (NULL == (obj = json_object_get (denom_key_obj, "fee_refresh")));
|
EXITIF (NULL == (obj = json_object_get (denom_key_obj, "fee_refresh")));
|
||||||
EXITIF (GNUNET_SYSERR == parse_json_amount (obj, &fee_refresh));
|
EXITIF (GNUNET_SYSERR == parse_json_amount (obj, &fee_refresh));
|
||||||
denom_key_issue.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOM);
|
denom_key_issue.purpose.purpose = htonl (TALER_SIGNATURE_MINT_DENOMINATION_KEY_VALIDITY);
|
||||||
denom_key_issue.purpose.size = htonl
|
denom_key_issue.purpose.size = htonl
|
||||||
(sizeof (struct TALER_MINT_DenomKeyIssue) -
|
(sizeof (struct TALER_DenominationKeyValidityPS) -
|
||||||
offsetof (struct TALER_MINT_DenomKeyIssue, purpose));
|
offsetof (struct TALER_DenominationKeyValidityPS, purpose));
|
||||||
denom_key_issue.master = *master_key;
|
denom_key_issue.master = *master_key;
|
||||||
denom_key_issue.start = GNUNET_TIME_absolute_hton (valid_from);
|
denom_key_issue.start = GNUNET_TIME_absolute_hton (valid_from);
|
||||||
denom_key_issue.expire_withdraw = GNUNET_TIME_absolute_hton (withdraw_valid_until);
|
denom_key_issue.expire_withdraw = GNUNET_TIME_absolute_hton (withdraw_valid_until);
|
||||||
@ -425,7 +425,7 @@ parse_json_denomkey (struct TALER_MINT_DenomPublicKey **_denom_key,
|
|||||||
TALER_amount_hton (&denom_key_issue.fee_refresh,
|
TALER_amount_hton (&denom_key_issue.fee_refresh,
|
||||||
&fee_refresh);
|
&fee_refresh);
|
||||||
EXITIF (GNUNET_SYSERR ==
|
EXITIF (GNUNET_SYSERR ==
|
||||||
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DENOM,
|
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MINT_DENOMINATION_KEY_VALIDITY,
|
||||||
&denom_key_issue.purpose,
|
&denom_key_issue.purpose,
|
||||||
&sig,
|
&sig,
|
||||||
&master_key->eddsa_pub));
|
&master_key->eddsa_pub));
|
||||||
@ -455,7 +455,7 @@ parse_response_keys_get (const char *in, size_t size,
|
|||||||
{
|
{
|
||||||
json_t *resp_obj;
|
json_t *resp_obj;
|
||||||
struct TALER_MINT_DenomPublicKey **denom_keys;
|
struct TALER_MINT_DenomPublicKey **denom_keys;
|
||||||
struct TALER_MasterPublicKey master_key;
|
struct TALER_MasterPublicKeyP master_key;
|
||||||
struct GNUNET_TIME_Absolute list_issue_date;
|
struct GNUNET_TIME_Absolute list_issue_date;
|
||||||
struct TALER_MINT_SigningPublicKey **sign_keys;
|
struct TALER_MINT_SigningPublicKey **sign_keys;
|
||||||
unsigned int n_denom_keys;
|
unsigned int n_denom_keys;
|
||||||
@ -485,7 +485,7 @@ parse_response_keys_get (const char *in, size_t size,
|
|||||||
json_t *master_key_obj;
|
json_t *master_key_obj;
|
||||||
const char *master_key_enc;
|
const char *master_key_enc;
|
||||||
|
|
||||||
EXITIF (NULL == (master_key_obj = json_object_get (resp_obj, "master_pub")));
|
EXITIF (NULL == (master_key_obj = json_object_get (resp_obj, "TMH_master_public_key")));
|
||||||
EXITIF (NULL == (master_key_enc = json_string_value (master_key_obj)));
|
EXITIF (NULL == (master_key_enc = json_string_value (master_key_obj)));
|
||||||
EXITIF (52 != strlen (master_key_enc)); /* strlen(base32(char[32])) = 52 */
|
EXITIF (52 != strlen (master_key_enc)); /* strlen(base32(char[32])) = 52 */
|
||||||
EXITIF (GNUNET_OK !=
|
EXITIF (GNUNET_OK !=
|
||||||
@ -584,7 +584,7 @@ parse_deposit_response (void *buf, size_t size, int *r_status, json_t **r_obj)
|
|||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
EXITIF (-1 == json_unpack (obj, "{s:s}", "status", &status_str));
|
EXITIF (-1 == json_unpack (obj, "{s:s}", "status", &status_str));
|
||||||
LOG_DEBUG ("Received deposit response: %s from mint\n", status_str);
|
TALER_LOG_DEBUG ("Received deposit response: %s from mint\n", status_str);
|
||||||
if (0 == strcmp ("DEPOSIT_OK", status_str))
|
if (0 == strcmp ("DEPOSIT_OK", status_str))
|
||||||
*r_status = 1;
|
*r_status = 1;
|
||||||
else if (0 == strcmp ("DEPOSIT_QUEUED", status_str))
|
else if (0 == strcmp ("DEPOSIT_QUEUED", status_str))
|
||||||
@ -916,7 +916,7 @@ struct TALER_MINT_Handle *
|
|||||||
TALER_MINT_connect (struct TALER_MINT_Context *ctx,
|
TALER_MINT_connect (struct TALER_MINT_Context *ctx,
|
||||||
const char *hostname,
|
const char *hostname,
|
||||||
uint16_t port,
|
uint16_t port,
|
||||||
const struct TALER_MasterPublicKey *mint_key)
|
const struct TALER_MasterPublicKeyP *mint_key)
|
||||||
{
|
{
|
||||||
struct TALER_MINT_Handle *mint;
|
struct TALER_MINT_Handle *mint;
|
||||||
|
|
||||||
|
@ -22,8 +22,7 @@ lib_LTLIBRARIES = \
|
|||||||
|
|
||||||
libtalermint_common_la_SOURCES = \
|
libtalermint_common_la_SOURCES = \
|
||||||
key_io.c key_io.h \
|
key_io.c key_io.h \
|
||||||
plugin.c plugin.h \
|
plugin.c plugin.h
|
||||||
taler_mintdb_plugin.h
|
|
||||||
|
|
||||||
libtalermint_common_la_LIBADD = \
|
libtalermint_common_la_LIBADD = \
|
||||||
$(top_builddir)/src/util/libtalerutil.la \
|
$(top_builddir)/src/util/libtalerutil.la \
|
||||||
|
@ -60,12 +60,12 @@ signkeys_iterate_dir_iter (void *cls,
|
|||||||
{
|
{
|
||||||
struct SignkeysIterateContext *skc = cls;
|
struct SignkeysIterateContext *skc = cls;
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
struct TALER_MINT_SignKeyIssuePriv issue;
|
struct TALER_MintSigningKeyValidityPSPriv issue;
|
||||||
|
|
||||||
nread = GNUNET_DISK_fn_read (filename,
|
nread = GNUNET_DISK_fn_read (filename,
|
||||||
&issue,
|
&issue,
|
||||||
sizeof (struct TALER_MINT_SignKeyIssuePriv));
|
sizeof (struct TALER_MintSigningKeyValidityPSPriv));
|
||||||
if (nread != sizeof (struct TALER_MINT_SignKeyIssuePriv))
|
if (nread != sizeof (struct TALER_MintSigningKeyValidityPSPriv))
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||||
"Invalid signkey file `%s': wrong size\n",
|
"Invalid signkey file `%s': wrong size\n",
|
||||||
@ -122,7 +122,7 @@ TALER_MINT_signkeys_iterate (const char *mint_base_dir,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_read_denom_key (const char *filename,
|
TALER_MINT_read_denom_key (const char *filename,
|
||||||
struct TALER_MINT_DenomKeyIssuePriv *dki)
|
struct TALER_DenominationKeyIssueInformation *dki)
|
||||||
{
|
{
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
size_t offset;
|
size_t offset;
|
||||||
@ -139,7 +139,7 @@ TALER_MINT_read_denom_key (const char *filename,
|
|||||||
filename);
|
filename);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
offset = sizeof (struct TALER_MINT_DenomKeyIssue);
|
offset = sizeof (struct TALER_DenominationKeyValidityPS);
|
||||||
if (size <= offset)
|
if (size <= offset)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
@ -184,7 +184,7 @@ TALER_MINT_read_denom_key (const char *filename,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_write_denom_key (const char *filename,
|
TALER_MINT_write_denom_key (const char *filename,
|
||||||
const struct TALER_MINT_DenomKeyIssuePriv *dki)
|
const struct TALER_DenominationKeyIssueInformation *dki)
|
||||||
{
|
{
|
||||||
char *priv_enc;
|
char *priv_enc;
|
||||||
size_t priv_enc_size;
|
size_t priv_enc_size;
|
||||||
@ -203,7 +203,7 @@ TALER_MINT_write_denom_key (const char *filename,
|
|||||||
GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_TRUNCATE,
|
GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_TRUNCATE,
|
||||||
GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE)))
|
GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
wsize = sizeof (struct TALER_MINT_DenomKeyIssue);
|
wsize = sizeof (struct TALER_DenominationKeyValidityPS);
|
||||||
if (GNUNET_SYSERR == (wrote = GNUNET_DISK_file_write (fh,
|
if (GNUNET_SYSERR == (wrote = GNUNET_DISK_file_write (fh,
|
||||||
&dki->issue.signature,
|
&dki->issue.signature,
|
||||||
wsize)))
|
wsize)))
|
||||||
@ -267,7 +267,7 @@ denomkeys_iterate_keydir_iter (void *cls,
|
|||||||
const char *filename)
|
const char *filename)
|
||||||
{
|
{
|
||||||
struct DenomkeysIterateContext *dic = cls;
|
struct DenomkeysIterateContext *dic = cls;
|
||||||
struct TALER_MINT_DenomKeyIssuePriv issue;
|
struct TALER_DenominationKeyIssueInformation issue;
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_MINT_read_denom_key (filename,
|
TALER_MINT_read_denom_key (filename,
|
||||||
|
@ -47,17 +47,17 @@ GNUNET_NETWORK_STRUCT_BEGIN
|
|||||||
* Includes the private key followed by the public information about
|
* Includes the private key followed by the public information about
|
||||||
* the signing key.
|
* the signing key.
|
||||||
*/
|
*/
|
||||||
struct TALER_MINT_SignKeyIssuePriv
|
struct TALER_MintSigningKeyValidityPSPriv
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Private key part of the mint's signing key.
|
* Private key part of the mint's signing key.
|
||||||
*/
|
*/
|
||||||
struct TALER_MintPrivateKey signkey_priv;
|
struct TALER_MintPrivateKeyP signkey_priv;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public information about a mint signing key.
|
* Public information about a mint signing key.
|
||||||
*/
|
*/
|
||||||
struct TALER_MINT_SignKeyIssue issue;
|
struct TALER_MintSigningKeyValidityPS issue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ GNUNET_NETWORK_STRUCT_END
|
|||||||
* All information about a denomination key (which is used to
|
* All information about a denomination key (which is used to
|
||||||
* sign coins into existence).
|
* sign coins into existence).
|
||||||
*/
|
*/
|
||||||
struct TALER_MINT_DenomKeyIssuePriv
|
struct TALER_DenominationKeyIssueInformation
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The private key of the denomination. Will be NULL if the private
|
* The private key of the denomination. Will be NULL if the private
|
||||||
@ -86,7 +86,7 @@ struct TALER_MINT_DenomKeyIssuePriv
|
|||||||
/**
|
/**
|
||||||
* Signed public information about a denomination key.
|
* Signed public information about a denomination key.
|
||||||
*/
|
*/
|
||||||
struct TALER_MINT_DenomKeyIssue issue;
|
struct TALER_DenominationKeyValidityPS issue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ struct TALER_MINT_DenomKeyIssuePriv
|
|||||||
typedef int
|
typedef int
|
||||||
(*TALER_MINT_SignkeyIterator)(void *cls,
|
(*TALER_MINT_SignkeyIterator)(void *cls,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
const struct TALER_MINT_SignKeyIssuePriv *ski);
|
const struct TALER_MintSigningKeyValidityPSPriv *ski);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -119,7 +119,7 @@ typedef int
|
|||||||
typedef int
|
typedef int
|
||||||
(*TALER_MINT_DenomkeyIterator)(void *cls,
|
(*TALER_MINT_DenomkeyIterator)(void *cls,
|
||||||
const char *alias,
|
const char *alias,
|
||||||
const struct TALER_MINT_DenomKeyIssuePriv *dki);
|
const struct TALER_DenominationKeyIssueInformation *dki);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ TALER_MINT_denomkeys_iterate (const char *mint_base_dir,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_write_denom_key (const char *filename,
|
TALER_MINT_write_denom_key (const char *filename,
|
||||||
const struct TALER_MINT_DenomKeyIssuePriv *dki);
|
const struct TALER_DenominationKeyIssueInformation *dki);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -181,7 +181,7 @@ TALER_MINT_write_denom_key (const char *filename,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_read_denom_key (const char *filename,
|
TALER_MINT_read_denom_key (const char *filename,
|
||||||
struct TALER_MINT_DenomKeyIssuePriv *dki);
|
struct TALER_DenominationKeyIssueInformation *dki);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -109,7 +109,7 @@ plugin_init ()
|
|||||||
opath = lt_dlgetsearchpath ();
|
opath = lt_dlgetsearchpath ();
|
||||||
if (NULL != opath)
|
if (NULL != opath)
|
||||||
old_dlsearchpath = GNUNET_strdup (opath);
|
old_dlsearchpath = GNUNET_strdup (opath);
|
||||||
path = TALER_OS_installation_get_path (GNUNET_OS_IPK_LIBDIR);
|
path = TALER_os_installation_get_path (GNUNET_OS_IPK_LIBDIR);
|
||||||
if (NULL != path)
|
if (NULL != path)
|
||||||
{
|
{
|
||||||
if (NULL != opath)
|
if (NULL != opath)
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
* @author Sree Harsha Totakura
|
* @author Sree Harsha Totakura
|
||||||
*/
|
*/
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "db_pq.h"
|
#include "taler_pq_lib.h"
|
||||||
#include "taler_signatures.h"
|
#include "taler_signatures.h"
|
||||||
#include "taler_mintdb_plugin.h"
|
#include "taler_mintdb_plugin.h"
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
@ -67,7 +67,7 @@
|
|||||||
* that we need to use this at the DB layer instead of TALER_CURRENCY_LEN as the
|
* that we need to use this at the DB layer instead of TALER_CURRENCY_LEN as the
|
||||||
* DB only needs to store 3 bytes instead of 8 bytes.
|
* DB only needs to store 3 bytes instead of 8 bytes.
|
||||||
*/
|
*/
|
||||||
#define TALER_DB_CURRENCY_LEN 3
|
#define TALER_PQ_CURRENCY_LEN 3
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -99,7 +99,7 @@ struct PostgresClosure
|
|||||||
* Database connection string, as read from
|
* Database connection string, as read from
|
||||||
* the configuration.
|
* the configuration.
|
||||||
*/
|
*/
|
||||||
char *TALER_MINT_db_connection_cfg_str;
|
char *connection_cfg_str;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -162,10 +162,10 @@ postgres_create_tables (void *cls,
|
|||||||
PGconn *conn;
|
PGconn *conn;
|
||||||
|
|
||||||
result = NULL;
|
result = NULL;
|
||||||
conn = PQconnectdb (pc->TALER_MINT_db_connection_cfg_str);
|
conn = PQconnectdb (pc->connection_cfg_str);
|
||||||
if (CONNECTION_OK != PQstatus (conn))
|
if (CONNECTION_OK != PQstatus (conn))
|
||||||
{
|
{
|
||||||
LOG_ERROR ("Database connection failed: %s\n",
|
TALER_LOG_ERROR ("Database connection failed: %s\n",
|
||||||
PQerrorMessage (conn));
|
PQerrorMessage (conn));
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
@ -247,7 +247,7 @@ postgres_create_tables (void *cls,
|
|||||||
// index of the old coin in the customer's request
|
// index of the old coin in the customer's request
|
||||||
",oldcoin_index INT2 NOT NULL"
|
",oldcoin_index INT2 NOT NULL"
|
||||||
// index for cut and choose,
|
// index for cut and choose,
|
||||||
// ranges from 0 to #KAPPA-1
|
// ranges from 0 to #TALER_CNC_KAPPA-1
|
||||||
",cnc_index INT2 NOT NULL"
|
",cnc_index INT2 NOT NULL"
|
||||||
")");
|
")");
|
||||||
SQLEXEC("CREATE TABLE IF NOT EXISTS refresh_commit_coin"
|
SQLEXEC("CREATE TABLE IF NOT EXISTS refresh_commit_coin"
|
||||||
@ -626,11 +626,11 @@ postgres_get_session (void *cls,
|
|||||||
|
|
||||||
if (NULL != (session = pthread_getspecific (pc->db_conn_threadlocal)))
|
if (NULL != (session = pthread_getspecific (pc->db_conn_threadlocal)))
|
||||||
return session;
|
return session;
|
||||||
db_conn = PQconnectdb (pc->TALER_MINT_db_connection_cfg_str);
|
db_conn = PQconnectdb (pc->connection_cfg_str);
|
||||||
if (CONNECTION_OK !=
|
if (CONNECTION_OK !=
|
||||||
PQstatus (db_conn))
|
PQstatus (db_conn))
|
||||||
{
|
{
|
||||||
LOG_ERROR ("Database connection failed: %s\n",
|
TALER_LOG_ERROR ("Database connection failed: %s\n",
|
||||||
PQerrorMessage (db_conn));
|
PQerrorMessage (db_conn));
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -679,7 +679,7 @@ postgres_start (void *cls,
|
|||||||
if (PGRES_COMMAND_OK !=
|
if (PGRES_COMMAND_OK !=
|
||||||
PQresultStatus (result))
|
PQresultStatus (result))
|
||||||
{
|
{
|
||||||
LOG_ERROR ("Failed to start transaction: %s\n",
|
TALER_LOG_ERROR ("Failed to start transaction: %s\n",
|
||||||
PQresultErrorMessage (result));
|
PQresultErrorMessage (result));
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
PQclear (result);
|
PQclear (result);
|
||||||
@ -757,12 +757,12 @@ postgres_reserve_get (void *cls,
|
|||||||
{
|
{
|
||||||
PGresult *result;
|
PGresult *result;
|
||||||
uint64_t expiration_date_nbo;
|
uint64_t expiration_date_nbo;
|
||||||
struct TALER_DB_QueryParam params[] = {
|
struct TALER_PQ_QueryParam params[] = {
|
||||||
TALER_DB_QUERY_PARAM_PTR(&reserve->pub),
|
TALER_PQ_QUERY_PARAM_PTR(&reserve->pub),
|
||||||
TALER_DB_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
|
|
||||||
result = TALER_DB_exec_prepared (session->conn,
|
result = TALER_PQ_exec_prepared (session->conn,
|
||||||
"get_reserve",
|
"get_reserve",
|
||||||
params);
|
params);
|
||||||
if (PGRES_TUPLES_OK != PQresultStatus (result))
|
if (PGRES_TUPLES_OK != PQresultStatus (result))
|
||||||
@ -776,13 +776,13 @@ postgres_reserve_get (void *cls,
|
|||||||
PQclear (result);
|
PQclear (result);
|
||||||
return GNUNET_NO;
|
return GNUNET_NO;
|
||||||
}
|
}
|
||||||
struct TALER_DB_ResultSpec rs[] = {
|
struct TALER_PQ_ResultSpec rs[] = {
|
||||||
TALER_DB_RESULT_SPEC("expiration_date", &expiration_date_nbo),
|
TALER_PQ_RESULT_SPEC("expiration_date", &expiration_date_nbo),
|
||||||
TALER_DB_RESULT_SPEC_END
|
TALER_PQ_RESULT_SPEC_END
|
||||||
};
|
};
|
||||||
EXITIF (GNUNET_OK != TALER_DB_extract_result (result, rs, 0));
|
EXITIF (GNUNET_OK != TALER_PQ_extract_result (result, rs, 0));
|
||||||
EXITIF (GNUNET_OK !=
|
EXITIF (GNUNET_OK !=
|
||||||
TALER_DB_extract_amount (result, 0,
|
TALER_PQ_extract_amount (result, 0,
|
||||||
"current_balance_value",
|
"current_balance_value",
|
||||||
"current_balance_fraction",
|
"current_balance_fraction",
|
||||||
"balance_currency",
|
"balance_currency",
|
||||||
@ -819,17 +819,17 @@ postgres_reserves_update (void *cls,
|
|||||||
if (NULL == reserve)
|
if (NULL == reserve)
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
ret = GNUNET_OK;
|
ret = GNUNET_OK;
|
||||||
struct TALER_DB_QueryParam params[] = {
|
struct TALER_PQ_QueryParam params[] = {
|
||||||
TALER_DB_QUERY_PARAM_PTR (&reserve->pub),
|
TALER_PQ_QUERY_PARAM_PTR (&reserve->pub),
|
||||||
TALER_DB_QUERY_PARAM_PTR (&balance_nbo.value),
|
TALER_PQ_QUERY_PARAM_PTR (&balance_nbo.value),
|
||||||
TALER_DB_QUERY_PARAM_PTR (&balance_nbo.fraction),
|
TALER_PQ_QUERY_PARAM_PTR (&balance_nbo.fraction),
|
||||||
TALER_DB_QUERY_PARAM_PTR (&expiry_nbo),
|
TALER_PQ_QUERY_PARAM_PTR (&expiry_nbo),
|
||||||
TALER_DB_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
TALER_amount_hton (&balance_nbo,
|
TALER_amount_hton (&balance_nbo,
|
||||||
&reserve->balance);
|
&reserve->balance);
|
||||||
expiry_nbo = GNUNET_TIME_absolute_hton (reserve->expiry);
|
expiry_nbo = GNUNET_TIME_absolute_hton (reserve->expiry);
|
||||||
result = TALER_DB_exec_prepared (session->conn,
|
result = TALER_PQ_exec_prepared (session->conn,
|
||||||
"update_reserve",
|
"update_reserve",
|
||||||
params);
|
params);
|
||||||
if (PGRES_COMMAND_OK != PQresultStatus(result))
|
if (PGRES_COMMAND_OK != PQresultStatus(result))
|
||||||
@ -895,16 +895,16 @@ postgres_reserves_in_insert (void *cls,
|
|||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
||||||
"Reserve does not exist; creating a new one\n");
|
"Reserve does not exist; creating a new one\n");
|
||||||
struct TALER_DB_QueryParam params[] = {
|
struct TALER_PQ_QueryParam params[] = {
|
||||||
TALER_DB_QUERY_PARAM_PTR (&reserve->pub),
|
TALER_PQ_QUERY_PARAM_PTR (&reserve->pub),
|
||||||
TALER_DB_QUERY_PARAM_PTR (&balance_nbo.value),
|
TALER_PQ_QUERY_PARAM_PTR (&balance_nbo.value),
|
||||||
TALER_DB_QUERY_PARAM_PTR (&balance_nbo.fraction),
|
TALER_PQ_QUERY_PARAM_PTR (&balance_nbo.fraction),
|
||||||
TALER_DB_QUERY_PARAM_PTR_SIZED (balance_nbo.currency,
|
TALER_PQ_QUERY_PARAM_PTR_SIZED (balance_nbo.currency,
|
||||||
TALER_DB_CURRENCY_LEN),
|
TALER_PQ_CURRENCY_LEN),
|
||||||
TALER_DB_QUERY_PARAM_PTR (&expiry_nbo),
|
TALER_PQ_QUERY_PARAM_PTR (&expiry_nbo),
|
||||||
TALER_DB_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
result = TALER_DB_exec_prepared (session->conn,
|
result = TALER_PQ_exec_prepared (session->conn,
|
||||||
"create_reserve",
|
"create_reserve",
|
||||||
params);
|
params);
|
||||||
if (PGRES_COMMAND_OK != PQresultStatus(result))
|
if (PGRES_COMMAND_OK != PQresultStatus(result))
|
||||||
@ -917,16 +917,16 @@ postgres_reserves_in_insert (void *cls,
|
|||||||
PQclear (result);
|
PQclear (result);
|
||||||
result = NULL;
|
result = NULL;
|
||||||
/* create new incoming transaction */
|
/* create new incoming transaction */
|
||||||
struct TALER_DB_QueryParam params[] = {
|
struct TALER_PQ_QueryParam params[] = {
|
||||||
TALER_DB_QUERY_PARAM_PTR (&reserve->pub),
|
TALER_PQ_QUERY_PARAM_PTR (&reserve->pub),
|
||||||
TALER_DB_QUERY_PARAM_PTR (&balance_nbo.value),
|
TALER_PQ_QUERY_PARAM_PTR (&balance_nbo.value),
|
||||||
TALER_DB_QUERY_PARAM_PTR (&balance_nbo.fraction),
|
TALER_PQ_QUERY_PARAM_PTR (&balance_nbo.fraction),
|
||||||
TALER_DB_QUERY_PARAM_PTR_SIZED (&balance_nbo.currency,
|
TALER_PQ_QUERY_PARAM_PTR_SIZED (&balance_nbo.currency,
|
||||||
TALER_DB_CURRENCY_LEN),
|
TALER_PQ_CURRENCY_LEN),
|
||||||
TALER_DB_QUERY_PARAM_PTR (&expiry_nbo),
|
TALER_PQ_QUERY_PARAM_PTR (&expiry_nbo),
|
||||||
TALER_DB_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
result = TALER_DB_exec_prepared (session->conn,
|
result = TALER_PQ_exec_prepared (session->conn,
|
||||||
"create_reserves_in_transaction",
|
"create_reserves_in_transaction",
|
||||||
params);
|
params);
|
||||||
if (PGRES_COMMAND_OK != PQresultStatus(result))
|
if (PGRES_COMMAND_OK != PQresultStatus(result))
|
||||||
@ -996,9 +996,9 @@ postgres_get_collectable_blindcoin (void *cls,
|
|||||||
struct CollectableBlindcoin *collectable)
|
struct CollectableBlindcoin *collectable)
|
||||||
{
|
{
|
||||||
PGresult *result;
|
PGresult *result;
|
||||||
struct TALER_DB_QueryParam params[] = {
|
struct TALER_PQ_QueryParam params[] = {
|
||||||
TALER_DB_QUERY_PARAM_PTR (h_blind),
|
TALER_PQ_QUERY_PARAM_PTR (h_blind),
|
||||||
TALER_DB_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub;
|
struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub;
|
||||||
struct GNUNET_CRYPTO_rsa_Signature *denom_sig;
|
struct GNUNET_CRYPTO_rsa_Signature *denom_sig;
|
||||||
@ -1012,7 +1012,7 @@ postgres_get_collectable_blindcoin (void *cls,
|
|||||||
denom_pub = NULL;
|
denom_pub = NULL;
|
||||||
denom_pub_enc = NULL;
|
denom_pub_enc = NULL;
|
||||||
denom_sig_enc = NULL;
|
denom_sig_enc = NULL;
|
||||||
result = TALER_DB_exec_prepared (session->conn,
|
result = TALER_PQ_exec_prepared (session->conn,
|
||||||
"get_collectable_blindcoin",
|
"get_collectable_blindcoin",
|
||||||
params);
|
params);
|
||||||
|
|
||||||
@ -1026,15 +1026,15 @@ postgres_get_collectable_blindcoin (void *cls,
|
|||||||
ret = GNUNET_NO;
|
ret = GNUNET_NO;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
struct TALER_DB_ResultSpec rs[] = {
|
struct TALER_PQ_ResultSpec rs[] = {
|
||||||
TALER_DB_RESULT_SPEC_VAR("denom_pub", &denom_pub_enc, &denom_pub_enc_size),
|
TALER_PQ_RESULT_SPEC_VAR("denom_pub", &denom_pub_enc, &denom_pub_enc_size),
|
||||||
TALER_DB_RESULT_SPEC_VAR("denom_sig", &denom_sig_enc, &denom_sig_enc_size),
|
TALER_PQ_RESULT_SPEC_VAR("denom_sig", &denom_sig_enc, &denom_sig_enc_size),
|
||||||
TALER_DB_RESULT_SPEC("reserve_sig", &collectable->reserve_sig),
|
TALER_PQ_RESULT_SPEC("reserve_sig", &collectable->reserve_sig),
|
||||||
TALER_DB_RESULT_SPEC("reserve_pub", &collectable->reserve_pub),
|
TALER_PQ_RESULT_SPEC("reserve_pub", &collectable->reserve_pub),
|
||||||
TALER_DB_RESULT_SPEC_END
|
TALER_PQ_RESULT_SPEC_END
|
||||||
};
|
};
|
||||||
|
|
||||||
if (GNUNET_OK != TALER_DB_extract_result (result, rs, 0))
|
if (GNUNET_OK != TALER_PQ_extract_result (result, rs, 0))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1103,18 +1103,18 @@ postgres_insert_collectable_blindcoin (void *cls,
|
|||||||
denom_sig_enc_size =
|
denom_sig_enc_size =
|
||||||
GNUNET_CRYPTO_rsa_signature_encode (collectable->sig.rsa_signature,
|
GNUNET_CRYPTO_rsa_signature_encode (collectable->sig.rsa_signature,
|
||||||
&denom_sig_enc);
|
&denom_sig_enc);
|
||||||
struct TALER_DB_QueryParam params[] = {
|
struct TALER_PQ_QueryParam params[] = {
|
||||||
TALER_DB_QUERY_PARAM_PTR (h_blind),
|
TALER_PQ_QUERY_PARAM_PTR (h_blind),
|
||||||
TALER_DB_QUERY_PARAM_PTR_SIZED (denom_pub_enc, denom_pub_enc_size - 1),
|
TALER_PQ_QUERY_PARAM_PTR_SIZED (denom_pub_enc, denom_pub_enc_size - 1),
|
||||||
TALER_DB_QUERY_PARAM_PTR_SIZED (denom_sig_enc, denom_sig_enc_size - 1), /* DB doesn't like the trailing \0 */
|
TALER_PQ_QUERY_PARAM_PTR_SIZED (denom_sig_enc, denom_sig_enc_size - 1), /* DB doesn't like the trailing \0 */
|
||||||
TALER_DB_QUERY_PARAM_PTR (&collectable->reserve_pub),
|
TALER_PQ_QUERY_PARAM_PTR (&collectable->reserve_pub),
|
||||||
TALER_DB_QUERY_PARAM_PTR (&collectable->reserve_sig),
|
TALER_PQ_QUERY_PARAM_PTR (&collectable->reserve_sig),
|
||||||
TALER_DB_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
if (GNUNET_OK != postgres_start (cls,
|
if (GNUNET_OK != postgres_start (cls,
|
||||||
session))
|
session))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
result = TALER_DB_exec_prepared (session->conn,
|
result = TALER_PQ_exec_prepared (session->conn,
|
||||||
"insert_collectable_blindcoin",
|
"insert_collectable_blindcoin",
|
||||||
params);
|
params);
|
||||||
if (PGRES_COMMAND_OK != PQresultStatus (result))
|
if (PGRES_COMMAND_OK != PQresultStatus (result))
|
||||||
@ -1166,7 +1166,7 @@ postgres_insert_collectable_blindcoin (void *cls,
|
|||||||
static struct ReserveHistory *
|
static struct ReserveHistory *
|
||||||
postgres_get_reserve_history (void *cls,
|
postgres_get_reserve_history (void *cls,
|
||||||
struct TALER_MINTDB_Session *session,
|
struct TALER_MINTDB_Session *session,
|
||||||
const struct TALER_ReservePublicKey *reserve_pub)
|
const struct TALER_ReservePublicKeyP *reserve_pub)
|
||||||
{
|
{
|
||||||
PGresult *result;
|
PGresult *result;
|
||||||
struct ReserveHistory *rh;
|
struct ReserveHistory *rh;
|
||||||
@ -1180,12 +1180,12 @@ postgres_get_reserve_history (void *cls,
|
|||||||
ret = GNUNET_SYSERR;
|
ret = GNUNET_SYSERR;
|
||||||
{
|
{
|
||||||
struct BankTransfer *bt;
|
struct BankTransfer *bt;
|
||||||
struct TALER_DB_QueryParam params[] = {
|
struct TALER_PQ_QueryParam params[] = {
|
||||||
TALER_DB_QUERY_PARAM_PTR (reserve_pub),
|
TALER_PQ_QUERY_PARAM_PTR (reserve_pub),
|
||||||
TALER_DB_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
|
|
||||||
result = TALER_DB_exec_prepared (session->conn,
|
result = TALER_PQ_exec_prepared (session->conn,
|
||||||
"get_reserves_in_transactions",
|
"get_reserves_in_transactions",
|
||||||
params);
|
params);
|
||||||
if (PGRES_TUPLES_OK != PQresultStatus (result))
|
if (PGRES_TUPLES_OK != PQresultStatus (result))
|
||||||
@ -1202,7 +1202,7 @@ postgres_get_reserve_history (void *cls,
|
|||||||
while (0 < rows)
|
while (0 < rows)
|
||||||
{
|
{
|
||||||
bt = GNUNET_new (struct BankTransfer);
|
bt = GNUNET_new (struct BankTransfer);
|
||||||
if (GNUNET_OK != TALER_DB_extract_amount (result,
|
if (GNUNET_OK != TALER_PQ_extract_amount (result,
|
||||||
--rows,
|
--rows,
|
||||||
"balance_value",
|
"balance_value",
|
||||||
"balance_fraction",
|
"balance_fraction",
|
||||||
@ -1232,18 +1232,18 @@ postgres_get_reserve_history (void *cls,
|
|||||||
result = NULL;
|
result = NULL;
|
||||||
{
|
{
|
||||||
struct GNUNET_HashCode blind_ev;
|
struct GNUNET_HashCode blind_ev;
|
||||||
struct TALER_ReserveSignature reserve_sig;
|
struct TALER_ReserveSignatureP reserve_sig;
|
||||||
struct CollectableBlindcoin *cbc;
|
struct CollectableBlindcoin *cbc;
|
||||||
char *denom_pub_enc;
|
char *denom_pub_enc;
|
||||||
char *denom_sig_enc;
|
char *denom_sig_enc;
|
||||||
size_t denom_pub_enc_size;
|
size_t denom_pub_enc_size;
|
||||||
size_t denom_sig_enc_size;
|
size_t denom_sig_enc_size;
|
||||||
|
|
||||||
struct TALER_DB_QueryParam params[] = {
|
struct TALER_PQ_QueryParam params[] = {
|
||||||
TALER_DB_QUERY_PARAM_PTR (reserve_pub),
|
TALER_PQ_QUERY_PARAM_PTR (reserve_pub),
|
||||||
TALER_DB_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
result = TALER_DB_exec_prepared (session->conn,
|
result = TALER_PQ_exec_prepared (session->conn,
|
||||||
"get_reserves_blindcoins",
|
"get_reserves_blindcoins",
|
||||||
params);
|
params);
|
||||||
if (PGRES_TUPLES_OK != PQresultStatus (result))
|
if (PGRES_TUPLES_OK != PQresultStatus (result))
|
||||||
@ -1256,19 +1256,19 @@ postgres_get_reserve_history (void *cls,
|
|||||||
ret = GNUNET_OK; /* Its OK if there are no withdrawls yet */
|
ret = GNUNET_OK; /* Its OK if there are no withdrawls yet */
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
struct TALER_DB_ResultSpec rs[] = {
|
struct TALER_PQ_ResultSpec rs[] = {
|
||||||
TALER_DB_RESULT_SPEC ("blind_ev", &blind_ev),
|
TALER_PQ_RESULT_SPEC ("blind_ev", &blind_ev),
|
||||||
TALER_DB_RESULT_SPEC_VAR ("denom_pub", &denom_pub_enc, &denom_pub_enc_size),
|
TALER_PQ_RESULT_SPEC_VAR ("denom_pub", &denom_pub_enc, &denom_pub_enc_size),
|
||||||
TALER_DB_RESULT_SPEC_VAR ("denom_sig", &denom_sig_enc, &denom_sig_enc_size),
|
TALER_PQ_RESULT_SPEC_VAR ("denom_sig", &denom_sig_enc, &denom_sig_enc_size),
|
||||||
TALER_DB_RESULT_SPEC ("reserve_sig", &reserve_sig),
|
TALER_PQ_RESULT_SPEC ("reserve_sig", &reserve_sig),
|
||||||
TALER_DB_RESULT_SPEC_END
|
TALER_PQ_RESULT_SPEC_END
|
||||||
};
|
};
|
||||||
GNUNET_assert (NULL != rh);
|
GNUNET_assert (NULL != rh);
|
||||||
GNUNET_assert (NULL != rh_head);
|
GNUNET_assert (NULL != rh_head);
|
||||||
GNUNET_assert (NULL == rh_head->next);
|
GNUNET_assert (NULL == rh_head->next);
|
||||||
while (0 < rows)
|
while (0 < rows)
|
||||||
{
|
{
|
||||||
if (GNUNET_YES != TALER_DB_extract_result (result, rs, --rows))
|
if (GNUNET_YES != TALER_PQ_extract_result (result, rs, --rows))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1333,17 +1333,17 @@ postgres_have_deposit (void *cls,
|
|||||||
struct TALER_MINTDB_Session *session,
|
struct TALER_MINTDB_Session *session,
|
||||||
const struct Deposit *deposit)
|
const struct Deposit *deposit)
|
||||||
{
|
{
|
||||||
struct TALER_DB_QueryParam params[] = {
|
struct TALER_PQ_QueryParam params[] = {
|
||||||
TALER_DB_QUERY_PARAM_PTR (&deposit->coin.coin_pub),
|
TALER_PQ_QUERY_PARAM_PTR (&deposit->coin.coin_pub),
|
||||||
TALER_DB_QUERY_PARAM_PTR (&deposit->transaction_id),
|
TALER_PQ_QUERY_PARAM_PTR (&deposit->transaction_id),
|
||||||
TALER_DB_QUERY_PARAM_PTR (&deposit->merchant_pub),
|
TALER_PQ_QUERY_PARAM_PTR (&deposit->merchant_pub),
|
||||||
TALER_DB_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
PGresult *result;
|
PGresult *result;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = GNUNET_SYSERR;
|
ret = GNUNET_SYSERR;
|
||||||
result = TALER_DB_exec_prepared (session->conn,
|
result = TALER_PQ_exec_prepared (session->conn,
|
||||||
"get_deposit",
|
"get_deposit",
|
||||||
params);
|
params);
|
||||||
if (PGRES_TUPLES_OK !=
|
if (PGRES_TUPLES_OK !=
|
||||||
@ -1399,24 +1399,24 @@ postgres_insert_deposit (void *cls,
|
|||||||
json_wire_enc = json_dumps (deposit->wire, JSON_COMPACT);
|
json_wire_enc = json_dumps (deposit->wire, JSON_COMPACT);
|
||||||
TALER_amount_hton (&amount_nbo,
|
TALER_amount_hton (&amount_nbo,
|
||||||
&deposit->amount_with_fee);
|
&deposit->amount_with_fee);
|
||||||
struct TALER_DB_QueryParam params[]= {
|
struct TALER_PQ_QueryParam params[]= {
|
||||||
TALER_DB_QUERY_PARAM_PTR (&deposit->coin.coin_pub),
|
TALER_PQ_QUERY_PARAM_PTR (&deposit->coin.coin_pub),
|
||||||
TALER_DB_QUERY_PARAM_PTR_SIZED (denom_pub_enc, denom_pub_enc_size),
|
TALER_PQ_QUERY_PARAM_PTR_SIZED (denom_pub_enc, denom_pub_enc_size),
|
||||||
TALER_DB_QUERY_PARAM_PTR_SIZED (denom_sig_enc, denom_sig_enc_size),
|
TALER_PQ_QUERY_PARAM_PTR_SIZED (denom_sig_enc, denom_sig_enc_size),
|
||||||
TALER_DB_QUERY_PARAM_PTR (&deposit->transaction_id),
|
TALER_PQ_QUERY_PARAM_PTR (&deposit->transaction_id),
|
||||||
TALER_DB_QUERY_PARAM_PTR (&amount_nbo.value),
|
TALER_PQ_QUERY_PARAM_PTR (&amount_nbo.value),
|
||||||
TALER_DB_QUERY_PARAM_PTR (&amount_nbo.fraction),
|
TALER_PQ_QUERY_PARAM_PTR (&amount_nbo.fraction),
|
||||||
TALER_DB_QUERY_PARAM_PTR_SIZED (amount_nbo.currency,
|
TALER_PQ_QUERY_PARAM_PTR_SIZED (amount_nbo.currency,
|
||||||
TALER_CURRENCY_LEN - 1),
|
TALER_CURRENCY_LEN - 1),
|
||||||
TALER_DB_QUERY_PARAM_PTR (&deposit->merchant_pub),
|
TALER_PQ_QUERY_PARAM_PTR (&deposit->merchant_pub),
|
||||||
TALER_DB_QUERY_PARAM_PTR (&deposit->h_contract),
|
TALER_PQ_QUERY_PARAM_PTR (&deposit->h_contract),
|
||||||
TALER_DB_QUERY_PARAM_PTR (&deposit->h_wire),
|
TALER_PQ_QUERY_PARAM_PTR (&deposit->h_wire),
|
||||||
TALER_DB_QUERY_PARAM_PTR (&deposit->csig),
|
TALER_PQ_QUERY_PARAM_PTR (&deposit->csig),
|
||||||
TALER_DB_QUERY_PARAM_PTR_SIZED (json_wire_enc,
|
TALER_PQ_QUERY_PARAM_PTR_SIZED (json_wire_enc,
|
||||||
strlen (json_wire_enc)),
|
strlen (json_wire_enc)),
|
||||||
TALER_DB_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
result = TALER_DB_exec_prepared (session->conn, "insert_deposit", params);
|
result = TALER_PQ_exec_prepared (session->conn, "insert_deposit", params);
|
||||||
if (PGRES_COMMAND_OK != PQresultStatus (result))
|
if (PGRES_COMMAND_OK != PQresultStatus (result))
|
||||||
{
|
{
|
||||||
BREAK_DB_ERR (result);
|
BREAK_DB_ERR (result);
|
||||||
@ -1452,12 +1452,12 @@ postgres_get_refresh_session (void *cls,
|
|||||||
{
|
{
|
||||||
// FIXME: check logic!
|
// FIXME: check logic!
|
||||||
int res;
|
int res;
|
||||||
struct TALER_DB_QueryParam params[] = {
|
struct TALER_PQ_QueryParam params[] = {
|
||||||
TALER_DB_QUERY_PARAM_PTR(session_hash),
|
TALER_PQ_QUERY_PARAM_PTR(session_hash),
|
||||||
TALER_DB_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
|
|
||||||
PGresult *result = TALER_DB_exec_prepared (session->conn,
|
PGresult *result = TALER_PQ_exec_prepared (session->conn,
|
||||||
"get_refresh_session",
|
"get_refresh_session",
|
||||||
params);
|
params);
|
||||||
|
|
||||||
@ -1483,14 +1483,14 @@ postgres_get_refresh_session (void *cls,
|
|||||||
|
|
||||||
memset (session, 0, sizeof (struct RefreshSession));
|
memset (session, 0, sizeof (struct RefreshSession));
|
||||||
|
|
||||||
struct TALER_DB_ResultSpec rs[] = {
|
struct TALER_PQ_ResultSpec rs[] = {
|
||||||
TALER_DB_RESULT_SPEC("num_oldcoins", &refresh_session->num_oldcoins),
|
TALER_PQ_RESULT_SPEC("num_oldcoins", &refresh_session->num_oldcoins),
|
||||||
TALER_DB_RESULT_SPEC("num_newcoins", &refresh_session->num_newcoins),
|
TALER_PQ_RESULT_SPEC("num_newcoins", &refresh_session->num_newcoins),
|
||||||
TALER_DB_RESULT_SPEC("noreveal_index", &refresh_session->noreveal_index),
|
TALER_PQ_RESULT_SPEC("noreveal_index", &refresh_session->noreveal_index),
|
||||||
TALER_DB_RESULT_SPEC_END
|
TALER_PQ_RESULT_SPEC_END
|
||||||
};
|
};
|
||||||
|
|
||||||
res = TALER_DB_extract_result (result, rs, 0);
|
res = TALER_PQ_extract_result (result, rs, 0);
|
||||||
|
|
||||||
if (GNUNET_OK != res)
|
if (GNUNET_OK != res)
|
||||||
{
|
{
|
||||||
@ -1526,16 +1526,16 @@ postgres_create_refresh_session (void *cls,
|
|||||||
{
|
{
|
||||||
// FIXME: actually store session data!
|
// FIXME: actually store session data!
|
||||||
uint16_t noreveal_index;
|
uint16_t noreveal_index;
|
||||||
struct TALER_DB_QueryParam params[] = {
|
struct TALER_PQ_QueryParam params[] = {
|
||||||
TALER_DB_QUERY_PARAM_PTR(session_hash),
|
TALER_PQ_QUERY_PARAM_PTR(session_hash),
|
||||||
TALER_DB_QUERY_PARAM_PTR(&noreveal_index),
|
TALER_PQ_QUERY_PARAM_PTR(&noreveal_index),
|
||||||
TALER_DB_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
|
|
||||||
noreveal_index = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1<<15);
|
noreveal_index = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1<<15);
|
||||||
noreveal_index = htonl (noreveal_index);
|
noreveal_index = htonl (noreveal_index);
|
||||||
|
|
||||||
PGresult *result = TALER_DB_exec_prepared (session->conn,
|
PGresult *result = TALER_PQ_exec_prepared (session->conn,
|
||||||
"insert_refresh_session",
|
"insert_refresh_session",
|
||||||
params);
|
params);
|
||||||
|
|
||||||
@ -1577,14 +1577,14 @@ postgres_insert_refresh_melt (void *cls,
|
|||||||
buf_size = GNUNET_CRYPTO_rsa_public_key_encode (melt->coin.denom_pub.rsa_public_key,
|
buf_size = GNUNET_CRYPTO_rsa_public_key_encode (melt->coin.denom_pub.rsa_public_key,
|
||||||
&buf);
|
&buf);
|
||||||
{
|
{
|
||||||
struct TALER_DB_QueryParam params[] = {
|
struct TALER_PQ_QueryParam params[] = {
|
||||||
TALER_DB_QUERY_PARAM_PTR(&melt->session_hash),
|
TALER_PQ_QUERY_PARAM_PTR(&melt->session_hash),
|
||||||
TALER_DB_QUERY_PARAM_PTR(&oldcoin_index_nbo),
|
TALER_PQ_QUERY_PARAM_PTR(&oldcoin_index_nbo),
|
||||||
TALER_DB_QUERY_PARAM_PTR(&melt->coin.coin_pub),
|
TALER_PQ_QUERY_PARAM_PTR(&melt->coin.coin_pub),
|
||||||
TALER_DB_QUERY_PARAM_PTR_SIZED(buf, buf_size),
|
TALER_PQ_QUERY_PARAM_PTR_SIZED(buf, buf_size),
|
||||||
TALER_DB_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
result = TALER_DB_exec_prepared (session->conn,
|
result = TALER_PQ_exec_prepared (session->conn,
|
||||||
"insert_refresh_melt",
|
"insert_refresh_melt",
|
||||||
params);
|
params);
|
||||||
}
|
}
|
||||||
@ -1653,13 +1653,13 @@ postgres_insert_refresh_order (void *cls,
|
|||||||
&buf);
|
&buf);
|
||||||
|
|
||||||
{
|
{
|
||||||
struct TALER_DB_QueryParam params[] = {
|
struct TALER_PQ_QueryParam params[] = {
|
||||||
TALER_DB_QUERY_PARAM_PTR (&newcoin_index_nbo),
|
TALER_PQ_QUERY_PARAM_PTR (&newcoin_index_nbo),
|
||||||
TALER_DB_QUERY_PARAM_PTR (session_hash),
|
TALER_PQ_QUERY_PARAM_PTR (session_hash),
|
||||||
TALER_DB_QUERY_PARAM_PTR_SIZED (buf, buf_size),
|
TALER_PQ_QUERY_PARAM_PTR_SIZED (buf, buf_size),
|
||||||
TALER_DB_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
result = TALER_DB_exec_prepared (session->conn,
|
result = TALER_PQ_exec_prepared (session->conn,
|
||||||
"insert_refresh_order",
|
"insert_refresh_order",
|
||||||
params);
|
params);
|
||||||
}
|
}
|
||||||
@ -1704,13 +1704,13 @@ postgres_get_refresh_order (void *cls,
|
|||||||
size_t buf_size;
|
size_t buf_size;
|
||||||
uint16_t newcoin_index_nbo = htons (num_newcoins);
|
uint16_t newcoin_index_nbo = htons (num_newcoins);
|
||||||
|
|
||||||
struct TALER_DB_QueryParam params[] = {
|
struct TALER_PQ_QueryParam params[] = {
|
||||||
TALER_DB_QUERY_PARAM_PTR(session_hash),
|
TALER_PQ_QUERY_PARAM_PTR(session_hash),
|
||||||
TALER_DB_QUERY_PARAM_PTR(&newcoin_index_nbo),
|
TALER_PQ_QUERY_PARAM_PTR(&newcoin_index_nbo),
|
||||||
TALER_DB_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
|
|
||||||
PGresult *result = TALER_DB_exec_prepared (session->conn,
|
PGresult *result = TALER_PQ_exec_prepared (session->conn,
|
||||||
"get_refresh_order", params);
|
"get_refresh_order", params);
|
||||||
|
|
||||||
if (PGRES_TUPLES_OK != PQresultStatus (result))
|
if (PGRES_TUPLES_OK != PQresultStatus (result))
|
||||||
@ -1727,11 +1727,11 @@ postgres_get_refresh_order (void *cls,
|
|||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
GNUNET_assert (1 == PQntuples (result));
|
GNUNET_assert (1 == PQntuples (result));
|
||||||
struct TALER_DB_ResultSpec rs[] = {
|
struct TALER_PQ_ResultSpec rs[] = {
|
||||||
TALER_DB_RESULT_SPEC_VAR ("denom_pub", &buf, &buf_size),
|
TALER_PQ_RESULT_SPEC_VAR ("denom_pub", &buf, &buf_size),
|
||||||
TALER_DB_RESULT_SPEC_END
|
TALER_PQ_RESULT_SPEC_END
|
||||||
};
|
};
|
||||||
if (GNUNET_OK != TALER_DB_extract_result (result, rs, 0))
|
if (GNUNET_OK != TALER_PQ_extract_result (result, rs, 0))
|
||||||
{
|
{
|
||||||
PQclear (result);
|
PQclear (result);
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
@ -1771,18 +1771,18 @@ postgres_insert_refresh_commit_coins (void *cls,
|
|||||||
// FIXME: check logic! -- was written for single commit_coin!
|
// FIXME: check logic! -- was written for single commit_coin!
|
||||||
uint16_t cnc_index_nbo = htons (i);
|
uint16_t cnc_index_nbo = htons (i);
|
||||||
uint16_t newcoin_index_nbo = htons (num_newcoins);
|
uint16_t newcoin_index_nbo = htons (num_newcoins);
|
||||||
struct TALER_DB_QueryParam params[] = {
|
struct TALER_PQ_QueryParam params[] = {
|
||||||
TALER_DB_QUERY_PARAM_PTR(session_hash),
|
TALER_PQ_QUERY_PARAM_PTR(session_hash),
|
||||||
TALER_DB_QUERY_PARAM_PTR_SIZED(commit_coins->coin_ev, commit_coins->coin_ev_size),
|
TALER_PQ_QUERY_PARAM_PTR_SIZED(commit_coins->coin_ev, commit_coins->coin_ev_size),
|
||||||
TALER_DB_QUERY_PARAM_PTR(&cnc_index_nbo),
|
TALER_PQ_QUERY_PARAM_PTR(&cnc_index_nbo),
|
||||||
TALER_DB_QUERY_PARAM_PTR(&newcoin_index_nbo),
|
TALER_PQ_QUERY_PARAM_PTR(&newcoin_index_nbo),
|
||||||
TALER_DB_QUERY_PARAM_PTR_SIZED (commit_coins->refresh_link->coin_priv_enc,
|
TALER_PQ_QUERY_PARAM_PTR_SIZED (commit_coins->refresh_link->coin_priv_enc,
|
||||||
commit_coins->refresh_link->blinding_key_enc_size +
|
commit_coins->refresh_link->blinding_key_enc_size +
|
||||||
sizeof (struct TALER_CoinSpendPrivateKey)),
|
sizeof (union TALER_CoinSpendPrivateKeyP)),
|
||||||
TALER_DB_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
|
|
||||||
PGresult *result = TALER_DB_exec_prepared (session->conn,
|
PGresult *result = TALER_PQ_exec_prepared (session->conn,
|
||||||
"insert_refresh_commit_coin",
|
"insert_refresh_commit_coin",
|
||||||
params);
|
params);
|
||||||
|
|
||||||
@ -1829,11 +1829,11 @@ postgres_get_refresh_commit_coins (void *cls,
|
|||||||
// FIXME: check logic!
|
// FIXME: check logic!
|
||||||
uint16_t cnc_index_nbo = htons (cnc_index);
|
uint16_t cnc_index_nbo = htons (cnc_index);
|
||||||
uint16_t newcoin_index_nbo = htons (newcoin_index);
|
uint16_t newcoin_index_nbo = htons (newcoin_index);
|
||||||
struct TALER_DB_QueryParam params[] = {
|
struct TALER_PQ_QueryParam params[] = {
|
||||||
TALER_DB_QUERY_PARAM_PTR(session_hash),
|
TALER_PQ_QUERY_PARAM_PTR(session_hash),
|
||||||
TALER_DB_QUERY_PARAM_PTR(&cnc_index_nbo),
|
TALER_PQ_QUERY_PARAM_PTR(&cnc_index_nbo),
|
||||||
TALER_DB_QUERY_PARAM_PTR(&newcoin_index_nbo),
|
TALER_PQ_QUERY_PARAM_PTR(&newcoin_index_nbo),
|
||||||
TALER_DB_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
char *c_buf;
|
char *c_buf;
|
||||||
size_t c_buf_size;
|
size_t c_buf_size;
|
||||||
@ -1841,7 +1841,7 @@ postgres_get_refresh_commit_coins (void *cls,
|
|||||||
size_t rl_buf_size;
|
size_t rl_buf_size;
|
||||||
struct TALER_RefreshLinkEncrypted *rl;
|
struct TALER_RefreshLinkEncrypted *rl;
|
||||||
|
|
||||||
PGresult *result = TALER_DB_exec_prepared (session->conn,
|
PGresult *result = TALER_PQ_exec_prepared (session->conn,
|
||||||
"get_refresh_commit_coin",
|
"get_refresh_commit_coin",
|
||||||
params);
|
params);
|
||||||
|
|
||||||
@ -1858,18 +1858,18 @@ postgres_get_refresh_commit_coins (void *cls,
|
|||||||
return GNUNET_NO;
|
return GNUNET_NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TALER_DB_ResultSpec rs[] = {
|
struct TALER_PQ_ResultSpec rs[] = {
|
||||||
TALER_DB_RESULT_SPEC_VAR("coin_ev", &c_buf, &c_buf_size),
|
TALER_PQ_RESULT_SPEC_VAR("coin_ev", &c_buf, &c_buf_size),
|
||||||
TALER_DB_RESULT_SPEC_VAR("link_vector_enc", &rl_buf, &rl_buf_size),
|
TALER_PQ_RESULT_SPEC_VAR("link_vector_enc", &rl_buf, &rl_buf_size),
|
||||||
TALER_DB_RESULT_SPEC_END
|
TALER_PQ_RESULT_SPEC_END
|
||||||
};
|
};
|
||||||
if (GNUNET_YES != TALER_DB_extract_result (result, rs, 0))
|
if (GNUNET_YES != TALER_PQ_extract_result (result, rs, 0))
|
||||||
{
|
{
|
||||||
PQclear (result);
|
PQclear (result);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
PQclear (result);
|
PQclear (result);
|
||||||
if (rl_buf_size < sizeof (struct TALER_CoinSpendPrivateKey))
|
if (rl_buf_size < sizeof (union TALER_CoinSpendPrivateKeyP))
|
||||||
{
|
{
|
||||||
GNUNET_free (c_buf);
|
GNUNET_free (c_buf);
|
||||||
GNUNET_free (rl_buf);
|
GNUNET_free (rl_buf);
|
||||||
@ -1908,16 +1908,16 @@ postgres_insert_refresh_commit_links (void *cls,
|
|||||||
// FIXME: check logic!
|
// FIXME: check logic!
|
||||||
uint16_t cnc_index_nbo = htons (i);
|
uint16_t cnc_index_nbo = htons (i);
|
||||||
uint16_t oldcoin_index_nbo = htons (j);
|
uint16_t oldcoin_index_nbo = htons (j);
|
||||||
struct TALER_DB_QueryParam params[] = {
|
struct TALER_PQ_QueryParam params[] = {
|
||||||
TALER_DB_QUERY_PARAM_PTR(session_hash),
|
TALER_PQ_QUERY_PARAM_PTR(session_hash),
|
||||||
TALER_DB_QUERY_PARAM_PTR(&commit_link->transfer_pub),
|
TALER_PQ_QUERY_PARAM_PTR(&commit_link->transfer_pub),
|
||||||
TALER_DB_QUERY_PARAM_PTR(&cnc_index_nbo),
|
TALER_PQ_QUERY_PARAM_PTR(&cnc_index_nbo),
|
||||||
TALER_DB_QUERY_PARAM_PTR(&oldcoin_index_nbo),
|
TALER_PQ_QUERY_PARAM_PTR(&oldcoin_index_nbo),
|
||||||
TALER_DB_QUERY_PARAM_PTR(&commit_link->shared_secret_enc),
|
TALER_PQ_QUERY_PARAM_PTR(&commit_link->shared_secret_enc),
|
||||||
TALER_DB_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
|
|
||||||
PGresult *result = TALER_DB_exec_prepared (session->conn,
|
PGresult *result = TALER_PQ_exec_prepared (session->conn,
|
||||||
"insert_refresh_commit_link",
|
"insert_refresh_commit_link",
|
||||||
params);
|
params);
|
||||||
if (PGRES_COMMAND_OK != PQresultStatus (result))
|
if (PGRES_COMMAND_OK != PQresultStatus (result))
|
||||||
@ -1964,14 +1964,14 @@ postgres_get_refresh_commit_links (void *cls,
|
|||||||
uint16_t cnc_index_nbo = htons (i);
|
uint16_t cnc_index_nbo = htons (i);
|
||||||
uint16_t oldcoin_index_nbo = htons (num_links);
|
uint16_t oldcoin_index_nbo = htons (num_links);
|
||||||
|
|
||||||
struct TALER_DB_QueryParam params[] = {
|
struct TALER_PQ_QueryParam params[] = {
|
||||||
TALER_DB_QUERY_PARAM_PTR(session_hash),
|
TALER_PQ_QUERY_PARAM_PTR(session_hash),
|
||||||
TALER_DB_QUERY_PARAM_PTR(&cnc_index_nbo),
|
TALER_PQ_QUERY_PARAM_PTR(&cnc_index_nbo),
|
||||||
TALER_DB_QUERY_PARAM_PTR(&oldcoin_index_nbo),
|
TALER_PQ_QUERY_PARAM_PTR(&oldcoin_index_nbo),
|
||||||
TALER_DB_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
|
|
||||||
PGresult *result = TALER_DB_exec_prepared (session->conn,
|
PGresult *result = TALER_PQ_exec_prepared (session->conn,
|
||||||
"get_refresh_commit_link",
|
"get_refresh_commit_link",
|
||||||
params);
|
params);
|
||||||
if (PGRES_TUPLES_OK != PQresultStatus (result))
|
if (PGRES_TUPLES_OK != PQresultStatus (result))
|
||||||
@ -1987,13 +1987,13 @@ postgres_get_refresh_commit_links (void *cls,
|
|||||||
return GNUNET_NO;
|
return GNUNET_NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TALER_DB_ResultSpec rs[] = {
|
struct TALER_PQ_ResultSpec rs[] = {
|
||||||
TALER_DB_RESULT_SPEC("transfer_pub", &links->transfer_pub),
|
TALER_PQ_RESULT_SPEC("transfer_pub", &links->transfer_pub),
|
||||||
TALER_DB_RESULT_SPEC("link_secret_enc", &links->shared_secret_enc),
|
TALER_PQ_RESULT_SPEC("link_secret_enc", &links->shared_secret_enc),
|
||||||
TALER_DB_RESULT_SPEC_END
|
TALER_PQ_RESULT_SPEC_END
|
||||||
};
|
};
|
||||||
|
|
||||||
if (GNUNET_YES != TALER_DB_extract_result (result, rs, 0))
|
if (GNUNET_YES != TALER_PQ_extract_result (result, rs, 0))
|
||||||
{
|
{
|
||||||
PQclear (result);
|
PQclear (result);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
@ -2033,13 +2033,13 @@ postgres_insert_refresh_collectable (void *cls,
|
|||||||
buf_size = GNUNET_CRYPTO_rsa_signature_encode (ev_sig->rsa_signature,
|
buf_size = GNUNET_CRYPTO_rsa_signature_encode (ev_sig->rsa_signature,
|
||||||
&buf);
|
&buf);
|
||||||
{
|
{
|
||||||
struct TALER_DB_QueryParam params[] = {
|
struct TALER_PQ_QueryParam params[] = {
|
||||||
TALER_DB_QUERY_PARAM_PTR(session_hash),
|
TALER_PQ_QUERY_PARAM_PTR(session_hash),
|
||||||
TALER_DB_QUERY_PARAM_PTR(&newcoin_index_nbo),
|
TALER_PQ_QUERY_PARAM_PTR(&newcoin_index_nbo),
|
||||||
TALER_DB_QUERY_PARAM_PTR_SIZED(buf, buf_size),
|
TALER_PQ_QUERY_PARAM_PTR_SIZED(buf, buf_size),
|
||||||
TALER_DB_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
result = TALER_DB_exec_prepared (session->conn,
|
result = TALER_PQ_exec_prepared (session->conn,
|
||||||
"insert_refresh_collectable",
|
"insert_refresh_collectable",
|
||||||
params);
|
params);
|
||||||
}
|
}
|
||||||
@ -2067,16 +2067,16 @@ postgres_insert_refresh_collectable (void *cls,
|
|||||||
static struct LinkDataList *
|
static struct LinkDataList *
|
||||||
postgres_get_link_data_list (void *cls,
|
postgres_get_link_data_list (void *cls,
|
||||||
struct TALER_MINTDB_Session *session,
|
struct TALER_MINTDB_Session *session,
|
||||||
const struct TALER_CoinSpendPublicKey *coin_pub)
|
const union TALER_CoinSpendPublicKeyP *coin_pub)
|
||||||
{
|
{
|
||||||
// FIXME: check logic!
|
// FIXME: check logic!
|
||||||
struct LinkDataList *ldl;
|
struct LinkDataList *ldl;
|
||||||
struct LinkDataList *pos;
|
struct LinkDataList *pos;
|
||||||
struct TALER_DB_QueryParam params[] = {
|
struct TALER_PQ_QueryParam params[] = {
|
||||||
TALER_DB_QUERY_PARAM_PTR(coin_pub),
|
TALER_PQ_QUERY_PARAM_PTR(coin_pub),
|
||||||
TALER_DB_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
PGresult *result = TALER_DB_exec_prepared (session->conn, "get_link", params);
|
PGresult *result = TALER_PQ_exec_prepared (session->conn, "get_link", params);
|
||||||
|
|
||||||
ldl = NULL;
|
ldl = NULL;
|
||||||
if (PGRES_TUPLES_OK != PQresultStatus (result))
|
if (PGRES_TUPLES_OK != PQresultStatus (result))
|
||||||
@ -2106,14 +2106,14 @@ postgres_get_link_data_list (void *cls,
|
|||||||
size_t pk_buf_size;
|
size_t pk_buf_size;
|
||||||
char *sig_buf;
|
char *sig_buf;
|
||||||
size_t sig_buf_size;
|
size_t sig_buf_size;
|
||||||
struct TALER_DB_ResultSpec rs[] = {
|
struct TALER_PQ_ResultSpec rs[] = {
|
||||||
TALER_DB_RESULT_SPEC_VAR("link_vector_enc", &ld_buf, &ld_buf_size),
|
TALER_PQ_RESULT_SPEC_VAR("link_vector_enc", &ld_buf, &ld_buf_size),
|
||||||
TALER_DB_RESULT_SPEC_VAR("denom_pub", &pk_buf, &pk_buf_size),
|
TALER_PQ_RESULT_SPEC_VAR("denom_pub", &pk_buf, &pk_buf_size),
|
||||||
TALER_DB_RESULT_SPEC_VAR("ev_sig", &sig_buf, &sig_buf_size),
|
TALER_PQ_RESULT_SPEC_VAR("ev_sig", &sig_buf, &sig_buf_size),
|
||||||
TALER_DB_RESULT_SPEC_END
|
TALER_PQ_RESULT_SPEC_END
|
||||||
};
|
};
|
||||||
|
|
||||||
if (GNUNET_OK != TALER_DB_extract_result (result, rs, i))
|
if (GNUNET_OK != TALER_PQ_extract_result (result, rs, i))
|
||||||
{
|
{
|
||||||
PQclear (result);
|
PQclear (result);
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
@ -2192,17 +2192,17 @@ postgres_get_link_data_list (void *cls,
|
|||||||
static int
|
static int
|
||||||
postgres_get_transfer (void *cls,
|
postgres_get_transfer (void *cls,
|
||||||
struct TALER_MINTDB_Session *session,
|
struct TALER_MINTDB_Session *session,
|
||||||
const struct TALER_CoinSpendPublicKey *coin_pub,
|
const union TALER_CoinSpendPublicKeyP *coin_pub,
|
||||||
struct TALER_TransferPublicKey *transfer_pub,
|
struct TALER_TransferPublicKeyP *transfer_pub,
|
||||||
struct TALER_EncryptedLinkSecret *shared_secret_enc)
|
struct TALER_EncryptedLinkSecretP *shared_secret_enc)
|
||||||
{
|
{
|
||||||
// FIXME: check logic!
|
// FIXME: check logic!
|
||||||
struct TALER_DB_QueryParam params[] = {
|
struct TALER_PQ_QueryParam params[] = {
|
||||||
TALER_DB_QUERY_PARAM_PTR(coin_pub),
|
TALER_PQ_QUERY_PARAM_PTR(coin_pub),
|
||||||
TALER_DB_QUERY_PARAM_END
|
TALER_PQ_QUERY_PARAM_END
|
||||||
};
|
};
|
||||||
|
|
||||||
PGresult *result = TALER_DB_exec_prepared (session->conn, "get_transfer", params);
|
PGresult *result = TALER_PQ_exec_prepared (session->conn, "get_transfer", params);
|
||||||
|
|
||||||
if (PGRES_TUPLES_OK != PQresultStatus (result))
|
if (PGRES_TUPLES_OK != PQresultStatus (result))
|
||||||
{
|
{
|
||||||
@ -2226,13 +2226,13 @@ postgres_get_transfer (void *cls,
|
|||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TALER_DB_ResultSpec rs[] = {
|
struct TALER_PQ_ResultSpec rs[] = {
|
||||||
TALER_DB_RESULT_SPEC("transfer_pub", transfer_pub),
|
TALER_PQ_RESULT_SPEC("transfer_pub", transfer_pub),
|
||||||
TALER_DB_RESULT_SPEC("link_secret_enc", shared_secret_enc),
|
TALER_PQ_RESULT_SPEC("link_secret_enc", shared_secret_enc),
|
||||||
TALER_DB_RESULT_SPEC_END
|
TALER_PQ_RESULT_SPEC_END
|
||||||
};
|
};
|
||||||
|
|
||||||
if (GNUNET_OK != TALER_DB_extract_result (result, rs, 0))
|
if (GNUNET_OK != TALER_PQ_extract_result (result, rs, 0))
|
||||||
{
|
{
|
||||||
PQclear (result);
|
PQclear (result);
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
@ -2256,7 +2256,7 @@ postgres_get_transfer (void *cls,
|
|||||||
static struct TALER_MINT_DB_TransactionList *
|
static struct TALER_MINT_DB_TransactionList *
|
||||||
postgres_get_coin_transactions (void *cls,
|
postgres_get_coin_transactions (void *cls,
|
||||||
struct TALER_MINTDB_Session *session,
|
struct TALER_MINTDB_Session *session,
|
||||||
const struct TALER_CoinSpendPublicKey *coin_pub)
|
const union TALER_CoinSpendPublicKeyP *coin_pub)
|
||||||
{
|
{
|
||||||
// FIXME: check logic!
|
// FIXME: check logic!
|
||||||
GNUNET_break (0); // FIXME: implement!
|
GNUNET_break (0); // FIXME: implement!
|
||||||
@ -2283,14 +2283,14 @@ libtaler_plugin_mintdb_postgres_init (void *cls)
|
|||||||
if (0 != pthread_key_create (&pg->db_conn_threadlocal,
|
if (0 != pthread_key_create (&pg->db_conn_threadlocal,
|
||||||
&db_conn_destroy))
|
&db_conn_destroy))
|
||||||
{
|
{
|
||||||
LOG_ERROR ("Cannnot create pthread key.\n");
|
TALER_LOG_ERROR ("Cannnot create pthread key.\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* FIXME: use configuration section with "postgres" in its name... */
|
/* FIXME: use configuration section with "postgres" in its name... */
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
GNUNET_CONFIGURATION_get_value_string (cfg,
|
||||||
"mint", "db_conn_str",
|
"mint", "db_conn_str",
|
||||||
&pg->TALER_MINT_db_connection_cfg_str))
|
&pg->connection_cfg_str))
|
||||||
{
|
{
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"mint",
|
"mint",
|
||||||
@ -2348,7 +2348,7 @@ libtaler_plugin_mintdb_postgres_done (void *cls)
|
|||||||
struct TALER_MINTDB_Plugin *plugin = cls;
|
struct TALER_MINTDB_Plugin *plugin = cls;
|
||||||
struct PostgresClosure *pg = plugin->cls;
|
struct PostgresClosure *pg = plugin->cls;
|
||||||
|
|
||||||
GNUNET_free (pg->TALER_MINT_db_connection_cfg_str);
|
GNUNET_free (pg->connection_cfg_str);
|
||||||
GNUNET_free (pg);
|
GNUNET_free (pg);
|
||||||
GNUNET_free (plugin);
|
GNUNET_free (plugin);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
/**
|
/**
|
||||||
* Base directory of the mint (global)
|
* Base directory of the mint (global)
|
||||||
*/
|
*/
|
||||||
char *mintdir;
|
char *TMH_mint_directory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The mint's configuration (global)
|
* The mint's configuration (global)
|
||||||
@ -53,12 +53,12 @@ struct GNUNET_CONFIGURATION_Handle *cfg;
|
|||||||
* Master public key (according to the
|
* Master public key (according to the
|
||||||
* configuration in the mint directory).
|
* configuration in the mint directory).
|
||||||
*/
|
*/
|
||||||
struct GNUNET_CRYPTO_EddsaPublicKey master_pub;
|
struct GNUNET_CRYPTO_EddsaPublicKey TMH_master_public_key;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In which format does this MINT expect wiring instructions?
|
* In which format does this MINT expect wiring instructions?
|
||||||
*/
|
*/
|
||||||
char *expected_wire_format = "sepa";
|
char *TMH_expected_wire_format = "sepa";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The HTTP Daemon.
|
* The HTTP Daemon.
|
||||||
@ -98,7 +98,7 @@ handle_mhd_completion_callback (void *cls,
|
|||||||
{
|
{
|
||||||
if (NULL == *con_cls)
|
if (NULL == *con_cls)
|
||||||
return;
|
return;
|
||||||
TALER_MINT_parse_post_cleanup_callback (*con_cls);
|
TMH_PARSE_post_cleanup_callback (*con_cls);
|
||||||
*con_cls = NULL;
|
*con_cls = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,71 +125,71 @@ handle_mhd_request (void *cls,
|
|||||||
size_t *upload_data_size,
|
size_t *upload_data_size,
|
||||||
void **con_cls)
|
void **con_cls)
|
||||||
{
|
{
|
||||||
static struct RequestHandler handlers[] =
|
static struct TMH_RequestHandler handlers[] =
|
||||||
{
|
{
|
||||||
{ "/", MHD_HTTP_METHOD_GET, "text/plain",
|
{ "/", MHD_HTTP_METHOD_GET, "text/plain",
|
||||||
"Hello, I'm the mint\n", 0,
|
"Hello, I'm the mint\n", 0,
|
||||||
&TALER_MINT_handler_static_response, MHD_HTTP_OK },
|
&TMH_MHD_handler_static_response, MHD_HTTP_OK },
|
||||||
{ "/agpl", MHD_HTTP_METHOD_GET, "text/plain",
|
{ "/agpl", MHD_HTTP_METHOD_GET, "text/plain",
|
||||||
NULL, 0,
|
NULL, 0,
|
||||||
&TALER_MINT_handler_agpl_redirect, MHD_HTTP_FOUND },
|
&TMH_MHD_handler_agpl_redirect, MHD_HTTP_FOUND },
|
||||||
{ "/keys", MHD_HTTP_METHOD_GET, "application/json",
|
{ "/keys", MHD_HTTP_METHOD_GET, "application/json",
|
||||||
NULL, 0,
|
NULL, 0,
|
||||||
&TALER_MINT_handler_keys, MHD_HTTP_OK },
|
&TMH_KS_handler_keys, MHD_HTTP_OK },
|
||||||
{ "/keys", NULL, "text/plain",
|
{ "/keys", NULL, "text/plain",
|
||||||
"Only GET is allowed", 0,
|
"Only GET is allowed", 0,
|
||||||
&TALER_MINT_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
&TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
||||||
{ "/withdraw/status", MHD_HTTP_METHOD_GET, "application/json",
|
{ "/withdraw/status", MHD_HTTP_METHOD_GET, "application/json",
|
||||||
NULL, 0,
|
NULL, 0,
|
||||||
&TALER_MINT_handler_withdraw_status, MHD_HTTP_OK },
|
&TMH_WITHDRAW_handler_withdraw_status, MHD_HTTP_OK },
|
||||||
{ "/withdraw/status", NULL, "text/plain",
|
{ "/withdraw/status", NULL, "text/plain",
|
||||||
"Only GET is allowed", 0,
|
"Only GET is allowed", 0,
|
||||||
&TALER_MINT_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
&TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
||||||
{ "/withdraw/sign", MHD_HTTP_METHOD_GET, "application/json",
|
{ "/withdraw/sign", MHD_HTTP_METHOD_GET, "application/json",
|
||||||
NULL, 0,
|
NULL, 0,
|
||||||
&TALER_MINT_handler_withdraw_sign, MHD_HTTP_OK },
|
&TMH_WITHDRAW_handler_withdraw_sign, MHD_HTTP_OK },
|
||||||
{ "/withdraw/sign", NULL, "text/plain",
|
{ "/withdraw/sign", NULL, "text/plain",
|
||||||
"Only GET is allowed", 0,
|
"Only GET is allowed", 0,
|
||||||
&TALER_MINT_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
&TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
||||||
{ "/refresh/melt", MHD_HTTP_METHOD_POST, "application/json",
|
{ "/refresh/melt", MHD_HTTP_METHOD_POST, "application/json",
|
||||||
NULL, 0,
|
NULL, 0,
|
||||||
&TALER_MINT_handler_refresh_melt, MHD_HTTP_OK },
|
&TMH_REFRESH_handler_refresh_melt, MHD_HTTP_OK },
|
||||||
{ "/refresh/melt", NULL, "text/plain",
|
{ "/refresh/melt", NULL, "text/plain",
|
||||||
"Only POST is allowed", 0,
|
"Only POST is allowed", 0,
|
||||||
&TALER_MINT_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
&TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
||||||
{ "/refresh/reveal", MHD_HTTP_METHOD_POST, "application/json",
|
{ "/refresh/reveal", MHD_HTTP_METHOD_POST, "application/json",
|
||||||
NULL, 0,
|
NULL, 0,
|
||||||
&TALER_MINT_handler_refresh_melt, MHD_HTTP_OK },
|
&TMH_REFRESH_handler_refresh_melt, MHD_HTTP_OK },
|
||||||
{ "/refresh/reveal", NULL, "text/plain",
|
{ "/refresh/reveal", NULL, "text/plain",
|
||||||
"Only POST is allowed", 0,
|
"Only POST is allowed", 0,
|
||||||
&TALER_MINT_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
&TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
||||||
{ "/refresh/link", MHD_HTTP_METHOD_GET, "application/json",
|
{ "/refresh/link", MHD_HTTP_METHOD_GET, "application/json",
|
||||||
NULL, 0,
|
NULL, 0,
|
||||||
&TALER_MINT_handler_refresh_link, MHD_HTTP_OK },
|
&TMH_REFRESH_handler_refresh_link, MHD_HTTP_OK },
|
||||||
{ "/refresh/link", NULL, "text/plain",
|
{ "/refresh/link", NULL, "text/plain",
|
||||||
"Only GET is allowed", 0,
|
"Only GET is allowed", 0,
|
||||||
&TALER_MINT_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
&TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
||||||
{ "/refresh/reveal", MHD_HTTP_METHOD_GET, "application/json",
|
{ "/refresh/reveal", MHD_HTTP_METHOD_GET, "application/json",
|
||||||
NULL, 0,
|
NULL, 0,
|
||||||
&TALER_MINT_handler_refresh_reveal, MHD_HTTP_OK },
|
&TMH_REFRESH_handler_refresh_reveal, MHD_HTTP_OK },
|
||||||
{ "/refresh/reveal", NULL, "text/plain",
|
{ "/refresh/reveal", NULL, "text/plain",
|
||||||
"Only GET is allowed", 0,
|
"Only GET is allowed", 0,
|
||||||
&TALER_MINT_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
&TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
||||||
{ "/deposit", MHD_HTTP_METHOD_POST, "application/json",
|
{ "/deposit", MHD_HTTP_METHOD_POST, "application/json",
|
||||||
NULL, 0,
|
NULL, 0,
|
||||||
&TALER_MINT_handler_deposit, MHD_HTTP_OK },
|
&TMH_DEPOSIT_handler_deposit, MHD_HTTP_OK },
|
||||||
{ "/deposit", NULL, "text/plain",
|
{ "/deposit", NULL, "text/plain",
|
||||||
"Only POST is allowed", 0,
|
"Only POST is allowed", 0,
|
||||||
&TALER_MINT_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
&TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
||||||
{ NULL, NULL, NULL, NULL, 0, 0 }
|
{ NULL, NULL, NULL, NULL, 0, 0 }
|
||||||
};
|
};
|
||||||
static struct RequestHandler h404 =
|
static struct TMH_RequestHandler h404 =
|
||||||
{
|
{
|
||||||
"", NULL, "text/html",
|
"", NULL, "text/html",
|
||||||
"<html><title>404: not found</title></html>", 0,
|
"<html><title>404: not found</title></html>", 0,
|
||||||
&TALER_MINT_handler_static_response, MHD_HTTP_NOT_FOUND
|
&TMH_MHD_handler_static_response, MHD_HTTP_NOT_FOUND
|
||||||
};
|
};
|
||||||
struct RequestHandler *rh;
|
struct TMH_RequestHandler *rh;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
@ -209,7 +209,7 @@ handle_mhd_request (void *cls,
|
|||||||
upload_data,
|
upload_data,
|
||||||
upload_data_size);
|
upload_data_size);
|
||||||
}
|
}
|
||||||
return TALER_MINT_handler_static_response (&h404,
|
return TMH_MHD_handler_static_response (&h404,
|
||||||
connection,
|
connection,
|
||||||
con_cls,
|
con_cls,
|
||||||
upload_data,
|
upload_data,
|
||||||
@ -229,7 +229,7 @@ mint_serve_process_config (const char *mint_directory)
|
|||||||
{
|
{
|
||||||
unsigned long long port;
|
unsigned long long port;
|
||||||
unsigned long long kappa;
|
unsigned long long kappa;
|
||||||
char *master_pub_str;
|
char *TMH_master_public_key_str;
|
||||||
|
|
||||||
cfg = TALER_config_load (mint_directory);
|
cfg = TALER_config_load (mint_directory);
|
||||||
if (NULL == cfg)
|
if (NULL == cfg)
|
||||||
@ -240,24 +240,25 @@ mint_serve_process_config (const char *mint_directory)
|
|||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
GNUNET_CONFIGURATION_get_value_string (cfg,
|
||||||
"mint", "master_pub",
|
"mint",
|
||||||
&master_pub_str))
|
"master_public_key",
|
||||||
|
&TMH_master_public_key_str))
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"No master public key given in mint configuration.");
|
"No master public key given in mint configuration.");
|
||||||
return GNUNET_NO;
|
return GNUNET_NO;
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CRYPTO_eddsa_public_key_from_string (master_pub_str,
|
GNUNET_CRYPTO_eddsa_public_key_from_string (TMH_master_public_key_str,
|
||||||
strlen (master_pub_str),
|
strlen (TMH_master_public_key_str),
|
||||||
&master_pub))
|
&TMH_master_public_key))
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"Invalid master public key given in mint configuration.");
|
"Invalid master public key given in mint configuration.");
|
||||||
GNUNET_free (master_pub_str);
|
GNUNET_free (TMH_master_public_key_str);
|
||||||
return GNUNET_NO;
|
return GNUNET_NO;
|
||||||
}
|
}
|
||||||
GNUNET_free (master_pub_str);
|
GNUNET_free (TMH_master_public_key_str);
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_MINT_plugin_load (cfg))
|
TALER_MINT_plugin_load (cfg))
|
||||||
@ -314,7 +315,7 @@ main (int argc, char *const *argv)
|
|||||||
GNUNET_GETOPT_OPTION_HELP ("gnunet-mint-keyup OPTIONS"),
|
GNUNET_GETOPT_OPTION_HELP ("gnunet-mint-keyup OPTIONS"),
|
||||||
{'d', "mint-dir", "DIR",
|
{'d', "mint-dir", "DIR",
|
||||||
"mint directory", 1,
|
"mint directory", 1,
|
||||||
&GNUNET_GETOPT_set_filename, &mintdir},
|
&GNUNET_GETOPT_set_filename, &TMH_mint_directory},
|
||||||
GNUNET_GETOPT_OPTION_END
|
GNUNET_GETOPT_OPTION_END
|
||||||
};
|
};
|
||||||
int ret;
|
int ret;
|
||||||
@ -327,14 +328,14 @@ main (int argc, char *const *argv)
|
|||||||
options,
|
options,
|
||||||
argc, argv) < 0)
|
argc, argv) < 0)
|
||||||
return 1;
|
return 1;
|
||||||
if (NULL == mintdir)
|
if (NULL == TMH_mint_directory)
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"no mint dir given\n");
|
"no mint dir given\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GNUNET_OK != mint_serve_process_config (mintdir))
|
if (GNUNET_OK != mint_serve_process_config (TMH_mint_directory))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|
||||||
@ -352,7 +353,7 @@ main (int argc, char *const *argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = TALER_MINT_key_reload_loop ();
|
ret = TMH_KS_loop ();
|
||||||
MHD_stop_daemon (mydaemon);
|
MHD_stop_daemon (mydaemon);
|
||||||
return (GNUNET_OK == ret) ? 0 : 1;
|
return (GNUNET_OK == ret) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
* For now, we just do EUR. Should become configurable
|
* For now, we just do EUR. Should become configurable
|
||||||
* in the future!
|
* in the future!
|
||||||
*/
|
*/
|
||||||
#define MINT_CURRENCY "EUR"
|
#define TMH_MINT_CURRENCY "EUR"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,29 +41,29 @@ extern struct GNUNET_CONFIGURATION_Handle *cfg;
|
|||||||
* Main directory with mint data.
|
* Main directory with mint data.
|
||||||
* FIXME: should we have those globals really here?
|
* FIXME: should we have those globals really here?
|
||||||
*/
|
*/
|
||||||
extern char *mintdir;
|
extern char *TMH_mint_directory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In which format does this MINT expect wiring instructions?
|
* In which format does this MINT expect wiring instructions?
|
||||||
*/
|
*/
|
||||||
extern char *expected_wire_format;
|
extern char *TMH_expected_wire_format;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Master public key (according to the
|
* Master public key (according to the
|
||||||
* configuration in the mint directory).
|
* configuration in the mint directory).
|
||||||
*/
|
*/
|
||||||
extern struct GNUNET_CRYPTO_EddsaPublicKey master_pub;
|
extern struct GNUNET_CRYPTO_EddsaPublicKey TMH_master_public_key;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private key of the mint we use to sign messages.
|
* Private key of the mint we use to sign messages.
|
||||||
*/
|
*/
|
||||||
extern struct GNUNET_CRYPTO_EddsaPrivateKey mint_priv;
|
extern struct GNUNET_CRYPTO_EddsaPrivateKey TMH_mint_private_signing_key;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Struct describing an URL and the handler for it.
|
* Struct describing an URL and the handler for it.
|
||||||
*/
|
*/
|
||||||
struct RequestHandler
|
struct TMH_RequestHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,7 +102,7 @@ struct RequestHandler
|
|||||||
* @param[IN|OUT] upload_data_size number of bytes (left) in @a upload_data
|
* @param[IN|OUT] upload_data_size number of bytes (left) in @a upload_data
|
||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int (*handler)(struct RequestHandler *rh,
|
int (*handler)(struct TMH_RequestHandler *rh,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
void **connection_cls,
|
void **connection_cls,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
|
@ -98,29 +98,29 @@ calculate_transaction_list_totals (struct TALER_MINT_DB_TransactionList *tl,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_db_execute_deposit (struct MHD_Connection *connection,
|
TMH_DB_execute_deposit (struct MHD_Connection *connection,
|
||||||
const struct Deposit *deposit)
|
const struct Deposit *deposit)
|
||||||
{
|
{
|
||||||
struct TALER_MINTDB_Session *session;
|
struct TALER_MINTDB_Session *session;
|
||||||
struct TALER_MINT_DB_TransactionList *tl;
|
struct TALER_MINT_DB_TransactionList *tl;
|
||||||
struct TALER_Amount spent;
|
struct TALER_Amount spent;
|
||||||
struct TALER_Amount value;
|
struct TALER_Amount value;
|
||||||
struct MintKeyState *mks;
|
struct TMH_KS_StateHandle *mks;
|
||||||
struct TALER_MINT_DenomKeyIssuePriv *dki;
|
struct TALER_DenominationKeyIssueInformation *dki;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (NULL == (session = plugin->get_session (plugin->cls,
|
if (NULL == (session = plugin->get_session (plugin->cls,
|
||||||
GNUNET_NO)))
|
GNUNET_NO)))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
if (GNUNET_YES ==
|
if (GNUNET_YES ==
|
||||||
plugin->have_deposit (plugin->cls,
|
plugin->have_deposit (plugin->cls,
|
||||||
session,
|
session,
|
||||||
deposit))
|
deposit))
|
||||||
{
|
{
|
||||||
return TALER_MINT_reply_deposit_success (connection,
|
return TMH_RESPONSE_reply_deposit_success (connection,
|
||||||
&deposit->coin.coin_pub,
|
&deposit->coin.coin_pub,
|
||||||
&deposit->h_wire,
|
&deposit->h_wire,
|
||||||
&deposit->h_contract,
|
&deposit->h_contract,
|
||||||
@ -128,19 +128,19 @@ TALER_MINT_db_execute_deposit (struct MHD_Connection *connection,
|
|||||||
&deposit->merchant_pub,
|
&deposit->merchant_pub,
|
||||||
&deposit->amount_with_fee);
|
&deposit->amount_with_fee);
|
||||||
}
|
}
|
||||||
mks = TALER_MINT_key_state_acquire ();
|
mks = TMH_KS_acquire ();
|
||||||
dki = TALER_MINT_get_denom_key (mks,
|
dki = TMH_KS_denomination_key_lookup (mks,
|
||||||
&deposit->coin.denom_pub);
|
&deposit->coin.denom_pub);
|
||||||
TALER_amount_ntoh (&value,
|
TALER_amount_ntoh (&value,
|
||||||
&dki->issue.value);
|
&dki->issue.value);
|
||||||
TALER_MINT_key_state_release (mks);
|
TMH_KS_release (mks);
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
plugin->start (plugin->cls,
|
plugin->start (plugin->cls,
|
||||||
session))
|
session))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
/* fee for THIS transaction */
|
/* fee for THIS transaction */
|
||||||
spent = deposit->amount_with_fee;
|
spent = deposit->amount_with_fee;
|
||||||
@ -155,7 +155,7 @@ TALER_MINT_db_execute_deposit (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
plugin->free_coin_transaction_list (plugin->cls,
|
plugin->free_coin_transaction_list (plugin->cls,
|
||||||
tl);
|
tl);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
/* Check that cost of all transactions is smaller than
|
/* Check that cost of all transactions is smaller than
|
||||||
the value of the coin. */
|
the value of the coin. */
|
||||||
@ -164,7 +164,7 @@ TALER_MINT_db_execute_deposit (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
plugin->rollback (plugin->cls,
|
plugin->rollback (plugin->cls,
|
||||||
session);
|
session);
|
||||||
ret = TALER_MINT_reply_deposit_insufficient_funds (connection,
|
ret = TMH_RESPONSE_reply_deposit_insufficient_funds (connection,
|
||||||
tl);
|
tl);
|
||||||
plugin->free_coin_transaction_list (plugin->cls,
|
plugin->free_coin_transaction_list (plugin->cls,
|
||||||
tl);
|
tl);
|
||||||
@ -178,20 +178,20 @@ TALER_MINT_db_execute_deposit (struct MHD_Connection *connection,
|
|||||||
session,
|
session,
|
||||||
deposit))
|
deposit))
|
||||||
{
|
{
|
||||||
LOG_WARNING ("Failed to store /deposit information in database\n");
|
TALER_LOG_WARNING ("Failed to store /deposit information in database\n");
|
||||||
plugin->rollback (plugin->cls,
|
plugin->rollback (plugin->cls,
|
||||||
session);
|
session);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
plugin->commit (plugin->cls,
|
plugin->commit (plugin->cls,
|
||||||
session))
|
session))
|
||||||
{
|
{
|
||||||
LOG_WARNING ("/deposit transaction commit failed\n");
|
TALER_LOG_WARNING ("/deposit transaction commit failed\n");
|
||||||
return TALER_MINT_reply_commit_error (connection);
|
return TMH_RESPONSE_reply_commit_error (connection);
|
||||||
}
|
}
|
||||||
return TALER_MINT_reply_deposit_success (connection,
|
return TMH_RESPONSE_reply_deposit_success (connection,
|
||||||
&deposit->coin.coin_pub,
|
&deposit->coin.coin_pub,
|
||||||
&deposit->h_wire,
|
&deposit->h_wire,
|
||||||
&deposit->h_contract,
|
&deposit->h_contract,
|
||||||
@ -210,8 +210,8 @@ TALER_MINT_db_execute_deposit (struct MHD_Connection *connection,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_db_execute_withdraw_status (struct MHD_Connection *connection,
|
TMH_DB_execute_withdraw_status (struct MHD_Connection *connection,
|
||||||
const struct TALER_ReservePublicKey *reserve_pub)
|
const struct TALER_ReservePublicKeyP *reserve_pub)
|
||||||
{
|
{
|
||||||
struct TALER_MINTDB_Session *session;
|
struct TALER_MINTDB_Session *session;
|
||||||
struct ReserveHistory *rh;
|
struct ReserveHistory *rh;
|
||||||
@ -221,17 +221,17 @@ TALER_MINT_db_execute_withdraw_status (struct MHD_Connection *connection,
|
|||||||
GNUNET_NO)))
|
GNUNET_NO)))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
rh = plugin->get_reserve_history (plugin->cls,
|
rh = plugin->get_reserve_history (plugin->cls,
|
||||||
session,
|
session,
|
||||||
reserve_pub);
|
reserve_pub);
|
||||||
if (NULL == rh)
|
if (NULL == rh)
|
||||||
return TALER_MINT_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_NOT_FOUND,
|
MHD_HTTP_NOT_FOUND,
|
||||||
"{s:s}",
|
"{s:s}",
|
||||||
"error", "Reserve not found");
|
"error", "Reserve not found");
|
||||||
res = TALER_MINT_reply_withdraw_status_success (connection,
|
res = TMH_RESPONSE_reply_withdraw_status_success (connection,
|
||||||
rh);
|
rh);
|
||||||
plugin->free_reserve_history (plugin->cls,
|
plugin->free_reserve_history (plugin->cls,
|
||||||
rh);
|
rh);
|
||||||
@ -254,20 +254,20 @@ TALER_MINT_db_execute_withdraw_status (struct MHD_Connection *connection,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection,
|
TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
|
||||||
const struct TALER_ReservePublicKey *reserve,
|
const struct TALER_ReservePublicKeyP *reserve,
|
||||||
const struct TALER_DenominationPublicKey *denomination_pub,
|
const struct TALER_DenominationPublicKey *denomination_pub,
|
||||||
const char *blinded_msg,
|
const char *blinded_msg,
|
||||||
size_t blinded_msg_len,
|
size_t blinded_msg_len,
|
||||||
const struct TALER_ReserveSignature *signature)
|
const struct TALER_ReserveSignatureP *signature)
|
||||||
{
|
{
|
||||||
struct TALER_MINTDB_Session *session;
|
struct TALER_MINTDB_Session *session;
|
||||||
struct ReserveHistory *rh;
|
struct ReserveHistory *rh;
|
||||||
const struct ReserveHistory *pos;
|
const struct ReserveHistory *pos;
|
||||||
struct MintKeyState *key_state;
|
struct TMH_KS_StateHandle *key_state;
|
||||||
struct CollectableBlindcoin collectable;
|
struct CollectableBlindcoin collectable;
|
||||||
struct TALER_MINT_DenomKeyIssuePriv *dki;
|
struct TALER_DenominationKeyIssueInformation *dki;
|
||||||
struct TALER_MINT_DenomKeyIssuePriv *tdki;
|
struct TALER_DenominationKeyIssueInformation *tdki;
|
||||||
struct GNUNET_CRYPTO_rsa_Signature *sig;
|
struct GNUNET_CRYPTO_rsa_Signature *sig;
|
||||||
struct TALER_Amount amount_required;
|
struct TALER_Amount amount_required;
|
||||||
struct TALER_Amount deposit_total;
|
struct TALER_Amount deposit_total;
|
||||||
@ -286,7 +286,7 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
GNUNET_NO)))
|
GNUNET_NO)))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
res = plugin->get_collectable_blindcoin (plugin->cls,
|
res = plugin->get_collectable_blindcoin (plugin->cls,
|
||||||
session,
|
session,
|
||||||
@ -295,13 +295,13 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
if (GNUNET_SYSERR == res)
|
if (GNUNET_SYSERR == res)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't sign again if we have already signed the coin */
|
/* Don't sign again if we have already signed the coin */
|
||||||
if (GNUNET_YES == res)
|
if (GNUNET_YES == res)
|
||||||
{
|
{
|
||||||
res = TALER_MINT_reply_withdraw_sign_success (connection,
|
res = TMH_RESPONSE_reply_withdraw_sign_success (connection,
|
||||||
&collectable);
|
&collectable);
|
||||||
GNUNET_CRYPTO_rsa_signature_free (collectable.sig.rsa_signature);
|
GNUNET_CRYPTO_rsa_signature_free (collectable.sig.rsa_signature);
|
||||||
GNUNET_CRYPTO_rsa_public_key_free (collectable.denom_pub.rsa_public_key);
|
GNUNET_CRYPTO_rsa_public_key_free (collectable.denom_pub.rsa_public_key);
|
||||||
@ -310,13 +310,13 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
GNUNET_assert (GNUNET_NO == res);
|
GNUNET_assert (GNUNET_NO == res);
|
||||||
|
|
||||||
/* Check if balance is sufficient */
|
/* Check if balance is sufficient */
|
||||||
key_state = TALER_MINT_key_state_acquire ();
|
key_state = TMH_KS_acquire ();
|
||||||
dki = TALER_MINT_get_denom_key (key_state,
|
dki = TMH_KS_denomination_key_lookup (key_state,
|
||||||
denomination_pub);
|
denomination_pub);
|
||||||
if (NULL == dki)
|
if (NULL == dki)
|
||||||
{
|
{
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return TALER_MINT_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_NOT_FOUND,
|
MHD_HTTP_NOT_FOUND,
|
||||||
"{s:s}",
|
"{s:s}",
|
||||||
"error",
|
"error",
|
||||||
@ -327,8 +327,8 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
session))
|
session))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
rh = plugin->get_reserve_history (plugin->cls,
|
rh = plugin->get_reserve_history (plugin->cls,
|
||||||
@ -338,8 +338,8 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
plugin->rollback (plugin->cls,
|
plugin->rollback (plugin->cls,
|
||||||
session);
|
session);
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return TALER_MINT_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_NOT_FOUND,
|
MHD_HTTP_NOT_FOUND,
|
||||||
"{s:s}",
|
"{s:s}",
|
||||||
"error",
|
"error",
|
||||||
@ -359,8 +359,8 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
plugin->rollback (plugin->cls,
|
plugin->rollback (plugin->cls,
|
||||||
session);
|
session);
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* calculate balance of the reserve */
|
/* calculate balance of the reserve */
|
||||||
@ -380,13 +380,13 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
plugin->rollback (plugin->cls,
|
plugin->rollback (plugin->cls,
|
||||||
session);
|
session);
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
res |= 1;
|
res |= 1;
|
||||||
break;
|
break;
|
||||||
case TALER_MINT_DB_RO_WITHDRAW_COIN:
|
case TALER_MINT_DB_RO_WITHDRAW_COIN:
|
||||||
tdki = TALER_MINT_get_denom_key (key_state,
|
tdki = TMH_KS_denomination_key_lookup (key_state,
|
||||||
&pos->details.withdraw->denom_pub);
|
&pos->details.withdraw->denom_pub);
|
||||||
TALER_amount_ntoh (&value,
|
TALER_amount_ntoh (&value,
|
||||||
&tdki->issue.value);
|
&tdki->issue.value);
|
||||||
@ -400,8 +400,8 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
plugin->rollback (plugin->cls,
|
plugin->rollback (plugin->cls,
|
||||||
session);
|
session);
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
res |= 2;
|
res |= 2;
|
||||||
break;
|
break;
|
||||||
@ -415,10 +415,10 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
if (0 < TALER_amount_cmp (&amount_required,
|
if (0 < TALER_amount_cmp (&amount_required,
|
||||||
&balance))
|
&balance))
|
||||||
{
|
{
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
plugin->rollback (plugin->cls,
|
plugin->rollback (plugin->cls,
|
||||||
session);
|
session);
|
||||||
res = TALER_MINT_reply_withdraw_sign_insufficient_funds (connection,
|
res = TMH_RESPONSE_reply_withdraw_sign_insufficient_funds (connection,
|
||||||
rh);
|
rh);
|
||||||
plugin->free_reserve_history (plugin->cls,
|
plugin->free_reserve_history (plugin->cls,
|
||||||
rh);
|
rh);
|
||||||
@ -431,13 +431,13 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
sig = GNUNET_CRYPTO_rsa_sign (dki->denom_priv.rsa_private_key,
|
sig = GNUNET_CRYPTO_rsa_sign (dki->denom_priv.rsa_private_key,
|
||||||
blinded_msg,
|
blinded_msg,
|
||||||
blinded_msg_len);
|
blinded_msg_len);
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
if (NULL == sig)
|
if (NULL == sig)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
plugin->rollback (plugin->cls,
|
plugin->rollback (plugin->cls,
|
||||||
session);
|
session);
|
||||||
return TALER_MINT_reply_internal_error (connection,
|
return TMH_RESPONSE_reply_internal_error (connection,
|
||||||
"Internal error");
|
"Internal error");
|
||||||
}
|
}
|
||||||
collectable.sig.rsa_signature = sig;
|
collectable.sig.rsa_signature = sig;
|
||||||
@ -458,16 +458,16 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
GNUNET_CRYPTO_rsa_signature_free (sig);
|
GNUNET_CRYPTO_rsa_signature_free (sig);
|
||||||
plugin->rollback (plugin->cls,
|
plugin->rollback (plugin->cls,
|
||||||
session);
|
session);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
plugin->commit (plugin->cls,
|
plugin->commit (plugin->cls,
|
||||||
session))
|
session))
|
||||||
{
|
{
|
||||||
LOG_WARNING ("/withdraw/sign transaction commit failed\n");
|
TALER_LOG_WARNING ("/withdraw/sign transaction commit failed\n");
|
||||||
return TALER_MINT_reply_commit_error (connection);
|
return TMH_RESPONSE_reply_commit_error (connection);
|
||||||
}
|
}
|
||||||
res = TALER_MINT_reply_withdraw_sign_success (connection,
|
res = TMH_RESPONSE_reply_withdraw_sign_success (connection,
|
||||||
&collectable);
|
&collectable);
|
||||||
GNUNET_CRYPTO_rsa_signature_free (sig);
|
GNUNET_CRYPTO_rsa_signature_free (sig);
|
||||||
return res;
|
return res;
|
||||||
@ -492,13 +492,13 @@ TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
static int
|
static int
|
||||||
refresh_accept_melts (struct MHD_Connection *connection,
|
refresh_accept_melts (struct MHD_Connection *connection,
|
||||||
struct TALER_MINTDB_Session *session,
|
struct TALER_MINTDB_Session *session,
|
||||||
const struct MintKeyState *key_state,
|
const struct TMH_KS_StateHandle *key_state,
|
||||||
const struct GNUNET_HashCode *session_hash,
|
const struct GNUNET_HashCode *session_hash,
|
||||||
const struct TALER_CoinPublicInfo *coin_public_info,
|
const struct TALER_CoinPublicInfo *coin_public_info,
|
||||||
const struct MeltDetails *coin_details,
|
const struct TMH_DB_MeltDetails *coin_details,
|
||||||
uint16_t oldcoin_index)
|
uint16_t oldcoin_index)
|
||||||
{
|
{
|
||||||
struct TALER_MINT_DenomKeyIssue *dki;
|
struct TALER_DenominationKeyValidityPS *dki;
|
||||||
struct TALER_MINT_DB_TransactionList *tl;
|
struct TALER_MINT_DB_TransactionList *tl;
|
||||||
struct TALER_Amount coin_value;
|
struct TALER_Amount coin_value;
|
||||||
struct TALER_Amount coin_residual;
|
struct TALER_Amount coin_residual;
|
||||||
@ -506,12 +506,12 @@ refresh_accept_melts (struct MHD_Connection *connection,
|
|||||||
struct RefreshMelt melt;
|
struct RefreshMelt melt;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
dki = &TALER_MINT_get_denom_key (key_state,
|
dki = &TMH_KS_denomination_key_lookup (key_state,
|
||||||
&coin_public_info->denom_pub)->issue;
|
&coin_public_info->denom_pub)->issue;
|
||||||
|
|
||||||
if (NULL == dki)
|
if (NULL == dki)
|
||||||
return (MHD_YES ==
|
return (MHD_YES ==
|
||||||
TALER_MINT_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_NOT_FOUND,
|
MHD_HTTP_NOT_FOUND,
|
||||||
"{s:s}",
|
"{s:s}",
|
||||||
"error",
|
"error",
|
||||||
@ -534,7 +534,7 @@ refresh_accept_melts (struct MHD_Connection *connection,
|
|||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
plugin->free_coin_transaction_list (plugin->cls,
|
plugin->free_coin_transaction_list (plugin->cls,
|
||||||
tl);
|
tl);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
/* Refuse to refresh when the coin's value is insufficient
|
/* Refuse to refresh when the coin's value is insufficient
|
||||||
for the cost of all transactions. */
|
for the cost of all transactions. */
|
||||||
@ -546,7 +546,7 @@ refresh_accept_melts (struct MHD_Connection *connection,
|
|||||||
&spent,
|
&spent,
|
||||||
&coin_details->melt_amount_with_fee));
|
&coin_details->melt_amount_with_fee));
|
||||||
res = (MHD_YES ==
|
res = (MHD_YES ==
|
||||||
TALER_MINT_reply_refresh_melt_insufficient_funds (connection,
|
TMH_RESPONSE_reply_refresh_melt_insufficient_funds (connection,
|
||||||
&coin_public_info->coin_pub,
|
&coin_public_info->coin_pub,
|
||||||
coin_value,
|
coin_value,
|
||||||
tl,
|
tl,
|
||||||
@ -593,25 +593,25 @@ refresh_accept_melts (struct MHD_Connection *connection,
|
|||||||
* @param coin_melt_details signatures and (residual) value of the respective coin should be melted
|
* @param coin_melt_details signatures and (residual) value of the respective coin should be melted
|
||||||
* @param commit_coin 2d array of coin commitments (what the mint is to sign
|
* @param commit_coin 2d array of coin commitments (what the mint is to sign
|
||||||
* once the "/refres/reveal" of cut and choose is done),
|
* once the "/refres/reveal" of cut and choose is done),
|
||||||
* x-dimension must be #KAPPA
|
* x-dimension must be #TALER_CNC_KAPPA
|
||||||
* @param commit_link 2d array of coin link commitments (what the mint is
|
* @param commit_link 2d array of coin link commitments (what the mint is
|
||||||
* to return via "/refresh/link" to enable linkage in the
|
* to return via "/refresh/link" to enable linkage in the
|
||||||
* future)
|
* future)
|
||||||
* x-dimension must be #KAPPA
|
* x-dimension must be #TALER_CNC_KAPPA
|
||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
|
TMH_DB_execute_refresh_melt (struct MHD_Connection *connection,
|
||||||
const struct GNUNET_HashCode *session_hash,
|
const struct GNUNET_HashCode *session_hash,
|
||||||
unsigned int num_new_denoms,
|
unsigned int num_new_denoms,
|
||||||
const struct TALER_DenominationPublicKey *denom_pubs,
|
const struct TALER_DenominationPublicKey *denom_pubs,
|
||||||
unsigned int coin_count,
|
unsigned int coin_count,
|
||||||
const struct TALER_CoinPublicInfo *coin_public_infos,
|
const struct TALER_CoinPublicInfo *coin_public_infos,
|
||||||
const struct MeltDetails *coin_melt_details,
|
const struct TMH_DB_MeltDetails *coin_melt_details,
|
||||||
struct RefreshCommitCoin *const* commit_coin,
|
struct RefreshCommitCoin *const* commit_coin,
|
||||||
struct RefreshCommitLink *const* commit_link)
|
struct RefreshCommitLink *const* commit_link)
|
||||||
{
|
{
|
||||||
struct MintKeyState *key_state;
|
struct TMH_KS_StateHandle *key_state;
|
||||||
struct RefreshSession refresh_session;
|
struct RefreshSession refresh_session;
|
||||||
struct TALER_MINTDB_Session *session;
|
struct TALER_MINTDB_Session *session;
|
||||||
int res;
|
int res;
|
||||||
@ -621,14 +621,14 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
|
|||||||
GNUNET_NO)))
|
GNUNET_NO)))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
plugin->start (plugin->cls,
|
plugin->start (plugin->cls,
|
||||||
session))
|
session))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
res = plugin->get_refresh_session (plugin->cls,
|
res = plugin->get_refresh_session (plugin->cls,
|
||||||
session,
|
session,
|
||||||
@ -638,7 +638,7 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
plugin->rollback (plugin->cls,
|
plugin->rollback (plugin->cls,
|
||||||
session);
|
session);
|
||||||
res = TALER_MINT_reply_refresh_melt_success (connection,
|
res = TMH_RESPONSE_reply_refresh_melt_success (connection,
|
||||||
session_hash,
|
session_hash,
|
||||||
refresh_session.noreveal_index);
|
refresh_session.noreveal_index);
|
||||||
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
||||||
@ -647,11 +647,11 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
plugin->rollback (plugin->cls,
|
plugin->rollback (plugin->cls,
|
||||||
session);
|
session);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Melt old coins and check that they had enough residual value */
|
/* Melt old coins and check that they had enough residual value */
|
||||||
key_state = TALER_MINT_key_state_acquire ();
|
key_state = TMH_KS_acquire ();
|
||||||
for (i=0;i<coin_count;i++)
|
for (i=0;i<coin_count;i++)
|
||||||
{
|
{
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
@ -663,13 +663,13 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
|
|||||||
&coin_melt_details[i],
|
&coin_melt_details[i],
|
||||||
i)))
|
i)))
|
||||||
{
|
{
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
plugin->rollback (plugin->cls,
|
plugin->rollback (plugin->cls,
|
||||||
session);
|
session);
|
||||||
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
|
|
||||||
/* store requested new denominations */
|
/* store requested new denominations */
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
@ -681,10 +681,10 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
plugin->rollback (plugin->cls,
|
plugin->rollback (plugin->cls,
|
||||||
session);
|
session);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < KAPPA; i++)
|
for (i = 0; i < TALER_CNC_KAPPA; i++)
|
||||||
{
|
{
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
plugin->insert_refresh_commit_coins (plugin->cls,
|
plugin->insert_refresh_commit_coins (plugin->cls,
|
||||||
@ -696,10 +696,10 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
plugin->rollback (plugin->cls,
|
plugin->rollback (plugin->cls,
|
||||||
session);
|
session);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i < KAPPA; i++)
|
for (i = 0; i < TALER_CNC_KAPPA; i++)
|
||||||
{
|
{
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
plugin->insert_refresh_commit_links (plugin->cls,
|
plugin->insert_refresh_commit_links (plugin->cls,
|
||||||
@ -711,7 +711,7 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
plugin->rollback (plugin->cls,
|
plugin->rollback (plugin->cls,
|
||||||
session);
|
session);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -721,7 +721,7 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
|
|||||||
refresh_session.num_newcoins = num_new_denoms;
|
refresh_session.num_newcoins = num_new_denoms;
|
||||||
refresh_session.noreveal_index
|
refresh_session.noreveal_index
|
||||||
= GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG,
|
= GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG,
|
||||||
KAPPA);
|
TALER_CNC_KAPPA);
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
(res = plugin->create_refresh_session (plugin->cls,
|
(res = plugin->create_refresh_session (plugin->cls,
|
||||||
session,
|
session,
|
||||||
@ -730,7 +730,7 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
plugin->rollback (plugin->cls,
|
plugin->rollback (plugin->cls,
|
||||||
session);
|
session);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -739,10 +739,10 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
|
|||||||
plugin->commit (plugin->cls,
|
plugin->commit (plugin->cls,
|
||||||
session))
|
session))
|
||||||
{
|
{
|
||||||
LOG_WARNING ("/refresh/melt transaction commit failed\n");
|
TALER_LOG_WARNING ("/refresh/melt transaction commit failed\n");
|
||||||
return TALER_MINT_reply_commit_error (connection);
|
return TMH_RESPONSE_reply_commit_error (connection);
|
||||||
}
|
}
|
||||||
return TALER_MINT_reply_refresh_melt_success (connection,
|
return TMH_RESPONSE_reply_refresh_melt_success (connection,
|
||||||
session_hash,
|
session_hash,
|
||||||
refresh_session.noreveal_index);
|
refresh_session.noreveal_index);
|
||||||
}
|
}
|
||||||
@ -752,7 +752,7 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
|
|||||||
* Check if the given @a transfer_privs correspond to an honest
|
* Check if the given @a transfer_privs correspond to an honest
|
||||||
* commitment for the given session.
|
* commitment for the given session.
|
||||||
* Checks that the transfer private keys match their commitments.
|
* Checks that the transfer private keys match their commitments.
|
||||||
* Then derives the shared secret for each #KAPPA, and check that they match.
|
* Then derives the shared secret for each #TALER_CNC_KAPPA, and check that they match.
|
||||||
*
|
*
|
||||||
* @param connection the MHD connection to handle
|
* @param connection the MHD connection to handle
|
||||||
* @param session database connection to use
|
* @param session database connection to use
|
||||||
@ -773,13 +773,13 @@ check_commitment (struct MHD_Connection *connection,
|
|||||||
const struct GNUNET_HashCode *session_hash,
|
const struct GNUNET_HashCode *session_hash,
|
||||||
unsigned int off,
|
unsigned int off,
|
||||||
unsigned int num_oldcoins,
|
unsigned int num_oldcoins,
|
||||||
const struct TALER_TransferPrivateKey *transfer_privs,
|
const struct TALER_TransferPrivateKeyP *transfer_privs,
|
||||||
const struct RefreshMelt *melts,
|
const struct RefreshMelt *melts,
|
||||||
unsigned int num_newcoins,
|
unsigned int num_newcoins,
|
||||||
const struct TALER_DenominationPublicKey *denom_pubs)
|
const struct TALER_DenominationPublicKey *denom_pubs)
|
||||||
{
|
{
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
struct TALER_LinkSecret last_shared_secret;
|
struct TALER_LinkSecretP last_shared_secret;
|
||||||
int secret_initialized = GNUNET_NO;
|
int secret_initialized = GNUNET_NO;
|
||||||
struct GNUNET_CRYPTO_EcdhePublicKey coin_ecdhe;
|
struct GNUNET_CRYPTO_EcdhePublicKey coin_ecdhe;
|
||||||
struct GNUNET_CRYPTO_EcdhePrivateKey transfer_ecdhe;
|
struct GNUNET_CRYPTO_EcdhePrivateKey transfer_ecdhe;
|
||||||
@ -798,29 +798,29 @@ check_commitment (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_free (commit_links);
|
GNUNET_free (commit_links);
|
||||||
return (MHD_YES == TALER_MINT_reply_internal_db_error (connection))
|
return (MHD_YES == TMH_RESPONSE_reply_internal_db_error (connection))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < num_oldcoins; j++)
|
for (j = 0; j < num_oldcoins; j++)
|
||||||
{
|
{
|
||||||
struct TALER_TransferSecret transfer_secret;
|
struct TALER_TransferSecretP transfer_secret;
|
||||||
struct TALER_LinkSecret shared_secret;
|
struct TALER_LinkSecretP shared_secret;
|
||||||
struct TALER_TransferPublicKey transfer_pub_check;
|
struct TALER_TransferPublicKeyP transfer_pub_check;
|
||||||
|
|
||||||
GNUNET_CRYPTO_ecdsa_key_get_public (&transfer_privs[j].ecdsa_priv,
|
GNUNET_CRYPTO_ecdsa_key_get_public (&transfer_privs[j].ecdsa_priv,
|
||||||
&transfer_pub_check.ecdsa_pub);
|
&transfer_pub_check.ecdsa_pub);
|
||||||
if (0 !=
|
if (0 !=
|
||||||
memcmp (&transfer_pub_check,
|
memcmp (&transfer_pub_check,
|
||||||
&commit_links[j].transfer_pub,
|
&commit_links[j].transfer_pub,
|
||||||
sizeof (struct TALER_TransferPublicKey)))
|
sizeof (struct TALER_TransferPublicKeyP)))
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"transfer keys do not match\n");
|
"transfer keys do not match\n");
|
||||||
GNUNET_free (commit_links);
|
GNUNET_free (commit_links);
|
||||||
/* FIXME: return more specific error with original signature (#3712) */
|
/* FIXME: return more specific error with original signature (#3712) */
|
||||||
return (MHD_YES ==
|
return (MHD_YES ==
|
||||||
TALER_MINT_reply_refresh_reveal_missmatch (connection,
|
TMH_RESPONSE_reply_refresh_reveal_missmatch (connection,
|
||||||
off,
|
off,
|
||||||
j,
|
j,
|
||||||
"transfer key"))
|
"transfer key"))
|
||||||
@ -841,7 +841,7 @@ check_commitment (struct MHD_Connection *connection,
|
|||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_CRYPTO_ecdhe_key_clear (&transfer_ecdhe);
|
GNUNET_CRYPTO_ecdhe_key_clear (&transfer_ecdhe);
|
||||||
GNUNET_free (commit_links);
|
GNUNET_free (commit_links);
|
||||||
return (MHD_YES == TALER_MINT_reply_internal_error (connection,
|
return (MHD_YES == TMH_RESPONSE_reply_internal_error (connection,
|
||||||
"ECDH error"))
|
"ECDH error"))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
@ -854,7 +854,7 @@ check_commitment (struct MHD_Connection *connection,
|
|||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_free (commit_links);
|
GNUNET_free (commit_links);
|
||||||
return (MHD_YES ==
|
return (MHD_YES ==
|
||||||
TALER_MINT_reply_internal_error (connection,
|
TMH_RESPONSE_reply_internal_error (connection,
|
||||||
"Decryption error"))
|
"Decryption error"))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
@ -873,7 +873,7 @@ check_commitment (struct MHD_Connection *connection,
|
|||||||
GNUNET_free (commit_links);
|
GNUNET_free (commit_links);
|
||||||
/* FIXME: return more specific error with original signature (#3712) */
|
/* FIXME: return more specific error with original signature (#3712) */
|
||||||
return (MHD_YES ==
|
return (MHD_YES ==
|
||||||
TALER_MINT_reply_refresh_reveal_missmatch (connection,
|
TMH_RESPONSE_reply_refresh_reveal_missmatch (connection,
|
||||||
off,
|
off,
|
||||||
j,
|
j,
|
||||||
"transfer secret"))
|
"transfer secret"))
|
||||||
@ -897,14 +897,14 @@ check_commitment (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_free (commit_coins);
|
GNUNET_free (commit_coins);
|
||||||
return (MHD_YES == TALER_MINT_reply_internal_db_error (connection))
|
return (MHD_YES == TMH_RESPONSE_reply_internal_db_error (connection))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < num_newcoins; j++)
|
for (j = 0; j < num_newcoins; j++)
|
||||||
{
|
{
|
||||||
struct TALER_RefreshLinkDecrypted *link_data;
|
struct TALER_RefreshLinkDecryptedP *link_data;
|
||||||
struct TALER_CoinSpendPublicKey coin_pub;
|
union TALER_CoinSpendPublicKeyP coin_pub;
|
||||||
struct GNUNET_HashCode h_msg;
|
struct GNUNET_HashCode h_msg;
|
||||||
char *buf;
|
char *buf;
|
||||||
size_t buf_len;
|
size_t buf_len;
|
||||||
@ -915,7 +915,7 @@ check_commitment (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_free (commit_coins);
|
GNUNET_free (commit_coins);
|
||||||
return (MHD_YES == TALER_MINT_reply_internal_error (connection,
|
return (MHD_YES == TMH_RESPONSE_reply_internal_error (connection,
|
||||||
"Decryption error"))
|
"Decryption error"))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
@ -923,7 +923,7 @@ check_commitment (struct MHD_Connection *connection,
|
|||||||
GNUNET_CRYPTO_ecdsa_key_get_public (&link_data->coin_priv.ecdsa_priv,
|
GNUNET_CRYPTO_ecdsa_key_get_public (&link_data->coin_priv.ecdsa_priv,
|
||||||
&coin_pub.ecdsa_pub);
|
&coin_pub.ecdsa_pub);
|
||||||
GNUNET_CRYPTO_hash (&coin_pub,
|
GNUNET_CRYPTO_hash (&coin_pub,
|
||||||
sizeof (struct TALER_CoinSpendPublicKey),
|
sizeof (union TALER_CoinSpendPublicKeyP),
|
||||||
&h_msg);
|
&h_msg);
|
||||||
if (0 == (buf_len =
|
if (0 == (buf_len =
|
||||||
GNUNET_CRYPTO_rsa_blind (&h_msg,
|
GNUNET_CRYPTO_rsa_blind (&h_msg,
|
||||||
@ -934,7 +934,7 @@ check_commitment (struct MHD_Connection *connection,
|
|||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"blind failed\n");
|
"blind failed\n");
|
||||||
GNUNET_free (commit_coins);
|
GNUNET_free (commit_coins);
|
||||||
return (MHD_YES == TALER_MINT_reply_internal_error (connection,
|
return (MHD_YES == TMH_RESPONSE_reply_internal_error (connection,
|
||||||
"Blinding error"))
|
"Blinding error"))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
@ -951,7 +951,7 @@ check_commitment (struct MHD_Connection *connection,
|
|||||||
/* FIXME: return more specific error with original signature (#3712) */
|
/* FIXME: return more specific error with original signature (#3712) */
|
||||||
GNUNET_free (commit_coins);
|
GNUNET_free (commit_coins);
|
||||||
return (MHD_YES ==
|
return (MHD_YES ==
|
||||||
TALER_MINT_reply_refresh_reveal_missmatch (connection,
|
TMH_RESPONSE_reply_refresh_reveal_missmatch (connection,
|
||||||
off,
|
off,
|
||||||
j,
|
j,
|
||||||
"envelope"))
|
"envelope"))
|
||||||
@ -982,15 +982,15 @@ static struct TALER_DenominationSignature
|
|||||||
refresh_mint_coin (struct MHD_Connection *connection,
|
refresh_mint_coin (struct MHD_Connection *connection,
|
||||||
struct TALER_MINTDB_Session *session,
|
struct TALER_MINTDB_Session *session,
|
||||||
const struct GNUNET_HashCode *session_hash,
|
const struct GNUNET_HashCode *session_hash,
|
||||||
struct MintKeyState *key_state,
|
struct TMH_KS_StateHandle *key_state,
|
||||||
const struct TALER_DenominationPublicKey *denom_pub,
|
const struct TALER_DenominationPublicKey *denom_pub,
|
||||||
const struct RefreshCommitCoin *commit_coin,
|
const struct RefreshCommitCoin *commit_coin,
|
||||||
unsigned int coin_off)
|
unsigned int coin_off)
|
||||||
{
|
{
|
||||||
struct TALER_MINT_DenomKeyIssuePriv *dki;
|
struct TALER_DenominationKeyIssueInformation *dki;
|
||||||
struct TALER_DenominationSignature ev_sig;
|
struct TALER_DenominationSignature ev_sig;
|
||||||
|
|
||||||
dki = TALER_MINT_get_denom_key (key_state,
|
dki = TMH_KS_denomination_key_lookup (key_state,
|
||||||
denom_pub);
|
denom_pub);
|
||||||
if (NULL == dki)
|
if (NULL == dki)
|
||||||
{
|
{
|
||||||
@ -1024,7 +1024,7 @@ refresh_mint_coin (struct MHD_Connection *connection,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute a "/refresh/reveal". The client is revealing to us the
|
* Execute a "/refresh/reveal". The client is revealing to us the
|
||||||
* transfer keys for @a #KAPPA-1 sets of coins. Verify that the
|
* transfer keys for @a #TALER_CNC_KAPPA-1 sets of coins. Verify that the
|
||||||
* revealed transfer keys would allow linkage to the blinded coins,
|
* revealed transfer keys would allow linkage to the blinded coins,
|
||||||
* and if so, return the signed coins for corresponding to the set of
|
* and if so, return the signed coins for corresponding to the set of
|
||||||
* coins that was not chosen.
|
* coins that was not chosen.
|
||||||
@ -1033,19 +1033,19 @@ refresh_mint_coin (struct MHD_Connection *connection,
|
|||||||
* @param session_hash hash identifying the refresh session
|
* @param session_hash hash identifying the refresh session
|
||||||
* @param num_oldcoins size of y-dimension of @transfer_privs array
|
* @param num_oldcoins size of y-dimension of @transfer_privs array
|
||||||
* @param transfer_pubs array with the revealed transfer keys,
|
* @param transfer_pubs array with the revealed transfer keys,
|
||||||
* x-dimension must be #KAPPA - 1
|
* x-dimension must be #TALER_CNC_KAPPA - 1
|
||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
|
TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection,
|
||||||
const struct GNUNET_HashCode *session_hash,
|
const struct GNUNET_HashCode *session_hash,
|
||||||
unsigned int num_oldcoins,
|
unsigned int num_oldcoins,
|
||||||
struct TALER_TransferPrivateKey **transfer_privs)
|
struct TALER_TransferPrivateKeyP **transfer_privs)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
struct TALER_MINTDB_Session *session;
|
struct TALER_MINTDB_Session *session;
|
||||||
struct RefreshSession refresh_session;
|
struct RefreshSession refresh_session;
|
||||||
struct MintKeyState *key_state;
|
struct TMH_KS_StateHandle *key_state;
|
||||||
struct RefreshMelt *melts;
|
struct RefreshMelt *melts;
|
||||||
struct TALER_DenominationPublicKey *denom_pubs;
|
struct TALER_DenominationPublicKey *denom_pubs;
|
||||||
struct TALER_DenominationSignature *ev_sigs;
|
struct TALER_DenominationSignature *ev_sigs;
|
||||||
@ -1058,7 +1058,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
|
|||||||
GNUNET_NO)))
|
GNUNET_NO)))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
res = plugin->get_refresh_session (plugin->cls,
|
res = plugin->get_refresh_session (plugin->cls,
|
||||||
@ -1066,14 +1066,14 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
|
|||||||
session_hash,
|
session_hash,
|
||||||
&refresh_session);
|
&refresh_session);
|
||||||
if (GNUNET_NO == res)
|
if (GNUNET_NO == res)
|
||||||
return TALER_MINT_reply_arg_invalid (connection,
|
return TMH_RESPONSE_reply_arg_invalid (connection,
|
||||||
"session_hash");
|
"session_hash");
|
||||||
if (GNUNET_SYSERR == res)
|
if (GNUNET_SYSERR == res)
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
if (0 == refresh_session.num_oldcoins)
|
if (0 == refresh_session.num_oldcoins)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
melts = GNUNET_malloc (refresh_session.num_oldcoins *
|
melts = GNUNET_malloc (refresh_session.num_oldcoins *
|
||||||
@ -1089,7 +1089,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_free (melts);
|
GNUNET_free (melts);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
denom_pubs = GNUNET_malloc (refresh_session.num_newcoins *
|
denom_pubs = GNUNET_malloc (refresh_session.num_newcoins *
|
||||||
@ -1104,13 +1104,13 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
|
|||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_free (denom_pubs);
|
GNUNET_free (denom_pubs);
|
||||||
GNUNET_free (melts);
|
GNUNET_free (melts);
|
||||||
return (MHD_YES == TALER_MINT_reply_internal_db_error (connection))
|
return (MHD_YES == TMH_RESPONSE_reply_internal_db_error (connection))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
off = 0;
|
off = 0;
|
||||||
for (i=0;i<KAPPA - 1;i++)
|
for (i=0;i<TALER_CNC_KAPPA - 1;i++)
|
||||||
{
|
{
|
||||||
if (i == refresh_session.noreveal_index)
|
if (i == refresh_session.noreveal_index)
|
||||||
off = 1;
|
off = 1;
|
||||||
@ -1143,7 +1143,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
|
|||||||
for (j=0;j<refresh_session.num_newcoins;j++)
|
for (j=0;j<refresh_session.num_newcoins;j++)
|
||||||
GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key);
|
GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key);
|
||||||
GNUNET_free (denom_pubs);
|
GNUNET_free (denom_pubs);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
commit_coins = GNUNET_malloc (refresh_session.num_newcoins *
|
commit_coins = GNUNET_malloc (refresh_session.num_newcoins *
|
||||||
@ -1161,11 +1161,11 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
|
|||||||
for (j=0;j<refresh_session.num_newcoins;j++)
|
for (j=0;j<refresh_session.num_newcoins;j++)
|
||||||
GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key);
|
GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key);
|
||||||
GNUNET_free (denom_pubs);
|
GNUNET_free (denom_pubs);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
ev_sigs = GNUNET_malloc (refresh_session.num_newcoins *
|
ev_sigs = GNUNET_malloc (refresh_session.num_newcoins *
|
||||||
sizeof (struct TALER_DenominationSignature));
|
sizeof (struct TALER_DenominationSignature));
|
||||||
key_state = TALER_MINT_key_state_acquire ();
|
key_state = TMH_KS_acquire ();
|
||||||
for (j=0;j<refresh_session.num_newcoins;j++)
|
for (j=0;j<refresh_session.num_newcoins;j++)
|
||||||
{
|
{
|
||||||
ev_sigs[j] = refresh_mint_coin (connection,
|
ev_sigs[j] = refresh_mint_coin (connection,
|
||||||
@ -1177,7 +1177,7 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
|
|||||||
j);
|
j);
|
||||||
if (NULL == ev_sigs[j].rsa_signature)
|
if (NULL == ev_sigs[j].rsa_signature)
|
||||||
{
|
{
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
for (i=0;i<j;i++)
|
for (i=0;i<j;i++)
|
||||||
GNUNET_CRYPTO_rsa_signature_free (ev_sigs[i].rsa_signature);
|
GNUNET_CRYPTO_rsa_signature_free (ev_sigs[i].rsa_signature);
|
||||||
GNUNET_free (ev_sigs);
|
GNUNET_free (ev_sigs);
|
||||||
@ -1185,10 +1185,10 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
|
|||||||
GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key);
|
GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key);
|
||||||
GNUNET_free (denom_pubs);
|
GNUNET_free (denom_pubs);
|
||||||
GNUNET_free (commit_coins);
|
GNUNET_free (commit_coins);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
for (j=0;j<refresh_session.num_newcoins;j++)
|
for (j=0;j<refresh_session.num_newcoins;j++)
|
||||||
GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key);
|
GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key);
|
||||||
GNUNET_free (denom_pubs);
|
GNUNET_free (denom_pubs);
|
||||||
@ -1198,14 +1198,14 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
|
|||||||
plugin->commit (plugin->cls,
|
plugin->commit (plugin->cls,
|
||||||
session))
|
session))
|
||||||
{
|
{
|
||||||
LOG_WARNING ("/refresh/reveal transaction commit failed\n");
|
TALER_LOG_WARNING ("/refresh/reveal transaction commit failed\n");
|
||||||
for (i=0;i<refresh_session.num_newcoins;i++)
|
for (i=0;i<refresh_session.num_newcoins;i++)
|
||||||
GNUNET_CRYPTO_rsa_signature_free (ev_sigs[i].rsa_signature);
|
GNUNET_CRYPTO_rsa_signature_free (ev_sigs[i].rsa_signature);
|
||||||
GNUNET_free (ev_sigs);
|
GNUNET_free (ev_sigs);
|
||||||
return TALER_MINT_reply_commit_error (connection);
|
return TMH_RESPONSE_reply_commit_error (connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
res = TALER_MINT_reply_refresh_reveal_success (connection,
|
res = TMH_RESPONSE_reply_refresh_reveal_success (connection,
|
||||||
refresh_session.num_newcoins,
|
refresh_session.num_newcoins,
|
||||||
ev_sigs);
|
ev_sigs);
|
||||||
for (i=0;i<refresh_session.num_newcoins;i++)
|
for (i=0;i<refresh_session.num_newcoins;i++)
|
||||||
@ -1225,20 +1225,20 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_db_execute_refresh_link (struct MHD_Connection *connection,
|
TMH_DB_execute_refresh_link (struct MHD_Connection *connection,
|
||||||
const struct TALER_CoinSpendPublicKey *coin_pub)
|
const union TALER_CoinSpendPublicKeyP *coin_pub)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
struct TALER_MINTDB_Session *session;
|
struct TALER_MINTDB_Session *session;
|
||||||
struct TALER_TransferPublicKey transfer_pub;
|
struct TALER_TransferPublicKeyP transfer_pub;
|
||||||
struct TALER_EncryptedLinkSecret shared_secret_enc;
|
struct TALER_EncryptedLinkSecretP shared_secret_enc;
|
||||||
struct LinkDataList *ldl;
|
struct LinkDataList *ldl;
|
||||||
|
|
||||||
if (NULL == (session = plugin->get_session (plugin->cls,
|
if (NULL == (session = plugin->get_session (plugin->cls,
|
||||||
GNUNET_NO)))
|
GNUNET_NO)))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
res = plugin->get_transfer (plugin->cls,
|
res = plugin->get_transfer (plugin->cls,
|
||||||
session,
|
session,
|
||||||
@ -1248,11 +1248,11 @@ TALER_MINT_db_execute_refresh_link (struct MHD_Connection *connection,
|
|||||||
if (GNUNET_SYSERR == res)
|
if (GNUNET_SYSERR == res)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return TALER_MINT_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
if (GNUNET_NO == res)
|
if (GNUNET_NO == res)
|
||||||
{
|
{
|
||||||
return TALER_MINT_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_NOT_FOUND,
|
MHD_HTTP_NOT_FOUND,
|
||||||
"{s:s}",
|
"{s:s}",
|
||||||
"error",
|
"error",
|
||||||
@ -1265,13 +1265,13 @@ TALER_MINT_db_execute_refresh_link (struct MHD_Connection *connection,
|
|||||||
coin_pub);
|
coin_pub);
|
||||||
if (NULL == ldl)
|
if (NULL == ldl)
|
||||||
{
|
{
|
||||||
return TALER_MINT_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_NOT_FOUND,
|
MHD_HTTP_NOT_FOUND,
|
||||||
"{s:s}",
|
"{s:s}",
|
||||||
"error",
|
"error",
|
||||||
"link data not found (link)");
|
"link data not found (link)");
|
||||||
}
|
}
|
||||||
res = TALER_MINT_reply_refresh_link_success (connection,
|
res = TMH_RESPONSE_reply_refresh_link_success (connection,
|
||||||
&transfer_pub,
|
&transfer_pub,
|
||||||
&shared_secret_enc,
|
&shared_secret_enc,
|
||||||
ldl);
|
ldl);
|
||||||
|
@ -39,8 +39,8 @@
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_db_execute_deposit (struct MHD_Connection *connection,
|
TMH_DB_execute_deposit (struct MHD_Connection *connection,
|
||||||
const struct Deposit *deposit);
|
const struct Deposit *deposit);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,8 +52,8 @@ TALER_MINT_db_execute_deposit (struct MHD_Connection *connection,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_db_execute_withdraw_status (struct MHD_Connection *connection,
|
TMH_DB_execute_withdraw_status (struct MHD_Connection *connection,
|
||||||
const struct TALER_ReservePublicKey *reserve_pub);
|
const struct TALER_ReservePublicKeyP *reserve_pub);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,24 +71,24 @@ TALER_MINT_db_execute_withdraw_status (struct MHD_Connection *connection,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_db_execute_withdraw_sign (struct MHD_Connection *connection,
|
TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
|
||||||
const struct TALER_ReservePublicKey *reserve,
|
const struct TALER_ReservePublicKeyP *reserve,
|
||||||
const struct TALER_DenominationPublicKey *denomination_pub,
|
const struct TALER_DenominationPublicKey *denomination_pub,
|
||||||
const char *blinded_msg,
|
const char *blinded_msg,
|
||||||
size_t blinded_msg_len,
|
size_t blinded_msg_len,
|
||||||
const struct TALER_ReserveSignature *signature);
|
const struct TALER_ReserveSignatureP *signature);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Details about a melt operation of an individual coin.
|
* Details about a melt operation of an individual coin.
|
||||||
*/
|
*/
|
||||||
struct MeltDetails
|
struct TMH_DB_MeltDetails
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Signature allowing the melt (using
|
* Signature allowing the melt (using
|
||||||
* a `struct RefreshMeltConfirmSignRequestBody`) to sign over.
|
* a `struct RefreshMeltConfirmSignRequestBody`) to sign over.
|
||||||
*/
|
*/
|
||||||
struct TALER_CoinSpendSignature melt_sig;
|
union TALER_CoinSpendSignatureP melt_sig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How much of the coin's value did the client allow to be melted?
|
* How much of the coin's value did the client allow to be melted?
|
||||||
@ -121,20 +121,20 @@ struct MeltDetails
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
|
TMH_DB_execute_refresh_melt (struct MHD_Connection *connection,
|
||||||
const struct GNUNET_HashCode *session_hash,
|
const struct GNUNET_HashCode *session_hash,
|
||||||
unsigned int num_new_denoms,
|
unsigned int num_new_denoms,
|
||||||
const struct TALER_DenominationPublicKey *denom_pubs,
|
const struct TALER_DenominationPublicKey *denom_pubs,
|
||||||
unsigned int coin_count,
|
unsigned int coin_count,
|
||||||
const struct TALER_CoinPublicInfo *coin_public_infos,
|
const struct TALER_CoinPublicInfo *coin_public_infos,
|
||||||
const struct MeltDetails *coin_melt_details,
|
const struct TMH_DB_MeltDetails *coin_melt_details,
|
||||||
struct RefreshCommitCoin *const* commit_coin,
|
struct RefreshCommitCoin *const* commit_coin,
|
||||||
struct RefreshCommitLink *const* commit_link);
|
struct RefreshCommitLink *const* commit_link);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute a "/refresh/reveal". The client is revealing to us the
|
* Execute a "/refresh/reveal". The client is revealing to us the
|
||||||
* transfer keys for #KAPPA-1 sets of coins. Verify that the
|
* transfer keys for #TALER_CNC_KAPPA-1 sets of coins. Verify that the
|
||||||
* revealed transfer keys would allow linkage to the blinded coins,
|
* revealed transfer keys would allow linkage to the blinded coins,
|
||||||
* and if so, return the signed coins for corresponding to the set of
|
* and if so, return the signed coins for corresponding to the set of
|
||||||
* coins that was not chosen.
|
* coins that was not chosen.
|
||||||
@ -142,14 +142,14 @@ TALER_MINT_db_execute_refresh_melt (struct MHD_Connection *connection,
|
|||||||
* @param connection the MHD connection to handle
|
* @param connection the MHD connection to handle
|
||||||
* @param session_hash hash over the refresh session
|
* @param session_hash hash over the refresh session
|
||||||
* @param num_oldcoins size of y-dimension of @transfer_privs array
|
* @param num_oldcoins size of y-dimension of @transfer_privs array
|
||||||
* @param transfer_pubs array with the revealed transfer keys, #KAPPA is 1st-dimension
|
* @param transfer_pubs array with the revealed transfer keys, #TALER_CNC_KAPPA is 1st-dimension
|
||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
|
TMH_DB_execute_refresh_reveal (struct MHD_Connection *connection,
|
||||||
const struct GNUNET_HashCode *session_hash,
|
const struct GNUNET_HashCode *session_hash,
|
||||||
unsigned int num_oldcoins,
|
unsigned int num_oldcoins,
|
||||||
struct TALER_TransferPrivateKey **transfer_privs);
|
struct TALER_TransferPrivateKeyP **transfer_privs);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -162,8 +162,8 @@ TALER_MINT_db_execute_refresh_reveal (struct MHD_Connection *connection,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_db_execute_refresh_link (struct MHD_Connection *connection,
|
TMH_DB_execute_refresh_link (struct MHD_Connection *connection,
|
||||||
const struct TALER_CoinSpendPublicKey *coin_pub);
|
const union TALER_CoinSpendPublicKeyP *coin_pub);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -56,13 +56,13 @@ static int
|
|||||||
verify_and_execute_deposit (struct MHD_Connection *connection,
|
verify_and_execute_deposit (struct MHD_Connection *connection,
|
||||||
const struct Deposit *deposit)
|
const struct Deposit *deposit)
|
||||||
{
|
{
|
||||||
struct MintKeyState *key_state;
|
struct TMH_KS_StateHandle *key_state;
|
||||||
struct TALER_DepositRequest dr;
|
struct TALER_DepositRequestPS dr;
|
||||||
struct TALER_MINT_DenomKeyIssuePriv *dki;
|
struct TALER_DenominationKeyIssueInformation *dki;
|
||||||
struct TALER_Amount fee_deposit;
|
struct TALER_Amount fee_deposit;
|
||||||
|
|
||||||
dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_DEPOSIT);
|
dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_DEPOSIT);
|
||||||
dr.purpose.size = htonl (sizeof (struct TALER_DepositRequest));
|
dr.purpose.size = htonl (sizeof (struct TALER_DepositRequestPS));
|
||||||
dr.h_contract = deposit->h_contract;
|
dr.h_contract = deposit->h_contract;
|
||||||
dr.h_wire = deposit->h_wire;
|
dr.h_wire = deposit->h_wire;
|
||||||
dr.transaction_id = GNUNET_htonll (deposit->transaction_id);
|
dr.transaction_id = GNUNET_htonll (deposit->transaction_id);
|
||||||
@ -75,43 +75,43 @@ verify_and_execute_deposit (struct MHD_Connection *connection,
|
|||||||
&deposit->csig.ecdsa_signature,
|
&deposit->csig.ecdsa_signature,
|
||||||
&deposit->coin.coin_pub.ecdsa_pub))
|
&deposit->coin.coin_pub.ecdsa_pub))
|
||||||
{
|
{
|
||||||
LOG_WARNING ("Invalid signature on /deposit request\n");
|
TALER_LOG_WARNING ("Invalid signature on /deposit request\n");
|
||||||
return TALER_MINT_reply_arg_invalid (connection,
|
return TMH_RESPONSE_reply_arg_invalid (connection,
|
||||||
"csig");
|
"csig");
|
||||||
}
|
}
|
||||||
/* check denomination exists and is valid */
|
/* check denomination exists and is valid */
|
||||||
key_state = TALER_MINT_key_state_acquire ();
|
key_state = TMH_KS_acquire ();
|
||||||
dki = TALER_MINT_get_denom_key (key_state,
|
dki = TMH_KS_denomination_key_lookup (key_state,
|
||||||
&deposit->coin.denom_pub);
|
&deposit->coin.denom_pub);
|
||||||
if (NULL == dki)
|
if (NULL == dki)
|
||||||
{
|
{
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
LOG_WARNING ("Unknown denomination key in /deposit request\n");
|
TALER_LOG_WARNING ("Unknown denomination key in /deposit request\n");
|
||||||
return TALER_MINT_reply_arg_invalid (connection,
|
return TMH_RESPONSE_reply_arg_invalid (connection,
|
||||||
"denom_pub");
|
"denom_pub");
|
||||||
}
|
}
|
||||||
/* check coin signature */
|
/* check coin signature */
|
||||||
if (GNUNET_YES !=
|
if (GNUNET_YES !=
|
||||||
TALER_test_coin_valid (&deposit->coin))
|
TALER_test_coin_valid (&deposit->coin))
|
||||||
{
|
{
|
||||||
LOG_WARNING ("Invalid coin passed for /deposit\n");
|
TALER_LOG_WARNING ("Invalid coin passed for /deposit\n");
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return TALER_MINT_reply_coin_invalid (connection);
|
return TMH_RESPONSE_reply_coin_invalid (connection);
|
||||||
}
|
}
|
||||||
TALER_amount_ntoh (&fee_deposit,
|
TALER_amount_ntoh (&fee_deposit,
|
||||||
&dki->issue.fee_deposit);
|
&dki->issue.fee_deposit);
|
||||||
if (TALER_amount_cmp (&fee_deposit,
|
if (TALER_amount_cmp (&fee_deposit,
|
||||||
&deposit->amount_with_fee) < 0)
|
&deposit->amount_with_fee) < 0)
|
||||||
{
|
{
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return (MHD_YES ==
|
return (MHD_YES ==
|
||||||
TALER_MINT_reply_external_error (connection,
|
TMH_RESPONSE_reply_external_error (connection,
|
||||||
"deposited amount smaller than depositing fee"))
|
"deposited amount smaller than depositing fee"))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
|
|
||||||
return TALER_MINT_db_execute_deposit (connection,
|
return TMH_DB_execute_deposit (connection,
|
||||||
deposit);
|
deposit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,20 +137,20 @@ parse_and_handle_deposit_request (struct MHD_Connection *connection,
|
|||||||
struct Deposit deposit;
|
struct Deposit deposit;
|
||||||
char *wire_enc;
|
char *wire_enc;
|
||||||
size_t len;
|
size_t len;
|
||||||
struct GNUNET_MINT_ParseFieldSpec spec[] = {
|
struct TMH_PARSE_FieldSpecification spec[] = {
|
||||||
TALER_MINT_PARSE_RSA_PUBLIC_KEY ("denom_pub", &deposit.coin.denom_pub),
|
TMH_PARSE_MEMBER_RSA_PUBLIC_KEY ("denom_pub", &deposit.coin.denom_pub),
|
||||||
TALER_MINT_PARSE_RSA_SIGNATURE ("ubsig", &deposit.coin.denom_sig),
|
TMH_PARSE_MEMBER_RSA_SIGNATURE ("ubsig", &deposit.coin.denom_sig),
|
||||||
TALER_MINT_PARSE_FIXED ("coin_pub", &deposit.coin.coin_pub),
|
TMH_PARSE_MEMBER_FIXED ("coin_pub", &deposit.coin.coin_pub),
|
||||||
TALER_MINT_PARSE_FIXED ("merchant_pub", &deposit.merchant_pub),
|
TMH_PARSE_MEMBER_FIXED ("merchant_pub", &deposit.merchant_pub),
|
||||||
TALER_MINT_PARSE_FIXED ("H_a", &deposit.h_contract),
|
TMH_PARSE_MEMBER_FIXED ("H_a", &deposit.h_contract),
|
||||||
TALER_MINT_PARSE_FIXED ("H_wire", &deposit.h_wire),
|
TMH_PARSE_MEMBER_FIXED ("H_wire", &deposit.h_wire),
|
||||||
TALER_MINT_PARSE_FIXED ("csig", &deposit.csig),
|
TMH_PARSE_MEMBER_FIXED ("csig", &deposit.csig),
|
||||||
TALER_MINT_PARSE_FIXED ("transaction_id", &deposit.transaction_id),
|
TMH_PARSE_MEMBER_FIXED ("transaction_id", &deposit.transaction_id),
|
||||||
TALER_MINT_PARSE_END
|
TMH_PARSE_MEMBER_END
|
||||||
};
|
};
|
||||||
|
|
||||||
memset (&deposit, 0, sizeof (deposit));
|
memset (&deposit, 0, sizeof (deposit));
|
||||||
res = TALER_MINT_parse_json_data (connection,
|
res = TMH_PARSE_json_data (connection,
|
||||||
root,
|
root,
|
||||||
spec);
|
spec);
|
||||||
if (GNUNET_SYSERR == res)
|
if (GNUNET_SYSERR == res)
|
||||||
@ -158,18 +158,18 @@ parse_and_handle_deposit_request (struct MHD_Connection *connection,
|
|||||||
if (GNUNET_NO == res)
|
if (GNUNET_NO == res)
|
||||||
return MHD_YES; /* failure */
|
return MHD_YES; /* failure */
|
||||||
if (GNUNET_YES !=
|
if (GNUNET_YES !=
|
||||||
TALER_JSON_validate_wireformat (expected_wire_format,
|
TALER_json_validate_wireformat (TMH_expected_wire_format,
|
||||||
wire))
|
wire))
|
||||||
{
|
{
|
||||||
TALER_MINT_release_parsed_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
return TALER_MINT_reply_arg_invalid (connection,
|
return TMH_RESPONSE_reply_arg_invalid (connection,
|
||||||
"wire");
|
"wire");
|
||||||
}
|
}
|
||||||
if (NULL == (wire_enc = json_dumps (wire, JSON_COMPACT | JSON_SORT_KEYS)))
|
if (NULL == (wire_enc = json_dumps (wire, JSON_COMPACT | JSON_SORT_KEYS)))
|
||||||
{
|
{
|
||||||
LOG_WARNING ("Failed to parse JSON wire format specification for /deposit request\n");
|
TALER_LOG_WARNING ("Failed to parse JSON wire format specification for /deposit request\n");
|
||||||
TALER_MINT_release_parsed_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
return TALER_MINT_reply_arg_invalid (connection,
|
return TMH_RESPONSE_reply_arg_invalid (connection,
|
||||||
"wire");
|
"wire");
|
||||||
}
|
}
|
||||||
len = strlen (wire_enc) + 1;
|
len = strlen (wire_enc) + 1;
|
||||||
@ -182,7 +182,7 @@ parse_and_handle_deposit_request (struct MHD_Connection *connection,
|
|||||||
deposit.amount_with_fee = *amount;
|
deposit.amount_with_fee = *amount;
|
||||||
res = verify_and_execute_deposit (connection,
|
res = verify_and_execute_deposit (connection,
|
||||||
&deposit);
|
&deposit);
|
||||||
TALER_MINT_release_parsed_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ parse_and_handle_deposit_request (struct MHD_Connection *connection,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_handler_deposit (struct RequestHandler *rh,
|
TMH_DEPOSIT_handler_deposit (struct TMH_RequestHandler *rh,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
void **connection_cls,
|
void **connection_cls,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
@ -216,7 +216,7 @@ TALER_MINT_handler_deposit (struct RequestHandler *rh,
|
|||||||
struct TALER_Amount amount;
|
struct TALER_Amount amount;
|
||||||
json_t *f;
|
json_t *f;
|
||||||
|
|
||||||
res = TALER_MINT_parse_post_json (connection,
|
res = TMH_PARSE_post_json (connection,
|
||||||
connection_cls,
|
connection_cls,
|
||||||
upload_data,
|
upload_data,
|
||||||
upload_data_size,
|
upload_data_size,
|
||||||
@ -232,12 +232,12 @@ TALER_MINT_handler_deposit (struct RequestHandler *rh,
|
|||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
json_decref (json);
|
json_decref (json);
|
||||||
return TALER_MINT_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s}",
|
"{s:s}",
|
||||||
"error", "Bad format");
|
"error", "Bad format");
|
||||||
}
|
}
|
||||||
res = TALER_MINT_parse_amount_json (connection,
|
res = TMH_PARSE_amount_json (connection,
|
||||||
f,
|
f,
|
||||||
&amount);
|
&amount);
|
||||||
json_decref (f);
|
json_decref (f);
|
||||||
|
@ -45,10 +45,10 @@
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_handler_deposit (struct RequestHandler *rh,
|
TMH_DEPOSIT_handler_deposit (struct TMH_RequestHandler *rh,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
void **connection_cls,
|
void **connection_cls,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
size_t *upload_data_size);
|
size_t *upload_data_size);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -30,12 +30,12 @@
|
|||||||
* the mint. There can be multiple instances of this struct, as it is
|
* the mint. There can be multiple instances of this struct, as it is
|
||||||
* reference counted and only destroyed once the last user is done
|
* reference counted and only destroyed once the last user is done
|
||||||
* with it. The current instance is acquired using
|
* with it. The current instance is acquired using
|
||||||
* #TALER_MINT_key_state_acquire(). Using this function increases the
|
* #TMH_KS_acquire(). Using this function increases the
|
||||||
* reference count. The contents of this structure (except for the
|
* reference count. The contents of this structure (except for the
|
||||||
* reference counter) should be considered READ-ONLY until it is
|
* reference counter) should be considered READ-ONLY until it is
|
||||||
* ultimately destroyed (as there can be many concurrent users).
|
* ultimately destroyed (as there can be many concurrent users).
|
||||||
*/
|
*/
|
||||||
struct MintKeyState
|
struct TMH_KS_StateHandle
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* JSON array with denomination keys. (Currently not really used
|
* JSON array with denomination keys. (Currently not really used
|
||||||
@ -51,7 +51,7 @@ struct MintKeyState
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Cached JSON text that the mint will send for a "/keys" request.
|
* Cached JSON text that the mint will send for a "/keys" request.
|
||||||
* Includes our @e master_pub public key, the signing and
|
* Includes our @e TMH_master_public_key public key, the signing and
|
||||||
* denomination keys as well as the @e reload_time.
|
* denomination keys as well as the @e reload_time.
|
||||||
*/
|
*/
|
||||||
char *keys_json;
|
char *keys_json;
|
||||||
@ -76,7 +76,7 @@ struct MintKeyState
|
|||||||
/**
|
/**
|
||||||
* Mint signing key that should be used currently.
|
* Mint signing key that should be used currently.
|
||||||
*/
|
*/
|
||||||
struct TALER_MINT_SignKeyIssuePriv current_sign_key_issue;
|
struct TALER_MintSigningKeyValidityPSPriv current_sign_key_issue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reference count. The struct is released when the RC hits zero.
|
* Reference count. The struct is released when the RC hits zero.
|
||||||
@ -87,9 +87,9 @@ struct MintKeyState
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Mint key state. Never use directly, instead access via
|
* Mint key state. Never use directly, instead access via
|
||||||
* #TALER_MINT_key_state_acquire() and #TALER_MINT_key_state_release().
|
* #TMH_KS_acquire() and #TMH_KS_release().
|
||||||
*/
|
*/
|
||||||
static struct MintKeyState *internal_key_state;
|
static struct TMH_KS_StateHandle *internal_key_state;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mutex protecting access to #internal_key_state.
|
* Mutex protecting access to #internal_key_state.
|
||||||
@ -112,7 +112,7 @@ static int reload_pipe[2];
|
|||||||
*/
|
*/
|
||||||
static json_t *
|
static json_t *
|
||||||
denom_key_issue_to_json (const struct TALER_DenominationPublicKey *pk,
|
denom_key_issue_to_json (const struct TALER_DenominationPublicKey *pk,
|
||||||
const struct TALER_MINT_DenomKeyIssue *dki)
|
const struct TALER_DenominationKeyValidityPS *dki)
|
||||||
{
|
{
|
||||||
struct TALER_Amount value;
|
struct TALER_Amount value;
|
||||||
struct TALER_Amount fee_withdraw;
|
struct TALER_Amount fee_withdraw;
|
||||||
@ -130,24 +130,24 @@ denom_key_issue_to_json (const struct TALER_DenominationPublicKey *pk,
|
|||||||
return
|
return
|
||||||
json_pack ("{s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}",
|
json_pack ("{s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}",
|
||||||
"master_sig",
|
"master_sig",
|
||||||
TALER_JSON_from_data (&dki->signature,
|
TALER_json_from_data (&dki->signature,
|
||||||
sizeof (struct GNUNET_CRYPTO_EddsaSignature)),
|
sizeof (struct GNUNET_CRYPTO_EddsaSignature)),
|
||||||
"stamp_start",
|
"stamp_start",
|
||||||
TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (dki->start)),
|
TALER_json_from_abs (GNUNET_TIME_absolute_ntoh (dki->start)),
|
||||||
"stamp_expire_withdraw",
|
"stamp_expire_withdraw",
|
||||||
TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (dki->expire_withdraw)),
|
TALER_json_from_abs (GNUNET_TIME_absolute_ntoh (dki->expire_withdraw)),
|
||||||
"stamp_expire_deposit",
|
"stamp_expire_deposit",
|
||||||
TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (dki->expire_spend)),
|
TALER_json_from_abs (GNUNET_TIME_absolute_ntoh (dki->expire_spend)),
|
||||||
"denom_pub",
|
"denom_pub",
|
||||||
TALER_JSON_from_rsa_public_key (pk->rsa_public_key),
|
TALER_json_from_rsa_public_key (pk->rsa_public_key),
|
||||||
"value",
|
"value",
|
||||||
TALER_JSON_from_amount (&value),
|
TALER_json_from_amount (&value),
|
||||||
"fee_withdraw",
|
"fee_withdraw",
|
||||||
TALER_JSON_from_amount (&fee_withdraw),
|
TALER_json_from_amount (&fee_withdraw),
|
||||||
"fee_deposit",
|
"fee_deposit",
|
||||||
TALER_JSON_from_amount (&fee_deposit),
|
TALER_json_from_amount (&fee_deposit),
|
||||||
"fee_refresh",
|
"fee_refresh",
|
||||||
TALER_JSON_from_amount (&fee_refresh));
|
TALER_json_from_amount (&fee_refresh));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -189,13 +189,13 @@ TALER_MINT_conf_duration_provide ()
|
|||||||
static int
|
static int
|
||||||
reload_keys_denom_iter (void *cls,
|
reload_keys_denom_iter (void *cls,
|
||||||
const char *alias,
|
const char *alias,
|
||||||
const struct TALER_MINT_DenomKeyIssuePriv *dki)
|
const struct TALER_DenominationKeyIssueInformation *dki)
|
||||||
{
|
{
|
||||||
struct MintKeyState *ctx = cls;
|
struct TMH_KS_StateHandle *ctx = cls;
|
||||||
struct GNUNET_TIME_Absolute now;
|
struct GNUNET_TIME_Absolute now;
|
||||||
struct GNUNET_TIME_Absolute horizon;
|
struct GNUNET_TIME_Absolute horizon;
|
||||||
struct GNUNET_HashCode denom_key_hash;
|
struct GNUNET_HashCode denom_key_hash;
|
||||||
struct TALER_MINT_DenomKeyIssuePriv *d2;
|
struct TALER_DenominationKeyIssueInformation *d2;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
horizon = GNUNET_TIME_relative_to_absolute (TALER_MINT_conf_duration_provide ());
|
horizon = GNUNET_TIME_relative_to_absolute (TALER_MINT_conf_duration_provide ());
|
||||||
@ -220,7 +220,7 @@ reload_keys_denom_iter (void *cls,
|
|||||||
GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key,
|
GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key,
|
||||||
&denom_key_hash);
|
&denom_key_hash);
|
||||||
d2 = GNUNET_memdup (dki,
|
d2 = GNUNET_memdup (dki,
|
||||||
sizeof (struct TALER_MINT_DenomKeyIssuePriv));
|
sizeof (struct TALER_DenominationKeyIssueInformation));
|
||||||
res = GNUNET_CONTAINER_multihashmap_put (ctx->denomkey_map,
|
res = GNUNET_CONTAINER_multihashmap_put (ctx->denomkey_map,
|
||||||
&denom_key_hash,
|
&denom_key_hash,
|
||||||
d2,
|
d2,
|
||||||
@ -247,19 +247,19 @@ reload_keys_denom_iter (void *cls,
|
|||||||
* @return a JSON object describing the sign key isue (public part)
|
* @return a JSON object describing the sign key isue (public part)
|
||||||
*/
|
*/
|
||||||
static json_t *
|
static json_t *
|
||||||
sign_key_issue_to_json (const struct TALER_MINT_SignKeyIssue *ski)
|
sign_key_issue_to_json (const struct TALER_MintSigningKeyValidityPS *ski)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
json_pack ("{s:o, s:o, s:o, s:o}",
|
json_pack ("{s:o, s:o, s:o, s:o}",
|
||||||
"stamp_start",
|
"stamp_start",
|
||||||
TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (ski->start)),
|
TALER_json_from_abs (GNUNET_TIME_absolute_ntoh (ski->start)),
|
||||||
"stamp_expire",
|
"stamp_expire",
|
||||||
TALER_JSON_from_abs (GNUNET_TIME_absolute_ntoh (ski->expire)),
|
TALER_json_from_abs (GNUNET_TIME_absolute_ntoh (ski->expire)),
|
||||||
"master_sig",
|
"master_sig",
|
||||||
TALER_JSON_from_data (&ski->signature,
|
TALER_json_from_data (&ski->signature,
|
||||||
sizeof (struct GNUNET_CRYPTO_EddsaSignature)),
|
sizeof (struct GNUNET_CRYPTO_EddsaSignature)),
|
||||||
"key",
|
"key",
|
||||||
TALER_JSON_from_data (&ski->signkey_pub,
|
TALER_json_from_data (&ski->signkey_pub,
|
||||||
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)));
|
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,9 +277,9 @@ sign_key_issue_to_json (const struct TALER_MINT_SignKeyIssue *ski)
|
|||||||
static int
|
static int
|
||||||
reload_keys_sign_iter (void *cls,
|
reload_keys_sign_iter (void *cls,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
const struct TALER_MINT_SignKeyIssuePriv *ski)
|
const struct TALER_MintSigningKeyValidityPSPriv *ski)
|
||||||
{
|
{
|
||||||
struct MintKeyState *ctx = cls;
|
struct TMH_KS_StateHandle *ctx = cls;
|
||||||
struct GNUNET_TIME_Absolute now;
|
struct GNUNET_TIME_Absolute now;
|
||||||
struct GNUNET_TIME_Absolute horizon;
|
struct GNUNET_TIME_Absolute horizon;
|
||||||
|
|
||||||
@ -320,7 +320,7 @@ reload_keys_sign_iter (void *cls,
|
|||||||
/**
|
/**
|
||||||
* Iterator for freeing denomination keys.
|
* Iterator for freeing denomination keys.
|
||||||
*
|
*
|
||||||
* @param cls closure with the `struct MintKeyState`
|
* @param cls closure with the `struct TMH_KS_StateHandle`
|
||||||
* @param key key for the denomination key
|
* @param key key for the denomination key
|
||||||
* @param alias coin alias
|
* @param alias coin alias
|
||||||
* @return #GNUNET_OK to continue to iterate,
|
* @return #GNUNET_OK to continue to iterate,
|
||||||
@ -332,7 +332,7 @@ free_denom_key (void *cls,
|
|||||||
const struct GNUNET_HashCode *key,
|
const struct GNUNET_HashCode *key,
|
||||||
void *value)
|
void *value)
|
||||||
{
|
{
|
||||||
struct TALER_MINT_DenomKeyIssuePriv *dki = value;
|
struct TALER_DenominationKeyIssueInformation *dki = value;
|
||||||
|
|
||||||
GNUNET_free (dki);
|
GNUNET_free (dki);
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
@ -345,7 +345,7 @@ free_denom_key (void *cls,
|
|||||||
* @param key_state the key state to release
|
* @param key_state the key state to release
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
TALER_MINT_key_state_release (struct MintKeyState *key_state)
|
TMH_KS_release (struct TMH_KS_StateHandle *key_state)
|
||||||
{
|
{
|
||||||
GNUNET_assert (0 == pthread_mutex_lock (&internal_key_state_mutex));
|
GNUNET_assert (0 == pthread_mutex_lock (&internal_key_state_mutex));
|
||||||
GNUNET_assert (0 < key_state->refcnt);
|
GNUNET_assert (0 < key_state->refcnt);
|
||||||
@ -367,30 +367,30 @@ TALER_MINT_key_state_release (struct MintKeyState *key_state)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Acquire the key state of the mint. Updates keys if necessary.
|
* Acquire the key state of the mint. Updates keys if necessary.
|
||||||
* For every call to #TALER_MINT_key_state_acquire(), a matching call
|
* For every call to #TMH_KS_acquire(), a matching call
|
||||||
* to #TALER_MINT_key_state_release() must be made.
|
* to #TMH_KS_release() must be made.
|
||||||
*
|
*
|
||||||
* @return the key state
|
* @return the key state
|
||||||
*/
|
*/
|
||||||
struct MintKeyState *
|
struct TMH_KS_StateHandle *
|
||||||
TALER_MINT_key_state_acquire (void)
|
TMH_KS_acquire (void)
|
||||||
{
|
{
|
||||||
struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
|
struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
|
||||||
struct MintKeyState *key_state;
|
struct TMH_KS_StateHandle *key_state;
|
||||||
json_t *keys;
|
json_t *keys;
|
||||||
char *inner;
|
char *inner;
|
||||||
struct TALER_MINT_KeySetSignature ks;
|
struct TALER_MintKeySetPS ks;
|
||||||
struct TALER_MintSignature sig;
|
struct TALER_MintSignatureP sig;
|
||||||
|
|
||||||
GNUNET_assert (0 == pthread_mutex_lock (&internal_key_state_mutex));
|
GNUNET_assert (0 == pthread_mutex_lock (&internal_key_state_mutex));
|
||||||
if (internal_key_state->next_reload.abs_value_us <= now.abs_value_us)
|
if (internal_key_state->next_reload.abs_value_us <= now.abs_value_us)
|
||||||
{
|
{
|
||||||
TALER_MINT_key_state_release (internal_key_state);
|
TMH_KS_release (internal_key_state);
|
||||||
internal_key_state = NULL;
|
internal_key_state = NULL;
|
||||||
}
|
}
|
||||||
if (NULL == internal_key_state)
|
if (NULL == internal_key_state)
|
||||||
{
|
{
|
||||||
key_state = GNUNET_new (struct MintKeyState);
|
key_state = GNUNET_new (struct TMH_KS_StateHandle);
|
||||||
key_state->denom_keys_array = json_array ();
|
key_state->denom_keys_array = json_array ();
|
||||||
GNUNET_assert (NULL != key_state->denom_keys_array);
|
GNUNET_assert (NULL != key_state->denom_keys_array);
|
||||||
key_state->sign_keys_array = json_array ();
|
key_state->sign_keys_array = json_array ();
|
||||||
@ -398,10 +398,10 @@ TALER_MINT_key_state_acquire (void)
|
|||||||
key_state->denomkey_map = GNUNET_CONTAINER_multihashmap_create (32,
|
key_state->denomkey_map = GNUNET_CONTAINER_multihashmap_create (32,
|
||||||
GNUNET_NO);
|
GNUNET_NO);
|
||||||
key_state->reload_time = GNUNET_TIME_absolute_get ();
|
key_state->reload_time = GNUNET_TIME_absolute_get ();
|
||||||
TALER_MINT_denomkeys_iterate (mintdir,
|
TALER_MINT_denomkeys_iterate (TMH_mint_directory,
|
||||||
&reload_keys_denom_iter,
|
&reload_keys_denom_iter,
|
||||||
key_state);
|
key_state);
|
||||||
TALER_MINT_signkeys_iterate (mintdir,
|
TALER_MINT_signkeys_iterate (TMH_mint_directory,
|
||||||
&reload_keys_sign_iter,
|
&reload_keys_sign_iter,
|
||||||
key_state);
|
key_state);
|
||||||
key_state->next_reload = GNUNET_TIME_absolute_ntoh (key_state->current_sign_key_issue.issue.expire);
|
key_state->next_reload = GNUNET_TIME_absolute_ntoh (key_state->current_sign_key_issue.issue.expire);
|
||||||
@ -410,26 +410,26 @@ TALER_MINT_key_state_acquire (void)
|
|||||||
"No valid signing key found!\n");
|
"No valid signing key found!\n");
|
||||||
|
|
||||||
keys = json_pack ("{s:o, s:o, s:o, s:o}",
|
keys = json_pack ("{s:o, s:o, s:o, s:o}",
|
||||||
"master_pub",
|
"TMH_master_public_key",
|
||||||
TALER_JSON_from_data (&master_pub,
|
TALER_json_from_data (&TMH_master_public_key,
|
||||||
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)),
|
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)),
|
||||||
"signkeys", key_state->sign_keys_array,
|
"signkeys", key_state->sign_keys_array,
|
||||||
"denoms", key_state->denom_keys_array,
|
"denoms", key_state->denom_keys_array,
|
||||||
"list_issue_date", TALER_JSON_from_abs (key_state->reload_time));
|
"list_issue_date", TALER_json_from_abs (key_state->reload_time));
|
||||||
inner = json_dumps (keys,
|
inner = json_dumps (keys,
|
||||||
JSON_INDENT(2));
|
JSON_INDENT(2));
|
||||||
ks.purpose.size = htonl (sizeof (ks));
|
ks.purpose.size = htonl (sizeof (ks));
|
||||||
ks.purpose.purpose = htonl (TALER_SIGNATURE_KEYS_SET);
|
ks.purpose.purpose = htonl (TALER_SIGNATURE_MINT_KEY_SET);
|
||||||
ks.list_issue_date = GNUNET_TIME_absolute_hton (key_state->reload_time);
|
ks.list_issue_date = GNUNET_TIME_absolute_hton (key_state->reload_time);
|
||||||
GNUNET_CRYPTO_hash (inner,
|
GNUNET_CRYPTO_hash (inner,
|
||||||
strlen (inner),
|
strlen (inner),
|
||||||
&ks.hc);
|
&ks.hc);
|
||||||
GNUNET_free (inner);
|
GNUNET_free (inner);
|
||||||
TALER_MINT_keys_sign (&ks.purpose,
|
TMH_KS_sign (&ks.purpose,
|
||||||
&sig);
|
&sig);
|
||||||
keys = json_pack ("{s:o, s:o}",
|
keys = json_pack ("{s:o, s:o}",
|
||||||
"keys", keys,
|
"keys", keys,
|
||||||
"eddsa-signature", TALER_JSON_from_eddsa_sig (&ks.purpose,
|
"eddsa-signature", TALER_json_from_eddsa_sig (&ks.purpose,
|
||||||
&sig.eddsa_signature));
|
&sig.eddsa_signature));
|
||||||
key_state->keys_json = json_dumps (keys,
|
key_state->keys_json = json_dumps (keys,
|
||||||
JSON_INDENT (2));
|
JSON_INDENT (2));
|
||||||
@ -452,8 +452,8 @@ TALER_MINT_key_state_acquire (void)
|
|||||||
* @return the denomination key issue,
|
* @return the denomination key issue,
|
||||||
* or NULL if denom_pub could not be found
|
* or NULL if denom_pub could not be found
|
||||||
*/
|
*/
|
||||||
struct TALER_MINT_DenomKeyIssuePriv *
|
struct TALER_DenominationKeyIssueInformation *
|
||||||
TALER_MINT_get_denom_key (const struct MintKeyState *key_state,
|
TMH_KS_denomination_key_lookup (const struct TMH_KS_StateHandle *key_state,
|
||||||
const struct TALER_DenominationPublicKey *denom_pub)
|
const struct TALER_DenominationPublicKey *denom_pub)
|
||||||
{
|
{
|
||||||
struct GNUNET_HashCode hc;
|
struct GNUNET_HashCode hc;
|
||||||
@ -505,7 +505,7 @@ handle_signal (int signal_number)
|
|||||||
* (FIXME: #3474)
|
* (FIXME: #3474)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_key_reload_loop (void)
|
TMH_KS_loop (void)
|
||||||
{
|
{
|
||||||
struct sigaction act;
|
struct sigaction act;
|
||||||
struct sigaction rec;
|
struct sigaction rec;
|
||||||
@ -541,12 +541,12 @@ TALER_MINT_key_reload_loop (void)
|
|||||||
"(re-)loading keys\n");
|
"(re-)loading keys\n");
|
||||||
if (NULL != internal_key_state)
|
if (NULL != internal_key_state)
|
||||||
{
|
{
|
||||||
TALER_MINT_key_state_release (internal_key_state);
|
TMH_KS_release (internal_key_state);
|
||||||
internal_key_state = NULL;
|
internal_key_state = NULL;
|
||||||
}
|
}
|
||||||
/* This will re-initialize 'internal_key_state' with
|
/* This will re-initialize 'internal_key_state' with
|
||||||
an initial refcnt of 1 */
|
an initial refcnt of 1 */
|
||||||
(void) TALER_MINT_key_state_acquire ();
|
(void) TMH_KS_acquire ();
|
||||||
|
|
||||||
read_again:
|
read_again:
|
||||||
errno = 0;
|
errno = 0;
|
||||||
@ -582,18 +582,18 @@ read_again:
|
|||||||
* @param[OUT] sig signature over purpose using current signing key
|
* @param[OUT] sig signature over purpose using current signing key
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
TALER_MINT_keys_sign (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
|
TMH_KS_sign (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
|
||||||
struct TALER_MintSignature *sig)
|
struct TALER_MintSignatureP *sig)
|
||||||
|
|
||||||
{
|
{
|
||||||
struct MintKeyState *key_state;
|
struct TMH_KS_StateHandle *key_state;
|
||||||
|
|
||||||
key_state = TALER_MINT_key_state_acquire ();
|
key_state = TMH_KS_acquire ();
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
GNUNET_CRYPTO_eddsa_sign (&key_state->current_sign_key_issue.signkey_priv.eddsa_priv,
|
GNUNET_CRYPTO_eddsa_sign (&key_state->current_sign_key_issue.signkey_priv.eddsa_priv,
|
||||||
purpose,
|
purpose,
|
||||||
&sig->eddsa_signature));
|
&sig->eddsa_signature));
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -609,21 +609,21 @@ TALER_MINT_keys_sign (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_handler_keys (struct RequestHandler *rh,
|
TMH_KS_handler_keys (struct TMH_RequestHandler *rh,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
void **connection_cls,
|
void **connection_cls,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
size_t *upload_data_size)
|
size_t *upload_data_size)
|
||||||
{
|
{
|
||||||
struct MintKeyState *key_state;
|
struct TMH_KS_StateHandle *key_state;
|
||||||
struct MHD_Response *response;
|
struct MHD_Response *response;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
key_state = TALER_MINT_key_state_acquire ();
|
key_state = TMH_KS_acquire ();
|
||||||
response = MHD_create_response_from_buffer (strlen (key_state->keys_json),
|
response = MHD_create_response_from_buffer (strlen (key_state->keys_json),
|
||||||
key_state->keys_json,
|
key_state->keys_json,
|
||||||
MHD_RESPMEM_MUST_COPY);
|
MHD_RESPMEM_MUST_COPY);
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
if (NULL == response)
|
if (NULL == response)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
|
@ -33,18 +33,18 @@
|
|||||||
* Snapshot of the (coin and signing)
|
* Snapshot of the (coin and signing)
|
||||||
* keys (including private keys) of the mint.
|
* keys (including private keys) of the mint.
|
||||||
*/
|
*/
|
||||||
struct MintKeyState;
|
struct TMH_KS_StateHandle;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Acquire the key state of the mint. Updates keys if necessary.
|
* Acquire the key state of the mint. Updates keys if necessary.
|
||||||
* For every call to #TALER_MINT_key_state_acquire(), a matching call
|
* For every call to #TMH_KS_acquire(), a matching call
|
||||||
* to #TALER_MINT_key_state_release() must be made.
|
* to #TMH_KS_release() must be made.
|
||||||
*
|
*
|
||||||
* @return the key state
|
* @return the key state
|
||||||
*/
|
*/
|
||||||
struct MintKeyState *
|
struct TMH_KS_StateHandle *
|
||||||
TALER_MINT_key_state_acquire (void);
|
TMH_KS_acquire (void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,7 +53,7 @@ TALER_MINT_key_state_acquire (void);
|
|||||||
* @param key_state the key state to release
|
* @param key_state the key state to release
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
TALER_MINT_key_state_release (struct MintKeyState *key_state);
|
TMH_KS_release (struct TMH_KS_StateHandle *key_state);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,9 +65,9 @@ TALER_MINT_key_state_release (struct MintKeyState *key_state);
|
|||||||
* @return the denomination key issue,
|
* @return the denomination key issue,
|
||||||
* or NULL if denom_pub could not be found
|
* or NULL if denom_pub could not be found
|
||||||
*/
|
*/
|
||||||
struct TALER_MINT_DenomKeyIssuePriv *
|
struct TALER_DenominationKeyIssueInformation *
|
||||||
TALER_MINT_get_denom_key (const struct MintKeyState *key_state,
|
TMH_KS_denomination_key_lookup (const struct TMH_KS_StateHandle *key_state,
|
||||||
const struct TALER_DenominationPublicKey *denom_pub);
|
const struct TALER_DenominationPublicKey *denom_pub);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,7 +78,7 @@ TALER_MINT_get_denom_key (const struct MintKeyState *key_state,
|
|||||||
* #GNUNET_SYSERR on error
|
* #GNUNET_SYSERR on error
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_key_reload_loop (void);
|
TMH_KS_loop (void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,8 +89,8 @@ TALER_MINT_key_reload_loop (void);
|
|||||||
* @param[OUT] sig signature over purpose using current signing key
|
* @param[OUT] sig signature over purpose using current signing key
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
TALER_MINT_keys_sign (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
|
TMH_KS_sign (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
|
||||||
struct TALER_MintSignature *sig);
|
struct TALER_MintSignatureP *sig);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -104,11 +104,11 @@ TALER_MINT_keys_sign (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_handler_keys (struct RequestHandler *rh,
|
TMH_KS_handler_keys (struct TMH_RequestHandler *rh,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
void **connection_cls,
|
void **connection_cls,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
size_t *upload_data_size);
|
size_t *upload_data_size);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_handler_static_response (struct RequestHandler *rh,
|
TMH_MHD_handler_static_response (struct TMH_RequestHandler *rh,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
void **connection_cls,
|
void **connection_cls,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
@ -90,7 +90,7 @@ TALER_MINT_handler_static_response (struct RequestHandler *rh,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_handler_agpl_redirect (struct RequestHandler *rh,
|
TMH_MHD_handler_agpl_redirect (struct TMH_RequestHandler *rh,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
void **connection_cls,
|
void **connection_cls,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
@ -136,13 +136,13 @@ TALER_MINT_handler_agpl_redirect (struct RequestHandler *rh,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_handler_send_json_pack_error (struct RequestHandler *rh,
|
TMH_MHD_handler_send_json_pack_error (struct TMH_RequestHandler *rh,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
void **connection_cls,
|
void **connection_cls,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
size_t *upload_data_size)
|
size_t *upload_data_size)
|
||||||
{
|
{
|
||||||
return TALER_MINT_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
rh->response_code,
|
rh->response_code,
|
||||||
"{s:s}",
|
"{s:s}",
|
||||||
"error",
|
"error",
|
||||||
|
@ -40,11 +40,11 @@
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_handler_static_response (struct RequestHandler *rh,
|
TMH_MHD_handler_static_response (struct TMH_RequestHandler *rh,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
void **connection_cls,
|
void **connection_cls,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
size_t *upload_data_size);
|
size_t *upload_data_size);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,11 +59,11 @@ TALER_MINT_handler_static_response (struct RequestHandler *rh,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_handler_agpl_redirect (struct RequestHandler *rh,
|
TMH_MHD_handler_agpl_redirect (struct TMH_RequestHandler *rh,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
void **connection_cls,
|
void **connection_cls,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
size_t *upload_data_size);
|
size_t *upload_data_size);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,13 +80,13 @@ TALER_MINT_handler_agpl_redirect (struct RequestHandler *rh,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_helper_send_json_pack (struct RequestHandler *rh,
|
TMH_MHD_helper_send_json_pack (struct TMH_RequestHandler *rh,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
void *connection_cls,
|
void *connection_cls,
|
||||||
int response_code,
|
int response_code,
|
||||||
int do_cache,
|
int do_cache,
|
||||||
const char *fmt,
|
const char *fmt,
|
||||||
...);
|
...);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,11 +101,11 @@ TALER_MINT_helper_send_json_pack (struct RequestHandler *rh,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_handler_send_json_pack_error (struct RequestHandler *rh,
|
TMH_MHD_handler_send_json_pack_error (struct TMH_RequestHandler *rh,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
void **connection_cls,
|
void **connection_cls,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
size_t *upload_data_size);
|
size_t *upload_data_size);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -146,7 +146,7 @@ buffer_append (struct Buffer *buf,
|
|||||||
* (incrementally) process JSON data uploaded to the HTTP
|
* (incrementally) process JSON data uploaded to the HTTP
|
||||||
* server. It will store the required state in the
|
* server. It will store the required state in the
|
||||||
* "connection_cls", which must be cleaned up using
|
* "connection_cls", which must be cleaned up using
|
||||||
* #TALER_MINT_parse_post_cleanup_callback().
|
* #TMH_PARSE_post_cleanup_callback().
|
||||||
*
|
*
|
||||||
* @param connection the MHD connection
|
* @param connection the MHD connection
|
||||||
* @param con_cs the closure (points to a `struct Buffer *`)
|
* @param con_cs the closure (points to a `struct Buffer *`)
|
||||||
@ -165,7 +165,7 @@ buffer_append (struct Buffer *buf,
|
|||||||
* close HTTP session with MHD_NO)
|
* close HTTP session with MHD_NO)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_parse_post_json (struct MHD_Connection *connection,
|
TMH_PARSE_post_json (struct MHD_Connection *connection,
|
||||||
void **con_cls,
|
void **con_cls,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
size_t *upload_data_size,
|
size_t *upload_data_size,
|
||||||
@ -189,7 +189,7 @@ TALER_MINT_parse_post_json (struct MHD_Connection *connection,
|
|||||||
buffer_deinit (r);
|
buffer_deinit (r);
|
||||||
GNUNET_free (r);
|
GNUNET_free (r);
|
||||||
return (MHD_NO ==
|
return (MHD_NO ==
|
||||||
TALER_MINT_reply_internal_error (connection,
|
TMH_RESPONSE_reply_internal_error (connection,
|
||||||
"out of memory"))
|
"out of memory"))
|
||||||
? GNUNET_SYSERR : GNUNET_NO;
|
? GNUNET_SYSERR : GNUNET_NO;
|
||||||
}
|
}
|
||||||
@ -213,7 +213,7 @@ TALER_MINT_parse_post_json (struct MHD_Connection *connection,
|
|||||||
buffer_deinit (r);
|
buffer_deinit (r);
|
||||||
GNUNET_free (r);
|
GNUNET_free (r);
|
||||||
return (MHD_NO ==
|
return (MHD_NO ==
|
||||||
TALER_MINT_reply_request_too_large (connection))
|
TMH_RESPONSE_reply_request_too_large (connection))
|
||||||
? GNUNET_SYSERR : GNUNET_NO;
|
? GNUNET_SYSERR : GNUNET_NO;
|
||||||
}
|
}
|
||||||
/* everything OK, wait for more POST data */
|
/* everything OK, wait for more POST data */
|
||||||
@ -234,7 +234,7 @@ TALER_MINT_parse_post_json (struct MHD_Connection *connection,
|
|||||||
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
|
||||||
"Failed to parse JSON request body\n");
|
"Failed to parse JSON request body\n");
|
||||||
return (MHD_YES ==
|
return (MHD_YES ==
|
||||||
TALER_MINT_reply_invalid_json (connection))
|
TMH_RESPONSE_reply_invalid_json (connection))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
*con_cls = NULL;
|
*con_cls = NULL;
|
||||||
@ -248,10 +248,10 @@ TALER_MINT_parse_post_json (struct MHD_Connection *connection,
|
|||||||
* to clean up our state.
|
* to clean up our state.
|
||||||
*
|
*
|
||||||
* @param con_cls value as it was left by
|
* @param con_cls value as it was left by
|
||||||
* #TALER_MINT_parse_post_json(), to be cleaned up
|
* #TMH_PARSE_post_json(), to be cleaned up
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
TALER_MINT_parse_post_cleanup_callback (void *con_cls)
|
TMH_PARSE_post_cleanup_callback (void *con_cls)
|
||||||
{
|
{
|
||||||
struct Buffer *r = con_cls;
|
struct Buffer *r = con_cls;
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ TALER_MINT_parse_post_cleanup_callback (void *con_cls)
|
|||||||
* #GNUNET_SYSERR on internal error (error response could not be sent)
|
* #GNUNET_SYSERR on internal error (error response could not be sent)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_mhd_request_arg_data (struct MHD_Connection *connection,
|
TMH_PARSE_mhd_request_arg_data (struct MHD_Connection *connection,
|
||||||
const char *param_name,
|
const char *param_name,
|
||||||
void *out_data,
|
void *out_data,
|
||||||
size_t out_size)
|
size_t out_size)
|
||||||
@ -289,7 +289,7 @@ TALER_MINT_mhd_request_arg_data (struct MHD_Connection *connection,
|
|||||||
if (NULL == str)
|
if (NULL == str)
|
||||||
{
|
{
|
||||||
return (MHD_NO ==
|
return (MHD_NO ==
|
||||||
TALER_MINT_reply_arg_missing (connection, param_name))
|
TMH_RESPONSE_reply_arg_missing (connection, param_name))
|
||||||
? GNUNET_SYSERR : GNUNET_NO;
|
? GNUNET_SYSERR : GNUNET_NO;
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
@ -298,7 +298,7 @@ TALER_MINT_mhd_request_arg_data (struct MHD_Connection *connection,
|
|||||||
out_data,
|
out_data,
|
||||||
out_size))
|
out_size))
|
||||||
return (MHD_NO ==
|
return (MHD_NO ==
|
||||||
TALER_MINT_reply_arg_invalid (connection, param_name))
|
TMH_RESPONSE_reply_arg_invalid (connection, param_name))
|
||||||
? GNUNET_SYSERR : GNUNET_NO;
|
? GNUNET_SYSERR : GNUNET_NO;
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
@ -320,7 +320,7 @@ TALER_MINT_mhd_request_arg_data (struct MHD_Connection *connection,
|
|||||||
* #GNUNET_SYSERR on internal error (error response could not be sent)
|
* #GNUNET_SYSERR on internal error (error response could not be sent)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_mhd_request_var_arg_data (struct MHD_Connection *connection,
|
TMH_PARSE_mhd_request_var_arg_data (struct MHD_Connection *connection,
|
||||||
const char *param_name,
|
const char *param_name,
|
||||||
void **out_data,
|
void **out_data,
|
||||||
size_t *out_size)
|
size_t *out_size)
|
||||||
@ -336,7 +336,7 @@ TALER_MINT_mhd_request_var_arg_data (struct MHD_Connection *connection,
|
|||||||
if (NULL == str)
|
if (NULL == str)
|
||||||
{
|
{
|
||||||
return (MHD_NO ==
|
return (MHD_NO ==
|
||||||
TALER_MINT_reply_arg_missing (connection, param_name))
|
TMH_RESPONSE_reply_arg_missing (connection, param_name))
|
||||||
? GNUNET_SYSERR : GNUNET_NO;
|
? GNUNET_SYSERR : GNUNET_NO;
|
||||||
}
|
}
|
||||||
slen = strlen (str);
|
slen = strlen (str);
|
||||||
@ -351,7 +351,7 @@ TALER_MINT_mhd_request_var_arg_data (struct MHD_Connection *connection,
|
|||||||
GNUNET_free (out);
|
GNUNET_free (out);
|
||||||
*out_size = 0;
|
*out_size = 0;
|
||||||
return (MHD_NO ==
|
return (MHD_NO ==
|
||||||
TALER_MINT_reply_arg_invalid (connection, param_name))
|
TMH_RESPONSE_reply_arg_invalid (connection, param_name))
|
||||||
? GNUNET_SYSERR : GNUNET_NO;
|
? GNUNET_SYSERR : GNUNET_NO;
|
||||||
}
|
}
|
||||||
*out_data = out;
|
*out_data = out;
|
||||||
@ -368,7 +368,7 @@ TALER_MINT_mhd_request_var_arg_data (struct MHD_Connection *connection,
|
|||||||
*
|
*
|
||||||
* @param connection the connection to send an error response to
|
* @param connection the connection to send an error response to
|
||||||
* @param root the JSON node to start the navigation at.
|
* @param root the JSON node to start the navigation at.
|
||||||
* @param ... navigation specification (see `enum TALER_MINT_JsonNavigationCommand`)
|
* @param ... navigation specification (see `enum TMH_PARSE_JsonNavigationCommand`)
|
||||||
* @return
|
* @return
|
||||||
* #GNUNET_YES if navigation was successful
|
* #GNUNET_YES if navigation was successful
|
||||||
* #GNUNET_NO if json is malformed, error response was generated
|
* #GNUNET_NO if json is malformed, error response was generated
|
||||||
@ -376,7 +376,7 @@ TALER_MINT_mhd_request_var_arg_data (struct MHD_Connection *connection,
|
|||||||
* connection must be closed)
|
* connection must be closed)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
||||||
const json_t *root,
|
const json_t *root,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
@ -389,13 +389,13 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
ret = 2; /* just not any of the valid return values */
|
ret = 2; /* just not any of the valid return values */
|
||||||
while (2 == ret)
|
while (2 == ret)
|
||||||
{
|
{
|
||||||
enum TALER_MINT_JsonNavigationCommand command
|
enum TMH_PARSE_JsonNavigationCommand command
|
||||||
= va_arg (argp,
|
= va_arg (argp,
|
||||||
enum TALER_MINT_JsonNavigationCommand);
|
enum TMH_PARSE_JsonNavigationCommand);
|
||||||
|
|
||||||
switch (command)
|
switch (command)
|
||||||
{
|
{
|
||||||
case JNAV_FIELD:
|
case TMH_PARSE_JNC_FIELD:
|
||||||
{
|
{
|
||||||
const char *fname = va_arg(argp, const char *);
|
const char *fname = va_arg(argp, const char *);
|
||||||
|
|
||||||
@ -406,7 +406,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
if (NULL == root)
|
if (NULL == root)
|
||||||
{
|
{
|
||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TALER_MINT_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:s, s:o}",
|
"{s:s, s:s, s:o}",
|
||||||
"error",
|
"error",
|
||||||
@ -421,7 +421,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JNAV_INDEX:
|
case TMH_PARSE_JNC_INDEX:
|
||||||
{
|
{
|
||||||
int fnum = va_arg(argp, int);
|
int fnum = va_arg(argp, int);
|
||||||
|
|
||||||
@ -432,7 +432,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
if (NULL == root)
|
if (NULL == root)
|
||||||
{
|
{
|
||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TALER_MINT_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"error",
|
"error",
|
||||||
@ -444,7 +444,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JNAV_RET_DATA:
|
case TMH_PARSE_JNC_RET_DATA:
|
||||||
{
|
{
|
||||||
void *where = va_arg (argp, void *);
|
void *where = va_arg (argp, void *);
|
||||||
size_t len = va_arg (argp, size_t);
|
size_t len = va_arg (argp, size_t);
|
||||||
@ -456,7 +456,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
if (NULL == str)
|
if (NULL == str)
|
||||||
{
|
{
|
||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TALER_MINT_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"error",
|
"error",
|
||||||
@ -471,7 +471,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
if (GNUNET_OK != res)
|
if (GNUNET_OK != res)
|
||||||
{
|
{
|
||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TALER_MINT_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"error",
|
"error",
|
||||||
@ -485,7 +485,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JNAV_RET_DATA_VAR:
|
case TMH_PARSE_JNC_RET_DATA_VAR:
|
||||||
{
|
{
|
||||||
void **where = va_arg (argp, void **);
|
void **where = va_arg (argp, void **);
|
||||||
size_t *len = va_arg (argp, size_t *);
|
size_t *len = va_arg (argp, size_t *);
|
||||||
@ -496,7 +496,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
if (NULL == str)
|
if (NULL == str)
|
||||||
{
|
{
|
||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TALER_MINT_reply_internal_error (connection,
|
TMH_RESPONSE_reply_internal_error (connection,
|
||||||
"json_string_value() failed"))
|
"json_string_value() failed"))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
break;
|
break;
|
||||||
@ -517,7 +517,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
*where = NULL;
|
*where = NULL;
|
||||||
*len = 0;
|
*len = 0;
|
||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TALER_MINT_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"error",
|
"error",
|
||||||
@ -531,7 +531,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JNAV_RET_TYPED_JSON:
|
case TMH_PARSE_JNC_RET_TYPED_JSON:
|
||||||
{
|
{
|
||||||
int typ = va_arg (argp, int);
|
int typ = va_arg (argp, int);
|
||||||
const json_t **r_json = va_arg (argp, const json_t **);
|
const json_t **r_json = va_arg (argp, const json_t **);
|
||||||
@ -539,7 +539,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
if ( (-1 != typ) && (json_typeof (root) != typ))
|
if ( (-1 != typ) && (json_typeof (root) != typ))
|
||||||
{
|
{
|
||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TALER_MINT_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:i, s:i, s:o}",
|
"{s:s, s:i, s:i, s:o}",
|
||||||
"error", "wrong JSON field type",
|
"error", "wrong JSON field type",
|
||||||
@ -554,7 +554,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JNAV_RET_RSA_PUBLIC_KEY:
|
case TMH_PARSE_JNC_RET_RSA_PUBLIC_KEY:
|
||||||
{
|
{
|
||||||
void **where = va_arg (argp, void **);
|
void **where = va_arg (argp, void **);
|
||||||
size_t len;
|
size_t len;
|
||||||
@ -567,7 +567,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
if (NULL == str)
|
if (NULL == str)
|
||||||
{
|
{
|
||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TALER_MINT_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"error",
|
"error",
|
||||||
@ -587,7 +587,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
GNUNET_free (buf);
|
GNUNET_free (buf);
|
||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TALER_MINT_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"error",
|
"error",
|
||||||
@ -603,7 +603,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
if (NULL == *where)
|
if (NULL == *where)
|
||||||
{
|
{
|
||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TALER_MINT_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"error",
|
"error",
|
||||||
@ -617,7 +617,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case JNAV_RET_RSA_SIGNATURE:
|
case TMH_PARSE_JNC_RET_RSA_SIGNATURE:
|
||||||
{
|
{
|
||||||
void **where = va_arg (argp, void **);
|
void **where = va_arg (argp, void **);
|
||||||
size_t len;
|
size_t len;
|
||||||
@ -630,7 +630,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
if (NULL == str)
|
if (NULL == str)
|
||||||
{
|
{
|
||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TALER_MINT_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"error",
|
"error",
|
||||||
@ -650,7 +650,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
GNUNET_free (buf);
|
GNUNET_free (buf);
|
||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TALER_MINT_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"error",
|
"error",
|
||||||
@ -666,7 +666,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
if (NULL == *where)
|
if (NULL == *where)
|
||||||
{
|
{
|
||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TALER_MINT_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"error",
|
"error",
|
||||||
@ -680,11 +680,11 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case JNAV_RET_AMOUNT:
|
case TMH_PARSE_JNC_RET_AMOUNT:
|
||||||
{
|
{
|
||||||
struct TALER_Amount *where = va_arg (argp, void *);
|
struct TALER_Amount *where = va_arg (argp, void *);
|
||||||
|
|
||||||
ret = TALER_MINT_parse_amount_json (connection,
|
ret = TMH_PARSE_amount_json (connection,
|
||||||
(json_t *) root,
|
(json_t *) root,
|
||||||
where);
|
where);
|
||||||
break;
|
break;
|
||||||
@ -693,7 +693,7 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
default:
|
default:
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TALER_MINT_reply_internal_error (connection,
|
TMH_RESPONSE_reply_internal_error (connection,
|
||||||
"unhandled value in switch"))
|
"unhandled value in switch"))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
break;
|
break;
|
||||||
@ -715,14 +715,14 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
* @return
|
* @return
|
||||||
* #GNUNET_YES if navigation was successful (caller is responsible
|
* #GNUNET_YES if navigation was successful (caller is responsible
|
||||||
* for freeing allocated variable-size data using
|
* for freeing allocated variable-size data using
|
||||||
* #TALER_MINT_release_parsed_data() when done)
|
* #TMH_PARSE_release_data() when done)
|
||||||
* #GNUNET_NO if json is malformed, error response was generated
|
* #GNUNET_NO if json is malformed, error response was generated
|
||||||
* #GNUNET_SYSERR on internal error
|
* #GNUNET_SYSERR on internal error
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_parse_json_data (struct MHD_Connection *connection,
|
TMH_PARSE_json_data (struct MHD_Connection *connection,
|
||||||
const json_t *root,
|
const json_t *root,
|
||||||
struct GNUNET_MINT_ParseFieldSpec *spec)
|
struct TMH_PARSE_FieldSpecification *spec)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int ret;
|
int ret;
|
||||||
@ -735,77 +735,77 @@ TALER_MINT_parse_json_data (struct MHD_Connection *connection,
|
|||||||
break;
|
break;
|
||||||
switch (spec[i].command)
|
switch (spec[i].command)
|
||||||
{
|
{
|
||||||
case JNAV_FIELD:
|
case TMH_PARSE_JNC_FIELD:
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
case JNAV_INDEX:
|
case TMH_PARSE_JNC_INDEX:
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
case JNAV_RET_DATA:
|
case TMH_PARSE_JNC_RET_DATA:
|
||||||
ret = GNUNET_MINT_parse_navigate_json (connection,
|
ret = TMH_PARSE_navigate_json (connection,
|
||||||
root,
|
root,
|
||||||
JNAV_FIELD,
|
TMH_PARSE_JNC_FIELD,
|
||||||
spec[i].field_name,
|
spec[i].field_name,
|
||||||
JNAV_RET_DATA,
|
TMH_PARSE_JNC_RET_DATA,
|
||||||
spec[i].destination,
|
spec[i].destination,
|
||||||
spec[i].destination_size_in);
|
spec[i].destination_size_in);
|
||||||
break;
|
break;
|
||||||
case JNAV_RET_DATA_VAR:
|
case TMH_PARSE_JNC_RET_DATA_VAR:
|
||||||
ptr = NULL;
|
ptr = NULL;
|
||||||
ret = GNUNET_MINT_parse_navigate_json (connection,
|
ret = TMH_PARSE_navigate_json (connection,
|
||||||
root,
|
root,
|
||||||
JNAV_FIELD,
|
TMH_PARSE_JNC_FIELD,
|
||||||
spec[i].field_name,
|
spec[i].field_name,
|
||||||
JNAV_RET_DATA_VAR,
|
TMH_PARSE_JNC_RET_DATA_VAR,
|
||||||
&ptr,
|
&ptr,
|
||||||
&spec[i].destination_size_out);
|
&spec[i].destination_size_out);
|
||||||
spec[i].destination = ptr;
|
spec[i].destination = ptr;
|
||||||
break;
|
break;
|
||||||
case JNAV_RET_TYPED_JSON:
|
case TMH_PARSE_JNC_RET_TYPED_JSON:
|
||||||
ptr = NULL;
|
ptr = NULL;
|
||||||
ret = GNUNET_MINT_parse_navigate_json (connection,
|
ret = TMH_PARSE_navigate_json (connection,
|
||||||
root,
|
root,
|
||||||
JNAV_FIELD,
|
TMH_PARSE_JNC_FIELD,
|
||||||
spec[i].field_name,
|
spec[i].field_name,
|
||||||
JNAV_RET_TYPED_JSON,
|
TMH_PARSE_JNC_RET_TYPED_JSON,
|
||||||
spec[i].type,
|
spec[i].type,
|
||||||
&ptr);
|
&ptr);
|
||||||
*((void**)spec[i].destination) = ptr;
|
*((void**)spec[i].destination) = ptr;
|
||||||
break;
|
break;
|
||||||
case JNAV_RET_RSA_PUBLIC_KEY:
|
case TMH_PARSE_JNC_RET_RSA_PUBLIC_KEY:
|
||||||
ptr = NULL;
|
ptr = NULL;
|
||||||
ret = GNUNET_MINT_parse_navigate_json (connection,
|
ret = TMH_PARSE_navigate_json (connection,
|
||||||
root,
|
root,
|
||||||
JNAV_FIELD,
|
TMH_PARSE_JNC_FIELD,
|
||||||
spec[i].field_name,
|
spec[i].field_name,
|
||||||
JNAV_RET_RSA_PUBLIC_KEY,
|
TMH_PARSE_JNC_RET_RSA_PUBLIC_KEY,
|
||||||
&ptr);
|
&ptr);
|
||||||
spec[i].destination = ptr;
|
spec[i].destination = ptr;
|
||||||
break;
|
break;
|
||||||
case JNAV_RET_RSA_SIGNATURE:
|
case TMH_PARSE_JNC_RET_RSA_SIGNATURE:
|
||||||
ptr = NULL;
|
ptr = NULL;
|
||||||
ret = GNUNET_MINT_parse_navigate_json (connection,
|
ret = TMH_PARSE_navigate_json (connection,
|
||||||
root,
|
root,
|
||||||
JNAV_FIELD,
|
TMH_PARSE_JNC_FIELD,
|
||||||
spec[i].field_name,
|
spec[i].field_name,
|
||||||
JNAV_RET_RSA_SIGNATURE,
|
TMH_PARSE_JNC_RET_RSA_SIGNATURE,
|
||||||
&ptr);
|
&ptr);
|
||||||
spec[i].destination = ptr;
|
spec[i].destination = ptr;
|
||||||
break;
|
break;
|
||||||
case JNAV_RET_AMOUNT:
|
case TMH_PARSE_JNC_RET_AMOUNT:
|
||||||
GNUNET_assert (sizeof (struct TALER_Amount) ==
|
GNUNET_assert (sizeof (struct TALER_Amount) ==
|
||||||
spec[i].destination_size_in);
|
spec[i].destination_size_in);
|
||||||
ret = GNUNET_MINT_parse_navigate_json (connection,
|
ret = TMH_PARSE_navigate_json (connection,
|
||||||
root,
|
root,
|
||||||
JNAV_FIELD,
|
TMH_PARSE_JNC_FIELD,
|
||||||
spec[i].field_name,
|
spec[i].field_name,
|
||||||
JNAV_RET_AMOUNT,
|
TMH_PARSE_JNC_RET_AMOUNT,
|
||||||
&spec[i].destination);
|
&spec[i].destination);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (GNUNET_YES != ret)
|
if (GNUNET_YES != ret)
|
||||||
TALER_MINT_release_parsed_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -817,7 +817,7 @@ TALER_MINT_parse_json_data (struct MHD_Connection *connection,
|
|||||||
* @param spec specification to free
|
* @param spec specification to free
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec)
|
TMH_PARSE_release_data (struct TMH_PARSE_FieldSpecification *spec)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
@ -826,15 +826,15 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec)
|
|||||||
{
|
{
|
||||||
switch (spec[i].command)
|
switch (spec[i].command)
|
||||||
{
|
{
|
||||||
case JNAV_FIELD:
|
case TMH_PARSE_JNC_FIELD:
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return;
|
return;
|
||||||
case JNAV_INDEX:
|
case TMH_PARSE_JNC_INDEX:
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return;
|
return;
|
||||||
case JNAV_RET_DATA:
|
case TMH_PARSE_JNC_RET_DATA:
|
||||||
break;
|
break;
|
||||||
case JNAV_RET_DATA_VAR:
|
case TMH_PARSE_JNC_RET_DATA_VAR:
|
||||||
if (0 != spec[i].destination_size_out)
|
if (0 != spec[i].destination_size_out)
|
||||||
{
|
{
|
||||||
GNUNET_free (spec[i].destination);
|
GNUNET_free (spec[i].destination);
|
||||||
@ -842,7 +842,7 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec)
|
|||||||
spec[i].destination_size_out = 0;
|
spec[i].destination_size_out = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case JNAV_RET_TYPED_JSON:
|
case TMH_PARSE_JNC_RET_TYPED_JSON:
|
||||||
ptr = *(void **) spec[i].destination;
|
ptr = *(void **) spec[i].destination;
|
||||||
if (NULL != ptr)
|
if (NULL != ptr)
|
||||||
{
|
{
|
||||||
@ -850,7 +850,7 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec)
|
|||||||
*(void**) spec[i].destination = NULL;
|
*(void**) spec[i].destination = NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case JNAV_RET_RSA_PUBLIC_KEY:
|
case TMH_PARSE_JNC_RET_RSA_PUBLIC_KEY:
|
||||||
ptr = *(void **) spec[i].destination;
|
ptr = *(void **) spec[i].destination;
|
||||||
if (NULL != ptr)
|
if (NULL != ptr)
|
||||||
{
|
{
|
||||||
@ -858,7 +858,7 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec)
|
|||||||
*(void**) spec[i].destination = NULL;
|
*(void**) spec[i].destination = NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case JNAV_RET_RSA_SIGNATURE:
|
case TMH_PARSE_JNC_RET_RSA_SIGNATURE:
|
||||||
ptr = *(void **) spec[i].destination;
|
ptr = *(void **) spec[i].destination;
|
||||||
if (NULL != ptr)
|
if (NULL != ptr)
|
||||||
{
|
{
|
||||||
@ -866,7 +866,7 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec)
|
|||||||
*(void**) spec[i].destination = NULL;
|
*(void**) spec[i].destination = NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case JNAV_RET_AMOUNT:
|
case TMH_PARSE_JNC_RET_AMOUNT:
|
||||||
memset (spec[i].destination,
|
memset (spec[i].destination,
|
||||||
0,
|
0,
|
||||||
sizeof (struct TALER_Amount));
|
sizeof (struct TALER_Amount));
|
||||||
@ -888,7 +888,7 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec)
|
|||||||
* #GNUNET_SYSERR on internal error, error response was not generated
|
* #GNUNET_SYSERR on internal error, error response was not generated
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_parse_amount_json (struct MHD_Connection *connection,
|
TMH_PARSE_amount_json (struct MHD_Connection *connection,
|
||||||
json_t *f,
|
json_t *f,
|
||||||
struct TALER_Amount *amount)
|
struct TALER_Amount *amount)
|
||||||
{
|
{
|
||||||
@ -905,9 +905,9 @@ TALER_MINT_parse_amount_json (struct MHD_Connection *connection,
|
|||||||
"fraction", &fraction,
|
"fraction", &fraction,
|
||||||
"currency", ¤cy))
|
"currency", ¤cy))
|
||||||
{
|
{
|
||||||
LOG_WARNING ("Failed to parse JSON amount specification\n");
|
TALER_LOG_WARNING ("Failed to parse JSON amount specification\n");
|
||||||
if (MHD_YES !=
|
if (MHD_YES !=
|
||||||
TALER_MINT_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s}",
|
"{s:s}",
|
||||||
"error", "Bad format"))
|
"error", "Bad format"))
|
||||||
@ -919,9 +919,9 @@ TALER_MINT_parse_amount_json (struct MHD_Connection *connection,
|
|||||||
(value > UINT64_MAX) ||
|
(value > UINT64_MAX) ||
|
||||||
(fraction > UINT32_MAX) )
|
(fraction > UINT32_MAX) )
|
||||||
{
|
{
|
||||||
LOG_WARNING ("Amount specified not in allowed range\n");
|
TALER_LOG_WARNING ("Amount specified not in allowed range\n");
|
||||||
if (MHD_YES !=
|
if (MHD_YES !=
|
||||||
TALER_MINT_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s}",
|
"{s:s}",
|
||||||
"error", "Amount outside of allowed range"))
|
"error", "Amount outside of allowed range"))
|
||||||
@ -929,11 +929,11 @@ TALER_MINT_parse_amount_json (struct MHD_Connection *connection,
|
|||||||
return GNUNET_NO;
|
return GNUNET_NO;
|
||||||
}
|
}
|
||||||
if (0 != strcmp (currency,
|
if (0 != strcmp (currency,
|
||||||
MINT_CURRENCY))
|
TMH_MINT_CURRENCY))
|
||||||
{
|
{
|
||||||
LOG_WARNING ("Currency specified not supported by this mint\n");
|
TALER_LOG_WARNING ("Currency specified not supported by this mint\n");
|
||||||
if (MHD_YES !=
|
if (MHD_YES !=
|
||||||
TALER_MINT_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:s}",
|
"{s:s, s:s}",
|
||||||
"error", "Currency not supported",
|
"error", "Currency not supported",
|
||||||
@ -943,8 +943,8 @@ TALER_MINT_parse_amount_json (struct MHD_Connection *connection,
|
|||||||
}
|
}
|
||||||
amount->value = (uint64_t) value;
|
amount->value = (uint64_t) value;
|
||||||
amount->fraction = (uint32_t) fraction;
|
amount->fraction = (uint32_t) fraction;
|
||||||
GNUNET_assert (strlen (MINT_CURRENCY) < TALER_CURRENCY_LEN);
|
GNUNET_assert (strlen (TMH_MINT_CURRENCY) < TALER_CURRENCY_LEN);
|
||||||
strcpy (amount->currency, MINT_CURRENCY);
|
strcpy (amount->currency, TMH_MINT_CURRENCY);
|
||||||
TALER_amount_normalize (amount);
|
TALER_amount_normalize (amount);
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
* @author Benedikt Mueller
|
* @author Benedikt Mueller
|
||||||
* @author Christian Grothoff
|
* @author Christian Grothoff
|
||||||
*/
|
*/
|
||||||
#ifndef TALER_MICROHTTPD_LIB_H_
|
#ifndef TALER_MINT_HTTPD_PARSING_H
|
||||||
#define TALER_MICROHTTPD_LIB_H_
|
#define TALER_MINT_HTTPD_PARSING_H
|
||||||
|
|
||||||
#include <microhttpd.h>
|
#include <microhttpd.h>
|
||||||
#include <jansson.h>
|
#include <jansson.h>
|
||||||
@ -34,7 +34,7 @@
|
|||||||
* (incrementally) process JSON data uploaded to the HTTP
|
* (incrementally) process JSON data uploaded to the HTTP
|
||||||
* server. It will store the required state in the
|
* server. It will store the required state in the
|
||||||
* "connection_cls", which must be cleaned up using
|
* "connection_cls", which must be cleaned up using
|
||||||
* #TALER_MINT_parse_post_cleanup_callback().
|
* #TMH_PARSE_post_cleanup_callback().
|
||||||
*
|
*
|
||||||
* @param connection the MHD connection
|
* @param connection the MHD connection
|
||||||
* @param con_cs the closure (points to a `struct Buffer *`)
|
* @param con_cs the closure (points to a `struct Buffer *`)
|
||||||
@ -53,11 +53,11 @@
|
|||||||
* close HTTP session with MHD_NO)
|
* close HTTP session with MHD_NO)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_parse_post_json (struct MHD_Connection *connection,
|
TMH_PARSE_post_json (struct MHD_Connection *connection,
|
||||||
void **con_cls,
|
void **con_cls,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
size_t *upload_data_size,
|
size_t *upload_data_size,
|
||||||
json_t **json);
|
json_t **json);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,42 +65,42 @@ TALER_MINT_parse_post_json (struct MHD_Connection *connection,
|
|||||||
* to clean up our state.
|
* to clean up our state.
|
||||||
*
|
*
|
||||||
* @param con_cls value as it was left by
|
* @param con_cls value as it was left by
|
||||||
* #TALER_MINT_parse_post_json(), to be cleaned up
|
* #TMH_PARSE_post_json(), to be cleaned up
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
TALER_MINT_parse_post_cleanup_callback (void *con_cls);
|
TMH_PARSE_post_cleanup_callback (void *con_cls);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constants for JSON navigation description.
|
* Constants for JSON navigation description.
|
||||||
*/
|
*/
|
||||||
enum TALER_MINT_JsonNavigationCommand
|
enum TMH_PARSE_JsonNavigationCommand
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Access a field.
|
* Access a field.
|
||||||
* Param: const char *
|
* Param: const char *
|
||||||
*/
|
*/
|
||||||
JNAV_FIELD,
|
TMH_PARSE_JNC_FIELD,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access an array index.
|
* Access an array index.
|
||||||
* Param: int
|
* Param: int
|
||||||
*/
|
*/
|
||||||
JNAV_INDEX,
|
TMH_PARSE_JNC_INDEX,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return base32crockford encoded data of
|
* Return base32crockford encoded data of
|
||||||
* constant size.
|
* constant size.
|
||||||
* Params: (void *, size_t)
|
* Params: (void *, size_t)
|
||||||
*/
|
*/
|
||||||
JNAV_RET_DATA,
|
TMH_PARSE_JNC_RET_DATA,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return base32crockford encoded data of
|
* Return base32crockford encoded data of
|
||||||
* variable size.
|
* variable size.
|
||||||
* Params: (void **, size_t *)
|
* Params: (void **, size_t *)
|
||||||
*/
|
*/
|
||||||
JNAV_RET_DATA_VAR,
|
TMH_PARSE_JNC_RET_DATA_VAR,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a json object, which must be
|
* Return a json object, which must be
|
||||||
@ -108,25 +108,25 @@ enum TALER_MINT_JsonNavigationCommand
|
|||||||
* or -1 for any type).
|
* or -1 for any type).
|
||||||
* Params: (int, json_t **)
|
* Params: (int, json_t **)
|
||||||
*/
|
*/
|
||||||
JNAV_RET_TYPED_JSON,
|
TMH_PARSE_JNC_RET_TYPED_JSON,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a `struct GNUNET_CRYPTO_rsa_PublicKey` which was
|
* Return a `struct GNUNET_CRYPTO_rsa_PublicKey` which was
|
||||||
* encoded as variable-size base32crockford encoded data.
|
* encoded as variable-size base32crockford encoded data.
|
||||||
*/
|
*/
|
||||||
JNAV_RET_RSA_PUBLIC_KEY,
|
TMH_PARSE_JNC_RET_RSA_PUBLIC_KEY,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a `struct GNUNET_CRYPTO_rsa_Signature` which was
|
* Return a `struct GNUNET_CRYPTO_rsa_Signature` which was
|
||||||
* encoded as variable-size base32crockford encoded data.
|
* encoded as variable-size base32crockford encoded data.
|
||||||
*/
|
*/
|
||||||
JNAV_RET_RSA_SIGNATURE,
|
TMH_PARSE_JNC_RET_RSA_SIGNATURE,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a `struct TALER_Amount` which was
|
* Return a `struct TALER_Amount` which was
|
||||||
* encoded within its own json object.
|
* encoded within its own json object.
|
||||||
*/
|
*/
|
||||||
JNAV_RET_AMOUNT
|
TMH_PARSE_JNC_RET_AMOUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -138,22 +138,22 @@ enum TALER_MINT_JsonNavigationCommand
|
|||||||
*
|
*
|
||||||
* @param connection the connection to send an error response to
|
* @param connection the connection to send an error response to
|
||||||
* @param root the JSON node to start the navigation at.
|
* @param root the JSON node to start the navigation at.
|
||||||
* @param ... navigation specification (see `enum TALER_MINT_JsonNavigationCommand`)
|
* @param ... navigation specification (see `enum TMH_PARSE_JsonNavigationCommand`)
|
||||||
* @return
|
* @return
|
||||||
* #GNUNET_YES if navigation was successful
|
* #GNUNET_YES if navigation was successful
|
||||||
* #GNUNET_NO if json is malformed, error response was generated
|
* #GNUNET_NO if json is malformed, error response was generated
|
||||||
* #GNUNET_SYSERR on internal error
|
* #GNUNET_SYSERR on internal error
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
||||||
const json_t *root,
|
const json_t *root,
|
||||||
...);
|
...);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specification for how to parse a JSON field.
|
* Specification for how to parse a JSON field.
|
||||||
*/
|
*/
|
||||||
struct GNUNET_MINT_ParseFieldSpec
|
struct TMH_PARSE_FieldSpecification
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Name of the field. NULL only to terminate array.
|
* Name of the field. NULL only to terminate array.
|
||||||
@ -183,15 +183,15 @@ struct GNUNET_MINT_ParseFieldSpec
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Navigation command to use to extract the value. Note that
|
* Navigation command to use to extract the value. Note that
|
||||||
* #JNAV_RET_DATA or #JNAV_RET_DATA_VAR must be used for @e
|
* #TMH_PARSE_JNC_RET_DATA or #TMH_PARSE_JNC_RET_DATA_VAR must be used for @e
|
||||||
* destination_size_in and @e destination_size_out to have a
|
* destination_size_in and @e destination_size_out to have a
|
||||||
* meaning. #JNAV_FIELD and #JNAV_INDEX must not be used here!
|
* meaning. #TMH_PARSE_JNC_FIELD and #TMH_PARSE_JNC_INDEX must not be used here!
|
||||||
*/
|
*/
|
||||||
enum TALER_MINT_JsonNavigationCommand command;
|
enum TMH_PARSE_JsonNavigationCommand command;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JSON type to use, only meaningful in connection with a @e command
|
* JSON type to use, only meaningful in connection with a @e command
|
||||||
* value of #JNAV_RET_TYPED_JSON. Typical values are
|
* value of #TMH_PARSE_JNC_RET_TYPED_JSON. Typical values are
|
||||||
* #JSON_ARRAY and #JSON_OBJECT.
|
* #JSON_ARRAY and #JSON_OBJECT.
|
||||||
*/
|
*/
|
||||||
int type;
|
int type;
|
||||||
@ -209,14 +209,14 @@ struct GNUNET_MINT_ParseFieldSpec
|
|||||||
* @return
|
* @return
|
||||||
* #GNUNET_YES if navigation was successful (caller is responsible
|
* #GNUNET_YES if navigation was successful (caller is responsible
|
||||||
* for freeing allocated variable-size data using
|
* for freeing allocated variable-size data using
|
||||||
* #TALER_MINT_release_parsed_data() when done)
|
* #TMH_PARSE_release_data() when done)
|
||||||
* #GNUNET_NO if json is malformed, error response was generated
|
* #GNUNET_NO if json is malformed, error response was generated
|
||||||
* #GNUNET_SYSERR on internal error
|
* #GNUNET_SYSERR on internal error
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_parse_json_data (struct MHD_Connection *connection,
|
TMH_PARSE_json_data (struct MHD_Connection *connection,
|
||||||
const json_t *root,
|
const json_t *root,
|
||||||
struct GNUNET_MINT_ParseFieldSpec *spec);
|
struct TMH_PARSE_FieldSpecification *spec);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -226,7 +226,7 @@ TALER_MINT_parse_json_data (struct MHD_Connection *connection,
|
|||||||
* @param spec specification to free
|
* @param spec specification to free
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec);
|
TMH_PARSE_release_data (struct TMH_PARSE_FieldSpecification *spec);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -235,14 +235,14 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec);
|
|||||||
* @param field name of the field
|
* @param field name of the field
|
||||||
* @param value where to store the value
|
* @param value where to store the value
|
||||||
*/
|
*/
|
||||||
#define TALER_MINT_PARSE_FIXED(field,value) { field, value, sizeof (*value), 0, JNAV_RET_DATA, 0 }
|
#define TMH_PARSE_MEMBER_FIXED(field,value) { field, value, sizeof (*value), 0, TMH_PARSE_JNC_RET_DATA, 0 }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate line in parser specification for variable-size value.
|
* Generate line in parser specification for variable-size value.
|
||||||
*
|
*
|
||||||
* @param field name of the field
|
* @param field name of the field
|
||||||
*/
|
*/
|
||||||
#define TALER_MINT_PARSE_VARIABLE(field) { field, NULL, 0, 0, JNAV_RET_DATA_VAR, 0 }
|
#define TMH_PARSE_MEMBER_VARIABLE(field) { field, NULL, 0, 0, TMH_PARSE_JNC_RET_DATA_VAR, 0 }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate line in parser specification for JSON array value.
|
* Generate line in parser specification for JSON array value.
|
||||||
@ -250,7 +250,7 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec);
|
|||||||
* @param field name of the field
|
* @param field name of the field
|
||||||
* @param ptraddr address of pointer to initialize (a `void **`)
|
* @param ptraddr address of pointer to initialize (a `void **`)
|
||||||
*/
|
*/
|
||||||
#define TALER_MINT_PARSE_ARRAY(field,ptraddr) { field, ptraddr, 0, 0, JNAV_RET_TYPED_JSON, JSON_ARRAY }
|
#define TMH_PARSE_MEMBER_ARRAY(field,ptraddr) { field, ptraddr, 0, 0, TMH_PARSE_JNC_RET_TYPED_JSON, JSON_ARRAY }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate line in parser specification for JSON object value.
|
* Generate line in parser specification for JSON object value.
|
||||||
@ -258,7 +258,7 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec);
|
|||||||
* @param field name of the field
|
* @param field name of the field
|
||||||
* @param ptraddr address of pointer to initialize (a `void **`)
|
* @param ptraddr address of pointer to initialize (a `void **`)
|
||||||
*/
|
*/
|
||||||
#define TALER_MINT_PARSE_OBJECT(field,ptraddr) { field, ptraddr, 0, 0, JNAV_RET_TYPED_JSON, JSON_OBJECT }
|
#define TMH_PARSE_MEMBER_OBJECT(field,ptraddr) { field, ptraddr, 0, 0, TMH_PARSE_JNC_RET_TYPED_JSON, JSON_OBJECT }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate line in parser specification for RSA public key.
|
* Generate line in parser specification for RSA public key.
|
||||||
@ -266,7 +266,7 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec);
|
|||||||
* @param field name of the field
|
* @param field name of the field
|
||||||
* @param ptraddr address of `struct GNUNET_CRYPTO_rsa_PublicKey *` initialize
|
* @param ptraddr address of `struct GNUNET_CRYPTO_rsa_PublicKey *` initialize
|
||||||
*/
|
*/
|
||||||
#define TALER_MINT_PARSE_RSA_PUBLIC_KEY(field,ptrpk) { field, ptrpk, 0, 0, JNAV_RET_RSA_PUBLIC_KEY, 0 }
|
#define TMH_PARSE_MEMBER_RSA_PUBLIC_KEY(field,ptrpk) { field, ptrpk, 0, 0, TMH_PARSE_JNC_RET_RSA_PUBLIC_KEY, 0 }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate line in parser specification for RSA public key.
|
* Generate line in parser specification for RSA public key.
|
||||||
@ -274,7 +274,7 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec);
|
|||||||
* @param field name of the field
|
* @param field name of the field
|
||||||
* @param ptrsig address of `struct GNUNET_CRYPTO_rsa_Signature *` initialize
|
* @param ptrsig address of `struct GNUNET_CRYPTO_rsa_Signature *` initialize
|
||||||
*/
|
*/
|
||||||
#define TALER_MINT_PARSE_RSA_SIGNATURE(field,ptrsig) { field, ptrsig, 0, 0, JNAV_RET_RSA_SIGNATURE, 0 }
|
#define TMH_PARSE_MEMBER_RSA_SIGNATURE(field,ptrsig) { field, ptrsig, 0, 0, TMH_PARSE_JNC_RET_RSA_SIGNATURE, 0 }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate line in parser specification for an amount.
|
* Generate line in parser specification for an amount.
|
||||||
@ -282,12 +282,12 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec);
|
|||||||
* @param field name of the field
|
* @param field name of the field
|
||||||
* @param amount a `struct TALER_Amount *` to initialize
|
* @param amount a `struct TALER_Amount *` to initialize
|
||||||
*/
|
*/
|
||||||
#define TALER_MINT_PARSE_AMOUNT(field,amount) { field, amount, sizeof(*amount), 0, JNAV_RET_AMOUNT, 0 }
|
#define TMH_PARSE_MEMBER_AMOUNT(field,amount) { field, amount, sizeof(*amount), 0, TMH_PARSE_JNC_RET_AMOUNT, 0 }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate line in parser specification indicating the end of the spec.
|
* Generate line in parser specification indicating the end of the spec.
|
||||||
*/
|
*/
|
||||||
#define TALER_MINT_PARSE_END { NULL, NULL, 0, 0, JNAV_FIELD, 0 }
|
#define TMH_PARSE_MEMBER_END { NULL, NULL, 0, 0, TMH_PARSE_JNC_FIELD, 0 }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -302,9 +302,9 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec);
|
|||||||
* #GNUNET_SYSERR on internal error, error response was not generated
|
* #GNUNET_SYSERR on internal error, error response was not generated
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_parse_amount_json (struct MHD_Connection *connection,
|
TMH_PARSE_amount_json (struct MHD_Connection *connection,
|
||||||
json_t *f,
|
json_t *f,
|
||||||
struct TALER_Amount *amount);
|
struct TALER_Amount *amount);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -323,10 +323,10 @@ TALER_MINT_parse_amount_json (struct MHD_Connection *connection,
|
|||||||
* #GNUNET_SYSERR on internal error (error response could not be sent)
|
* #GNUNET_SYSERR on internal error (error response could not be sent)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_mhd_request_arg_data (struct MHD_Connection *connection,
|
TMH_PARSE_mhd_request_arg_data (struct MHD_Connection *connection,
|
||||||
const char *param_name,
|
const char *param_name,
|
||||||
void *out_data,
|
void *out_data,
|
||||||
size_t out_size);
|
size_t out_size);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -345,12 +345,12 @@ TALER_MINT_mhd_request_arg_data (struct MHD_Connection *connection,
|
|||||||
* #GNUNET_SYSERR on internal error (error response could not be sent)
|
* #GNUNET_SYSERR on internal error (error response could not be sent)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_mhd_request_var_arg_data (struct MHD_Connection *connection,
|
TMH_PARSE_mhd_request_var_arg_data (struct MHD_Connection *connection,
|
||||||
const char *param_name,
|
const char *param_name,
|
||||||
void **out_data,
|
void **out_data,
|
||||||
size_t *out_size);
|
size_t *out_size);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* TALER_MICROHTTPD_LIB_H_ */
|
#endif /* TALER_MINT_HTTPD_PARSING_H */
|
||||||
|
@ -60,15 +60,15 @@ handle_refresh_melt_binary (struct MHD_Connection *connection,
|
|||||||
const struct TALER_DenominationPublicKey *denom_pubs,
|
const struct TALER_DenominationPublicKey *denom_pubs,
|
||||||
unsigned int coin_count,
|
unsigned int coin_count,
|
||||||
struct TALER_CoinPublicInfo *coin_public_infos,
|
struct TALER_CoinPublicInfo *coin_public_infos,
|
||||||
const struct MeltDetails *coin_melt_details,
|
const struct TMH_DB_MeltDetails *coin_melt_details,
|
||||||
const struct GNUNET_HashCode *session_hash,
|
const struct GNUNET_HashCode *session_hash,
|
||||||
struct RefreshCommitCoin *const* commit_coin,
|
struct RefreshCommitCoin *const* commit_coin,
|
||||||
struct RefreshCommitLink *const* commit_link)
|
struct RefreshCommitLink *const* commit_link)
|
||||||
|
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
struct MintKeyState *key_state;
|
struct TMH_KS_StateHandle *key_state;
|
||||||
struct TALER_MINT_DenomKeyIssue *dki;
|
struct TALER_DenominationKeyValidityPS *dki;
|
||||||
struct TALER_Amount cost;
|
struct TALER_Amount cost;
|
||||||
struct TALER_Amount total_cost;
|
struct TALER_Amount total_cost;
|
||||||
struct TALER_Amount melt;
|
struct TALER_Amount melt;
|
||||||
@ -78,12 +78,12 @@ handle_refresh_melt_binary (struct MHD_Connection *connection,
|
|||||||
struct TALER_Amount total_melt;
|
struct TALER_Amount total_melt;
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_amount_get_zero (MINT_CURRENCY,
|
TALER_amount_get_zero (TMH_MINT_CURRENCY,
|
||||||
&total_cost));
|
&total_cost));
|
||||||
key_state = TALER_MINT_key_state_acquire ();
|
key_state = TMH_KS_acquire ();
|
||||||
for (i=0;i<num_new_denoms;i++)
|
for (i=0;i<num_new_denoms;i++)
|
||||||
{
|
{
|
||||||
dki = &TALER_MINT_get_denom_key (key_state,
|
dki = &TMH_KS_denomination_key_lookup (key_state,
|
||||||
&denom_pubs[i])->issue;
|
&denom_pubs[i])->issue;
|
||||||
TALER_amount_ntoh (&value,
|
TALER_amount_ntoh (&value,
|
||||||
&dki->value);
|
&dki->value);
|
||||||
@ -98,20 +98,20 @@ handle_refresh_melt_binary (struct MHD_Connection *connection,
|
|||||||
&cost,
|
&cost,
|
||||||
&total_cost)) )
|
&total_cost)) )
|
||||||
{
|
{
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return TALER_MINT_reply_internal_error (connection,
|
return TMH_RESPONSE_reply_internal_error (connection,
|
||||||
"cost calculation failure");
|
"cost calculation failure");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_amount_get_zero (MINT_CURRENCY,
|
TALER_amount_get_zero (TMH_MINT_CURRENCY,
|
||||||
&total_melt));
|
&total_melt));
|
||||||
for (i=0;i<coin_count;i++)
|
for (i=0;i<coin_count;i++)
|
||||||
{
|
{
|
||||||
/* calculate contribution of the i-th melt by subtracting
|
/* calculate contribution of the i-th melt by subtracting
|
||||||
the fee; add the rest to the total_melt value */
|
the fee; add the rest to the total_melt value */
|
||||||
dki = &TALER_MINT_get_denom_key (key_state,
|
dki = &TMH_KS_denomination_key_lookup (key_state,
|
||||||
&coin_public_infos[i].denom_pub)->issue;
|
&coin_public_infos[i].denom_pub)->issue;
|
||||||
TALER_amount_ntoh (&fee_melt,
|
TALER_amount_ntoh (&fee_melt,
|
||||||
&dki->fee_refresh);
|
&dki->fee_refresh);
|
||||||
@ -120,8 +120,8 @@ handle_refresh_melt_binary (struct MHD_Connection *connection,
|
|||||||
&coin_melt_details->melt_amount_with_fee,
|
&coin_melt_details->melt_amount_with_fee,
|
||||||
&fee_melt))
|
&fee_melt))
|
||||||
{
|
{
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return TALER_MINT_reply_external_error (connection,
|
return TMH_RESPONSE_reply_external_error (connection,
|
||||||
"Melt contribution below melting fee");
|
"Melt contribution below melting fee");
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
@ -129,24 +129,24 @@ handle_refresh_melt_binary (struct MHD_Connection *connection,
|
|||||||
&melt,
|
&melt,
|
||||||
&total_melt))
|
&total_melt))
|
||||||
{
|
{
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return TALER_MINT_reply_internal_error (connection,
|
return TMH_RESPONSE_reply_internal_error (connection,
|
||||||
"balance calculation failure");
|
"balance calculation failure");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
if (0 !=
|
if (0 !=
|
||||||
TALER_amount_cmp (&total_cost,
|
TALER_amount_cmp (&total_cost,
|
||||||
&total_melt))
|
&total_melt))
|
||||||
{
|
{
|
||||||
/* We require total value of coins being melted and
|
/* We require total value of coins being melted and
|
||||||
total value of coins being generated to match! */
|
total value of coins being generated to match! */
|
||||||
return TALER_MINT_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s}",
|
"{s:s}",
|
||||||
"error", "value mismatch");
|
"error", "value mismatch");
|
||||||
}
|
}
|
||||||
return TALER_MINT_db_execute_refresh_melt (connection,
|
return TMH_DB_execute_refresh_melt (connection,
|
||||||
session_hash,
|
session_hash,
|
||||||
num_new_denoms,
|
num_new_denoms,
|
||||||
denom_pubs,
|
denom_pubs,
|
||||||
@ -173,23 +173,23 @@ static int
|
|||||||
get_coin_public_info (struct MHD_Connection *connection,
|
get_coin_public_info (struct MHD_Connection *connection,
|
||||||
json_t *coin_info,
|
json_t *coin_info,
|
||||||
struct TALER_CoinPublicInfo *r_public_info,
|
struct TALER_CoinPublicInfo *r_public_info,
|
||||||
struct MeltDetails *r_melt_detail)
|
struct TMH_DB_MeltDetails *r_melt_detail)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct TALER_CoinSpendSignature melt_sig;
|
union TALER_CoinSpendSignatureP melt_sig;
|
||||||
struct TALER_DenominationSignature sig;
|
struct TALER_DenominationSignature sig;
|
||||||
struct TALER_DenominationPublicKey pk;
|
struct TALER_DenominationPublicKey pk;
|
||||||
struct TALER_Amount amount;
|
struct TALER_Amount amount;
|
||||||
struct GNUNET_MINT_ParseFieldSpec spec[] = {
|
struct TMH_PARSE_FieldSpecification spec[] = {
|
||||||
TALER_MINT_PARSE_FIXED ("coin_pub", &r_public_info->coin_pub),
|
TMH_PARSE_MEMBER_FIXED ("coin_pub", &r_public_info->coin_pub),
|
||||||
TALER_MINT_PARSE_RSA_SIGNATURE ("denom_sig", &sig.rsa_signature),
|
TMH_PARSE_MEMBER_RSA_SIGNATURE ("denom_sig", &sig.rsa_signature),
|
||||||
TALER_MINT_PARSE_RSA_PUBLIC_KEY ("denom_pub", &pk.rsa_public_key),
|
TMH_PARSE_MEMBER_RSA_PUBLIC_KEY ("denom_pub", &pk.rsa_public_key),
|
||||||
TALER_MINT_PARSE_FIXED ("confirm_sig", &melt_sig),
|
TMH_PARSE_MEMBER_FIXED ("confirm_sig", &melt_sig),
|
||||||
TALER_MINT_PARSE_AMOUNT ("value_with_fee", &amount),
|
TMH_PARSE_MEMBER_AMOUNT ("value_with_fee", &amount),
|
||||||
TALER_MINT_PARSE_END
|
TMH_PARSE_MEMBER_END
|
||||||
};
|
};
|
||||||
|
|
||||||
ret = TALER_MINT_parse_json_data (connection,
|
ret = TMH_PARSE_json_data (connection,
|
||||||
coin_info,
|
coin_info,
|
||||||
spec);
|
spec);
|
||||||
if (GNUNET_OK != ret)
|
if (GNUNET_OK != ret)
|
||||||
@ -200,11 +200,11 @@ get_coin_public_info (struct MHD_Connection *connection,
|
|||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TALER_test_coin_valid (r_public_info))
|
TALER_test_coin_valid (r_public_info))
|
||||||
{
|
{
|
||||||
TALER_MINT_release_parsed_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
r_public_info->denom_sig.rsa_signature = NULL;
|
r_public_info->denom_sig.rsa_signature = NULL;
|
||||||
r_public_info->denom_pub.rsa_public_key = NULL;
|
r_public_info->denom_pub.rsa_public_key = NULL;
|
||||||
return (MHD_YES ==
|
return (MHD_YES ==
|
||||||
TALER_MINT_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_NOT_FOUND,
|
MHD_HTTP_NOT_FOUND,
|
||||||
"{s:s}",
|
"{s:s}",
|
||||||
"error", "coin invalid"))
|
"error", "coin invalid"))
|
||||||
@ -212,7 +212,7 @@ get_coin_public_info (struct MHD_Connection *connection,
|
|||||||
}
|
}
|
||||||
r_melt_detail->melt_sig = melt_sig;
|
r_melt_detail->melt_sig = melt_sig;
|
||||||
r_melt_detail->melt_amount_with_fee = amount;
|
r_melt_detail->melt_amount_with_fee = amount;
|
||||||
TALER_MINT_release_parsed_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,41 +236,41 @@ static int
|
|||||||
verify_coin_public_info (struct MHD_Connection *connection,
|
verify_coin_public_info (struct MHD_Connection *connection,
|
||||||
const struct GNUNET_HashCode *session_hash,
|
const struct GNUNET_HashCode *session_hash,
|
||||||
const struct TALER_CoinPublicInfo *r_public_info,
|
const struct TALER_CoinPublicInfo *r_public_info,
|
||||||
const struct MeltDetails *r_melt_detail)
|
const struct TMH_DB_MeltDetails *r_melt_detail)
|
||||||
{
|
{
|
||||||
struct RefreshMeltCoinSignature body;
|
struct TALER_RefreshMeltCoinAffirmationPS body;
|
||||||
struct MintKeyState *key_state;
|
struct TMH_KS_StateHandle *key_state;
|
||||||
struct TALER_MINT_DenomKeyIssuePriv *dki;
|
struct TALER_DenominationKeyIssueInformation *dki;
|
||||||
struct TALER_Amount fee_refresh;
|
struct TALER_Amount fee_refresh;
|
||||||
|
|
||||||
body.purpose.size = htonl (sizeof (struct RefreshMeltCoinSignature));
|
body.purpose.size = htonl (sizeof (struct TALER_RefreshMeltCoinAffirmationPS));
|
||||||
body.purpose.purpose = htonl (TALER_SIGNATURE_REFRESH_MELT_COIN);
|
body.purpose.purpose = htonl (TALER_SIGNATURE_COIN_MELT);
|
||||||
body.session_hash = *session_hash;
|
body.session_hash = *session_hash;
|
||||||
TALER_amount_hton (&body.amount_with_fee,
|
TALER_amount_hton (&body.amount_with_fee,
|
||||||
&r_melt_detail->melt_amount_with_fee);
|
&r_melt_detail->melt_amount_with_fee);
|
||||||
body.coin_pub = r_public_info->coin_pub;
|
body.coin_pub = r_public_info->coin_pub;
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CRYPTO_ecdsa_verify (TALER_SIGNATURE_REFRESH_MELT_COIN,
|
GNUNET_CRYPTO_ecdsa_verify (TALER_SIGNATURE_COIN_MELT,
|
||||||
&body.purpose,
|
&body.purpose,
|
||||||
&r_melt_detail->melt_sig.ecdsa_signature,
|
&r_melt_detail->melt_sig.ecdsa_signature,
|
||||||
&r_public_info->coin_pub.ecdsa_pub))
|
&r_public_info->coin_pub.ecdsa_pub))
|
||||||
{
|
{
|
||||||
if (MHD_YES !=
|
if (MHD_YES !=
|
||||||
TALER_MINT_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_UNAUTHORIZED,
|
MHD_HTTP_UNAUTHORIZED,
|
||||||
"{s:s}",
|
"{s:s}",
|
||||||
"error", "signature invalid"))
|
"error", "signature invalid"))
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
return GNUNET_NO;
|
return GNUNET_NO;
|
||||||
}
|
}
|
||||||
key_state = TALER_MINT_key_state_acquire ();
|
key_state = TMH_KS_acquire ();
|
||||||
dki = TALER_MINT_get_denom_key (key_state,
|
dki = TMH_KS_denomination_key_lookup (key_state,
|
||||||
&r_public_info->denom_pub);
|
&r_public_info->denom_pub);
|
||||||
if (NULL == dki)
|
if (NULL == dki)
|
||||||
{
|
{
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
LOG_WARNING ("Unknown denomination key in /refresh/melt request\n");
|
TALER_LOG_WARNING ("Unknown denomination key in /refresh/melt request\n");
|
||||||
return TALER_MINT_reply_arg_invalid (connection,
|
return TMH_RESPONSE_reply_arg_invalid (connection,
|
||||||
"denom_pub");
|
"denom_pub");
|
||||||
}
|
}
|
||||||
/* FIXME: need to check if denomination key is still
|
/* FIXME: need to check if denomination key is still
|
||||||
@ -280,14 +280,14 @@ verify_coin_public_info (struct MHD_Connection *connection,
|
|||||||
if (TALER_amount_cmp (&fee_refresh,
|
if (TALER_amount_cmp (&fee_refresh,
|
||||||
&r_melt_detail->melt_amount_with_fee) < 0)
|
&r_melt_detail->melt_amount_with_fee) < 0)
|
||||||
{
|
{
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return (MHD_YES ==
|
return (MHD_YES ==
|
||||||
TALER_MINT_reply_external_error (connection,
|
TMH_RESPONSE_reply_external_error (connection,
|
||||||
"melt amount smaller than melting fee"))
|
"melt amount smaller than melting fee"))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,11 +357,11 @@ free_commit_links (struct RefreshCommitLink **commit_link,
|
|||||||
* @param melt_sig_json signature affirming the melt operation
|
* @param melt_sig_json signature affirming the melt operation
|
||||||
* @param commit_signature signature over the commit
|
* @param commit_signature signature over the commit
|
||||||
* @param num_oldcoins number of coins that are being melted
|
* @param num_oldcoins number of coins that are being melted
|
||||||
* @param transfer_pubs #KAPPA-dimensional array of @a num_oldcoins transfer keys
|
* @param transfer_pubs #TALER_CNC_KAPPA-dimensional array of @a num_oldcoins transfer keys
|
||||||
* @param secret_encs #KAPPA-dimensional array of @a num_oldcoins secrets
|
* @param secret_encs #TALER_CNC_KAPPA-dimensional array of @a num_oldcoins secrets
|
||||||
* @param num_newcoins number of coins that the refresh will generate
|
* @param num_newcoins number of coins that the refresh will generate
|
||||||
* @param coin_envs #KAPPA-dimensional array of @a num_newcoins envelopes to sign
|
* @param coin_envs #TALER_CNC_KAPPA-dimensional array of @a num_newcoins envelopes to sign
|
||||||
* @param link_encs #KAPPA-dimensional array of @a num_newcoins encrypted links
|
* @param link_encs #TALER_CNC_KAPPA-dimensional array of @a num_newcoins encrypted links
|
||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
@ -384,12 +384,12 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
|
|||||||
struct TALER_DenominationPublicKey *denom_pubs;
|
struct TALER_DenominationPublicKey *denom_pubs;
|
||||||
unsigned int num_new_denoms;
|
unsigned int num_new_denoms;
|
||||||
struct TALER_CoinPublicInfo *coin_public_infos;
|
struct TALER_CoinPublicInfo *coin_public_infos;
|
||||||
struct MeltDetails *coin_melt_details;
|
struct TMH_DB_MeltDetails *coin_melt_details;
|
||||||
unsigned int coin_count;
|
unsigned int coin_count;
|
||||||
struct GNUNET_HashCode session_hash;
|
struct GNUNET_HashCode session_hash;
|
||||||
struct GNUNET_HashContext *hash_context;
|
struct GNUNET_HashContext *hash_context;
|
||||||
struct RefreshCommitCoin *commit_coin[KAPPA];
|
struct RefreshCommitCoin *commit_coin[TALER_CNC_KAPPA];
|
||||||
struct RefreshCommitLink *commit_link[KAPPA];
|
struct RefreshCommitLink *commit_link[TALER_CNC_KAPPA];
|
||||||
|
|
||||||
/* For the signature check, we hash most of the inputs together
|
/* For the signature check, we hash most of the inputs together
|
||||||
(except for the signatures on the coins). */
|
(except for the signatures on the coins). */
|
||||||
@ -402,10 +402,10 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
|
|||||||
char *buf;
|
char *buf;
|
||||||
size_t buf_size;
|
size_t buf_size;
|
||||||
|
|
||||||
res = GNUNET_MINT_parse_navigate_json (connection,
|
res = TMH_PARSE_navigate_json (connection,
|
||||||
new_denoms,
|
new_denoms,
|
||||||
JNAV_INDEX, (int) i,
|
TMH_PARSE_JNC_INDEX, (int) i,
|
||||||
JNAV_RET_RSA_PUBLIC_KEY,
|
TMH_PARSE_JNC_RET_RSA_PUBLIC_KEY,
|
||||||
&denom_pubs[i].rsa_public_key);
|
&denom_pubs[i].rsa_public_key);
|
||||||
if (GNUNET_OK != res)
|
if (GNUNET_OK != res)
|
||||||
{
|
{
|
||||||
@ -423,12 +423,12 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
|
|||||||
}
|
}
|
||||||
|
|
||||||
coin_count = json_array_size (melt_coins);
|
coin_count = json_array_size (melt_coins);
|
||||||
/* FIXME: make 'struct TALER_CoinPublicInfo' part of `struct MeltDetails`
|
/* FIXME: make 'struct TALER_CoinPublicInfo' part of `struct TMH_DB_MeltDetails`
|
||||||
and combine these two arrays/arguments! (#3726) */
|
and combine these two arrays/arguments! (#3726) */
|
||||||
coin_public_infos = GNUNET_malloc (coin_count *
|
coin_public_infos = GNUNET_malloc (coin_count *
|
||||||
sizeof (struct TALER_CoinPublicInfo));
|
sizeof (struct TALER_CoinPublicInfo));
|
||||||
coin_melt_details = GNUNET_malloc (coin_count *
|
coin_melt_details = GNUNET_malloc (coin_count *
|
||||||
sizeof (struct MeltDetails));
|
sizeof (struct TMH_DB_MeltDetails));
|
||||||
for (i=0;i<coin_count;i++)
|
for (i=0;i<coin_count;i++)
|
||||||
{
|
{
|
||||||
/* decode JSON data on coin to melt */
|
/* decode JSON data on coin to melt */
|
||||||
@ -458,7 +458,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
if (0 == memcmp (&coin_public_infos[i].coin_pub,
|
if (0 == memcmp (&coin_public_infos[i].coin_pub,
|
||||||
&coin_public_infos[j].coin_pub,
|
&coin_public_infos[j].coin_pub,
|
||||||
sizeof (struct TALER_CoinSpendPublicKey)))
|
sizeof (union TALER_CoinSpendPublicKeyP)))
|
||||||
{
|
{
|
||||||
for (j=0;j<i;j++)
|
for (j=0;j<i;j++)
|
||||||
{
|
{
|
||||||
@ -470,7 +470,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
|
|||||||
GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key);
|
GNUNET_CRYPTO_rsa_public_key_free (denom_pubs[j].rsa_public_key);
|
||||||
GNUNET_free (coin_melt_details);
|
GNUNET_free (coin_melt_details);
|
||||||
GNUNET_free (denom_pubs);
|
GNUNET_free (denom_pubs);
|
||||||
return TALER_MINT_reply_external_error (connection,
|
return TMH_RESPONSE_reply_external_error (connection,
|
||||||
"melting same coin twice in same session is not allowed");
|
"melting same coin twice in same session is not allowed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -478,7 +478,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
|
|||||||
&coin_melt_details[i].melt_amount_with_fee);
|
&coin_melt_details[i].melt_amount_with_fee);
|
||||||
GNUNET_CRYPTO_hash_context_read (hash_context,
|
GNUNET_CRYPTO_hash_context_read (hash_context,
|
||||||
&coin_public_infos[i].coin_pub,
|
&coin_public_infos[i].coin_pub,
|
||||||
sizeof (struct TALER_CoinSpendPublicKey));
|
sizeof (union TALER_CoinSpendPublicKeyP));
|
||||||
GNUNET_CRYPTO_hash_context_read (hash_context,
|
GNUNET_CRYPTO_hash_context_read (hash_context,
|
||||||
&melt_amount,
|
&melt_amount,
|
||||||
sizeof (struct TALER_AmountNBO));
|
sizeof (struct TALER_AmountNBO));
|
||||||
@ -489,7 +489,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
|
|||||||
together for the signature check */
|
together for the signature check */
|
||||||
memset (commit_coin, 0, sizeof (commit_coin));
|
memset (commit_coin, 0, sizeof (commit_coin));
|
||||||
memset (commit_link, 0, sizeof (commit_link));
|
memset (commit_link, 0, sizeof (commit_link));
|
||||||
for (i = 0; i < KAPPA; i++)
|
for (i = 0; i < TALER_CNC_KAPPA; i++)
|
||||||
{
|
{
|
||||||
commit_coin[i] = GNUNET_malloc (num_newcoins *
|
commit_coin[i] = GNUNET_malloc (num_newcoins *
|
||||||
sizeof (struct RefreshCommitCoin));
|
sizeof (struct RefreshCommitCoin));
|
||||||
@ -499,11 +499,11 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
|
|||||||
size_t link_enc_size;
|
size_t link_enc_size;
|
||||||
struct RefreshCommitCoin *rcc = &commit_coin[i][j];
|
struct RefreshCommitCoin *rcc = &commit_coin[i][j];
|
||||||
|
|
||||||
res = GNUNET_MINT_parse_navigate_json (connection,
|
res = TMH_PARSE_navigate_json (connection,
|
||||||
coin_evs,
|
coin_evs,
|
||||||
JNAV_INDEX, (int) i,
|
TMH_PARSE_JNC_INDEX, (int) i,
|
||||||
JNAV_INDEX, (int) j,
|
TMH_PARSE_JNC_INDEX, (int) j,
|
||||||
JNAV_RET_DATA_VAR,
|
TMH_PARSE_JNC_RET_DATA_VAR,
|
||||||
&rcc->coin_ev,
|
&rcc->coin_ev,
|
||||||
&rcc->coin_ev_size);
|
&rcc->coin_ev_size);
|
||||||
|
|
||||||
@ -511,25 +511,25 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
GNUNET_CRYPTO_hash_context_abort (hash_context);
|
GNUNET_CRYPTO_hash_context_abort (hash_context);
|
||||||
free_commit_coins (commit_coin,
|
free_commit_coins (commit_coin,
|
||||||
KAPPA,
|
TALER_CNC_KAPPA,
|
||||||
num_newcoins);
|
num_newcoins);
|
||||||
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
||||||
}
|
}
|
||||||
GNUNET_CRYPTO_hash_context_read (hash_context,
|
GNUNET_CRYPTO_hash_context_read (hash_context,
|
||||||
rcc->coin_ev,
|
rcc->coin_ev,
|
||||||
rcc->coin_ev_size);
|
rcc->coin_ev_size);
|
||||||
res = GNUNET_MINT_parse_navigate_json (connection,
|
res = TMH_PARSE_navigate_json (connection,
|
||||||
link_encs,
|
link_encs,
|
||||||
JNAV_INDEX, (int) i,
|
TMH_PARSE_JNC_INDEX, (int) i,
|
||||||
JNAV_INDEX, (int) j,
|
TMH_PARSE_JNC_INDEX, (int) j,
|
||||||
JNAV_RET_DATA_VAR,
|
TMH_PARSE_JNC_RET_DATA_VAR,
|
||||||
&link_enc,
|
&link_enc,
|
||||||
&link_enc_size);
|
&link_enc_size);
|
||||||
if (GNUNET_OK != res)
|
if (GNUNET_OK != res)
|
||||||
{
|
{
|
||||||
GNUNET_CRYPTO_hash_context_abort (hash_context);
|
GNUNET_CRYPTO_hash_context_abort (hash_context);
|
||||||
free_commit_coins (commit_coin,
|
free_commit_coins (commit_coin,
|
||||||
KAPPA,
|
TALER_CNC_KAPPA,
|
||||||
num_newcoins);
|
num_newcoins);
|
||||||
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
||||||
}
|
}
|
||||||
@ -542,7 +542,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < KAPPA; i++)
|
for (i = 0; i < TALER_CNC_KAPPA; i++)
|
||||||
{
|
{
|
||||||
commit_link[i] = GNUNET_malloc (num_oldcoins *
|
commit_link[i] = GNUNET_malloc (num_oldcoins *
|
||||||
sizeof (struct RefreshCommitLink));
|
sizeof (struct RefreshCommitLink));
|
||||||
@ -550,31 +550,31 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
struct RefreshCommitLink *rcl = &commit_link[i][j];
|
struct RefreshCommitLink *rcl = &commit_link[i][j];
|
||||||
|
|
||||||
res = GNUNET_MINT_parse_navigate_json (connection,
|
res = TMH_PARSE_navigate_json (connection,
|
||||||
transfer_pubs,
|
transfer_pubs,
|
||||||
JNAV_INDEX, (int) i,
|
TMH_PARSE_JNC_INDEX, (int) i,
|
||||||
JNAV_INDEX, (int) j,
|
TMH_PARSE_JNC_INDEX, (int) j,
|
||||||
JNAV_RET_DATA,
|
TMH_PARSE_JNC_RET_DATA,
|
||||||
&rcl->transfer_pub,
|
&rcl->transfer_pub,
|
||||||
sizeof (struct TALER_TransferPublicKey));
|
sizeof (struct TALER_TransferPublicKeyP));
|
||||||
|
|
||||||
if (GNUNET_OK != res)
|
if (GNUNET_OK != res)
|
||||||
{
|
{
|
||||||
GNUNET_break (GNUNET_SYSERR != res);
|
GNUNET_break (GNUNET_SYSERR != res);
|
||||||
GNUNET_CRYPTO_hash_context_abort (hash_context);
|
GNUNET_CRYPTO_hash_context_abort (hash_context);
|
||||||
free_commit_coins (commit_coin,
|
free_commit_coins (commit_coin,
|
||||||
KAPPA,
|
TALER_CNC_KAPPA,
|
||||||
num_newcoins);
|
num_newcoins);
|
||||||
free_commit_links (commit_link,
|
free_commit_links (commit_link,
|
||||||
KAPPA,
|
TALER_CNC_KAPPA,
|
||||||
num_oldcoins);
|
num_oldcoins);
|
||||||
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
||||||
}
|
}
|
||||||
res = GNUNET_MINT_parse_navigate_json (connection,
|
res = TMH_PARSE_navigate_json (connection,
|
||||||
secret_encs,
|
secret_encs,
|
||||||
JNAV_INDEX, (int) i,
|
TMH_PARSE_JNC_INDEX, (int) i,
|
||||||
JNAV_INDEX, (int) j,
|
TMH_PARSE_JNC_INDEX, (int) j,
|
||||||
JNAV_RET_DATA,
|
TMH_PARSE_JNC_RET_DATA,
|
||||||
&rcl->shared_secret_enc,
|
&rcl->shared_secret_enc,
|
||||||
sizeof (struct GNUNET_HashCode));
|
sizeof (struct GNUNET_HashCode));
|
||||||
|
|
||||||
@ -583,10 +583,10 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
|
|||||||
GNUNET_break (GNUNET_SYSERR != res);
|
GNUNET_break (GNUNET_SYSERR != res);
|
||||||
GNUNET_CRYPTO_hash_context_abort (hash_context);
|
GNUNET_CRYPTO_hash_context_abort (hash_context);
|
||||||
free_commit_coins (commit_coin,
|
free_commit_coins (commit_coin,
|
||||||
KAPPA,
|
TALER_CNC_KAPPA,
|
||||||
num_newcoins);
|
num_newcoins);
|
||||||
free_commit_links (commit_link,
|
free_commit_links (commit_link,
|
||||||
KAPPA,
|
TALER_CNC_KAPPA,
|
||||||
num_oldcoins);
|
num_oldcoins);
|
||||||
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
||||||
}
|
}
|
||||||
@ -626,10 +626,10 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
|
|||||||
commit_link);
|
commit_link);
|
||||||
cleanup:
|
cleanup:
|
||||||
free_commit_coins (commit_coin,
|
free_commit_coins (commit_coin,
|
||||||
KAPPA,
|
TALER_CNC_KAPPA,
|
||||||
num_newcoins);
|
num_newcoins);
|
||||||
free_commit_links (commit_link,
|
free_commit_links (commit_link,
|
||||||
KAPPA,
|
TALER_CNC_KAPPA,
|
||||||
num_oldcoins);
|
num_oldcoins);
|
||||||
for (j=0;j<coin_count;j++)
|
for (j=0;j<coin_count;j++)
|
||||||
{
|
{
|
||||||
@ -649,7 +649,7 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
|
|||||||
* Handle a "/refresh/melt" request. Parses the request into the JSON
|
* Handle a "/refresh/melt" request. Parses the request into the JSON
|
||||||
* components and then hands things of to #handle_referesh_melt_json()
|
* components and then hands things of to #handle_referesh_melt_json()
|
||||||
* to validate the melted coins, the signature and execute the melt
|
* to validate the melted coins, the signature and execute the melt
|
||||||
* using TALER_MINT_db_execute_refresh_melt().
|
* using TMH_DB_execute_refresh_melt().
|
||||||
*
|
*
|
||||||
* @param rh context of the handler
|
* @param rh context of the handler
|
||||||
* @param connection the MHD connection to handle
|
* @param connection the MHD connection to handle
|
||||||
@ -659,11 +659,11 @@ handle_refresh_melt_json (struct MHD_Connection *connection,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_handler_refresh_melt (struct RequestHandler *rh,
|
TMH_REFRESH_handler_refresh_melt (struct TMH_RequestHandler *rh,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
void **connection_cls,
|
void **connection_cls,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
size_t *upload_data_size)
|
size_t *upload_data_size)
|
||||||
{
|
{
|
||||||
json_t *root;
|
json_t *root;
|
||||||
json_t *new_denoms;
|
json_t *new_denoms;
|
||||||
@ -678,19 +678,19 @@ TALER_MINT_handler_refresh_melt (struct RequestHandler *rh,
|
|||||||
unsigned int num_newcoins;
|
unsigned int num_newcoins;
|
||||||
json_t *coin_detail;
|
json_t *coin_detail;
|
||||||
int res;
|
int res;
|
||||||
struct GNUNET_MINT_ParseFieldSpec spec[] = {
|
struct TMH_PARSE_FieldSpecification spec[] = {
|
||||||
TALER_MINT_PARSE_ARRAY ("new_denoms", &new_denoms),
|
TMH_PARSE_MEMBER_ARRAY ("new_denoms", &new_denoms),
|
||||||
TALER_MINT_PARSE_ARRAY ("melt_coins", &melt_coins),
|
TMH_PARSE_MEMBER_ARRAY ("melt_coins", &melt_coins),
|
||||||
TALER_MINT_PARSE_ARRAY ("melt_signature", &melt_sig_json),
|
TMH_PARSE_MEMBER_ARRAY ("melt_signature", &melt_sig_json),
|
||||||
TALER_MINT_PARSE_ARRAY ("coin_evs", &coin_evs),
|
TMH_PARSE_MEMBER_ARRAY ("coin_evs", &coin_evs),
|
||||||
TALER_MINT_PARSE_ARRAY ("link_encs", &link_encs),
|
TMH_PARSE_MEMBER_ARRAY ("link_encs", &link_encs),
|
||||||
TALER_MINT_PARSE_ARRAY ("transfer_pubs", &transfer_pubs),
|
TMH_PARSE_MEMBER_ARRAY ("transfer_pubs", &transfer_pubs),
|
||||||
TALER_MINT_PARSE_ARRAY ("secret_encs", &secret_encs),
|
TMH_PARSE_MEMBER_ARRAY ("secret_encs", &secret_encs),
|
||||||
TALER_MINT_PARSE_OBJECT ("commit_signature", &commit_sig_json),
|
TMH_PARSE_MEMBER_OBJECT ("commit_signature", &commit_sig_json),
|
||||||
TALER_MINT_PARSE_END
|
TMH_PARSE_MEMBER_END
|
||||||
};
|
};
|
||||||
|
|
||||||
res = TALER_MINT_parse_post_json (connection,
|
res = TMH_PARSE_post_json (connection,
|
||||||
connection_cls,
|
connection_cls,
|
||||||
upload_data,
|
upload_data,
|
||||||
upload_data_size,
|
upload_data_size,
|
||||||
@ -700,7 +700,7 @@ TALER_MINT_handler_refresh_melt (struct RequestHandler *rh,
|
|||||||
if ( (GNUNET_NO == res) || (NULL == root) )
|
if ( (GNUNET_NO == res) || (NULL == root) )
|
||||||
return MHD_YES;
|
return MHD_YES;
|
||||||
|
|
||||||
res = TALER_MINT_parse_json_data (connection,
|
res = TMH_PARSE_json_data (connection,
|
||||||
root,
|
root,
|
||||||
spec);
|
spec);
|
||||||
json_decref (root);
|
json_decref (root);
|
||||||
@ -708,38 +708,38 @@ TALER_MINT_handler_refresh_melt (struct RequestHandler *rh,
|
|||||||
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
||||||
|
|
||||||
/* Determine dimensionality of the request (kappa, #old and #new coins) */
|
/* Determine dimensionality of the request (kappa, #old and #new coins) */
|
||||||
if (KAPPA != json_array_size (coin_evs))
|
if (TALER_CNC_KAPPA != json_array_size (coin_evs))
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
TALER_MINT_release_parsed_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
return TALER_MINT_reply_arg_invalid (connection,
|
return TMH_RESPONSE_reply_arg_invalid (connection,
|
||||||
"coin_evs");
|
"coin_evs");
|
||||||
}
|
}
|
||||||
if (KAPPA != json_array_size (transfer_pubs))
|
if (TALER_CNC_KAPPA != json_array_size (transfer_pubs))
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
TALER_MINT_release_parsed_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
return TALER_MINT_reply_arg_invalid (connection,
|
return TMH_RESPONSE_reply_arg_invalid (connection,
|
||||||
"transfer_pubs");
|
"transfer_pubs");
|
||||||
}
|
}
|
||||||
res = GNUNET_MINT_parse_navigate_json (connection, coin_evs,
|
res = TMH_PARSE_navigate_json (connection, coin_evs,
|
||||||
JNAV_INDEX, (int) 0,
|
TMH_PARSE_JNC_INDEX, (int) 0,
|
||||||
JNAV_RET_DATA,
|
TMH_PARSE_JNC_RET_DATA,
|
||||||
JSON_ARRAY, &coin_detail);
|
JSON_ARRAY, &coin_detail);
|
||||||
if (GNUNET_OK != res)
|
if (GNUNET_OK != res)
|
||||||
{
|
{
|
||||||
TALER_MINT_release_parsed_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
||||||
}
|
}
|
||||||
num_newcoins = json_array_size (coin_detail);
|
num_newcoins = json_array_size (coin_detail);
|
||||||
res = GNUNET_MINT_parse_navigate_json (connection,
|
res = TMH_PARSE_navigate_json (connection,
|
||||||
transfer_pubs,
|
transfer_pubs,
|
||||||
JNAV_INDEX, (int) 0,
|
TMH_PARSE_JNC_INDEX, (int) 0,
|
||||||
JNAV_RET_DATA,
|
TMH_PARSE_JNC_RET_DATA,
|
||||||
JSON_ARRAY, &coin_detail);
|
JSON_ARRAY, &coin_detail);
|
||||||
if (GNUNET_OK != res)
|
if (GNUNET_OK != res)
|
||||||
{
|
{
|
||||||
TALER_MINT_release_parsed_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
||||||
}
|
}
|
||||||
num_oldcoins = json_array_size (coin_detail);
|
num_oldcoins = json_array_size (coin_detail);
|
||||||
@ -756,7 +756,7 @@ TALER_MINT_handler_refresh_melt (struct RequestHandler *rh,
|
|||||||
coin_evs,
|
coin_evs,
|
||||||
link_encs);
|
link_encs);
|
||||||
|
|
||||||
TALER_MINT_release_parsed_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -764,7 +764,7 @@ TALER_MINT_handler_refresh_melt (struct RequestHandler *rh,
|
|||||||
/**
|
/**
|
||||||
* Handle a "/refresh/reveal" request. Parses the given JSON
|
* Handle a "/refresh/reveal" request. Parses the given JSON
|
||||||
* transfer private keys and if successful, passes everything to
|
* transfer private keys and if successful, passes everything to
|
||||||
* #TALER_MINT_db_execute_refresh_reveal() which will verify that the
|
* #TMH_DB_execute_refresh_reveal() which will verify that the
|
||||||
* revealed information is valid then returns the signed refreshed
|
* revealed information is valid then returns the signed refreshed
|
||||||
* coins.
|
* coins.
|
||||||
*
|
*
|
||||||
@ -780,16 +780,16 @@ handle_refresh_reveal_json (struct MHD_Connection *connection,
|
|||||||
unsigned int num_oldcoins,
|
unsigned int num_oldcoins,
|
||||||
const json_t *tp_json)
|
const json_t *tp_json)
|
||||||
{
|
{
|
||||||
struct TALER_TransferPrivateKey *transfer_privs[KAPPA - 1];
|
struct TALER_TransferPrivateKeyP *transfer_privs[TALER_CNC_KAPPA - 1];
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
for (i = 0; i < KAPPA - 1; i++)
|
for (i = 0; i < TALER_CNC_KAPPA - 1; i++)
|
||||||
transfer_privs[i] = GNUNET_malloc (num_oldcoins *
|
transfer_privs[i] = GNUNET_malloc (num_oldcoins *
|
||||||
sizeof (struct TALER_TransferPrivateKey));
|
sizeof (struct TALER_TransferPrivateKeyP));
|
||||||
res = GNUNET_OK;
|
res = GNUNET_OK;
|
||||||
for (i = 0; i < KAPPA - 1; i++)
|
for (i = 0; i < TALER_CNC_KAPPA - 1; i++)
|
||||||
{
|
{
|
||||||
if (GNUNET_OK != res)
|
if (GNUNET_OK != res)
|
||||||
break;
|
break;
|
||||||
@ -797,23 +797,23 @@ handle_refresh_reveal_json (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
if (GNUNET_OK != res)
|
if (GNUNET_OK != res)
|
||||||
break;
|
break;
|
||||||
res = GNUNET_MINT_parse_navigate_json (connection,
|
res = TMH_PARSE_navigate_json (connection,
|
||||||
tp_json,
|
tp_json,
|
||||||
JNAV_INDEX, (int) i,
|
TMH_PARSE_JNC_INDEX, (int) i,
|
||||||
JNAV_INDEX, (int) j,
|
TMH_PARSE_JNC_INDEX, (int) j,
|
||||||
JNAV_RET_DATA,
|
TMH_PARSE_JNC_RET_DATA,
|
||||||
&transfer_privs[i][j],
|
&transfer_privs[i][j],
|
||||||
sizeof (struct TALER_TransferPrivateKey));
|
sizeof (struct TALER_TransferPrivateKeyP));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (GNUNET_OK != res)
|
if (GNUNET_OK != res)
|
||||||
res = (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
res = (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
||||||
else
|
else
|
||||||
res = TALER_MINT_db_execute_refresh_reveal (connection,
|
res = TMH_DB_execute_refresh_reveal (connection,
|
||||||
session_hash,
|
session_hash,
|
||||||
num_oldcoins,
|
num_oldcoins,
|
||||||
transfer_privs);
|
transfer_privs);
|
||||||
for (i = 0; i < KAPPA - 1; i++)
|
for (i = 0; i < TALER_CNC_KAPPA - 1; i++)
|
||||||
GNUNET_free (transfer_privs[i]);
|
GNUNET_free (transfer_privs[i]);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -824,7 +824,7 @@ handle_refresh_reveal_json (struct MHD_Connection *connection,
|
|||||||
* the private transfer keys except for the cut-and-choose value
|
* the private transfer keys except for the cut-and-choose value
|
||||||
* returned from "/refresh/melt". This function parses the revealed
|
* returned from "/refresh/melt". This function parses the revealed
|
||||||
* keys and secrets and ultimately passes everything to
|
* keys and secrets and ultimately passes everything to
|
||||||
* #TALER_MINT_db_execute_refresh_reveal() which will verify that the
|
* #TMH_DB_execute_refresh_reveal() which will verify that the
|
||||||
* revealed information is valid then returns the signed refreshed
|
* revealed information is valid then returns the signed refreshed
|
||||||
* coins.
|
* coins.
|
||||||
*
|
*
|
||||||
@ -836,11 +836,11 @@ handle_refresh_reveal_json (struct MHD_Connection *connection,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh,
|
TMH_REFRESH_handler_refresh_reveal (struct TMH_RequestHandler *rh,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
void **connection_cls,
|
void **connection_cls,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
size_t *upload_data_size)
|
size_t *upload_data_size)
|
||||||
{
|
{
|
||||||
struct GNUNET_HashCode session_hash;
|
struct GNUNET_HashCode session_hash;
|
||||||
int res;
|
int res;
|
||||||
@ -848,13 +848,13 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh,
|
|||||||
json_t *reveal_detail;
|
json_t *reveal_detail;
|
||||||
json_t *root;
|
json_t *root;
|
||||||
json_t *transfer_privs;
|
json_t *transfer_privs;
|
||||||
struct GNUNET_MINT_ParseFieldSpec spec[] = {
|
struct TMH_PARSE_FieldSpecification spec[] = {
|
||||||
TALER_MINT_PARSE_FIXED ("session_hash", &session_hash),
|
TMH_PARSE_MEMBER_FIXED ("session_hash", &session_hash),
|
||||||
TALER_MINT_PARSE_ARRAY ("transfer_privs", &transfer_privs),
|
TMH_PARSE_MEMBER_ARRAY ("transfer_privs", &transfer_privs),
|
||||||
TALER_MINT_PARSE_END
|
TMH_PARSE_MEMBER_END
|
||||||
};
|
};
|
||||||
|
|
||||||
res = TALER_MINT_parse_post_json (connection,
|
res = TMH_PARSE_post_json (connection,
|
||||||
connection_cls,
|
connection_cls,
|
||||||
upload_data,
|
upload_data,
|
||||||
upload_data_size,
|
upload_data_size,
|
||||||
@ -864,7 +864,7 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh,
|
|||||||
if ( (GNUNET_NO == res) || (NULL == root) )
|
if ( (GNUNET_NO == res) || (NULL == root) )
|
||||||
return MHD_YES;
|
return MHD_YES;
|
||||||
|
|
||||||
res = TALER_MINT_parse_json_data (connection,
|
res = TMH_PARSE_json_data (connection,
|
||||||
root,
|
root,
|
||||||
spec);
|
spec);
|
||||||
json_decref (root);
|
json_decref (root);
|
||||||
@ -872,22 +872,22 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh,
|
|||||||
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
||||||
|
|
||||||
/* Determine dimensionality of the request (kappa and #old coins) */
|
/* Determine dimensionality of the request (kappa and #old coins) */
|
||||||
if (KAPPA != json_array_size (transfer_privs) + 1)
|
if (TALER_CNC_KAPPA != json_array_size (transfer_privs) + 1)
|
||||||
{
|
{
|
||||||
TALER_MINT_release_parsed_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
return TALER_MINT_reply_arg_invalid (connection,
|
return TMH_RESPONSE_reply_arg_invalid (connection,
|
||||||
"transfer_privs");
|
"transfer_privs");
|
||||||
}
|
}
|
||||||
/* Note we do +1 as 1 row (cut-and-choose!) is missing! */
|
/* Note we do +1 as 1 row (cut-and-choose!) is missing! */
|
||||||
res = GNUNET_MINT_parse_navigate_json (connection,
|
res = TMH_PARSE_navigate_json (connection,
|
||||||
transfer_privs,
|
transfer_privs,
|
||||||
JNAV_INDEX, 0,
|
TMH_PARSE_JNC_INDEX, 0,
|
||||||
JNAV_RET_TYPED_JSON,
|
TMH_PARSE_JNC_RET_TYPED_JSON,
|
||||||
JSON_ARRAY,
|
JSON_ARRAY,
|
||||||
&reveal_detail);
|
&reveal_detail);
|
||||||
if (GNUNET_OK != res)
|
if (GNUNET_OK != res)
|
||||||
{
|
{
|
||||||
TALER_MINT_release_parsed_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
|
||||||
}
|
}
|
||||||
num_oldcoins = json_array_size (reveal_detail);
|
num_oldcoins = json_array_size (reveal_detail);
|
||||||
@ -895,7 +895,7 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh,
|
|||||||
&session_hash,
|
&session_hash,
|
||||||
num_oldcoins,
|
num_oldcoins,
|
||||||
transfer_privs);
|
transfer_privs);
|
||||||
TALER_MINT_release_parsed_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -911,25 +911,25 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_handler_refresh_link (struct RequestHandler *rh,
|
TMH_REFRESH_handler_refresh_link (struct TMH_RequestHandler *rh,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
void **connection_cls,
|
void **connection_cls,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
size_t *upload_data_size)
|
size_t *upload_data_size)
|
||||||
{
|
{
|
||||||
struct TALER_CoinSpendPublicKey coin_pub;
|
union TALER_CoinSpendPublicKeyP coin_pub;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
res = TALER_MINT_mhd_request_arg_data (connection,
|
res = TMH_PARSE_mhd_request_arg_data (connection,
|
||||||
"coin_pub",
|
"coin_pub",
|
||||||
&coin_pub,
|
&coin_pub,
|
||||||
sizeof (struct TALER_CoinSpendPublicKey));
|
sizeof (union TALER_CoinSpendPublicKeyP));
|
||||||
if (GNUNET_SYSERR == res)
|
if (GNUNET_SYSERR == res)
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
if (GNUNET_OK != res)
|
if (GNUNET_OK != res)
|
||||||
return MHD_YES;
|
return MHD_YES;
|
||||||
|
|
||||||
return TALER_MINT_db_execute_refresh_link (connection,
|
return TMH_DB_execute_refresh_link (connection,
|
||||||
&coin_pub);
|
&coin_pub);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
* Handle a "/refresh/melt" request. Parses the request into the JSON
|
* Handle a "/refresh/melt" request. Parses the request into the JSON
|
||||||
* components and then hands things of to #handle_referesh_melt_json()
|
* components and then hands things of to #handle_referesh_melt_json()
|
||||||
* to validate the melted coins, the signature and execute the melt
|
* to validate the melted coins, the signature and execute the melt
|
||||||
* using TALER_MINT_db_execute_refresh_melt().
|
* using TMH_DB_execute_refresh_melt().
|
||||||
*
|
*
|
||||||
* @param rh context of the handler
|
* @param rh context of the handler
|
||||||
* @param connection the MHD connection to handle
|
* @param connection the MHD connection to handle
|
||||||
@ -42,11 +42,11 @@
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_handler_refresh_melt (struct RequestHandler *rh,
|
TMH_REFRESH_handler_refresh_melt (struct TMH_RequestHandler *rh,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
void **connection_cls,
|
void **connection_cls,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
size_t *upload_data_size);
|
size_t *upload_data_size);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,7 +54,7 @@ TALER_MINT_handler_refresh_melt (struct RequestHandler *rh,
|
|||||||
* the private transfer keys except for the cut-and-choose value
|
* the private transfer keys except for the cut-and-choose value
|
||||||
* returned from "/refresh/commit". This function parses the revealed
|
* returned from "/refresh/commit". This function parses the revealed
|
||||||
* keys and secrets and ultimately passes everything to
|
* keys and secrets and ultimately passes everything to
|
||||||
* #TALER_MINT_db_execute_refresh_reveal() which will verify that the
|
* #TMH_DB_execute_refresh_reveal() which will verify that the
|
||||||
* revealed information is valid then returns the signed refreshed
|
* revealed information is valid then returns the signed refreshed
|
||||||
* coins.
|
* coins.
|
||||||
*
|
*
|
||||||
@ -66,11 +66,11 @@ TALER_MINT_handler_refresh_melt (struct RequestHandler *rh,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh,
|
TMH_REFRESH_handler_refresh_reveal (struct TMH_RequestHandler *rh,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
void **connection_cls,
|
void **connection_cls,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
size_t *upload_data_size);
|
size_t *upload_data_size);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,11 +84,11 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_handler_refresh_link (struct RequestHandler *rh,
|
TMH_REFRESH_handler_refresh_link (struct TMH_RequestHandler *rh,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
void **connection_cls,
|
void **connection_cls,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
size_t *upload_data_size);
|
size_t *upload_data_size);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file taler-mint-httpd_responses.c
|
* @file taler-mint-httpd_responses.c
|
||||||
* @brief API for generating the various replies of the mint; these
|
* @brief API for generating the various replies of the mint; these
|
||||||
* functions are called TALER_MINT_reply_ and they generate
|
* functions are called TMH_RESPONSE_reply_ and they generate
|
||||||
* and queue MHD response objects for a given connection.
|
* and queue MHD response objects for a given connection.
|
||||||
* @author Florian Dold
|
* @author Florian Dold
|
||||||
* @author Benedikt Mueller
|
* @author Benedikt Mueller
|
||||||
@ -38,7 +38,7 @@
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_json (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_json (struct MHD_Connection *connection,
|
||||||
const json_t *json,
|
const json_t *json,
|
||||||
unsigned int response_code)
|
unsigned int response_code)
|
||||||
{
|
{
|
||||||
@ -71,7 +71,7 @@ TALER_MINT_reply_json (struct MHD_Connection *connection,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_json_pack (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_json_pack (struct MHD_Connection *connection,
|
||||||
unsigned int response_code,
|
unsigned int response_code,
|
||||||
const char *fmt,
|
const char *fmt,
|
||||||
...)
|
...)
|
||||||
@ -85,7 +85,7 @@ TALER_MINT_reply_json_pack (struct MHD_Connection *connection,
|
|||||||
va_end (argp);
|
va_end (argp);
|
||||||
if (NULL == json)
|
if (NULL == json)
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
ret = TALER_MINT_reply_json (connection,
|
ret = TMH_RESPONSE_reply_json (connection,
|
||||||
json,
|
json,
|
||||||
response_code);
|
response_code);
|
||||||
json_decref (json);
|
json_decref (json);
|
||||||
@ -101,10 +101,10 @@ TALER_MINT_reply_json_pack (struct MHD_Connection *connection,
|
|||||||
* @return a MHD result code
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_arg_invalid (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_arg_invalid (struct MHD_Connection *connection,
|
||||||
const char *param_name)
|
const char *param_name)
|
||||||
{
|
{
|
||||||
return TALER_MINT_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:s}",
|
"{s:s, s:s}",
|
||||||
"error", "invalid parameter",
|
"error", "invalid parameter",
|
||||||
@ -121,11 +121,11 @@ TALER_MINT_reply_arg_invalid (struct MHD_Connection *connection,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_coin_invalid (struct MHD_Connection *connection)
|
TMH_RESPONSE_reply_coin_invalid (struct MHD_Connection *connection)
|
||||||
{
|
{
|
||||||
/* TODO: may want to be more precise in the future and
|
/* TODO: may want to be more precise in the future and
|
||||||
distinguish bogus signatures from bogus public keys. */
|
distinguish bogus signatures from bogus public keys. */
|
||||||
return TALER_MINT_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_NOT_FOUND,
|
MHD_HTTP_NOT_FOUND,
|
||||||
"{s:s}",
|
"{s:s}",
|
||||||
"error", "Coin is not valid");
|
"error", "Coin is not valid");
|
||||||
@ -140,10 +140,10 @@ TALER_MINT_reply_coin_invalid (struct MHD_Connection *connection)
|
|||||||
* @return a MHD result code
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_arg_missing (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_arg_missing (struct MHD_Connection *connection,
|
||||||
const char *param_name)
|
const char *param_name)
|
||||||
{
|
{
|
||||||
return TALER_MINT_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{ s:s, s:s}",
|
"{ s:s, s:s}",
|
||||||
"error", "missing parameter",
|
"error", "missing parameter",
|
||||||
@ -159,10 +159,10 @@ TALER_MINT_reply_arg_missing (struct MHD_Connection *connection,
|
|||||||
* @return a MHD result code
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_internal_error (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_internal_error (struct MHD_Connection *connection,
|
||||||
const char *hint)
|
const char *hint)
|
||||||
{
|
{
|
||||||
return TALER_MINT_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:s}",
|
"{s:s, s:s}",
|
||||||
"error", "internal error",
|
"error", "internal error",
|
||||||
@ -178,10 +178,10 @@ TALER_MINT_reply_internal_error (struct MHD_Connection *connection,
|
|||||||
* @return a MHD result code
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_external_error (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_external_error (struct MHD_Connection *connection,
|
||||||
const char *hint)
|
const char *hint)
|
||||||
{
|
{
|
||||||
return TALER_MINT_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:s}",
|
"{s:s, s:s}",
|
||||||
"error", "client error",
|
"error", "client error",
|
||||||
@ -197,9 +197,9 @@ TALER_MINT_reply_external_error (struct MHD_Connection *connection,
|
|||||||
* @return a MHD result code
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_commit_error (struct MHD_Connection *connection)
|
TMH_RESPONSE_reply_commit_error (struct MHD_Connection *connection)
|
||||||
{
|
{
|
||||||
return TALER_MINT_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s}",
|
"{s:s}",
|
||||||
"error", "commit failure");
|
"error", "commit failure");
|
||||||
@ -214,9 +214,9 @@ TALER_MINT_reply_commit_error (struct MHD_Connection *connection)
|
|||||||
* @return a MHD result code
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_internal_db_error (struct MHD_Connection *connection)
|
TMH_RESPONSE_reply_internal_db_error (struct MHD_Connection *connection)
|
||||||
{
|
{
|
||||||
return TALER_MINT_reply_internal_error (connection,
|
return TMH_RESPONSE_reply_internal_error (connection,
|
||||||
"Failed to connect to database");
|
"Failed to connect to database");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ TALER_MINT_reply_internal_db_error (struct MHD_Connection *connection)
|
|||||||
* @return a MHD result code
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_request_too_large (struct MHD_Connection *connection)
|
TMH_RESPONSE_reply_request_too_large (struct MHD_Connection *connection)
|
||||||
{
|
{
|
||||||
struct MHD_Response *resp;
|
struct MHD_Response *resp;
|
||||||
int ret;
|
int ret;
|
||||||
@ -253,9 +253,9 @@ TALER_MINT_reply_request_too_large (struct MHD_Connection *connection)
|
|||||||
* @return a MHD result code
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_invalid_json (struct MHD_Connection *connection)
|
TMH_RESPONSE_reply_invalid_json (struct MHD_Connection *connection)
|
||||||
{
|
{
|
||||||
return TALER_MINT_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s}",
|
"{s:s}",
|
||||||
"error",
|
"error",
|
||||||
@ -281,21 +281,21 @@ TALER_MINT_reply_invalid_json (struct MHD_Connection *connection)
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_deposit_success (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_deposit_success (struct MHD_Connection *connection,
|
||||||
const struct TALER_CoinSpendPublicKey *coin_pub,
|
const union TALER_CoinSpendPublicKeyP *coin_pub,
|
||||||
const struct GNUNET_HashCode *h_wire,
|
const struct GNUNET_HashCode *h_wire,
|
||||||
const struct GNUNET_HashCode *h_contract,
|
const struct GNUNET_HashCode *h_contract,
|
||||||
uint64_t transaction_id,
|
uint64_t transaction_id,
|
||||||
const struct TALER_MerchantPublicKey *merchant,
|
const struct TALER_MerchantPublicKeyP *merchant,
|
||||||
const struct TALER_Amount *amount)
|
const struct TALER_Amount *amount)
|
||||||
{
|
{
|
||||||
struct TALER_DepositConfirmation dc;
|
struct TALER_DepositConfirmationPS dc;
|
||||||
struct TALER_MintSignature sig;
|
struct TALER_MintSignatureP sig;
|
||||||
json_t *sig_json;
|
json_t *sig_json;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
dc.purpose.purpose = htonl (TALER_SIGNATURE_MINT_DEPOSIT);
|
dc.purpose.purpose = htonl (TALER_SIGNATURE_COIN_DEPOSIT);
|
||||||
dc.purpose.size = htonl (sizeof (struct TALER_DepositConfirmation));
|
dc.purpose.size = htonl (sizeof (struct TALER_DepositConfirmationPS));
|
||||||
dc.h_contract = *h_contract;
|
dc.h_contract = *h_contract;
|
||||||
dc.h_wire = *h_wire;
|
dc.h_wire = *h_wire;
|
||||||
dc.transaction_id = GNUNET_htonll (transaction_id);
|
dc.transaction_id = GNUNET_htonll (transaction_id);
|
||||||
@ -303,11 +303,11 @@ TALER_MINT_reply_deposit_success (struct MHD_Connection *connection,
|
|||||||
amount);
|
amount);
|
||||||
dc.coin_pub = *coin_pub;
|
dc.coin_pub = *coin_pub;
|
||||||
dc.merchant = *merchant;
|
dc.merchant = *merchant;
|
||||||
TALER_MINT_keys_sign (&dc.purpose,
|
TMH_KS_sign (&dc.purpose,
|
||||||
&sig);
|
&sig);
|
||||||
sig_json = TALER_JSON_from_eddsa_sig (&dc.purpose,
|
sig_json = TALER_json_from_eddsa_sig (&dc.purpose,
|
||||||
&sig.eddsa_signature);
|
&sig.eddsa_signature);
|
||||||
ret = TALER_MINT_reply_json_pack (connection,
|
ret = TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"status", "DEPOSIT_OK",
|
"status", "DEPOSIT_OK",
|
||||||
@ -339,37 +339,37 @@ compile_transaction_history (const struct TALER_MINT_DB_TransactionList *tl)
|
|||||||
{
|
{
|
||||||
case TALER_MINT_DB_TT_DEPOSIT:
|
case TALER_MINT_DB_TT_DEPOSIT:
|
||||||
{
|
{
|
||||||
struct TALER_DepositRequest dr;
|
struct TALER_DepositRequestPS dr;
|
||||||
const struct Deposit *deposit = pos->details.deposit;
|
const struct Deposit *deposit = pos->details.deposit;
|
||||||
|
|
||||||
type = "deposit";
|
type = "deposit";
|
||||||
value = deposit->amount_with_fee;
|
value = deposit->amount_with_fee;
|
||||||
dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_DEPOSIT);
|
dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_DEPOSIT);
|
||||||
dr.purpose.size = htonl (sizeof (struct TALER_DepositRequest));
|
dr.purpose.size = htonl (sizeof (struct TALER_DepositRequestPS));
|
||||||
dr.h_contract = deposit->h_contract;
|
dr.h_contract = deposit->h_contract;
|
||||||
dr.h_wire = deposit->h_wire;
|
dr.h_wire = deposit->h_wire;
|
||||||
dr.transaction_id = GNUNET_htonll (deposit->transaction_id);
|
dr.transaction_id = GNUNET_htonll (deposit->transaction_id);
|
||||||
TALER_amount_hton (&dr.amount_with_fee,
|
TALER_amount_hton (&dr.amount_with_fee,
|
||||||
&deposit->amount_with_fee);
|
&deposit->amount_with_fee);
|
||||||
dr.coin_pub = deposit->coin.coin_pub;
|
dr.coin_pub = deposit->coin.coin_pub;
|
||||||
transaction = TALER_JSON_from_ecdsa_sig (&dr.purpose,
|
transaction = TALER_json_from_ecdsa_sig (&dr.purpose,
|
||||||
&deposit->csig.ecdsa_signature);
|
&deposit->csig.ecdsa_signature);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TALER_MINT_DB_TT_REFRESH_MELT:
|
case TALER_MINT_DB_TT_REFRESH_MELT:
|
||||||
{
|
{
|
||||||
struct RefreshMeltCoinSignature ms;
|
struct TALER_RefreshMeltCoinAffirmationPS ms;
|
||||||
const struct RefreshMelt *melt = pos->details.melt;
|
const struct RefreshMelt *melt = pos->details.melt;
|
||||||
|
|
||||||
type = "melt";
|
type = "melt";
|
||||||
value = melt->amount_with_fee;
|
value = melt->amount_with_fee;
|
||||||
ms.purpose.purpose = htonl (TALER_SIGNATURE_REFRESH_MELT_COIN);
|
ms.purpose.purpose = htonl (TALER_SIGNATURE_COIN_MELT);
|
||||||
ms.purpose.size = htonl (sizeof (struct RefreshMeltCoinSignature));
|
ms.purpose.size = htonl (sizeof (struct TALER_RefreshMeltCoinAffirmationPS));
|
||||||
ms.session_hash = melt->session_hash;
|
ms.session_hash = melt->session_hash;
|
||||||
TALER_amount_hton (&ms.amount_with_fee,
|
TALER_amount_hton (&ms.amount_with_fee,
|
||||||
&melt->amount_with_fee);
|
&melt->amount_with_fee);
|
||||||
ms.coin_pub = melt->coin.coin_pub;
|
ms.coin_pub = melt->coin.coin_pub;
|
||||||
transaction = TALER_JSON_from_ecdsa_sig (&ms.purpose,
|
transaction = TALER_json_from_ecdsa_sig (&ms.purpose,
|
||||||
&melt->coin_sig.ecdsa_signature);
|
&melt->coin_sig.ecdsa_signature);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -387,7 +387,7 @@ compile_transaction_history (const struct TALER_MINT_DB_TransactionList *tl)
|
|||||||
json_array_append_new (history,
|
json_array_append_new (history,
|
||||||
json_pack ("{s:s, s:o}",
|
json_pack ("{s:s, s:o}",
|
||||||
"type", type,
|
"type", type,
|
||||||
"amount", TALER_JSON_from_amount (&value),
|
"amount", TALER_json_from_amount (&value),
|
||||||
"signature", transaction));
|
"signature", transaction));
|
||||||
}
|
}
|
||||||
return history;
|
return history;
|
||||||
@ -404,13 +404,13 @@ compile_transaction_history (const struct TALER_MINT_DB_TransactionList *tl)
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_deposit_insufficient_funds (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_deposit_insufficient_funds (struct MHD_Connection *connection,
|
||||||
const struct TALER_MINT_DB_TransactionList *tl)
|
const struct TALER_MINT_DB_TransactionList *tl)
|
||||||
{
|
{
|
||||||
json_t *history;
|
json_t *history;
|
||||||
|
|
||||||
history = compile_transaction_history (tl);
|
history = compile_transaction_history (tl);
|
||||||
return TALER_MINT_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_FORBIDDEN,
|
MHD_HTTP_FORBIDDEN,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"error", "insufficient funds",
|
"error", "insufficient funds",
|
||||||
@ -437,9 +437,9 @@ compile_reserve_history (const struct ReserveHistory *rh,
|
|||||||
json_t *transaction;
|
json_t *transaction;
|
||||||
int ret;
|
int ret;
|
||||||
const struct ReserveHistory *pos;
|
const struct ReserveHistory *pos;
|
||||||
struct TALER_MINT_DenomKeyIssuePriv *dki;
|
struct TALER_DenominationKeyIssueInformation *dki;
|
||||||
struct MintKeyState *key_state;
|
struct TMH_KS_StateHandle *key_state;
|
||||||
struct TALER_WithdrawRequest wr;
|
struct TALER_WithdrawRequestPS wr;
|
||||||
|
|
||||||
json_history = json_array ();
|
json_history = json_array ();
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -464,14 +464,14 @@ compile_reserve_history (const struct ReserveHistory *rh,
|
|||||||
json_pack ("{s:s, s:o, s:o}",
|
json_pack ("{s:s, s:o, s:o}",
|
||||||
"type", "DEPOSIT",
|
"type", "DEPOSIT",
|
||||||
"wire", pos->details.bank->wire,
|
"wire", pos->details.bank->wire,
|
||||||
"amount", TALER_JSON_from_amount (&pos->details.bank->amount)));
|
"amount", TALER_json_from_amount (&pos->details.bank->amount)));
|
||||||
break;
|
break;
|
||||||
case TALER_MINT_DB_RO_WITHDRAW_COIN:
|
case TALER_MINT_DB_RO_WITHDRAW_COIN:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
key_state = TALER_MINT_key_state_acquire ();
|
key_state = TMH_KS_acquire ();
|
||||||
ret = 0;
|
ret = 0;
|
||||||
for (pos = rh; NULL != pos; pos = pos->next)
|
for (pos = rh; NULL != pos; pos = pos->next)
|
||||||
{
|
{
|
||||||
@ -481,7 +481,7 @@ compile_reserve_history (const struct ReserveHistory *rh,
|
|||||||
break;
|
break;
|
||||||
case TALER_MINT_DB_RO_WITHDRAW_COIN:
|
case TALER_MINT_DB_RO_WITHDRAW_COIN:
|
||||||
|
|
||||||
dki = TALER_MINT_get_denom_key (key_state,
|
dki = TMH_KS_denomination_key_lookup (key_state,
|
||||||
&pos->details.withdraw->denom_pub);
|
&pos->details.withdraw->denom_pub);
|
||||||
TALER_amount_ntoh (&value,
|
TALER_amount_ntoh (&value,
|
||||||
&dki->issue.value);
|
&dki->issue.value);
|
||||||
@ -493,31 +493,31 @@ compile_reserve_history (const struct ReserveHistory *rh,
|
|||||||
&withdraw_total,
|
&withdraw_total,
|
||||||
&value))
|
&value))
|
||||||
{
|
{
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
json_decref (json_history);
|
json_decref (json_history);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ret = 1;
|
ret = 1;
|
||||||
wr.purpose.purpose = htonl (TALER_SIGNATURE_WITHDRAW);
|
wr.purpose.purpose = htonl (TALER_SIGNATURE_RESERVE_WITHDRAW_REQUEST);
|
||||||
wr.purpose.size = htonl (sizeof (struct TALER_WithdrawRequest));
|
wr.purpose.size = htonl (sizeof (struct TALER_WithdrawRequestPS));
|
||||||
wr.reserve_pub = pos->details.withdraw->reserve_pub;
|
wr.reserve_pub = pos->details.withdraw->reserve_pub;
|
||||||
GNUNET_CRYPTO_rsa_public_key_hash (pos->details.withdraw->denom_pub.rsa_public_key,
|
GNUNET_CRYPTO_rsa_public_key_hash (pos->details.withdraw->denom_pub.rsa_public_key,
|
||||||
&wr.h_denomination_pub);
|
&wr.h_denomination_pub);
|
||||||
wr.h_coin_envelope = pos->details.withdraw->h_coin_envelope;
|
wr.h_coin_envelope = pos->details.withdraw->h_coin_envelope;
|
||||||
|
|
||||||
transaction = TALER_JSON_from_eddsa_sig (&wr.purpose,
|
transaction = TALER_json_from_eddsa_sig (&wr.purpose,
|
||||||
&pos->details.withdraw->reserve_sig.eddsa_signature);
|
&pos->details.withdraw->reserve_sig.eddsa_signature);
|
||||||
|
|
||||||
json_array_append_new (json_history,
|
json_array_append_new (json_history,
|
||||||
json_pack ("{s:s, s:o, s:o}",
|
json_pack ("{s:s, s:o, s:o}",
|
||||||
"type", "WITHDRAW",
|
"type", "WITHDRAW",
|
||||||
"signature", transaction,
|
"signature", transaction,
|
||||||
"amount", TALER_JSON_from_amount (&value)));
|
"amount", TALER_json_from_amount (&value)));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TALER_MINT_key_state_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
|
|
||||||
if (GNUNET_SYSERR ==
|
if (GNUNET_SYSERR ==
|
||||||
TALER_amount_subtract (balance,
|
TALER_amount_subtract (balance,
|
||||||
@ -540,7 +540,7 @@ compile_reserve_history (const struct ReserveHistory *rh,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_withdraw_status_success (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_withdraw_status_success (struct MHD_Connection *connection,
|
||||||
const struct ReserveHistory *rh)
|
const struct ReserveHistory *rh)
|
||||||
{
|
{
|
||||||
json_t *json_balance;
|
json_t *json_balance;
|
||||||
@ -551,10 +551,10 @@ TALER_MINT_reply_withdraw_status_success (struct MHD_Connection *connection,
|
|||||||
json_history = compile_reserve_history (rh,
|
json_history = compile_reserve_history (rh,
|
||||||
&balance);
|
&balance);
|
||||||
if (NULL == json_history)
|
if (NULL == json_history)
|
||||||
return TALER_MINT_reply_internal_error (connection,
|
return TMH_RESPONSE_reply_internal_error (connection,
|
||||||
"balance calculation failure");
|
"balance calculation failure");
|
||||||
json_balance = TALER_JSON_from_amount (&balance);
|
json_balance = TALER_json_from_amount (&balance);
|
||||||
ret = TALER_MINT_reply_json_pack (connection,
|
ret = TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"{s:o, s:o}",
|
"{s:o, s:o}",
|
||||||
"balance", json_balance,
|
"balance", json_balance,
|
||||||
@ -575,7 +575,7 @@ TALER_MINT_reply_withdraw_status_success (struct MHD_Connection *connection,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_withdraw_sign_insufficient_funds (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_withdraw_sign_insufficient_funds (struct MHD_Connection *connection,
|
||||||
const struct ReserveHistory *rh)
|
const struct ReserveHistory *rh)
|
||||||
{
|
{
|
||||||
json_t *json_balance;
|
json_t *json_balance;
|
||||||
@ -586,10 +586,10 @@ TALER_MINT_reply_withdraw_sign_insufficient_funds (struct MHD_Connection *connec
|
|||||||
json_history = compile_reserve_history (rh,
|
json_history = compile_reserve_history (rh,
|
||||||
&balance);
|
&balance);
|
||||||
if (NULL == json_history)
|
if (NULL == json_history)
|
||||||
return TALER_MINT_reply_internal_error (connection,
|
return TMH_RESPONSE_reply_internal_error (connection,
|
||||||
"balance calculation failure");
|
"balance calculation failure");
|
||||||
json_balance = TALER_JSON_from_amount (&balance);
|
json_balance = TALER_json_from_amount (&balance);
|
||||||
ret = TALER_MINT_reply_json_pack (connection,
|
ret = TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_PAYMENT_REQUIRED,
|
MHD_HTTP_PAYMENT_REQUIRED,
|
||||||
"{s:s, s:o, s:o}",
|
"{s:s, s:o, s:o}",
|
||||||
"error", "Insufficient funds"
|
"error", "Insufficient funds"
|
||||||
@ -609,14 +609,14 @@ TALER_MINT_reply_withdraw_sign_insufficient_funds (struct MHD_Connection *connec
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_withdraw_sign_success (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_withdraw_sign_success (struct MHD_Connection *connection,
|
||||||
const struct CollectableBlindcoin *collectable)
|
const struct CollectableBlindcoin *collectable)
|
||||||
{
|
{
|
||||||
json_t *sig_json;
|
json_t *sig_json;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
sig_json = TALER_JSON_from_rsa_signature (collectable->sig.rsa_signature);
|
sig_json = TALER_json_from_rsa_signature (collectable->sig.rsa_signature);
|
||||||
ret = TALER_MINT_reply_json_pack (connection,
|
ret = TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"{s:o}",
|
"{s:o}",
|
||||||
"ev_sig", sig_json);
|
"ev_sig", sig_json);
|
||||||
@ -641,8 +641,8 @@ TALER_MINT_reply_withdraw_sign_success (struct MHD_Connection *connection,
|
|||||||
* @return a MHD result code
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_refresh_melt_insufficient_funds (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_refresh_melt_insufficient_funds (struct MHD_Connection *connection,
|
||||||
const struct TALER_CoinSpendPublicKey *coin_pub,
|
const union TALER_CoinSpendPublicKeyP *coin_pub,
|
||||||
struct TALER_Amount coin_value,
|
struct TALER_Amount coin_value,
|
||||||
struct TALER_MINT_DB_TransactionList *tl,
|
struct TALER_MINT_DB_TransactionList *tl,
|
||||||
struct TALER_Amount requested,
|
struct TALER_Amount requested,
|
||||||
@ -651,15 +651,15 @@ TALER_MINT_reply_refresh_melt_insufficient_funds (struct MHD_Connection *connect
|
|||||||
json_t *history;
|
json_t *history;
|
||||||
|
|
||||||
history = compile_transaction_history (tl);
|
history = compile_transaction_history (tl);
|
||||||
return TALER_MINT_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_NOT_FOUND,
|
MHD_HTTP_NOT_FOUND,
|
||||||
"{s:s, s:o, s:o, s:o, s:o, s:o}",
|
"{s:s, s:o, s:o, s:o, s:o, s:o}",
|
||||||
"error", "insufficient funds",
|
"error", "insufficient funds",
|
||||||
"coin-pub", TALER_JSON_from_data (coin_pub,
|
"coin-pub", TALER_json_from_data (coin_pub,
|
||||||
sizeof (struct TALER_CoinSpendPublicKey)),
|
sizeof (union TALER_CoinSpendPublicKeyP)),
|
||||||
"original-value", TALER_JSON_from_amount (&coin_value),
|
"original-value", TALER_json_from_amount (&coin_value),
|
||||||
"residual-value", TALER_JSON_from_amount (&residual),
|
"residual-value", TALER_json_from_amount (&residual),
|
||||||
"requested-value", TALER_JSON_from_amount (&requested),
|
"requested-value", TALER_json_from_amount (&requested),
|
||||||
"history", history);
|
"history", history);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -673,25 +673,25 @@ TALER_MINT_reply_refresh_melt_insufficient_funds (struct MHD_Connection *connect
|
|||||||
* @return a MHD status code
|
* @return a MHD status code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_refresh_melt_success (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_refresh_melt_success (struct MHD_Connection *connection,
|
||||||
const struct GNUNET_HashCode *session_hash,
|
const struct GNUNET_HashCode *session_hash,
|
||||||
uint16_t noreveal_index)
|
uint16_t noreveal_index)
|
||||||
{
|
{
|
||||||
struct RefreshMeltResponseSignatureBody body;
|
struct TALER_RefreshMeltConfirmationPS body;
|
||||||
struct TALER_MintSignature sig;
|
struct TALER_MintSignatureP sig;
|
||||||
json_t *sig_json;
|
json_t *sig_json;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
body.purpose.size = htonl (sizeof (struct RefreshMeltResponseSignatureBody));
|
body.purpose.size = htonl (sizeof (struct TALER_RefreshMeltConfirmationPS));
|
||||||
body.purpose.purpose = htonl (TALER_SIGNATURE_REFRESH_MELT_RESPONSE);
|
body.purpose.purpose = htonl (TALER_SIGNATURE_MINT_MELT_RESPONSE);
|
||||||
body.session_hash = *session_hash;
|
body.session_hash = *session_hash;
|
||||||
body.noreveal_index = htons (noreveal_index);
|
body.noreveal_index = htons (noreveal_index);
|
||||||
TALER_MINT_keys_sign (&body.purpose,
|
TMH_KS_sign (&body.purpose,
|
||||||
&sig);
|
&sig);
|
||||||
sig_json = TALER_JSON_from_eddsa_sig (&body.purpose,
|
sig_json = TALER_json_from_eddsa_sig (&body.purpose,
|
||||||
&sig.eddsa_signature);
|
&sig.eddsa_signature);
|
||||||
GNUNET_assert (NULL != sig_json);
|
GNUNET_assert (NULL != sig_json);
|
||||||
ret = TALER_MINT_reply_json_pack (connection,
|
ret = TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"{s:i, s:o}",
|
"{s:i, s:o}",
|
||||||
"noreveal_index", (int) noreveal_index,
|
"noreveal_index", (int) noreveal_index,
|
||||||
@ -710,7 +710,7 @@ TALER_MINT_reply_refresh_melt_success (struct MHD_Connection *connection,
|
|||||||
* @return a MHD result code
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_refresh_reveal_success (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_refresh_reveal_success (struct MHD_Connection *connection,
|
||||||
unsigned int num_newcoins,
|
unsigned int num_newcoins,
|
||||||
const struct TALER_DenominationSignature *sigs)
|
const struct TALER_DenominationSignature *sigs)
|
||||||
{
|
{
|
||||||
@ -726,8 +726,8 @@ TALER_MINT_reply_refresh_reveal_success (struct MHD_Connection *connection,
|
|||||||
list);
|
list);
|
||||||
for (newcoin_index = 0; newcoin_index < num_newcoins; newcoin_index++)
|
for (newcoin_index = 0; newcoin_index < num_newcoins; newcoin_index++)
|
||||||
json_array_append_new (list,
|
json_array_append_new (list,
|
||||||
TALER_JSON_from_rsa_signature (sigs[newcoin_index].rsa_signature));
|
TALER_json_from_rsa_signature (sigs[newcoin_index].rsa_signature));
|
||||||
ret = TALER_MINT_reply_json (connection,
|
ret = TMH_RESPONSE_reply_json (connection,
|
||||||
root,
|
root,
|
||||||
MHD_HTTP_OK);
|
MHD_HTTP_OK);
|
||||||
json_decref (root);
|
json_decref (root);
|
||||||
@ -753,12 +753,12 @@ TALER_MINT_reply_refresh_reveal_success (struct MHD_Connection *connection,
|
|||||||
* @return a MHD result code
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_refresh_reveal_missmatch (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection,
|
||||||
unsigned int off,
|
unsigned int off,
|
||||||
unsigned int j,
|
unsigned int j,
|
||||||
const char *missmatch_object)
|
const char *missmatch_object)
|
||||||
{
|
{
|
||||||
return TALER_MINT_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:i, s:i, s:s}",
|
"{s:s, s:i, s:i, s:s}",
|
||||||
"error", "commitment violation",
|
"error", "commitment violation",
|
||||||
@ -778,9 +778,9 @@ TALER_MINT_reply_refresh_reveal_missmatch (struct MHD_Connection *connection,
|
|||||||
* @return a MHD result code
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_refresh_link_success (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_refresh_link_success (struct MHD_Connection *connection,
|
||||||
const struct TALER_TransferPublicKey *transfer_pub,
|
const struct TALER_TransferPublicKeyP *transfer_pub,
|
||||||
const struct TALER_EncryptedLinkSecret *shared_secret_enc,
|
const struct TALER_EncryptedLinkSecretP *shared_secret_enc,
|
||||||
const struct LinkDataList *ldl)
|
const struct LinkDataList *ldl)
|
||||||
{
|
{
|
||||||
const struct LinkDataList *pos;
|
const struct LinkDataList *pos;
|
||||||
@ -795,15 +795,15 @@ TALER_MINT_reply_refresh_link_success (struct MHD_Connection *connection,
|
|||||||
|
|
||||||
obj = json_object ();
|
obj = json_object ();
|
||||||
json_object_set_new (obj, "link_enc",
|
json_object_set_new (obj, "link_enc",
|
||||||
TALER_JSON_from_data (ldl->link_data_enc->coin_priv_enc,
|
TALER_json_from_data (ldl->link_data_enc->coin_priv_enc,
|
||||||
sizeof (struct TALER_CoinSpendPrivateKey) +
|
sizeof (union TALER_CoinSpendPrivateKeyP) +
|
||||||
ldl->link_data_enc->blinding_key_enc_size));
|
ldl->link_data_enc->blinding_key_enc_size));
|
||||||
json_object_set_new (obj,
|
json_object_set_new (obj,
|
||||||
"denom_pub",
|
"denom_pub",
|
||||||
TALER_JSON_from_rsa_public_key (ldl->denom_pub.rsa_public_key));
|
TALER_json_from_rsa_public_key (ldl->denom_pub.rsa_public_key));
|
||||||
json_object_set_new (obj,
|
json_object_set_new (obj,
|
||||||
"ev_sig",
|
"ev_sig",
|
||||||
TALER_JSON_from_rsa_signature (ldl->ev_sig.rsa_signature));
|
TALER_json_from_rsa_signature (ldl->ev_sig.rsa_signature));
|
||||||
json_array_append_new (list, obj);
|
json_array_append_new (list, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -813,13 +813,13 @@ TALER_MINT_reply_refresh_link_success (struct MHD_Connection *connection,
|
|||||||
list);
|
list);
|
||||||
json_object_set_new (root,
|
json_object_set_new (root,
|
||||||
"transfer_pub",
|
"transfer_pub",
|
||||||
TALER_JSON_from_data (transfer_pub,
|
TALER_json_from_data (transfer_pub,
|
||||||
sizeof (struct TALER_TransferPublicKey)));
|
sizeof (struct TALER_TransferPublicKeyP)));
|
||||||
json_object_set_new (root,
|
json_object_set_new (root,
|
||||||
"secret_enc",
|
"secret_enc",
|
||||||
TALER_JSON_from_data (shared_secret_enc,
|
TALER_json_from_data (shared_secret_enc,
|
||||||
sizeof (struct TALER_EncryptedLinkSecret)));
|
sizeof (struct TALER_EncryptedLinkSecretP)));
|
||||||
res = TALER_MINT_reply_json (connection,
|
res = TMH_RESPONSE_reply_json (connection,
|
||||||
root,
|
root,
|
||||||
MHD_HTTP_OK);
|
MHD_HTTP_OK);
|
||||||
json_decref (root);
|
json_decref (root);
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file taler-mint-httpd_responses.h
|
* @file taler-mint-httpd_responses.h
|
||||||
* @brief API for generating the various replies of the mint; these
|
* @brief API for generating the various replies of the mint; these
|
||||||
* functions are called TALER_MINT_reply_ and they generate
|
* functions are called TMH_RESPONSE_reply_ and they generate
|
||||||
* and queue MHD response objects for a given connection.
|
* and queue MHD response objects for a given connection.
|
||||||
* @author Florian Dold
|
* @author Florian Dold
|
||||||
* @author Benedikt Mueller
|
* @author Benedikt Mueller
|
||||||
@ -42,9 +42,9 @@
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_json (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_json (struct MHD_Connection *connection,
|
||||||
const json_t *json,
|
const json_t *json,
|
||||||
unsigned int response_code);
|
unsigned int response_code);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,10 +58,10 @@ TALER_MINT_reply_json (struct MHD_Connection *connection,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_json_pack (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_json_pack (struct MHD_Connection *connection,
|
||||||
unsigned int response_code,
|
unsigned int response_code,
|
||||||
const char *fmt,
|
const char *fmt,
|
||||||
...);
|
...);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,8 +72,8 @@ TALER_MINT_reply_json_pack (struct MHD_Connection *connection,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_arg_invalid (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_arg_invalid (struct MHD_Connection *connection,
|
||||||
const char *param_name);
|
const char *param_name);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,7 +85,7 @@ TALER_MINT_reply_arg_invalid (struct MHD_Connection *connection,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_coin_invalid (struct MHD_Connection *connection);
|
TMH_RESPONSE_reply_coin_invalid (struct MHD_Connection *connection);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,8 +96,8 @@ TALER_MINT_reply_coin_invalid (struct MHD_Connection *connection);
|
|||||||
* @return a MHD result code
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_arg_missing (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_arg_missing (struct MHD_Connection *connection,
|
||||||
const char *param_name);
|
const char *param_name);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,8 +108,8 @@ TALER_MINT_reply_arg_missing (struct MHD_Connection *connection,
|
|||||||
* @return a MHD result code
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_internal_error (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_internal_error (struct MHD_Connection *connection,
|
||||||
const char *hint);
|
const char *hint);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -120,8 +120,8 @@ TALER_MINT_reply_internal_error (struct MHD_Connection *connection,
|
|||||||
* @return a MHD result code
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_external_error (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_external_error (struct MHD_Connection *connection,
|
||||||
const char *hint);
|
const char *hint);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -132,7 +132,7 @@ TALER_MINT_reply_external_error (struct MHD_Connection *connection,
|
|||||||
* @return a MHD result code
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_commit_error (struct MHD_Connection *connection);
|
TMH_RESPONSE_reply_commit_error (struct MHD_Connection *connection);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -143,7 +143,7 @@ TALER_MINT_reply_commit_error (struct MHD_Connection *connection);
|
|||||||
* @return a MHD result code
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_internal_db_error (struct MHD_Connection *connection);
|
TMH_RESPONSE_reply_internal_db_error (struct MHD_Connection *connection);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -153,7 +153,7 @@ TALER_MINT_reply_internal_db_error (struct MHD_Connection *connection);
|
|||||||
* @return a MHD result code
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_request_too_large (struct MHD_Connection *connection);
|
TMH_RESPONSE_reply_request_too_large (struct MHD_Connection *connection);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -163,7 +163,7 @@ TALER_MINT_reply_request_too_large (struct MHD_Connection *connection);
|
|||||||
* @return a MHD result code
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_invalid_json (struct MHD_Connection *connection);
|
TMH_RESPONSE_reply_invalid_json (struct MHD_Connection *connection);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -184,13 +184,13 @@ TALER_MINT_reply_invalid_json (struct MHD_Connection *connection);
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_deposit_success (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_deposit_success (struct MHD_Connection *connection,
|
||||||
const struct TALER_CoinSpendPublicKey *coin_pub,
|
const union TALER_CoinSpendPublicKeyP *coin_pub,
|
||||||
const struct GNUNET_HashCode *h_wire,
|
const struct GNUNET_HashCode *h_wire,
|
||||||
const struct GNUNET_HashCode *h_contract,
|
const struct GNUNET_HashCode *h_contract,
|
||||||
uint64_t transaction_id,
|
uint64_t transaction_id,
|
||||||
const struct TALER_MerchantPublicKey *merchant,
|
const struct TALER_MerchantPublicKeyP *merchant,
|
||||||
const struct TALER_Amount *amount);
|
const struct TALER_Amount *amount);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -203,8 +203,8 @@ TALER_MINT_reply_deposit_success (struct MHD_Connection *connection,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_deposit_insufficient_funds (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_deposit_insufficient_funds (struct MHD_Connection *connection,
|
||||||
const struct TALER_MINT_DB_TransactionList *tl);
|
const struct TALER_MINT_DB_TransactionList *tl);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -215,8 +215,8 @@ TALER_MINT_reply_deposit_insufficient_funds (struct MHD_Connection *connection,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_withdraw_status_success (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_withdraw_status_success (struct MHD_Connection *connection,
|
||||||
const struct ReserveHistory *rh);
|
const struct ReserveHistory *rh);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -229,8 +229,8 @@ TALER_MINT_reply_withdraw_status_success (struct MHD_Connection *connection,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_withdraw_sign_insufficient_funds (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_withdraw_sign_insufficient_funds (struct MHD_Connection *connection,
|
||||||
const struct ReserveHistory *rh);
|
const struct ReserveHistory *rh);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -241,8 +241,8 @@ TALER_MINT_reply_withdraw_sign_insufficient_funds (struct MHD_Connection *connec
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_withdraw_sign_success (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_withdraw_sign_success (struct MHD_Connection *connection,
|
||||||
const struct CollectableBlindcoin *collectable);
|
const struct CollectableBlindcoin *collectable);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -254,9 +254,9 @@ TALER_MINT_reply_withdraw_sign_success (struct MHD_Connection *connection,
|
|||||||
* @return a MHD status code
|
* @return a MHD status code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_refresh_melt_success (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_refresh_melt_success (struct MHD_Connection *connection,
|
||||||
const struct GNUNET_HashCode *session_hash,
|
const struct GNUNET_HashCode *session_hash,
|
||||||
uint16_t noreveal_index);
|
uint16_t noreveal_index);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -275,12 +275,12 @@ TALER_MINT_reply_refresh_melt_success (struct MHD_Connection *connection,
|
|||||||
* @return a MHD result code
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_refresh_melt_insufficient_funds (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_refresh_melt_insufficient_funds (struct MHD_Connection *connection,
|
||||||
const struct TALER_CoinSpendPublicKey *coin_pub,
|
const union TALER_CoinSpendPublicKeyP *coin_pub,
|
||||||
struct TALER_Amount coin_value,
|
struct TALER_Amount coin_value,
|
||||||
struct TALER_MINT_DB_TransactionList *tl,
|
struct TALER_MINT_DB_TransactionList *tl,
|
||||||
struct TALER_Amount requested,
|
struct TALER_Amount requested,
|
||||||
struct TALER_Amount residual);
|
struct TALER_Amount residual);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -292,9 +292,9 @@ TALER_MINT_reply_refresh_melt_insufficient_funds (struct MHD_Connection *connect
|
|||||||
* @return a MHD result code
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_refresh_reveal_success (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_refresh_reveal_success (struct MHD_Connection *connection,
|
||||||
unsigned int num_newcoins,
|
unsigned int num_newcoins,
|
||||||
const struct TALER_DenominationSignature *sigs);
|
const struct TALER_DenominationSignature *sigs);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -315,10 +315,10 @@ TALER_MINT_reply_refresh_reveal_success (struct MHD_Connection *connection,
|
|||||||
* @return a MHD result code
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_refresh_reveal_missmatch (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection,
|
||||||
unsigned int off,
|
unsigned int off,
|
||||||
unsigned int j,
|
unsigned int j,
|
||||||
const char *missmatch_object);
|
const char *missmatch_object);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -331,10 +331,10 @@ TALER_MINT_reply_refresh_reveal_missmatch (struct MHD_Connection *connection,
|
|||||||
* @return a MHD result code
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_reply_refresh_link_success (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_refresh_link_success (struct MHD_Connection *connection,
|
||||||
const struct TALER_TransferPublicKey *transfer_pub,
|
const struct TALER_TransferPublicKeyP *transfer_pub,
|
||||||
const struct TALER_EncryptedLinkSecret *shared_secret_enc,
|
const struct TALER_EncryptedLinkSecretP *shared_secret_enc,
|
||||||
const struct LinkDataList *ldl);
|
const struct LinkDataList *ldl);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -43,24 +43,24 @@
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_handler_withdraw_status (struct RequestHandler *rh,
|
TMH_WITHDRAW_handler_withdraw_status (struct TMH_RequestHandler *rh,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
void **connection_cls,
|
void **connection_cls,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
size_t *upload_data_size)
|
size_t *upload_data_size)
|
||||||
{
|
{
|
||||||
struct TALER_ReservePublicKey reserve_pub;
|
struct TALER_ReservePublicKeyP reserve_pub;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
res = TALER_MINT_mhd_request_arg_data (connection,
|
res = TMH_PARSE_mhd_request_arg_data (connection,
|
||||||
"reserve_pub",
|
"reserve_pub",
|
||||||
&reserve_pub,
|
&reserve_pub,
|
||||||
sizeof (struct TALER_ReservePublicKey));
|
sizeof (struct TALER_ReservePublicKeyP));
|
||||||
if (GNUNET_SYSERR == res)
|
if (GNUNET_SYSERR == res)
|
||||||
return MHD_NO; /* internal error */
|
return MHD_NO; /* internal error */
|
||||||
if (GNUNET_NO == res)
|
if (GNUNET_NO == res)
|
||||||
return MHD_YES; /* parse error */
|
return MHD_YES; /* parse error */
|
||||||
return TALER_MINT_db_execute_withdraw_status (connection,
|
return TMH_DB_execute_withdraw_status (connection,
|
||||||
&reserve_pub);
|
&reserve_pub);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,38 +82,38 @@ TALER_MINT_handler_withdraw_status (struct RequestHandler *rh,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh,
|
TMH_WITHDRAW_handler_withdraw_sign (struct TMH_RequestHandler *rh,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
void **connection_cls,
|
void **connection_cls,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
size_t *upload_data_size)
|
size_t *upload_data_size)
|
||||||
{
|
{
|
||||||
struct TALER_WithdrawRequest wsrd;
|
struct TALER_WithdrawRequestPS wsrd;
|
||||||
int res;
|
int res;
|
||||||
struct TALER_DenominationPublicKey denomination_pub;
|
struct TALER_DenominationPublicKey denomination_pub;
|
||||||
char *denomination_pub_data;
|
char *denomination_pub_data;
|
||||||
size_t denomination_pub_data_size;
|
size_t denomination_pub_data_size;
|
||||||
char *blinded_msg;
|
char *blinded_msg;
|
||||||
size_t blinded_msg_len;
|
size_t blinded_msg_len;
|
||||||
struct TALER_ReserveSignature signature;
|
struct TALER_ReserveSignatureP signature;
|
||||||
|
|
||||||
res = TALER_MINT_mhd_request_arg_data (connection,
|
res = TMH_PARSE_mhd_request_arg_data (connection,
|
||||||
"reserve_pub",
|
"reserve_pub",
|
||||||
&wsrd.reserve_pub,
|
&wsrd.reserve_pub,
|
||||||
sizeof (struct TALER_ReservePublicKey));
|
sizeof (struct TALER_ReservePublicKeyP));
|
||||||
if (GNUNET_SYSERR == res)
|
if (GNUNET_SYSERR == res)
|
||||||
return MHD_NO; /* internal error */
|
return MHD_NO; /* internal error */
|
||||||
if (GNUNET_NO == res)
|
if (GNUNET_NO == res)
|
||||||
return MHD_YES; /* invalid request */
|
return MHD_YES; /* invalid request */
|
||||||
res = TALER_MINT_mhd_request_arg_data (connection,
|
res = TMH_PARSE_mhd_request_arg_data (connection,
|
||||||
"reserve_sig",
|
"reserve_sig",
|
||||||
&signature,
|
&signature,
|
||||||
sizeof (struct TALER_ReserveSignature));
|
sizeof (struct TALER_ReserveSignatureP));
|
||||||
if (GNUNET_SYSERR == res)
|
if (GNUNET_SYSERR == res)
|
||||||
return MHD_NO; /* internal error */
|
return MHD_NO; /* internal error */
|
||||||
if (GNUNET_NO == res)
|
if (GNUNET_NO == res)
|
||||||
return MHD_YES; /* invalid request */
|
return MHD_YES; /* invalid request */
|
||||||
res = TALER_MINT_mhd_request_var_arg_data (connection,
|
res = TMH_PARSE_mhd_request_var_arg_data (connection,
|
||||||
"denom_pub",
|
"denom_pub",
|
||||||
(void **) &denomination_pub_data,
|
(void **) &denomination_pub_data,
|
||||||
&denomination_pub_data_size);
|
&denomination_pub_data_size);
|
||||||
@ -121,7 +121,7 @@ TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh,
|
|||||||
return MHD_NO; /* internal error */
|
return MHD_NO; /* internal error */
|
||||||
if (GNUNET_NO == res)
|
if (GNUNET_NO == res)
|
||||||
return MHD_YES; /* invalid request */
|
return MHD_YES; /* invalid request */
|
||||||
res = TALER_MINT_mhd_request_var_arg_data (connection,
|
res = TMH_PARSE_mhd_request_var_arg_data (connection,
|
||||||
"coin_ev",
|
"coin_ev",
|
||||||
(void **) &blinded_msg,
|
(void **) &blinded_msg,
|
||||||
&blinded_msg_len);
|
&blinded_msg_len);
|
||||||
@ -137,8 +137,8 @@ TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* verify signature! */
|
/* verify signature! */
|
||||||
wsrd.purpose.size = htonl (sizeof (struct TALER_WithdrawRequest));
|
wsrd.purpose.size = htonl (sizeof (struct TALER_WithdrawRequestPS));
|
||||||
wsrd.purpose.purpose = htonl (TALER_SIGNATURE_WITHDRAW);
|
wsrd.purpose.purpose = htonl (TALER_SIGNATURE_RESERVE_WITHDRAW_REQUEST);
|
||||||
GNUNET_CRYPTO_hash (denomination_pub_data,
|
GNUNET_CRYPTO_hash (denomination_pub_data,
|
||||||
denomination_pub_data_size,
|
denomination_pub_data_size,
|
||||||
&wsrd.h_denomination_pub);
|
&wsrd.h_denomination_pub);
|
||||||
@ -146,15 +146,15 @@ TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh,
|
|||||||
blinded_msg_len,
|
blinded_msg_len,
|
||||||
&wsrd.h_coin_envelope);
|
&wsrd.h_coin_envelope);
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WITHDRAW,
|
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_RESERVE_WITHDRAW_REQUEST,
|
||||||
&wsrd.purpose,
|
&wsrd.purpose,
|
||||||
&signature.eddsa_signature,
|
&signature.eddsa_signature,
|
||||||
&wsrd.reserve_pub.eddsa_pub))
|
&wsrd.reserve_pub.eddsa_pub))
|
||||||
{
|
{
|
||||||
LOG_WARNING ("Client supplied invalid signature for /withdraw/sign request\n");
|
TALER_LOG_WARNING ("Client supplied invalid signature for /withdraw/sign request\n");
|
||||||
GNUNET_free (denomination_pub_data);
|
GNUNET_free (denomination_pub_data);
|
||||||
GNUNET_free (blinded_msg);
|
GNUNET_free (blinded_msg);
|
||||||
return TALER_MINT_reply_arg_invalid (connection,
|
return TMH_RESPONSE_reply_arg_invalid (connection,
|
||||||
"reserve_sig");
|
"reserve_sig");
|
||||||
}
|
}
|
||||||
denomination_pub.rsa_public_key
|
denomination_pub.rsa_public_key
|
||||||
@ -163,12 +163,12 @@ TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh,
|
|||||||
GNUNET_free (denomination_pub_data);
|
GNUNET_free (denomination_pub_data);
|
||||||
if (NULL == denomination_pub.rsa_public_key)
|
if (NULL == denomination_pub.rsa_public_key)
|
||||||
{
|
{
|
||||||
LOG_WARNING ("Client supplied ill-formed denomination public key for /withdraw/sign request\n");
|
TALER_LOG_WARNING ("Client supplied ill-formed denomination public key for /withdraw/sign request\n");
|
||||||
GNUNET_free (blinded_msg);
|
GNUNET_free (blinded_msg);
|
||||||
return TALER_MINT_reply_arg_invalid (connection,
|
return TMH_RESPONSE_reply_arg_invalid (connection,
|
||||||
"denom_pub");
|
"denom_pub");
|
||||||
}
|
}
|
||||||
res = TALER_MINT_db_execute_withdraw_sign (connection,
|
res = TMH_DB_execute_withdraw_sign (connection,
|
||||||
&wsrd.reserve_pub,
|
&wsrd.reserve_pub,
|
||||||
&denomination_pub,
|
&denomination_pub,
|
||||||
blinded_msg,
|
blinded_msg,
|
||||||
|
@ -40,11 +40,11 @@
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_handler_withdraw_status (struct RequestHandler *rh,
|
TMH_WITHDRAW_handler_withdraw_status (struct TMH_RequestHandler *rh,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
void **connection_cls,
|
void **connection_cls,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
size_t *upload_data_size);
|
size_t *upload_data_size);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,10 +64,10 @@ TALER_MINT_handler_withdraw_status (struct RequestHandler *rh,
|
|||||||
* @return MHD result code
|
* @return MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_MINT_handler_withdraw_sign (struct RequestHandler *rh,
|
TMH_WITHDRAW_handler_withdraw_sign (struct TMH_RequestHandler *rh,
|
||||||
struct MHD_Connection *connection,
|
struct MHD_Connection *connection,
|
||||||
void **connection_cls,
|
void **connection_cls,
|
||||||
const char *upload_data,
|
const char *upload_data,
|
||||||
size_t *upload_data_size);
|
size_t *upload_data_size);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
/**
|
/**
|
||||||
* Mint directory with the keys.
|
* Mint directory with the keys.
|
||||||
*/
|
*/
|
||||||
static char *mintdir;
|
static char *mint_directory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Our configuration.
|
* Our configuration.
|
||||||
@ -50,7 +50,7 @@ static struct GNUNET_CONFIGURATION_Handle *kcfg;
|
|||||||
static int
|
static int
|
||||||
signkeys_iter (void *cls,
|
signkeys_iter (void *cls,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
const struct TALER_MINT_SignKeyIssuePriv *ski)
|
const struct TALER_MintSigningKeyValidityPSPriv *ski)
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
||||||
"Iterating over key `%s' for start time %s\n",
|
"Iterating over key `%s' for start time %s\n",
|
||||||
@ -59,8 +59,8 @@ signkeys_iter (void *cls,
|
|||||||
(GNUNET_TIME_absolute_ntoh (ski->issue.start)));
|
(GNUNET_TIME_absolute_ntoh (ski->issue.start)));
|
||||||
|
|
||||||
if (ntohl (ski->issue.purpose.size) !=
|
if (ntohl (ski->issue.purpose.size) !=
|
||||||
(sizeof (struct TALER_MINT_SignKeyIssue) -
|
(sizeof (struct TALER_MintSigningKeyValidityPS) -
|
||||||
offsetof (struct TALER_MINT_SignKeyIssue, purpose)))
|
offsetof (struct TALER_MintSigningKeyValidityPS, purpose)))
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"Signing key `%s' has invalid purpose size\n",
|
"Signing key `%s' has invalid purpose size\n",
|
||||||
@ -68,10 +68,10 @@ signkeys_iter (void *cls,
|
|||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_SIGNKEY,
|
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MINT_SIGNING_KEY_VALIDITY,
|
||||||
&ski->issue.purpose,
|
&ski->issue.purpose,
|
||||||
&ski->issue.signature.eddsa_signature,
|
&ski->issue.signature.eddsa_signature,
|
||||||
&ski->issue.master_pub.eddsa_pub))
|
&ski->issue.master_public_key.eddsa_pub))
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"Signing key `%s' has invalid signature\n",
|
"Signing key `%s' has invalid signature\n",
|
||||||
@ -93,7 +93,7 @@ signkeys_iter (void *cls,
|
|||||||
static int
|
static int
|
||||||
mint_signkeys_check ()
|
mint_signkeys_check ()
|
||||||
{
|
{
|
||||||
if (0 > TALER_MINT_signkeys_iterate (mintdir,
|
if (0 > TALER_MINT_signkeys_iterate (mint_directory,
|
||||||
&signkeys_iter,
|
&signkeys_iter,
|
||||||
NULL))
|
NULL))
|
||||||
return GNUNET_NO;
|
return GNUNET_NO;
|
||||||
@ -114,12 +114,12 @@ mint_signkeys_check ()
|
|||||||
static int
|
static int
|
||||||
denomkeys_iter (void *cls,
|
denomkeys_iter (void *cls,
|
||||||
const char *alias,
|
const char *alias,
|
||||||
const struct TALER_MINT_DenomKeyIssuePriv *dki)
|
const struct TALER_DenominationKeyIssueInformation *dki)
|
||||||
{
|
{
|
||||||
struct GNUNET_HashCode hc;
|
struct GNUNET_HashCode hc;
|
||||||
|
|
||||||
if (ntohl (dki->issue.purpose.size) !=
|
if (ntohl (dki->issue.purpose.size) !=
|
||||||
sizeof (struct TALER_MINT_DenomKeyIssue))
|
sizeof (struct TALER_DenominationKeyValidityPS))
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"Denomination key for `%s' has invalid purpose size\n",
|
"Denomination key for `%s' has invalid purpose size\n",
|
||||||
@ -128,7 +128,7 @@ denomkeys_iter (void *cls,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_DENOM,
|
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MINT_DENOMINATION_KEY_VALIDITY,
|
||||||
&dki->issue.purpose,
|
&dki->issue.purpose,
|
||||||
&dki->issue.signature.eddsa_signature,
|
&dki->issue.signature.eddsa_signature,
|
||||||
&dki->issue.master.eddsa_pub))
|
&dki->issue.master.eddsa_pub))
|
||||||
@ -165,7 +165,7 @@ denomkeys_iter (void *cls,
|
|||||||
static int
|
static int
|
||||||
mint_denomkeys_check ()
|
mint_denomkeys_check ()
|
||||||
{
|
{
|
||||||
if (0 > TALER_MINT_denomkeys_iterate (mintdir,
|
if (0 > TALER_MINT_denomkeys_iterate (mint_directory,
|
||||||
&denomkeys_iter,
|
&denomkeys_iter,
|
||||||
NULL))
|
NULL))
|
||||||
return GNUNET_NO;
|
return GNUNET_NO;
|
||||||
@ -187,7 +187,7 @@ main (int argc, char *const *argv)
|
|||||||
GNUNET_GETOPT_OPTION_HELP ("gnunet-mint-keycheck OPTIONS"),
|
GNUNET_GETOPT_OPTION_HELP ("gnunet-mint-keycheck OPTIONS"),
|
||||||
{'d', "directory", "DIRECTORY",
|
{'d', "directory", "DIRECTORY",
|
||||||
"mint directory with keys to check", 1,
|
"mint directory with keys to check", 1,
|
||||||
&GNUNET_GETOPT_set_filename, &mintdir},
|
&GNUNET_GETOPT_set_filename, &mint_directory},
|
||||||
GNUNET_GETOPT_OPTION_END
|
GNUNET_GETOPT_OPTION_END
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -200,14 +200,14 @@ main (int argc, char *const *argv)
|
|||||||
options,
|
options,
|
||||||
argc, argv) < 0)
|
argc, argv) < 0)
|
||||||
return 1;
|
return 1;
|
||||||
if (NULL == mintdir)
|
if (NULL == mint_directory)
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"Mint directory not given\n");
|
"Mint directory not given\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
kcfg = TALER_config_load (mintdir);
|
kcfg = TALER_config_load (mint_directory);
|
||||||
if (NULL == kcfg)
|
if (NULL == kcfg)
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
|
@ -51,7 +51,7 @@ GNUNET_NETWORK_STRUCT_BEGIN
|
|||||||
* Struct with all of the key information for a kind of coin. Hashed
|
* Struct with all of the key information for a kind of coin. Hashed
|
||||||
* to generate a unique directory name per coin type.
|
* to generate a unique directory name per coin type.
|
||||||
*/
|
*/
|
||||||
struct CoinTypeNBO
|
struct CoinTypeNBOP
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* How long can the coin be spend?
|
* How long can the coin be spend?
|
||||||
@ -158,7 +158,7 @@ static char *masterkeyfile;
|
|||||||
/**
|
/**
|
||||||
* Director of the mint, containing the keys.
|
* Director of the mint, containing the keys.
|
||||||
*/
|
*/
|
||||||
static char *mintdir;
|
static char *mint_directory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Time to pretend when the key update is executed.
|
* Time to pretend when the key update is executed.
|
||||||
@ -179,12 +179,12 @@ static struct GNUNET_TIME_Absolute now;
|
|||||||
/**
|
/**
|
||||||
* Master private key of the mint.
|
* Master private key of the mint.
|
||||||
*/
|
*/
|
||||||
static struct TALER_MasterPrivateKey master_priv;
|
static struct TALER_MasterPrivateKeyP master_priv;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Master public key of the mint.
|
* Master public key of the mint.
|
||||||
*/
|
*/
|
||||||
static struct TALER_MasterPublicKey master_pub;
|
static struct TALER_MasterPublicKeyP master_public_key;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Until what time do we provide keys?
|
* Until what time do we provide keys?
|
||||||
@ -208,7 +208,7 @@ get_signkey_file (struct GNUNET_TIME_Absolute start)
|
|||||||
GNUNET_snprintf (dir,
|
GNUNET_snprintf (dir,
|
||||||
sizeof (dir),
|
sizeof (dir),
|
||||||
"%s" DIR_SEPARATOR_STR DIR_SIGNKEYS DIR_SEPARATOR_STR "%llu",
|
"%s" DIR_SEPARATOR_STR DIR_SIGNKEYS DIR_SEPARATOR_STR "%llu",
|
||||||
mintdir,
|
mint_directory,
|
||||||
(unsigned long long) start.abs_value_us);
|
(unsigned long long) start.abs_value_us);
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
@ -226,11 +226,11 @@ static void
|
|||||||
hash_coin_type (const struct CoinTypeParams *p,
|
hash_coin_type (const struct CoinTypeParams *p,
|
||||||
struct GNUNET_HashCode *hash)
|
struct GNUNET_HashCode *hash)
|
||||||
{
|
{
|
||||||
struct CoinTypeNBO p_nbo;
|
struct CoinTypeNBOP p_nbo;
|
||||||
|
|
||||||
memset (&p_nbo,
|
memset (&p_nbo,
|
||||||
0,
|
0,
|
||||||
sizeof (struct CoinTypeNBO));
|
sizeof (struct CoinTypeNBOP));
|
||||||
p_nbo.duration_spend = GNUNET_TIME_relative_hton (p->duration_spend);
|
p_nbo.duration_spend = GNUNET_TIME_relative_hton (p->duration_spend);
|
||||||
p_nbo.duration_withdraw = GNUNET_TIME_relative_hton (p->duration_withdraw);
|
p_nbo.duration_withdraw = GNUNET_TIME_relative_hton (p->duration_withdraw);
|
||||||
TALER_amount_hton (&p_nbo.value,
|
TALER_amount_hton (&p_nbo.value,
|
||||||
@ -243,7 +243,7 @@ hash_coin_type (const struct CoinTypeParams *p,
|
|||||||
&p->fee_refresh);
|
&p->fee_refresh);
|
||||||
p_nbo.rsa_keysize = htonl (p->rsa_keysize);
|
p_nbo.rsa_keysize = htonl (p->rsa_keysize);
|
||||||
GNUNET_CRYPTO_hash (&p_nbo,
|
GNUNET_CRYPTO_hash (&p_nbo,
|
||||||
sizeof (struct CoinTypeNBO),
|
sizeof (struct CoinTypeNBOP),
|
||||||
hash);
|
hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ get_cointype_dir (const struct CoinTypeParams *p)
|
|||||||
GNUNET_snprintf (dir,
|
GNUNET_snprintf (dir,
|
||||||
sizeof (dir),
|
sizeof (dir),
|
||||||
"%s" DIR_SEPARATOR_STR DIR_DENOMKEYS DIR_SEPARATOR_STR "%s-%s",
|
"%s" DIR_SEPARATOR_STR DIR_DENOMKEYS DIR_SEPARATOR_STR "%s-%s",
|
||||||
mintdir,
|
mint_directory,
|
||||||
val_str,
|
val_str,
|
||||||
hash_str);
|
hash_str);
|
||||||
GNUNET_free (hash_str);
|
GNUNET_free (hash_str);
|
||||||
@ -434,23 +434,23 @@ get_anchor (const char *dir,
|
|||||||
static void
|
static void
|
||||||
create_signkey_issue_priv (struct GNUNET_TIME_Absolute start,
|
create_signkey_issue_priv (struct GNUNET_TIME_Absolute start,
|
||||||
struct GNUNET_TIME_Relative duration,
|
struct GNUNET_TIME_Relative duration,
|
||||||
struct TALER_MINT_SignKeyIssuePriv *pi)
|
struct TALER_MintSigningKeyValidityPSPriv *pi)
|
||||||
{
|
{
|
||||||
struct GNUNET_CRYPTO_EddsaPrivateKey *priv;
|
struct GNUNET_CRYPTO_EddsaPrivateKey *priv;
|
||||||
struct TALER_MINT_SignKeyIssue *issue = &pi->issue;
|
struct TALER_MintSigningKeyValidityPS *issue = &pi->issue;
|
||||||
|
|
||||||
priv = GNUNET_CRYPTO_eddsa_key_create ();
|
priv = GNUNET_CRYPTO_eddsa_key_create ();
|
||||||
pi->signkey_priv.eddsa_priv = *priv;
|
pi->signkey_priv.eddsa_priv = *priv;
|
||||||
GNUNET_free (priv);
|
GNUNET_free (priv);
|
||||||
issue->master_pub = master_pub;
|
issue->master_public_key = master_public_key;
|
||||||
issue->start = GNUNET_TIME_absolute_hton (start);
|
issue->start = GNUNET_TIME_absolute_hton (start);
|
||||||
issue->expire = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (start,
|
issue->expire = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (start,
|
||||||
duration));
|
duration));
|
||||||
GNUNET_CRYPTO_eddsa_key_get_public (&pi->signkey_priv.eddsa_priv,
|
GNUNET_CRYPTO_eddsa_key_get_public (&pi->signkey_priv.eddsa_priv,
|
||||||
&issue->signkey_pub.eddsa_pub);
|
&issue->signkey_pub.eddsa_pub);
|
||||||
issue->purpose.purpose = htonl (TALER_SIGNATURE_MASTER_SIGNKEY);
|
issue->purpose.purpose = htonl (TALER_SIGNATURE_MINT_SIGNING_KEY_VALIDITY);
|
||||||
issue->purpose.size = htonl (sizeof (struct TALER_MINT_SignKeyIssue) -
|
issue->purpose.size = htonl (sizeof (struct TALER_MintSigningKeyValidityPS) -
|
||||||
offsetof (struct TALER_MINT_SignKeyIssue,
|
offsetof (struct TALER_MintSigningKeyValidityPS,
|
||||||
purpose));
|
purpose));
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
@ -488,7 +488,7 @@ mint_keys_update_signkeys ()
|
|||||||
rel_value_us);
|
rel_value_us);
|
||||||
GNUNET_asprintf (&signkey_dir,
|
GNUNET_asprintf (&signkey_dir,
|
||||||
"%s" DIR_SEPARATOR_STR DIR_SIGNKEYS,
|
"%s" DIR_SEPARATOR_STR DIR_SIGNKEYS,
|
||||||
mintdir);
|
mint_directory);
|
||||||
/* make sure the directory exists */
|
/* make sure the directory exists */
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_DISK_directory_create (signkey_dir))
|
GNUNET_DISK_directory_create (signkey_dir))
|
||||||
@ -506,7 +506,7 @@ mint_keys_update_signkeys ()
|
|||||||
while (anchor.abs_value_us < lookahead_sign_stamp.abs_value_us)
|
while (anchor.abs_value_us < lookahead_sign_stamp.abs_value_us)
|
||||||
{
|
{
|
||||||
const char *skf;
|
const char *skf;
|
||||||
struct TALER_MINT_SignKeyIssuePriv signkey_issue;
|
struct TALER_MintSigningKeyValidityPSPriv signkey_issue;
|
||||||
ssize_t nwrite;
|
ssize_t nwrite;
|
||||||
|
|
||||||
skf = get_signkey_file (anchor);
|
skf = get_signkey_file (anchor);
|
||||||
@ -520,9 +520,9 @@ mint_keys_update_signkeys ()
|
|||||||
&signkey_issue);
|
&signkey_issue);
|
||||||
nwrite = GNUNET_DISK_fn_write (skf,
|
nwrite = GNUNET_DISK_fn_write (skf,
|
||||||
&signkey_issue,
|
&signkey_issue,
|
||||||
sizeof (struct TALER_MINT_SignKeyIssue),
|
sizeof (struct TALER_MintSigningKeyValidityPS),
|
||||||
GNUNET_DISK_PERM_USER_WRITE | GNUNET_DISK_PERM_USER_READ);
|
GNUNET_DISK_PERM_USER_WRITE | GNUNET_DISK_PERM_USER_READ);
|
||||||
if (nwrite != sizeof (struct TALER_MINT_SignKeyIssue))
|
if (nwrite != sizeof (struct TALER_MintSigningKeyValidityPS))
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"Failed to write to file `%s': %s\n",
|
"Failed to write to file `%s': %s\n",
|
||||||
@ -676,7 +676,7 @@ get_cointype_params (const char *ct,
|
|||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
create_denomkey_issue (const struct CoinTypeParams *params,
|
create_denomkey_issue (const struct CoinTypeParams *params,
|
||||||
struct TALER_MINT_DenomKeyIssuePriv *dki)
|
struct TALER_DenominationKeyIssueInformation *dki)
|
||||||
{
|
{
|
||||||
dki->denom_priv.rsa_private_key
|
dki->denom_priv.rsa_private_key
|
||||||
= GNUNET_CRYPTO_rsa_private_key_create (params->rsa_keysize);
|
= GNUNET_CRYPTO_rsa_private_key_create (params->rsa_keysize);
|
||||||
@ -685,7 +685,7 @@ create_denomkey_issue (const struct CoinTypeParams *params,
|
|||||||
= GNUNET_CRYPTO_rsa_private_key_get_public (dki->denom_priv.rsa_private_key);
|
= GNUNET_CRYPTO_rsa_private_key_get_public (dki->denom_priv.rsa_private_key);
|
||||||
GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key,
|
GNUNET_CRYPTO_rsa_public_key_hash (dki->denom_pub.rsa_public_key,
|
||||||
&dki->issue.denom_hash);
|
&dki->issue.denom_hash);
|
||||||
dki->issue.master = master_pub;
|
dki->issue.master = master_public_key;
|
||||||
dki->issue.start = GNUNET_TIME_absolute_hton (params->anchor);
|
dki->issue.start = GNUNET_TIME_absolute_hton (params->anchor);
|
||||||
dki->issue.expire_withdraw =
|
dki->issue.expire_withdraw =
|
||||||
GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (params->anchor,
|
GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (params->anchor,
|
||||||
@ -701,9 +701,9 @@ create_denomkey_issue (const struct CoinTypeParams *params,
|
|||||||
¶ms->fee_deposit);
|
¶ms->fee_deposit);
|
||||||
TALER_amount_hton (&dki->issue.fee_refresh,
|
TALER_amount_hton (&dki->issue.fee_refresh,
|
||||||
¶ms->fee_refresh);
|
¶ms->fee_refresh);
|
||||||
dki->issue.purpose.purpose = htonl (TALER_SIGNATURE_MASTER_DENOM);
|
dki->issue.purpose.purpose = htonl (TALER_SIGNATURE_MINT_DENOMINATION_KEY_VALIDITY);
|
||||||
dki->issue.purpose.size = htonl (sizeof (struct TALER_MINT_DenomKeyIssuePriv) -
|
dki->issue.purpose.size = htonl (sizeof (struct TALER_DenominationKeyIssueInformation) -
|
||||||
offsetof (struct TALER_MINT_DenomKeyIssuePriv,
|
offsetof (struct TALER_DenominationKeyIssueInformation,
|
||||||
issue.purpose));
|
issue.purpose));
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
GNUNET_CRYPTO_eddsa_sign (&master_priv.eddsa_priv,
|
GNUNET_CRYPTO_eddsa_sign (&master_priv.eddsa_priv,
|
||||||
@ -726,7 +726,7 @@ mint_keys_update_cointype (void *cls,
|
|||||||
int *ret = cls;
|
int *ret = cls;
|
||||||
struct CoinTypeParams p;
|
struct CoinTypeParams p;
|
||||||
const char *dkf;
|
const char *dkf;
|
||||||
struct TALER_MINT_DenomKeyIssuePriv denomkey_issue;
|
struct TALER_DenominationKeyIssueInformation denomkey_issue;
|
||||||
|
|
||||||
if (0 != strncasecmp (coin_alias,
|
if (0 != strncasecmp (coin_alias,
|
||||||
"coin_",
|
"coin_",
|
||||||
@ -820,7 +820,7 @@ main (int argc,
|
|||||||
&GNUNET_GETOPT_set_filename, &masterkeyfile},
|
&GNUNET_GETOPT_set_filename, &masterkeyfile},
|
||||||
{'d', "mint-dir", "DIR",
|
{'d', "mint-dir", "DIR",
|
||||||
"mint directory with keys to update", 1,
|
"mint directory with keys to update", 1,
|
||||||
&GNUNET_GETOPT_set_filename, &mintdir},
|
&GNUNET_GETOPT_set_filename, &mint_directory},
|
||||||
{'t', "time", "TIMESTAMP",
|
{'t', "time", "TIMESTAMP",
|
||||||
"pretend it is a different time for the update", 0,
|
"pretend it is a different time for the update", 0,
|
||||||
&GNUNET_GETOPT_set_string, &pretend_time_str},
|
&GNUNET_GETOPT_set_string, &pretend_time_str},
|
||||||
@ -838,7 +838,7 @@ main (int argc,
|
|||||||
options,
|
options,
|
||||||
argc, argv) < 0)
|
argc, argv) < 0)
|
||||||
return 1;
|
return 1;
|
||||||
if (NULL == mintdir)
|
if (NULL == mint_directory)
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"Mint directory not given\n");
|
"Mint directory not given\n");
|
||||||
@ -862,7 +862,7 @@ main (int argc,
|
|||||||
}
|
}
|
||||||
ROUND_TO_SECS (now, abs_value_us);
|
ROUND_TO_SECS (now, abs_value_us);
|
||||||
|
|
||||||
kcfg = TALER_config_load (mintdir);
|
kcfg = TALER_config_load (mint_directory);
|
||||||
if (NULL == kcfg)
|
if (NULL == kcfg)
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
@ -886,32 +886,32 @@ main (int argc,
|
|||||||
master_priv.eddsa_priv = *eddsa_priv;
|
master_priv.eddsa_priv = *eddsa_priv;
|
||||||
GNUNET_free (eddsa_priv);
|
GNUNET_free (eddsa_priv);
|
||||||
GNUNET_CRYPTO_eddsa_key_get_public (&master_priv.eddsa_priv,
|
GNUNET_CRYPTO_eddsa_key_get_public (&master_priv.eddsa_priv,
|
||||||
&master_pub.eddsa_pub);
|
&master_public_key.eddsa_pub);
|
||||||
|
|
||||||
/* check if key from file matches the one from the configuration */
|
/* check if key from file matches the one from the configuration */
|
||||||
{
|
{
|
||||||
struct GNUNET_CRYPTO_EddsaPublicKey master_pub_from_cfg;
|
struct GNUNET_CRYPTO_EddsaPublicKey master_public_key_from_cfg;
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CONFIGURATION_get_data (kcfg,
|
GNUNET_CONFIGURATION_get_data (kcfg,
|
||||||
"mint",
|
"mint",
|
||||||
"master_pub",
|
"master_public_key",
|
||||||
&master_pub_from_cfg,
|
&master_public_key_from_cfg,
|
||||||
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)))
|
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)))
|
||||||
{
|
{
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"mint",
|
"mint",
|
||||||
"master_pub");
|
"master_public_key");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (0 !=
|
if (0 !=
|
||||||
memcmp (&master_pub,
|
memcmp (&master_public_key,
|
||||||
&master_pub_from_cfg,
|
&master_public_key_from_cfg,
|
||||||
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)))
|
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)))
|
||||||
{
|
{
|
||||||
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"mint",
|
"mint",
|
||||||
"master_pub",
|
"master_public_key",
|
||||||
_("does not match with private key"));
|
_("does not match with private key"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,13 @@
|
|||||||
#include "taler_util.h"
|
#include "taler_util.h"
|
||||||
#include "taler_signatures.h"
|
#include "taler_signatures.h"
|
||||||
#include "taler_mintdb_plugin.h"
|
#include "taler_mintdb_plugin.h"
|
||||||
#include "db_pq.h"
|
#include "taler_pq_lib.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Director of the mint, containing the keys.
|
* Director of the mint, containing the keys.
|
||||||
*/
|
*/
|
||||||
static char *mintdir;
|
static char *mint_directory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public key of the reserve to manipulate.
|
* Public key of the reserve to manipulate.
|
||||||
@ -156,7 +156,7 @@ reservemod_add (struct TALER_Amount denom)
|
|||||||
};
|
};
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_DB_extract_amount (result, 0,
|
TALER_PQ_extract_amount (result, 0,
|
||||||
"balance_value",
|
"balance_value",
|
||||||
"balance_fraction",
|
"balance_fraction",
|
||||||
"balance_currency",
|
"balance_currency",
|
||||||
@ -214,7 +214,7 @@ main (int argc, char *const *argv)
|
|||||||
GNUNET_GETOPT_OPTION_HELP ("gnunet-mint-reservemod OPTIONS"),
|
GNUNET_GETOPT_OPTION_HELP ("gnunet-mint-reservemod OPTIONS"),
|
||||||
{'d', "mint-dir", "DIR",
|
{'d', "mint-dir", "DIR",
|
||||||
"mint directory with keys to update", 1,
|
"mint directory with keys to update", 1,
|
||||||
&GNUNET_GETOPT_set_filename, &mintdir},
|
&GNUNET_GETOPT_set_filename, &mint_directory},
|
||||||
{'R', "reserve", "KEY",
|
{'R', "reserve", "KEY",
|
||||||
"reserve (public key) to modify", 1,
|
"reserve (public key) to modify", 1,
|
||||||
&GNUNET_GETOPT_set_string, &reserve_pub_str},
|
&GNUNET_GETOPT_set_string, &reserve_pub_str},
|
||||||
@ -223,7 +223,7 @@ main (int argc, char *const *argv)
|
|||||||
&GNUNET_GETOPT_set_string, &add_str},
|
&GNUNET_GETOPT_set_string, &add_str},
|
||||||
GNUNET_GETOPT_OPTION_END
|
GNUNET_GETOPT_OPTION_END
|
||||||
};
|
};
|
||||||
char *TALER_MINT_db_connection_cfg_str;
|
char *connection_cfg_str;
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
GNUNET_log_setup ("taler-mint-reservemod",
|
GNUNET_log_setup ("taler-mint-reservemod",
|
||||||
@ -234,7 +234,7 @@ main (int argc, char *const *argv)
|
|||||||
options,
|
options,
|
||||||
argc, argv) < 0)
|
argc, argv) < 0)
|
||||||
return 1;
|
return 1;
|
||||||
if (NULL == mintdir)
|
if (NULL == mint_directory)
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"Mint directory not given\n");
|
"Mint directory not given\n");
|
||||||
@ -253,7 +253,7 @@ main (int argc, char *const *argv)
|
|||||||
"Parsing reserve key invalid\n");
|
"Parsing reserve key invalid\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
cfg = TALER_config_load (mintdir);
|
cfg = TALER_config_load (mint_directory);
|
||||||
if (NULL == cfg)
|
if (NULL == cfg)
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
@ -264,13 +264,13 @@ main (int argc, char *const *argv)
|
|||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
GNUNET_CONFIGURATION_get_value_string (cfg,
|
||||||
"mint",
|
"mint",
|
||||||
"db",
|
"db",
|
||||||
&TALER_MINT_db_connection_cfg_str))
|
&connection_cfg_str))
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"Database configuration string not found\n");
|
"Database configuration string not found\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
db_conn = PQconnectdb (TALER_MINT_db_connection_cfg_str);
|
db_conn = PQconnectdb (connection_cfg_str);
|
||||||
if (CONNECTION_OK != PQstatus (db_conn))
|
if (CONNECTION_OK != PQstatus (db_conn))
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
|
@ -36,10 +36,10 @@ int
|
|||||||
main (int argc,
|
main (int argc,
|
||||||
const char *const argv[])
|
const char *const argv[])
|
||||||
{
|
{
|
||||||
struct TALER_MINT_DenomKeyIssuePriv dki;
|
struct TALER_DenominationKeyIssueInformation dki;
|
||||||
char *enc;
|
char *enc;
|
||||||
size_t enc_size;
|
size_t enc_size;
|
||||||
struct TALER_MINT_DenomKeyIssuePriv dki_read;
|
struct TALER_DenominationKeyIssueInformation dki_read;
|
||||||
char *enc_read;
|
char *enc_read;
|
||||||
size_t enc_read_size;
|
size_t enc_read_size;
|
||||||
char *tmpfile;
|
char *tmpfile;
|
||||||
@ -53,7 +53,7 @@ main (int argc,
|
|||||||
dki_read.denom_priv.rsa_private_key = NULL;
|
dki_read.denom_priv.rsa_private_key = NULL;
|
||||||
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
|
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
|
||||||
&dki.issue.signature,
|
&dki.issue.signature,
|
||||||
sizeof (dki) - offsetof (struct TALER_MINT_DenomKeyIssue,
|
sizeof (dki) - offsetof (struct TALER_DenominationKeyValidityPS,
|
||||||
signature));
|
signature));
|
||||||
dki.denom_priv.rsa_private_key
|
dki.denom_priv.rsa_private_key
|
||||||
= GNUNET_CRYPTO_rsa_private_key_create (RSA_KEY_SIZE);
|
= GNUNET_CRYPTO_rsa_private_key_create (RSA_KEY_SIZE);
|
||||||
|
@ -54,7 +54,7 @@ static int result;
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
check_reserve (struct TALER_MINTDB_Session *session,
|
check_reserve (struct TALER_MINTDB_Session *session,
|
||||||
const struct TALER_ReservePublicKey *pub,
|
const struct TALER_ReservePublicKeyP *pub,
|
||||||
uint64_t value,
|
uint64_t value,
|
||||||
uint32_t fraction,
|
uint32_t fraction,
|
||||||
const char *currency,
|
const char *currency,
|
||||||
@ -123,7 +123,7 @@ run (void *cls,
|
|||||||
const struct GNUNET_CONFIGURATION_Handle *cfg)
|
const struct GNUNET_CONFIGURATION_Handle *cfg)
|
||||||
{
|
{
|
||||||
struct TALER_MINTDB_Session *session;
|
struct TALER_MINTDB_Session *session;
|
||||||
struct TALER_ReservePublicKey reserve_pub;
|
struct TALER_ReservePublicKeyP reserve_pub;
|
||||||
struct Reserve reserve;
|
struct Reserve reserve;
|
||||||
struct GNUNET_TIME_Absolute expiry;
|
struct GNUNET_TIME_Absolute expiry;
|
||||||
struct TALER_Amount amount;
|
struct TALER_Amount amount;
|
||||||
@ -355,7 +355,7 @@ main (int argc,
|
|||||||
static const struct GNUNET_GETOPT_CommandLineOption options[] = {
|
static const struct GNUNET_GETOPT_CommandLineOption options[] = {
|
||||||
GNUNET_GETOPT_OPTION_END
|
GNUNET_GETOPT_OPTION_END
|
||||||
};
|
};
|
||||||
const char *argv2[] = {
|
char *argv2[] = {
|
||||||
"test-mint-db-<plugin_name>", /* will be replaced later */
|
"test-mint-db-<plugin_name>", /* will be replaced later */
|
||||||
"-c", "test-mint-db-<plugin_name>.conf", /* will be replaced later */
|
"-c", "test-mint-db-<plugin_name>.conf", /* will be replaced later */
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include <libpq-fe.h>
|
#include <libpq-fe.h>
|
||||||
#include <gnunet/gnunet_util_lib.h>
|
#include <gnunet/gnunet_util_lib.h>
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
#include "db_pq.h"
|
#include "taler_pq_lib.h"
|
||||||
#include "taler-mint-httpd.h"
|
#include "taler-mint-httpd.h"
|
||||||
|
|
||||||
#define DB_URI "postgres:///taler"
|
#define DB_URI "postgres:///taler"
|
||||||
@ -98,8 +98,8 @@ run (void *cls,
|
|||||||
htonl (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX));
|
htonl (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX));
|
||||||
deposit->amount_with_fee.fraction =
|
deposit->amount_with_fee.fraction =
|
||||||
htonl (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX));
|
htonl (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX));
|
||||||
GNUNET_assert (strlen (MINT_CURRENCY) < sizeof (deposit->amount_with_fee.currency));
|
GNUNET_assert (strlen (TMH_MINT_CURRENCY) < sizeof (deposit->amount_with_fee.currency));
|
||||||
strcpy (deposit->amount_with_fee.currency, MINT_CURRENCY);
|
strcpy (deposit->amount_with_fee.currency, TMH_MINT_CURRENCY);
|
||||||
/* Copy wireformat */
|
/* Copy wireformat */
|
||||||
deposit->wire = json_loads (wire, 0, NULL);
|
deposit->wire = json_loads (wire, 0, NULL);
|
||||||
EXITIF (GNUNET_OK !=
|
EXITIF (GNUNET_OK !=
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[mint]
|
[mint]
|
||||||
db = postgres:///taler
|
db = postgres:///taler
|
||||||
port = 4241
|
port = 4241
|
||||||
master_pub = 6ZE0HEY2M0FWP61M0470HYBF4K6RRD5DP54372PD2TN9N9VX2VJG
|
TMH_master_public_key = 6ZE0HEY2M0FWP61M0470HYBF4K6RRD5DP54372PD2TN9N9VX2VJG
|
||||||
refresh_security_parameter = 3
|
refresh_security_parameter = 3
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[mint]
|
[mint]
|
||||||
db = postgres:///taler
|
db = postgres:///taler
|
||||||
port = 4241
|
port = 4241
|
||||||
master_pub = 7995WKK71KPKTBBMA5BHNBSZFGNRZPYNXDJMQ8EK86V9598H03TG
|
TMH_master_public_key = 7995WKK71KPKTBBMA5BHNBSZFGNRZPYNXDJMQ8EK86V9598H03TG
|
||||||
refresh_security_parameter = 3
|
refresh_security_parameter = 3
|
||||||
|
|
||||||
|
@ -3,14 +3,11 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/include $(LIBGCRYPT_CFLAGS) $(POSTGRESQL_CPPFL
|
|||||||
|
|
||||||
talerincludedir = $(includedir)/taler
|
talerincludedir = $(includedir)/taler
|
||||||
|
|
||||||
talerinclude_HEADERS = \
|
|
||||||
db_pq.h
|
|
||||||
|
|
||||||
lib_LTLIBRARIES = \
|
lib_LTLIBRARIES = \
|
||||||
libtalerpq.la
|
libtalerpq.la
|
||||||
|
|
||||||
libtalerpq_la_SOURCES = \
|
libtalerpq_la_SOURCES = \
|
||||||
db_pq.c db_pq.h
|
db_pq.c
|
||||||
|
|
||||||
libtalerpq_la_LIBADD = \
|
libtalerpq_la_LIBADD = \
|
||||||
-lgnunetutil \
|
-lgnunetutil \
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
|
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @file util/db_pq.c
|
* @file pq/db_pq.c
|
||||||
* @brief helper functions for libpq (PostGres) interactions
|
* @brief helper functions for libpq (PostGres) interactions
|
||||||
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
|
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
|
||||||
* @author Florian Dold
|
* @author Florian Dold
|
||||||
@ -22,23 +22,23 @@
|
|||||||
*/
|
*/
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include <gnunet/gnunet_util_lib.h>
|
#include <gnunet/gnunet_util_lib.h>
|
||||||
#include "db_pq.h"
|
#include "taler_pq_lib.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute a prepared statement.
|
* Execute a prepared statement.
|
||||||
*/
|
*/
|
||||||
PGresult *
|
PGresult *
|
||||||
TALER_DB_exec_prepared (PGconn *db_conn,
|
TALER_PQ_exec_prepared (PGconn *db_conn,
|
||||||
const char *name,
|
const char *name,
|
||||||
const struct TALER_DB_QueryParam *params)
|
const struct TALER_PQ_QueryParam *params)
|
||||||
{
|
{
|
||||||
unsigned len;
|
unsigned len;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
/* count the number of parameters */
|
/* count the number of parameters */
|
||||||
{
|
{
|
||||||
const struct TALER_DB_QueryParam *x;
|
const struct TALER_PQ_QueryParam *x;
|
||||||
for (len = 0, x = params;
|
for (len = 0, x = params;
|
||||||
x->more;
|
x->more;
|
||||||
len++, x++);
|
len++, x++);
|
||||||
@ -76,8 +76,8 @@ TALER_DB_exec_prepared (PGconn *db_conn,
|
|||||||
* #GNUNET_SYSERR if a result was invalid (non-existing field)
|
* #GNUNET_SYSERR if a result was invalid (non-existing field)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_DB_extract_result (PGresult *result,
|
TALER_PQ_extract_result (PGresult *result,
|
||||||
struct TALER_DB_ResultSpec *rs,
|
struct TALER_PQ_ResultSpec *rs,
|
||||||
int row)
|
int row)
|
||||||
{
|
{
|
||||||
int had_null = GNUNET_NO;
|
int had_null = GNUNET_NO;
|
||||||
@ -141,7 +141,7 @@ TALER_DB_extract_result (PGresult *result,
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
TALER_DB_field_isnull (PGresult *result,
|
TALER_PQ_field_isnull (PGresult *result,
|
||||||
int row,
|
int row,
|
||||||
const char *fname)
|
const char *fname)
|
||||||
{
|
{
|
||||||
@ -156,7 +156,7 @@ TALER_DB_field_isnull (PGresult *result,
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
TALER_DB_extract_amount_nbo (PGresult *result,
|
TALER_PQ_extract_amount_nbo (PGresult *result,
|
||||||
int row,
|
int row,
|
||||||
const char *val_name,
|
const char *val_name,
|
||||||
const char *frac_name,
|
const char *frac_name,
|
||||||
@ -196,7 +196,7 @@ TALER_DB_extract_amount_nbo (PGresult *result,
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
TALER_DB_extract_amount (PGresult *result,
|
TALER_PQ_extract_amount (PGresult *result,
|
||||||
int row,
|
int row,
|
||||||
const char *val_name,
|
const char *val_name,
|
||||||
const char *frac_name,
|
const char *frac_name,
|
||||||
@ -206,7 +206,7 @@ TALER_DB_extract_amount (PGresult *result,
|
|||||||
struct TALER_AmountNBO amount_nbo;
|
struct TALER_AmountNBO amount_nbo;
|
||||||
|
|
||||||
(void)
|
(void)
|
||||||
TALER_DB_extract_amount_nbo (result,
|
TALER_PQ_extract_amount_nbo (result,
|
||||||
row,
|
row,
|
||||||
val_name,
|
val_name,
|
||||||
frac_name,
|
frac_name,
|
||||||
|
@ -40,7 +40,7 @@ fatal_error_handler (void *cls,
|
|||||||
int wtf,
|
int wtf,
|
||||||
const char *msg)
|
const char *msg)
|
||||||
{
|
{
|
||||||
LOG_ERROR ("Fatal error in libgcrypt: %s\n",
|
TALER_LOG_ERROR ("Fatal error in libgcrypt: %s\n",
|
||||||
msg);
|
msg);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ TALER_gcrypt_init ()
|
|||||||
* @param[out] skey set to session key
|
* @param[out] skey set to session key
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
derive_refresh_key (const struct TALER_LinkSecret *secret,
|
derive_refresh_key (const struct TALER_LinkSecretP *secret,
|
||||||
struct GNUNET_CRYPTO_SymmetricInitializationVector *iv,
|
struct GNUNET_CRYPTO_SymmetricInitializationVector *iv,
|
||||||
struct GNUNET_CRYPTO_SymmetricSessionKey *skey)
|
struct GNUNET_CRYPTO_SymmetricSessionKey *skey)
|
||||||
{
|
{
|
||||||
@ -81,12 +81,12 @@ derive_refresh_key (const struct TALER_LinkSecret *secret,
|
|||||||
GNUNET_assert (GNUNET_YES ==
|
GNUNET_assert (GNUNET_YES ==
|
||||||
GNUNET_CRYPTO_kdf (skey, sizeof (struct GNUNET_CRYPTO_SymmetricSessionKey),
|
GNUNET_CRYPTO_kdf (skey, sizeof (struct GNUNET_CRYPTO_SymmetricSessionKey),
|
||||||
ctx_key, strlen (ctx_key),
|
ctx_key, strlen (ctx_key),
|
||||||
secret, sizeof (struct TALER_LinkSecret),
|
secret, sizeof (struct TALER_LinkSecretP),
|
||||||
NULL, 0));
|
NULL, 0));
|
||||||
GNUNET_assert (GNUNET_YES ==
|
GNUNET_assert (GNUNET_YES ==
|
||||||
GNUNET_CRYPTO_kdf (iv, sizeof (struct GNUNET_CRYPTO_SymmetricInitializationVector),
|
GNUNET_CRYPTO_kdf (iv, sizeof (struct GNUNET_CRYPTO_SymmetricInitializationVector),
|
||||||
ctx_iv, strlen (ctx_iv),
|
ctx_iv, strlen (ctx_iv),
|
||||||
secret, sizeof (struct TALER_LinkSecret),
|
secret, sizeof (struct TALER_LinkSecretP),
|
||||||
NULL, 0));
|
NULL, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ derive_refresh_key (const struct TALER_LinkSecret *secret,
|
|||||||
* @param[out] skey set to session key
|
* @param[out] skey set to session key
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
derive_transfer_key (const struct TALER_TransferSecret *secret,
|
derive_transfer_key (const struct TALER_TransferSecretP *secret,
|
||||||
struct GNUNET_CRYPTO_SymmetricInitializationVector *iv,
|
struct GNUNET_CRYPTO_SymmetricInitializationVector *iv,
|
||||||
struct GNUNET_CRYPTO_SymmetricSessionKey *skey)
|
struct GNUNET_CRYPTO_SymmetricSessionKey *skey)
|
||||||
{
|
{
|
||||||
@ -110,12 +110,12 @@ derive_transfer_key (const struct TALER_TransferSecret *secret,
|
|||||||
GNUNET_assert (GNUNET_YES ==
|
GNUNET_assert (GNUNET_YES ==
|
||||||
GNUNET_CRYPTO_kdf (skey, sizeof (struct GNUNET_CRYPTO_SymmetricSessionKey),
|
GNUNET_CRYPTO_kdf (skey, sizeof (struct GNUNET_CRYPTO_SymmetricSessionKey),
|
||||||
ctx_key, strlen (ctx_key),
|
ctx_key, strlen (ctx_key),
|
||||||
secret, sizeof (struct TALER_TransferSecret),
|
secret, sizeof (struct TALER_TransferSecretP),
|
||||||
NULL, 0));
|
NULL, 0));
|
||||||
GNUNET_assert (GNUNET_YES ==
|
GNUNET_assert (GNUNET_YES ==
|
||||||
GNUNET_CRYPTO_kdf (iv, sizeof (struct GNUNET_CRYPTO_SymmetricInitializationVector),
|
GNUNET_CRYPTO_kdf (iv, sizeof (struct GNUNET_CRYPTO_SymmetricInitializationVector),
|
||||||
ctx_iv, strlen (ctx_iv),
|
ctx_iv, strlen (ctx_iv),
|
||||||
secret, sizeof (struct TALER_TransferSecret),
|
secret, sizeof (struct TALER_TransferSecretP),
|
||||||
NULL, 0));
|
NULL, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,18 +130,18 @@ derive_transfer_key (const struct TALER_TransferSecret *secret,
|
|||||||
* @return #GNUNET_OK on success
|
* @return #GNUNET_OK on success
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_transfer_decrypt (const struct TALER_EncryptedLinkSecret *secret_enc,
|
TALER_transfer_decrypt (const struct TALER_EncryptedLinkSecretP *secret_enc,
|
||||||
const struct TALER_TransferSecret *trans_sec,
|
const struct TALER_TransferSecretP *trans_sec,
|
||||||
struct TALER_LinkSecret *secret)
|
struct TALER_LinkSecretP *secret)
|
||||||
{
|
{
|
||||||
struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
|
struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
|
||||||
struct GNUNET_CRYPTO_SymmetricSessionKey skey;
|
struct GNUNET_CRYPTO_SymmetricSessionKey skey;
|
||||||
|
|
||||||
GNUNET_assert (sizeof (struct TALER_EncryptedLinkSecret) ==
|
GNUNET_assert (sizeof (struct TALER_EncryptedLinkSecretP) ==
|
||||||
sizeof (struct TALER_LinkSecret));
|
sizeof (struct TALER_LinkSecretP));
|
||||||
derive_transfer_key (trans_sec, &iv, &skey);
|
derive_transfer_key (trans_sec, &iv, &skey);
|
||||||
return GNUNET_CRYPTO_symmetric_decrypt (secret_enc,
|
return GNUNET_CRYPTO_symmetric_decrypt (secret_enc,
|
||||||
sizeof (struct TALER_LinkSecret),
|
sizeof (struct TALER_LinkSecretP),
|
||||||
&skey,
|
&skey,
|
||||||
&iv,
|
&iv,
|
||||||
secret);
|
secret);
|
||||||
@ -158,18 +158,18 @@ TALER_transfer_decrypt (const struct TALER_EncryptedLinkSecret *secret_enc,
|
|||||||
* @return #GNUNET_OK on success
|
* @return #GNUNET_OK on success
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_transfer_encrypt (const struct TALER_LinkSecret *secret,
|
TALER_transfer_encrypt (const struct TALER_LinkSecretP *secret,
|
||||||
const struct TALER_TransferSecret *trans_sec,
|
const struct TALER_TransferSecretP *trans_sec,
|
||||||
struct TALER_EncryptedLinkSecret *secret_enc)
|
struct TALER_EncryptedLinkSecretP *secret_enc)
|
||||||
{
|
{
|
||||||
struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
|
struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
|
||||||
struct GNUNET_CRYPTO_SymmetricSessionKey skey;
|
struct GNUNET_CRYPTO_SymmetricSessionKey skey;
|
||||||
|
|
||||||
GNUNET_assert (sizeof (struct TALER_EncryptedLinkSecret) ==
|
GNUNET_assert (sizeof (struct TALER_EncryptedLinkSecretP) ==
|
||||||
sizeof (struct TALER_LinkSecret));
|
sizeof (struct TALER_LinkSecretP));
|
||||||
derive_transfer_key (trans_sec, &iv, &skey);
|
derive_transfer_key (trans_sec, &iv, &skey);
|
||||||
return GNUNET_CRYPTO_symmetric_encrypt (secret,
|
return GNUNET_CRYPTO_symmetric_encrypt (secret,
|
||||||
sizeof (struct TALER_LinkSecret),
|
sizeof (struct TALER_LinkSecretP),
|
||||||
&skey,
|
&skey,
|
||||||
&iv,
|
&iv,
|
||||||
secret_enc);
|
secret_enc);
|
||||||
@ -183,11 +183,11 @@ TALER_transfer_encrypt (const struct TALER_LinkSecret *secret,
|
|||||||
* @param secret shared secret to use for decryption
|
* @param secret shared secret to use for decryption
|
||||||
* @return NULL on error
|
* @return NULL on error
|
||||||
*/
|
*/
|
||||||
struct TALER_RefreshLinkDecrypted *
|
struct TALER_RefreshLinkDecryptedP *
|
||||||
TALER_refresh_decrypt (const struct TALER_RefreshLinkEncrypted *input,
|
TALER_refresh_decrypt (const struct TALER_RefreshLinkEncrypted *input,
|
||||||
const struct TALER_LinkSecret *secret)
|
const struct TALER_LinkSecretP *secret)
|
||||||
{
|
{
|
||||||
struct TALER_RefreshLinkDecrypted *ret;
|
struct TALER_RefreshLinkDecryptedP *ret;
|
||||||
struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
|
struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
|
||||||
struct GNUNET_CRYPTO_SymmetricSessionKey skey;
|
struct GNUNET_CRYPTO_SymmetricSessionKey skey;
|
||||||
size_t buf_size = input->blinding_key_enc_size
|
size_t buf_size = input->blinding_key_enc_size
|
||||||
@ -203,10 +203,10 @@ TALER_refresh_decrypt (const struct TALER_RefreshLinkEncrypted *input,
|
|||||||
&iv,
|
&iv,
|
||||||
buf))
|
buf))
|
||||||
return NULL;
|
return NULL;
|
||||||
ret = GNUNET_new (struct TALER_RefreshLinkDecrypted);
|
ret = GNUNET_new (struct TALER_RefreshLinkDecryptedP);
|
||||||
memcpy (&ret->coin_priv,
|
memcpy (&ret->coin_priv,
|
||||||
buf,
|
buf,
|
||||||
sizeof (struct TALER_CoinSpendPrivateKey));
|
sizeof (union TALER_CoinSpendPrivateKeyP));
|
||||||
ret->blinding_key.rsa_blinding_key
|
ret->blinding_key.rsa_blinding_key
|
||||||
= GNUNET_CRYPTO_rsa_blinding_key_decode (&buf[sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)],
|
= GNUNET_CRYPTO_rsa_blinding_key_decode (&buf[sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)],
|
||||||
input->blinding_key_enc_size);
|
input->blinding_key_enc_size);
|
||||||
@ -227,8 +227,8 @@ TALER_refresh_decrypt (const struct TALER_RefreshLinkEncrypted *input,
|
|||||||
* @return NULL on error (should never happen)
|
* @return NULL on error (should never happen)
|
||||||
*/
|
*/
|
||||||
struct TALER_RefreshLinkEncrypted *
|
struct TALER_RefreshLinkEncrypted *
|
||||||
TALER_refresh_encrypt (const struct TALER_RefreshLinkDecrypted *input,
|
TALER_refresh_encrypt (const struct TALER_RefreshLinkDecryptedP *input,
|
||||||
const struct TALER_LinkSecret *secret)
|
const struct TALER_LinkSecretP *secret)
|
||||||
{
|
{
|
||||||
char *b_buf;
|
char *b_buf;
|
||||||
size_t b_buf_size;
|
size_t b_buf_size;
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
*/
|
*/
|
||||||
#define UNPACK_EXITIF(cond) \
|
#define UNPACK_EXITIF(cond) \
|
||||||
do { \
|
do { \
|
||||||
if (cond) { TALER_JSON_warn (error); goto EXITIF_exit; } \
|
if (cond) { TALER_json_warn (error); goto EXITIF_exit; } \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
@ -48,7 +48,7 @@
|
|||||||
* @return a json object describing the amount
|
* @return a json object describing the amount
|
||||||
*/
|
*/
|
||||||
json_t *
|
json_t *
|
||||||
TALER_JSON_from_amount (const struct TALER_Amount *amount)
|
TALER_json_from_amount (const struct TALER_Amount *amount)
|
||||||
{
|
{
|
||||||
json_t *j;
|
json_t *j;
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ TALER_JSON_from_amount (const struct TALER_Amount *amount)
|
|||||||
* @return a json string with the timestamp in @a stamp
|
* @return a json string with the timestamp in @a stamp
|
||||||
*/
|
*/
|
||||||
json_t *
|
json_t *
|
||||||
TALER_JSON_from_abs (struct GNUNET_TIME_Absolute stamp)
|
TALER_json_from_abs (struct GNUNET_TIME_Absolute stamp)
|
||||||
{
|
{
|
||||||
json_t *j;
|
json_t *j;
|
||||||
char *mystr;
|
char *mystr;
|
||||||
@ -101,7 +101,7 @@ TALER_JSON_from_abs (struct GNUNET_TIME_Absolute stamp)
|
|||||||
* @return the JSON reporesentation of the signature with purpose
|
* @return the JSON reporesentation of the signature with purpose
|
||||||
*/
|
*/
|
||||||
json_t *
|
json_t *
|
||||||
TALER_JSON_from_eddsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
|
TALER_json_from_eddsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
|
||||||
const struct GNUNET_CRYPTO_EddsaSignature *signature)
|
const struct GNUNET_CRYPTO_EddsaSignature *signature)
|
||||||
{
|
{
|
||||||
json_t *root;
|
json_t *root;
|
||||||
@ -115,11 +115,11 @@ TALER_JSON_from_eddsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpo
|
|||||||
el = json_integer ((json_int_t) ntohl (purpose->purpose));
|
el = json_integer ((json_int_t) ntohl (purpose->purpose));
|
||||||
json_object_set_new (root, "purpose", el);
|
json_object_set_new (root, "purpose", el);
|
||||||
|
|
||||||
el = TALER_JSON_from_data (purpose,
|
el = TALER_json_from_data (purpose,
|
||||||
ntohl (purpose->size));
|
ntohl (purpose->size));
|
||||||
json_object_set_new (root, "eddsa-val", el);
|
json_object_set_new (root, "eddsa-val", el);
|
||||||
|
|
||||||
el = TALER_JSON_from_data (signature,
|
el = TALER_json_from_data (signature,
|
||||||
sizeof (struct GNUNET_CRYPTO_EddsaSignature));
|
sizeof (struct GNUNET_CRYPTO_EddsaSignature));
|
||||||
json_object_set_new (root, "eddsa-sig", el);
|
json_object_set_new (root, "eddsa-sig", el);
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ TALER_JSON_from_eddsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpo
|
|||||||
* @return the JSON reporesentation of the signature with purpose
|
* @return the JSON reporesentation of the signature with purpose
|
||||||
*/
|
*/
|
||||||
json_t *
|
json_t *
|
||||||
TALER_JSON_from_ecdsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
|
TALER_json_from_ecdsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
|
||||||
const struct GNUNET_CRYPTO_EcdsaSignature *signature)
|
const struct GNUNET_CRYPTO_EcdsaSignature *signature)
|
||||||
{
|
{
|
||||||
json_t *root;
|
json_t *root;
|
||||||
@ -149,11 +149,11 @@ TALER_JSON_from_ecdsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpo
|
|||||||
el = json_integer ((json_int_t) ntohl (purpose->purpose));
|
el = json_integer ((json_int_t) ntohl (purpose->purpose));
|
||||||
json_object_set_new (root, "purpose", el);
|
json_object_set_new (root, "purpose", el);
|
||||||
|
|
||||||
el = TALER_JSON_from_data (purpose,
|
el = TALER_json_from_data (purpose,
|
||||||
ntohl (purpose->size));
|
ntohl (purpose->size));
|
||||||
json_object_set_new (root, "ecdsa-val", el);
|
json_object_set_new (root, "ecdsa-val", el);
|
||||||
|
|
||||||
el = TALER_JSON_from_data (signature,
|
el = TALER_json_from_data (signature,
|
||||||
sizeof (struct GNUNET_CRYPTO_EddsaSignature));
|
sizeof (struct GNUNET_CRYPTO_EddsaSignature));
|
||||||
json_object_set_new (root, "ecdsa-sig", el);
|
json_object_set_new (root, "ecdsa-sig", el);
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ TALER_JSON_from_ecdsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpo
|
|||||||
* @return corresponding JSON encoding
|
* @return corresponding JSON encoding
|
||||||
*/
|
*/
|
||||||
json_t *
|
json_t *
|
||||||
TALER_JSON_from_rsa_public_key (struct GNUNET_CRYPTO_rsa_PublicKey *pk)
|
TALER_json_from_rsa_public_key (struct GNUNET_CRYPTO_rsa_PublicKey *pk)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
size_t buf_len;
|
size_t buf_len;
|
||||||
@ -176,7 +176,7 @@ TALER_JSON_from_rsa_public_key (struct GNUNET_CRYPTO_rsa_PublicKey *pk)
|
|||||||
|
|
||||||
buf_len = GNUNET_CRYPTO_rsa_public_key_encode (pk,
|
buf_len = GNUNET_CRYPTO_rsa_public_key_encode (pk,
|
||||||
&buf);
|
&buf);
|
||||||
ret = TALER_JSON_from_data (buf,
|
ret = TALER_json_from_data (buf,
|
||||||
buf_len);
|
buf_len);
|
||||||
GNUNET_free (buf);
|
GNUNET_free (buf);
|
||||||
return ret;
|
return ret;
|
||||||
@ -190,7 +190,7 @@ TALER_JSON_from_rsa_public_key (struct GNUNET_CRYPTO_rsa_PublicKey *pk)
|
|||||||
* @return corresponding JSON encoding
|
* @return corresponding JSON encoding
|
||||||
*/
|
*/
|
||||||
json_t *
|
json_t *
|
||||||
TALER_JSON_from_rsa_signature (struct GNUNET_CRYPTO_rsa_Signature *sig)
|
TALER_json_from_rsa_signature (struct GNUNET_CRYPTO_rsa_Signature *sig)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
size_t buf_len;
|
size_t buf_len;
|
||||||
@ -198,7 +198,7 @@ TALER_JSON_from_rsa_signature (struct GNUNET_CRYPTO_rsa_Signature *sig)
|
|||||||
|
|
||||||
buf_len = GNUNET_CRYPTO_rsa_signature_encode (sig,
|
buf_len = GNUNET_CRYPTO_rsa_signature_encode (sig,
|
||||||
&buf);
|
&buf);
|
||||||
ret = TALER_JSON_from_data (buf,
|
ret = TALER_json_from_data (buf,
|
||||||
buf_len);
|
buf_len);
|
||||||
GNUNET_free (buf);
|
GNUNET_free (buf);
|
||||||
return ret;
|
return ret;
|
||||||
@ -214,7 +214,7 @@ TALER_JSON_from_rsa_signature (struct GNUNET_CRYPTO_rsa_Signature *sig)
|
|||||||
* @return json string that encodes @a data
|
* @return json string that encodes @a data
|
||||||
*/
|
*/
|
||||||
json_t *
|
json_t *
|
||||||
TALER_JSON_from_data (const void *data, size_t size)
|
TALER_json_from_data (const void *data, size_t size)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
json_t *json;
|
json_t *json;
|
||||||
@ -234,9 +234,9 @@ TALER_JSON_from_data (const void *data, size_t size)
|
|||||||
* @return json string that encodes @a hc
|
* @return json string that encodes @a hc
|
||||||
*/
|
*/
|
||||||
json_t *
|
json_t *
|
||||||
TALER_JSON_from_hash (const struct GNUNET_HashCode *hc)
|
TALER_json_from_hash (const struct GNUNET_HashCode *hc)
|
||||||
{
|
{
|
||||||
return TALER_JSON_from_data (hc, sizeof (struct GNUNET_HashCode));
|
return TALER_json_from_data (hc, sizeof (struct GNUNET_HashCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -248,7 +248,7 @@ TALER_JSON_from_hash (const struct GNUNET_HashCode *hc)
|
|||||||
* @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
|
* @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_JSON_to_amount (json_t *json,
|
TALER_json_to_amount (json_t *json,
|
||||||
struct TALER_Amount *r_amount)
|
struct TALER_Amount *r_amount)
|
||||||
{
|
{
|
||||||
char *currency;
|
char *currency;
|
||||||
@ -279,7 +279,7 @@ TALER_JSON_to_amount (json_t *json,
|
|||||||
* @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
|
* @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_JSON_to_abs (json_t *json,
|
TALER_json_to_abs (json_t *json,
|
||||||
struct GNUNET_TIME_Absolute *abs)
|
struct GNUNET_TIME_Absolute *abs)
|
||||||
{
|
{
|
||||||
const char *str;
|
const char *str;
|
||||||
@ -304,7 +304,7 @@ TALER_JSON_to_abs (json_t *json,
|
|||||||
* @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
|
* @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_JSON_to_data (json_t *json,
|
TALER_json_to_data (json_t *json,
|
||||||
void *out,
|
void *out,
|
||||||
size_t out_size)
|
size_t out_size)
|
||||||
{
|
{
|
||||||
@ -563,7 +563,7 @@ validate_iban (const char *iban)
|
|||||||
* @return #GNUNET_YES if correctly formatted; #GNUNET_NO if not
|
* @return #GNUNET_YES if correctly formatted; #GNUNET_NO if not
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TALER_JSON_validate_wireformat (const char *type,
|
TALER_json_validate_wireformat (const char *type,
|
||||||
const json_t *wire)
|
const json_t *wire)
|
||||||
{
|
{
|
||||||
json_error_t error;
|
json_error_t error;
|
||||||
|
@ -454,7 +454,7 @@ os_get_exec_path ()
|
|||||||
* @return a pointer to the dir path (to be freed by the caller)
|
* @return a pointer to the dir path (to be freed by the caller)
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
TALER_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind)
|
TALER_os_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind)
|
||||||
{
|
{
|
||||||
size_t n;
|
size_t n;
|
||||||
const char *dirname;
|
const char *dirname;
|
||||||
|
@ -44,10 +44,10 @@ int main(int argc, const char *const argv[])
|
|||||||
wire = json_loads (json_wire_str, 0, &error);
|
wire = json_loads (json_wire_str, 0, &error);
|
||||||
if (NULL == wire)
|
if (NULL == wire)
|
||||||
{
|
{
|
||||||
TALER_JSON_warn (error);
|
TALER_json_warn (error);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
ret = TALER_JSON_validate_wireformat ("SEPA", wire);
|
ret = TALER_json_validate_wireformat ("SEPA", wire);
|
||||||
if (1 == ret)
|
if (1 == ret)
|
||||||
return 0;
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user