summaryrefslogtreecommitdiff
path: root/src/include/taler_exchangedb_plugin.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-01-16 23:49:34 +0100
committerChristian Grothoff <christian@grothoff.org>2020-01-16 23:49:34 +0100
commitd61c2e400ac07574fc326c8d2be6f51be7c2a25c (patch)
tree277d9bf5ad2cd160a85d75992ae590e59dd28ac9 /src/include/taler_exchangedb_plugin.h
parent0305cf5f9eb904e7a3ab3e8d39f4974a92a9a0b3 (diff)
downloadexchange-d61c2e400ac07574fc326c8d2be6f51be7c2a25c.tar.gz
exchange-d61c2e400ac07574fc326c8d2be6f51be7c2a25c.tar.bz2
exchange-d61c2e400ac07574fc326c8d2be6f51be7c2a25c.zip
kill another FIXME
Diffstat (limited to 'src/include/taler_exchangedb_plugin.h')
-rw-r--r--src/include/taler_exchangedb_plugin.h235
1 files changed, 210 insertions, 25 deletions
diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h
index cb5d6cc68..3178209d0 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -275,7 +275,8 @@ struct TALER_EXCHANGEDB_CollectableBlindcoin
/**
- * Information the exchange records about a /payback request.
+ * Information the exchange records about a /payback request
+ * in a reserve history.
*/
struct TALER_EXCHANGEDB_Payback
{
@@ -316,13 +317,52 @@ struct TALER_EXCHANGEDB_Payback
/**
- * Information the exchange records about a /payback-refresh request.
+ * Information the exchange records about a /payback request
+ * in a coin history.
*/
-struct TALER_EXCHANGEDB_PaybackRefresh
+struct TALER_EXCHANGEDB_PaybackListEntry
{
/**
- * Information about the coin that was paid back.
+ * Blinding factor supplied to prove to the exchange that
+ * the coin came from this reserve.
+ */
+ struct TALER_DenominationBlindingKeyP coin_blind;
+
+ /**
+ * Signature of the coin of type
+ * #TALER_SIGNATURE_WALLET_COIN_PAYBACK.
+ */
+ struct TALER_CoinSpendSignatureP coin_sig;
+
+ /**
+ * Public key of the reserve the coin was paid back into.
+ */
+ struct TALER_ReservePublicKeyP reserve_pub;
+
+ /**
+ * How much was the coin still worth at this time?
+ */
+ struct TALER_Amount value;
+
+ /**
+ * When did the /payback operation happen?
+ */
+ struct GNUNET_TIME_Absolute timestamp;
+
+};
+
+
+/**
+ * Information the exchange records about a /payback-refresh request in
+ * a coin transaction history.
+ */
+struct TALER_EXCHANGEDB_PaybackRefreshListEntry
+{
+
+ /**
+ * Information about the coin that was paid back
+ * (NOT the coin we are considering the history of!)
*/
struct TALER_CoinPublicInfo coin;
@@ -534,22 +574,95 @@ struct TALER_EXCHANGEDB_Deposit
/**
- * @brief Specification for a /refund operation. The combination of
- * the coin's public key, the merchant's public key and the
- * transaction ID must be unique. While a coin can (theoretically) be
- * deposited at the same merchant twice (with partial spending), the
- * merchant must either use a different public key or a different
- * transaction ID for the two transactions. The same goes for
- * refunds, hence we also have a "rtransaction" ID which is disjoint
- * from the transaction ID. The same coin must not be used twice at
- * the same merchant for the same transaction or rtransaction ID.
+ * @brief Specification for a /deposit operation in the
+ * `struct TALER_EXCHANGEDB_TransactionList`.
*/
-struct TALER_EXCHANGEDB_Refund
+struct TALER_EXCHANGEDB_DepositListEntry
{
+
/**
- * Information about the coin that is being refunded.
+ * ECDSA signature affirming that the customer intends
+ * this coin to be deposited at the merchant identified
+ * by @e h_wire in relation to the proposal data identified
+ * by @e h_contract_terms.
*/
- struct TALER_CoinPublicInfo coin;
+ struct TALER_CoinSpendSignatureP csig;
+
+ /**
+ * Public key of the merchant. Enables later identification
+ * of the merchant in case of a need to rollback transactions.
+ */
+ struct TALER_MerchantPublicKeyP merchant_pub;
+
+ /**
+ * Hash over the proposa data between merchant and customer
+ * (remains unknown to the Exchange).
+ */
+ struct GNUNET_HashCode h_contract_terms;
+
+ /**
+ * Hash of the (canonical) representation of @e wire, used
+ * to check the signature on the request. Generated by
+ * the exchange from the detailed wire data provided by the
+ * merchant.
+ */
+ struct GNUNET_HashCode h_wire;
+
+ /**
+ * Detailed information about the receiver for executing the transaction.
+ * Includes URL in payto://-format and salt.
+ */
+ json_t *receiver_wire_account;
+
+ /**
+ * Time when this request was generated. Used, for example, to
+ * assess when (roughly) the income was achieved for tax purposes.
+ * Note that the Exchange will only check that the timestamp is not "too
+ * far" into the future (i.e. several days). The fact that the
+ * timestamp falls within the validity period of the coin's
+ * denomination key is irrelevant for the validity of the deposit
+ * request, as obviously the customer and merchant could conspire to
+ * set any timestamp. Also, the Exchange must accept very old deposit
+ * requests, as the merchant might have been unable to transmit the
+ * deposit request in a timely fashion (so back-dating is not
+ * prevented).
+ */
+ struct GNUNET_TIME_Absolute timestamp;
+
+ /**
+ * How much time does the merchant have to issue a refund request?
+ * Zero if refunds are not allowed. After this time, the coin
+ * cannot be refunded.
+ */
+ struct GNUNET_TIME_Absolute refund_deadline;
+
+ /**
+ * How much time does the merchant have to execute the wire transfer?
+ * This time is advisory for aggregating transactions, not a hard
+ * constraint (as the merchant can theoretically pick any time,
+ * including one in the past).
+ */
+ struct GNUNET_TIME_Absolute wire_deadline;
+
+ /**
+ * Fraction of the coin's remaining value to be deposited, including
+ * depositing fee (if any). The coin is identified by @e coin_pub.
+ */
+ struct TALER_Amount amount_with_fee;
+
+ /**
+ * Depositing fee.
+ */
+ struct TALER_Amount deposit_fee;
+
+};
+
+
+/**
+ * @brief Specification for a /refund operation in a coin's transaction list.
+ */
+struct TALER_EXCHANGEDB_RefundListEntry
+{
/**
* Public key of the merchant.
@@ -588,6 +701,32 @@ struct TALER_EXCHANGEDB_Refund
/**
+ * @brief Specification for a /refund operation. The combination of
+ * the coin's public key, the merchant's public key and the
+ * transaction ID must be unique. While a coin can (theoretically) be
+ * deposited at the same merchant twice (with partial spending), the
+ * merchant must either use a different public key or a different
+ * transaction ID for the two transactions. The same goes for
+ * refunds, hence we also have a "rtransaction" ID which is disjoint
+ * from the transaction ID. The same coin must not be used twice at
+ * the same merchant for the same transaction or rtransaction ID.
+ */
+struct TALER_EXCHANGEDB_Refund
+{
+ /**
+ * Information about the coin that is being refunded.
+ */
+ struct TALER_CoinPublicInfo coin;
+
+ /**
+ * Details about the refund.
+ */
+ struct TALER_EXCHANGEDB_RefundListEntry details;
+
+};
+
+
+/**
* @brief Specification for coin in a /refresh/melt operation.
*/
struct TALER_EXCHANGEDB_RefreshSession
@@ -627,7 +766,47 @@ struct TALER_EXCHANGEDB_RefreshSession
/**
- * Information about a /refresh/melt operation in the transaction history.
+ * Information about a /refresh/melt operation in a coin transaction history.
+ */
+struct TALER_EXCHANGEDB_RefreshMeltListEntry
+{
+
+ /**
+ * Signature over the melting operation.
+ */
+ struct TALER_CoinSpendSignatureP coin_sig;
+
+ /**
+ * Refresh commitment this coin is melted into.
+ */
+ struct TALER_RefreshCommitmentP rc;
+
+ /**
+ * How much value is being melted? This amount includes the fees,
+ * so the final amount contributed to the melt is this value minus
+ * the fee for melting the coin. We include the fee in what is
+ * being signed so that we can verify a reserve's remaining total
+ * balance without needing to access the respective denomination key
+ * information each time.
+ */
+ struct TALER_Amount amount_with_fee;
+
+ /**
+ * Melt fee the exchange charged.
+ */
+ struct TALER_Amount melt_fee;
+
+ /**
+ * Index (smaller #TALER_CNC_KAPPA) which the exchange has chosen to not
+ * have revealed during cut and choose.
+ */
+ uint32_t noreveal_index;
+
+};
+
+
+/**
+ * Information about a /refresh/melt operation.
*/
struct TALER_EXCHANGEDB_RefreshMelt
{
@@ -744,39 +923,39 @@ struct TALER_EXCHANGEDB_TransactionList
* Details if transaction was a /deposit operation.
* (#TALER_EXCHANGEDB_TT_DEPOSIT)
*/
- struct TALER_EXCHANGEDB_Deposit *deposit;
+ struct TALER_EXCHANGEDB_DepositListEntry *deposit;
/**
* Details if transaction was a /refresh/melt operation.
* (#TALER_EXCHANGEDB_TT_REFRESH_MELT)
*/
- struct TALER_EXCHANGEDB_RefreshMelt *melt;
+ struct TALER_EXCHANGEDB_RefreshMeltListEntry *melt;
/**
* Details if transaction was a /refund operation.
* (#TALER_EXCHANGEDB_TT_REFUND)
*/
- struct TALER_EXCHANGEDB_Refund *refund;
+ struct TALER_EXCHANGEDB_RefundListEntry *refund;
/**
* Details if transaction was a /payback-refund operation where
* this coin was the OLD coin.
* (#TALER_EXCHANGEDB_TT_OLD_COIN_PAYBACK).
*/
- struct TALER_EXCHANGEDB_PaybackRefresh *old_coin_payback;
+ struct TALER_EXCHANGEDB_PaybackRefreshListEntry *old_coin_payback;
/**
* Details if transaction was a /payback operation.
* (#TALER_EXCHANGEDB_TT_PAYBACK)
*/
- struct TALER_EXCHANGEDB_Payback *payback;
+ struct TALER_EXCHANGEDB_PaybackListEntry *payback;
/**
* Details if transaction was a /payback-refund operation where
* this coin was the REFRESHED coin.
* (#TALER_EXCHANGEDB_TT_PAYBACK_REFRESH)
*/
- struct TALER_EXCHANGEDB_PaybackRefresh *payback_refresh;
+ struct TALER_EXCHANGEDB_PaybackRefreshListEntry *payback_refresh;
} details;
@@ -1790,7 +1969,10 @@ struct TALER_EXCHANGEDB_Plugin
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param session connection to the database
- * @param deposit the deposit to check
+ * @param coin_pub the coin to check for deposit
+ * @param merchant_pub merchant to receive the deposit
+ * @param h_contract_terms contract terms of the deposit
+ * @param h_wire hash of the merchant's wire details
* @return #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT if is is marked done,
* #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if not,
* otherwise transaction error status (incl. deposit unknown)
@@ -1798,7 +1980,10 @@ struct TALER_EXCHANGEDB_Plugin
enum GNUNET_DB_QueryStatus
(*test_deposit_done)(void *cls,
struct TALER_EXCHANGEDB_Session *session,
- const struct TALER_EXCHANGEDB_Deposit *deposit);
+ const struct TALER_CoinSpendPublicKeyP *coin_pub,
+ const struct TALER_MerchantPublicKeyP *merchant_pub,
+ const struct GNUNET_HashCode *h_contract_terms,
+ const struct GNUNET_HashCode *h_wire);
/**