summaryrefslogtreecommitdiff
path: root/src/include/taler_exchangedb_plugin.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/taler_exchangedb_plugin.h')
-rw-r--r--src/include/taler_exchangedb_plugin.h161
1 files changed, 77 insertions, 84 deletions
diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h
index 5404f0b16..169359073 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -301,8 +301,7 @@ enum TALER_EXCHANGEDB_ReplicatedTable
TALER_EXCHANGEDB_RT_AML_HISTORY,
TALER_EXCHANGEDB_RT_KYC_ATTRIBUTES,
TALER_EXCHANGEDB_RT_PURSE_DELETION,
- TALER_EXCHANGEDB_RT_WITHDRAW_AGE_COMMITMENTS,
- TALER_EXCHANGEDB_RT_WITHDRAW_AGE_REVEALED_COINS,
+ TALER_EXCHANGEDB_RT_AGE_WITHDRAW,
};
@@ -773,22 +772,14 @@ struct TALER_EXCHANGEDB_TableData
struct TALER_AgeWithdrawCommitmentHashP h_commitment;
struct TALER_Amount amount_with_fee;
uint16_t max_age;
+ uint32_t noreveal_index;
struct TALER_ReservePublicKeyP reserve_pub;
struct TALER_ReserveSignatureP reserve_sig;
- uint32_t noreveal_index;
- struct GNUNET_TIME_Absolute timestamp;
- } age_withdraw_commitments;
-
- struct
- {
- struct TALER_AgeWithdrawCommitmentHashP h_commitment;
- uint32_t freshcoin_index;
- uint64_t denominations_serial;
- void *coin_ev;
- size_t coin_ev_size;
- // h_coin_ev omitted, to be recomputed!
- struct TALER_BlindedDenominationSignature ev_sig;
- } age_withdraw_revealed_coins;
+ uint64_t num_coins;
+ uint64_t *denominations_serials;
+ void *h_blind_evs;
+ struct TALER_BlindedDenominationSignature denom_sigs;
+ } age_withdraw;
} details;
@@ -949,6 +940,13 @@ struct TALER_EXCHANGEDB_Reserve
struct TALER_EXCHANGEDB_DenominationKeyMetaData
{
/**
+ * Serial of the denomination key as in the DB.
+ * Can be used in calls to stored procedures in order to spare
+ * additional lookups.
+ */
+ uint64_t serial;
+
+ /**
* Start time of the validity period for this key.
*/
struct GNUNET_TIME_Timestamp start;
@@ -1182,11 +1180,11 @@ struct TALER_EXCHANGEDB_CollectableBlindcoin
/**
- * @brief Information we keep for an age-withdraw commitment
+ * @brief Information we keep for an age-withdraw request
* to reproduce the /age-withdraw operation if needed, and to have proof
* that a reserve was drained by this amount.
*/
-struct TALER_EXCHANGEDB_AgeWithdrawCommitment
+struct TALER_EXCHANGEDB_AgeWithdraw
{
/**
* Total amount (with fee) committed to withdraw
@@ -1194,7 +1192,7 @@ struct TALER_EXCHANGEDB_AgeWithdrawCommitment
struct TALER_Amount amount_with_fee;
/**
- * Maximum age that the coins are restricted to.
+ * Maximum age (in years) that the coins are restricted to.
*/
uint16_t max_age;
@@ -1208,7 +1206,7 @@ struct TALER_EXCHANGEDB_AgeWithdrawCommitment
* revealed during cut and choose. This value applies to all n coins in the
* commitment.
*/
- uint32_t noreveal_index;
+ uint16_t noreveal_index;
/**
* Public key of the reserve that was drained.
@@ -1223,9 +1221,35 @@ struct TALER_EXCHANGEDB_AgeWithdrawCommitment
struct TALER_ReserveSignatureP reserve_sig;
/**
- * The exchange's signature of the response.
+ * Number of coins to be withdrawn.
*/
- struct TALER_ExchangeSignatureP sig;
+ size_t num_coins;
+
+ /**
+ * Array of @a num_coins blinded coins. These are the chosen coins
+ * (according to @a noreveal_index) from the request, which contained
+ * kappa*num_coins blinded coins.
+ */
+ struct TALER_BlindedCoinHashP *h_coin_evs;
+
+ /**
+ * Array of @a num_coins denomination signatures of the blinded coins @a
+ * h_coin_evs.
+ */
+ struct TALER_BlindedDenominationSignature *denom_sigs;
+
+ /**
+ * Array of @a num_coins serial id's of the denominations, corresponding to
+ * the coins in @a h_coin_evs.
+ */
+ uint64_t *denom_serials;
+
+ /**
+ * Array of @a num_coins hashes of the public keys of the denominations
+ * identified by @e denom_serials. This field is set when calling
+ * get_age_withdraw
+ */
+ struct TALER_DenominationHashP *denom_pub_hashes;
};
@@ -2751,28 +2775,6 @@ struct TALER_EXCHANGEDB_CsRevealFreshCoinData
uint32_t coin_off;
};
-/**
- * Information about a coin that was revealed to the exchange
- * during reveal.
- */
-struct TALER_EXCHANGEDB_AgeWithdrawRevealedCoin
-{
- /**
- * Hash of the public denomination key of the coin.
- */
- struct TALER_DenominationHashP h_denom_pub;
-
- /**
- * Signature generated by the exchange over the coin (in blinded format).
- */
- struct TALER_BlindedDenominationSignature coin_sig;
-
- /**
- * Blinded hash of the new coin
- */
- struct TALER_BlindedCoinHashP h_coin_ev;
-};
-
/**
* Generic KYC status for some operation.
@@ -3761,6 +3763,15 @@ struct TALER_EXCHANGEDB_Plugin
/**
+ * FIXME: merge do_batch_withdraw and do_batch_withdraw_insert into one API,
+ * which takes as input (among others)
+ * - denom_serial[]
+ * - blinded_coin_evs[]
+ * - denom_sigs[]
+ * The implementation should persist the data as _arrays_ in the DB.
+ */
+
+ /**
* Perform reserve update as part of a batch withdraw operation, checking
* for sufficient balance. Persisting the withdrawal details is done
* separately!
@@ -3769,8 +3780,11 @@ struct TALER_EXCHANGEDB_Plugin
* @param now current time (rounded)
* @param reserve_pub public key of the reserve to debit
* @param amount total amount to withdraw
+ * @param do_age_check if set, the batch-withdrawal can only succeed when the reserve has no age restriction (birthday) set.
* @param[out] found set to true if the reserve was found
* @param[out] balance_ok set to true if the balance was sufficient
+ * @param[out] age_ok set to true if no age requirements were defined on the reserve or @e do_age_check was false
+ * @param[out] allowed_maximum_age when @e age_ok is false, set to the allowed maximum age for withdrawal from the reserve. The client MUST then use the age-withdraw endpoint
* @param[out] ruuid set to the reserve's UUID (reserves table row)
* @return query execution status
*/
@@ -3780,8 +3794,11 @@ struct TALER_EXCHANGEDB_Plugin
struct GNUNET_TIME_Timestamp now,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_Amount *amount,
+ bool do_age_check,
bool *found,
bool *balance_ok,
+ bool *age_ok,
+ uint16_t *allowed_maximum_age,
uint64_t *ruuid);
@@ -3811,74 +3828,50 @@ struct TALER_EXCHANGEDB_Plugin
bool *nonce_reuse);
/**
- * Locate the response for a age-withdraw request under a hash that uniquely
- * identifies the age-withdraw operation. Used to ensure idempotency of the
- * request.
+ * Locate the response for a age-withdraw request under a hash of the
+ * commitment and reserve_pub that uniquely identifies the age-withdraw
+ * operation. Used to ensure idempotency of the request.
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param reserve_pub public key of the reserve for which the age-withdraw request is made
* @param ach hash that uniquely identifies the age-withdraw operation
- * @param[out] awc corresponding details of the previous age-withdraw request if an entry was found
+ * @param[out] aw corresponding details of the previous age-withdraw request if an entry was found
* @return statement execution status
*/
enum GNUNET_DB_QueryStatus
- (*get_age_withdraw_info)(
+ (*get_age_withdraw)(
void *cls,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_AgeWithdrawCommitmentHashP *ach,
- struct TALER_EXCHANGEDB_AgeWithdrawCommitment *awc);
+ struct TALER_EXCHANGEDB_AgeWithdraw *aw);
/**
- * Perform an age-withdraw operation, checking for sufficient balance
- * and possibly persisting the withdrawal details.
+ * Perform an age-withdraw operation, checking for sufficient balance and
+ * fulfillment of age requirements and possibly persisting the withdrawal
+ * details.
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
* @param commitment corresponding commitment for the age-withdraw
* @param[out] found set to true if the reserve was found
* @param[out] balance_ok set to true if the balance was sufficient
+ * @param[out] age_ok set to true if age requirements were met
+ * @param[out] allowed_maximum_age if @e age_ok is FALSE, this is set to the allowed maximum age
* @param[out] ruuid set to the reserve's UUID (reserves table row)
* @return query execution status
*/
enum GNUNET_DB_QueryStatus
(*do_age_withdraw)(
void *cls,
- const struct TALER_EXCHANGEDB_AgeWithdrawCommitment *commitment,
+ const struct TALER_EXCHANGEDB_AgeWithdraw *commitment,
+ struct GNUNET_TIME_Timestamp now,
bool *found,
bool *balance_ok,
+ bool *age_ok,
+ uint16_t *allowed_maximum_age,
+ bool *conflict,
uint64_t *ruuid);
/**
- * Store in the database which coin(s) the wallet wanted to withdraw with
- * age restriction enabled in a given age-withdraw operation and the relevant
- * information we learned or created in the reveal steop
- *
- * @param cls The `struct PostgresClosure` with the plugin-specific state
- * @param h_commitment The hash of the original age-withdraw commitment, which is a key into the age_withdraw_commitments table
- * @param num_awrcs Number of coins to generate, size of the @a coin_evs array
- * @param awrcs Array of @a num_awrcs information about coins to be created
- * @return query execution status
- */
- enum GNUNET_DB_QueryStatus
- (*insert_age_withdraw_reveal)(
- void *cls,
- const struct TALER_AgeWithdrawCommitmentHashP *h_commitment,
- uint32_t num_awrcs,
- const struct TALER_EXCHANGEDB_AgeWithdrawRevealedCoin *awrcs);
-
- /**
- * Lookup in the database for the fresh coins with age-restriction that
- * we created in the given age-withdraw operation.
- *
- * TODO: oec
- */
- enum GNUNET_DB_QueryStatus
- (*get_age_withdraw_reveal)(
- void *cls,
- uint64_t h_commitment
- /* TODO: oec */
- );
-
- /**
* Retrieve the details to a policy given by its hash_code
*
* @param cls the `struct PostgresClosure` with the plugin-specific state