summaryrefslogtreecommitdiff
path: root/src/include/taler_merchantdb_plugin.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/taler_merchantdb_plugin.h')
-rw-r--r--src/include/taler_merchantdb_plugin.h1534
1 files changed, 1014 insertions, 520 deletions
diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h
index d9fe0d24..44fdc0ab 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -23,6 +23,8 @@
#ifndef TALER_MERCHANTDB_PLUGIN_H
#define TALER_MERCHANTDB_PLUGIN_H
+#include <gnunet/gnunet_common.h>
+#include <gnunet/gnunet_time_lib.h>
#include <gnunet/gnunet_util_lib.h>
#include <gnunet/gnunet_db_lib.h>
#include <taler/taler_exchange_service.h>
@@ -96,7 +98,20 @@ struct TALER_MERCHANTDB_AccountDetails
/**
* Actual account address as a payto://-URI.
*/
- const char *payto_uri;
+ char *payto_uri;
+
+ /**
+ * Where can the taler-merchant-wirewatch helper
+ * download information about incoming transfers?
+ * NULL if not available.
+ */
+ char *credit_facade_url;
+
+ /**
+ * JSON with credentials to use to access the
+ * @e credit_facade_url.
+ */
+ json_t *credit_facade_credentials;
/**
* Is the account set for active use in new contracts?
@@ -105,6 +120,19 @@ struct TALER_MERCHANTDB_AccountDetails
};
+
+/**
+ * Binary login token. Just a vanilla token made out
+ * of random bits.
+ */
+struct TALER_MERCHANTDB_LoginTokenP
+{
+ /**
+ * 32 bytes of entropy.
+ */
+ uint64_t data[32 / 8];
+};
+
/**
* Authentication settings for an instance.
*/
@@ -151,6 +179,7 @@ struct TALER_MERCHANTDB_InstanceSettings
* merchant's logo data uri
*/
char *logo;
+
/**
* Address of the business
*/
@@ -162,22 +191,10 @@ struct TALER_MERCHANTDB_InstanceSettings
json_t *jurisdiction;
/**
- * Default max deposit fee that the merchant is willing to
- * pay; if deposit costs more, then the customer will cover
- * the difference.
- */
- struct TALER_Amount default_max_deposit_fee;
-
- /**
- * Default maximum wire fee to assume, unless stated differently in the
- * proposal already.
+ * Use STEFAN curves to determine acceptable
+ * fees by default (otherwise: accept no fees by default).
*/
- struct TALER_Amount default_max_wire_fee;
-
- /**
- * Default factor for wire fee amortization.
- */
- uint32_t default_wire_fee_amortization;
+ bool use_stefan;
/**
* If the frontend does NOT specify an execution date, how long should
@@ -193,6 +210,10 @@ struct TALER_MERCHANTDB_InstanceSettings
*/
struct GNUNET_TIME_Relative default_pay_delay;
+ /**
+ * Type of user this merchant represents.
+ */
+ enum TALER_KYCLOGIC_KycUserType ut;
};
@@ -204,8 +225,6 @@ struct TALER_MERCHANTDB_InstanceSettings
* @param merchant_priv private key of the instance, NULL if not available
* @param is general instance settings
* @param ias instance authentication settings
- * @param accounts_length length of the @a accounts array
- * @param accounts list of accounts of the merchant
*/
typedef void
(*TALER_MERCHANTDB_InstanceCallback)(
@@ -213,18 +232,31 @@ typedef void
const struct TALER_MerchantPublicKeyP *merchant_pub,
const struct TALER_MerchantPrivateKeyP *merchant_priv,
const struct TALER_MERCHANTDB_InstanceSettings *is,
- const struct TALER_MERCHANTDB_InstanceAuthSettings *ias,
- unsigned int accounts_length,
- const struct TALER_MERCHANTDB_AccountDetails accounts[]);
+ const struct TALER_MERCHANTDB_InstanceAuthSettings *ias);
+
+
+/**
+ * Callback invoked with information about a bank account.
+ *
+ * @param cls closure
+ * @param ad details about the account
+ */
+typedef void
+(*TALER_MERCHANTDB_AccountCallback)(
+ void *cls,
+ const struct TALER_MERCHANTDB_AccountDetails *ad);
+
/**
* Typically called by `lookup_products`.
*
* @param cls a `json_t *` JSON array to build
+ * @param product_serial row ID of the product
* @param product_id ID of the product
*/
typedef void
(*TALER_MERCHANTDB_ProductsCallback)(void *cls,
+ uint64_t product_serial,
const char *product_id);
@@ -305,7 +337,7 @@ struct TALER_MERCHANTDB_ProductDetails
/**
* Typically called by `lookup_templates`.
*
- * @param cls a `json_t *` JSON array to build
+ * @param cls closure
* @param template_id ID of the template
* @param template_description description of the template
*/
@@ -316,6 +348,19 @@ typedef void
/**
+ * Typically called by `lookup_otp_devices`.
+ *
+ * @param cls closure
+ * @param otp_id ID of the OTP device
+ * @param otp_description description of the OTP device
+ */
+typedef void
+(*TALER_MERCHANTDB_OtpDeviceCallback)(void *cls,
+ const char *otp_id,
+ const char *otp_description);
+
+
+/**
* Details about a template.
*/
struct TALER_MERCHANTDB_TemplateDetails
@@ -326,14 +371,56 @@ struct TALER_MERCHANTDB_TemplateDetails
char *template_description;
/**
- * Base64-encoded image, or NULL.
+ * In this template contract, we can have additional information.
*/
- char *image;
+ json_t *template_contract;
/**
- * In this template contract, we can have additional information.
+ * ID of the OTP device linked to the template, or NULL.
*/
- json_t *template_contract;
+ char *otp_id;
+
+ /**
+ * Currency the payment must be in, NULL to allow any
+ * supported currency.
+ */
+ char *required_currency;
+
+ /**
+ * Editable default values for fields not specified
+ * in the @e template_contract. NULL if the user
+ * cannot edit anything.
+ */
+ json_t *editable_defaults;
+
+};
+
+
+/**
+ * Details about an OTP device.
+ */
+struct TALER_MERCHANTDB_OtpDeviceDetails
+{
+
+ /**
+ * Description of the device.
+ */
+ char *otp_description;
+
+ /**
+ * Current usage counter value.
+ */
+ uint64_t otp_ctr;
+
+ /**
+ * Base64-encoded key.
+ */
+ char *otp_key;
+
+ /**
+ * Algorithm used to compute purchase confirmations.
+ */
+ enum TALER_MerchantConfirmationAlgorithm otp_algorithm;
};
@@ -409,7 +496,7 @@ typedef void
* Typically called by `lookup_pending_webhooks`.
*
* @param cls a `json_t *` JSON array to build
- * @param webhook_serial reference to the configured webhook template.
+ * @param webhook_pending_serial reference to the configured webhook template.
* @param next_attempt is the time we should make the next request to the webhook.
* @param retries how often have we tried this request to the webhook.
* @param url to make request to
@@ -419,7 +506,7 @@ typedef void
*/
typedef void
(*TALER_MERCHANTDB_PendingWebhooksCallback)(void *cls,
- uint64_t webhook_serial,
+ uint64_t webhook_pending_serial,
struct GNUNET_TIME_Absolute
next_attempt,
uint32_t retries,
@@ -434,6 +521,7 @@ typedef void
*/
struct TALER_MERCHANTDB_PendingWebhookDetails
{
+
/**
* Identifies when we should make the next request to the webhook. 0 for unknown,
* #GNUNET_TIME_UNIT_FOREVER_ABS for never.
@@ -455,13 +543,11 @@ struct TALER_MERCHANTDB_PendingWebhookDetails
*/
char *http_method;
-
/**
* Header of the webhook.
*/
char *header;
-
/**
* Body of the webhook.
*/
@@ -476,6 +562,16 @@ struct TALER_MERCHANTDB_PendingWebhookDetails
struct TALER_MERCHANTDB_OrderFilter
{
/**
+ * Filter orders by this fulfillment URL.
+ */
+ const char *fulfillment_url;
+
+ /**
+ * Filter orders by this session ID.
+ */
+ const char *session_id;
+
+ /**
* Filter by payment status.
*/
enum TALER_EXCHANGE_YesNoAll paid;
@@ -538,7 +634,6 @@ typedef void
* @param amount_with_fee amount the exchange will deposit for this coin
* @param deposit_fee fee the exchange will charge for this coin
* @param refund_fee fee the exchange will charge for refunding this coin
- * @param wire_fee wire fee the exchange charges
*/
typedef void
(*TALER_MERCHANTDB_DepositsCallback)(
@@ -547,8 +642,7 @@ typedef void
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const struct TALER_Amount *amount_with_fee,
const struct TALER_Amount *deposit_fee,
- const struct TALER_Amount *refund_fee,
- const struct TALER_Amount *wire_fee);
+ const struct TALER_Amount *refund_fee);
/**
@@ -625,6 +719,7 @@ typedef void
* @param exchange_url base URL of the exchange for which this is a status
* @param last_check when did we last get an update on our KYC status from the exchange
* @param kyc_ok true if we satisfied the KYC requirements
+ * @param aml_decision current AML decision state at the exchange
*/
typedef void
(*TALER_MERCHANTDB_KycCallback)(
@@ -634,7 +729,8 @@ typedef void
const char *payto_uri,
const char *exchange_url,
struct GNUNET_TIME_Timestamp last_check,
- bool kyc_ok);
+ bool kyc_ok,
+ enum TALER_AmlDecisionState aml_decision);
/**
@@ -644,6 +740,11 @@ enum TALER_MERCHANTDB_RefundStatus
{
/**
+ * Refund amount currency does not match original payment.
+ */
+ TALER_MERCHANTDB_RS_BAD_CURRENCY = -4,
+
+ /**
* Refund amount exceeds original payment.
*/
TALER_MERCHANTDB_RS_TOO_HIGH = -3,
@@ -688,6 +789,60 @@ typedef void
/**
+ * Function called with information about wire transfers
+ * that taler-merchant-exchange still needs to process.
+ *
+ * @param cls closure
+ * @param rowid row of the transfer in the merchant database
+ * @param instance_id instance that received the transfer
+ * @param exchange_url base URL of the exchange that initiated the transfer
+ * @param payto_uri account of the merchant that received the transfer
+ * @param wtid wire transfer subject identifying the aggregation
+ * @param total total amount that was wired
+ * @param next_attempt when should we next try to interact with the exchange
+ */
+typedef void
+(*TALER_MERCHANTDB_OpenTransferCallback)(
+ void *cls,
+ uint64_t rowid,
+ const char *instance_id,
+ const char *exchange_url,
+ const char *payto_uri,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ const struct TALER_Amount *total,
+ struct GNUNET_TIME_Absolute next_attempt);
+
+
+/**
+ * Callback for results from `lookup_pending_deposits`.
+ *
+ * @param cls NULL
+ * @param deposit_serial identifies the deposit operation
+ * @param wire_deadline when is the wire due
+ * @param retry_backoff current value of the retry backoff
+ * @param h_contract_terms hash of the contract terms
+ * @param merchant_priv private key of the merchant
+ * @param instance_id name of the instance
+ * @param h_wire hash of the merchant's wire account into * @param amount_with_fee amount the exchange will deposit for this coin
+ * @param deposit_fee fee the exchange will charge for this coin which the deposit was made
+ * @param coin_pub public key of the deposited coin
+ */
+typedef void
+(*TALER_MERCHANTDB_PendingDepositsCallback) (
+ void *cls,
+ uint64_t deposit_serial,
+ struct GNUNET_TIME_Absolute wire_deadline,
+ struct GNUNET_TIME_Relative retry_backoff,
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ const struct TALER_MerchantPrivateKeyP *merchant_priv,
+ const char *instance_id,
+ const struct TALER_MerchantWireHashP *h_wire,
+ const struct TALER_Amount *amount_with_fee,
+ const struct TALER_Amount *deposit_fee,
+ const struct TALER_CoinSpendPublicKeyP *coin_pub);
+
+
+/**
* Function called with detailed information about a wire transfer and
* the underlying deposits that are being aggregated.
*
@@ -703,6 +858,27 @@ typedef void
/**
+ * Function called with information about a accounts
+ * the wirewatcher should monitor.
+ *
+ * @param cls closure
+ * @param instance instance that owns the account
+ * @param payto_uri account URI
+ * @param credit_facade_url URL for the credit facade
+ * @param credit_facade_credentials account access credentials
+ * @param last_serial last transaction serial (inclusive) we have seen from this account
+ */
+typedef void
+(*TALER_MERCHANTDB_WirewatchWorkCallback)(
+ void *cls,
+ const char *instance,
+ const char *payto_uri,
+ const char *credit_facade_url,
+ const json_t *credit_facade_credentials,
+ uint64_t last_serial);
+
+
+/**
* Function called with information about a wire transfer.
*
* @param cls closure with a `json_t *` array to build up the response
@@ -732,71 +908,24 @@ typedef void
/**
- * Callback with reserve details.
- *
- * @param cls closure
- * @param reserve_pub public key of the reserve
- * @param creation_time time when the reserve was setup
- * @param expiration_time time when the reserve will be closed by the exchange
- * @param merchant_initial_amount initial amount that the merchant claims to have filled the
- * reserve with
- * @param exchange_initial_amount initial amount that the exchange claims to have received
- * @param pickup_amount total of tips that were picked up from this reserve
- * @param committed_amount total of tips that the merchant committed to, but that were not
- * picked up yet
- * @param active true if the reserve is still active (we have the private key)
- */
-typedef void
-(*TALER_MERCHANTDB_ReservesCallback)(
- void *cls,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- struct GNUNET_TIME_Timestamp creation_time,
- struct GNUNET_TIME_Timestamp expiration_time,
- const struct TALER_Amount *merchant_initial_amount,
- const struct TALER_Amount *exchange_initial_amount,
- const struct TALER_Amount *pickup_amount,
- const struct TALER_Amount *committed_amount,
- bool active);
-
-
-/**
- * Callback with details about a reserve pending exchange confirmation.
+ * If the given account is feasible, add it to the array
+ * of accounts we return.
*
* @param cls closure
- * @param instance_id for which instance is this reserve
- * @param exchange_url base URL of the exchange
- * @param reserve_pub public key of the reserve
- * @param expected_amount how much do we expect to see in the reserve
+ * @param payto_uri URI of the account
+ * @param conversion_url URL of a conversion service
+ * @param debit_restrictions restrictions for debits from account
+ * @param credit_restrictions restrictions for credits to account
+ * @param master_sig signature affirming the account
*/
typedef void
-(*TALER_MERCHANTDB_PendingReservesCallback)(
+(*TALER_MERCHANTDB_ExchangeAccountCallback) (
void *cls,
- const char *instance_id,
- const char *exchange_url,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- const struct TALER_Amount *expected_amount);
-
-
-/**
- * Details about a tip.
- */
-struct TALER_MERCHANTDB_TipDetails
-{
- /**
- * ID of the tip.
- */
- struct TALER_TipIdentifierP tip_id;
-
- /**
- * Total amount of the tip.
- */
- struct TALER_Amount total_amount;
-
- /**
- * Reason given for granting the tip.
- */
- char *reason;
-};
+ const char *payto_uri,
+ const char *conversion_url,
+ const json_t *debit_restrictions,
+ const json_t *credit_restrictions,
+ const struct TALER_MasterSignatureP *master_sig);
/**
@@ -805,9 +934,10 @@ struct TALER_MERCHANTDB_TipDetails
* @param cls closure
* @param deposit_serial which deposit operation is this about
* @param exchange_url URL of the exchange that issued the coin
+ * @param h_wire hash of merchant's wire details
+ * @param deposit_timestamp when was the deposit made
* @param amount_with_fee amount the exchange will deposit for this coin
* @param deposit_fee fee the exchange will charge for this coin
- * @param h_wire hash of merchant's wire details
* @param coin_pub public key of the coin
*/
typedef void
@@ -816,61 +946,13 @@ typedef void
uint64_t deposit_serial,
const char *exchange_url,
const struct TALER_MerchantWireHashP *h_wire,
+ struct GNUNET_TIME_Timestamp deposit_timestamp,
const struct TALER_Amount *amount_with_fee,
const struct TALER_Amount *deposit_fee,
const struct TALER_CoinSpendPublicKeyP *coin_pub);
/**
- * Callback with reserve details.
- *
- * @param cls closure
- * @param creation_time time when the reserve was setup
- * @param expiration_time time when the reserve will be closed by the exchange
- * @param merchant_initial_amount initial amount that the merchant claims to have filled the
- * reserve with
- * @param exchange_initial_amount initial amount that the exchange claims to have received
- * @param picked_up_amount total of tips that were picked up from this reserve
- * @param committed_amount total of tips that the merchant committed to, but that were not
- * picked up yet
- * @param active true if the reserve is still active (we have the private key)
- * @param exchange_url base URL of the exchange hosting the reserve, NULL if not @a active
- * @param payto_uri URI to use to fund the reserve, NULL if not @a active
- * @param tips_length length of the @a tips array
- * @param tips information about the tips created by this reserve
- */
-typedef void
-(*TALER_MERCHANTDB_ReserveDetailsCallback)(
- void *cls,
- struct GNUNET_TIME_Timestamp creation_time,
- struct GNUNET_TIME_Timestamp expiration_time,
- const struct TALER_Amount *merchant_initial_amount,
- const struct TALER_Amount *exchange_initial_amount,
- const struct TALER_Amount *picked_up_amount,
- const struct TALER_Amount *committed_amount,
- bool active,
- const char *exchange_url,
- const char *payto_uri,
- unsigned int tips_length,
- const struct TALER_MERCHANTDB_TipDetails *tips);
-
-
-/**
- * Typically called by `lookup_tips`.
- *
- * @param cls closure
- * @param row_id row of the tip in the database
- * @param tip_id id of the tip
- * @param amount amount of the tip
- */
-typedef void
-(*TALER_MERCHANTDB_TipsCallback)(void *cls,
- uint64_t row_id,
- struct TALER_TipIdentifierP tip_id,
- struct TALER_Amount amount);
-
-
-/**
* Function called with information about a coin that was deposited.
*
* @param cls closure
@@ -901,25 +983,151 @@ typedef void
/**
- * Details about a pickup operation executed by the merchant.
+ * Possible token family kinds.
*/
-struct TALER_MERCHANTDB_PickupDetails
+enum TALER_MERCHANTDB_TokenFamilyKind
{
+
/**
- * Identifier for the pickup operation.
+ * Token family representing a discount token
*/
- struct TALER_PickupIdentifierP pickup_id;
+ TALER_MERCHANTDB_TFK_Discount = 0,
/**
- * Total amount requested for this @e pickup_id.
+ * Token family representing a subscription token
*/
- struct TALER_Amount requested_amount;
+ TALER_MERCHANTDB_TFK_Subscription = 1,
+
+};
+
+
+/**
+ * Typically called by `lookup_token_families`.
+ *
+ * @param cls a `json_t *` JSON array to build
+ * @param slug slug of the token family
+ * @param name name of the token family
+ * @param start_time start time of the token family's validity period
+ * @param expiration end time of the token family's validity period
+ * @param kind kind of the token family
+ */
+typedef void
+(*TALER_MERCHANTDB_TokenFamiliesCallback)(
+ void *cls,
+ const char *slug,
+ const char *name,
+ struct GNUNET_TIME_Timestamp start_time,
+ struct GNUNET_TIME_Timestamp expiration,
+ const char *kind);
+
+
+/**
+ * Details about a token family.
+ */
+struct TALER_MERCHANTDB_TokenFamilyDetails
+{
+ /**
+ * Token family slug used for identification.
+ */
+ char *slug;
+
+ /**
+ * User readable name of the token family.
+ */
+ char *name;
+
+ /**
+ * Description of the token family.
+ */
+ char *description;
+
+ /**
+ * Internationalized token family description.
+ */
+ json_t *description_i18n;
+
+ /**
+ * Start time of the token family duration.
+ */
+ struct GNUNET_TIME_Timestamp valid_after;
+
+ /**
+ * End time of the token family duration.
+ */
+ struct GNUNET_TIME_Timestamp valid_before;
+
+ /**
+ * Validity duration of the token family.
+ */
+ struct GNUNET_TIME_Relative duration;
+
+ /**
+ * Token family kind.
+ */
+ enum TALER_MERCHANTDB_TokenFamilyKind kind;
+
+ /**
+ * Counter for each issued token of this family.
+ */
+ uint64_t issued;
+
+ /**
+ * Counter for each redeemed token of this family.
+ */
+ uint64_t redeemed;
+};
+
+
+/**
+ * Details about a token key.
+ */
+struct TALER_MERCHANTDB_TokenFamilyKeyDetails
+{
+ /**
+ * Tokens signed with this key are valid from this date on.
+ */
+ struct GNUNET_TIME_Timestamp valid_after;
+
+ /**
+ * Tokens signed with this key are valid until this date.
+ */
+ struct GNUNET_TIME_Timestamp valid_before;
/**
- * Number of planchets involved in the request.
+ * Token family public key.
*/
- unsigned int num_planchets;
+ struct TALER_TokenFamilyPublicKey *pub;
+ /**
+ * Token family private key.
+ */
+ struct TALER_TokenFamilyPrivateKey *priv;
+
+ /**
+ * Details about the token family this key belongs to.
+ */
+ struct TALER_MERCHANTDB_TokenFamilyDetails token_family;
+};
+
+/**
+ * Details about a spent token.
+*/
+struct TALER_MERCHANTDB_SpentTokenDetails
+{
+ /**
+ * Public key of the spent token.
+ */
+ struct TALER_TokenPublicKey pub;
+
+ /**
+ * Signature that this token was spent on the specified order.
+ */
+ struct TALER_TokenSignature sig;
+
+ /**
+ * Blind signature for the spent token to prove validity of it.
+ */
+ struct TALER_TokenBlindSignature blind_sig;
};
@@ -1052,7 +1260,6 @@ struct TALER_MERCHANTDB_Plugin
* Roll back the current transaction of a database connection.
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
- * @return #GNUNET_OK on success
*/
void
(*rollback) (void *cls);
@@ -1061,7 +1268,7 @@ struct TALER_MERCHANTDB_Plugin
* Commit the current transaction of a database connection.
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
- * @return transaction status code
+ * @return transaction status
*/
enum GNUNET_DB_QueryStatus
(*commit)(void *cls);
@@ -1139,6 +1346,132 @@ struct TALER_MERCHANTDB_Plugin
const char *id,
const struct TALER_MERCHANTDB_AccountDetails *account_details);
+
+ /**
+ * Insert instance login token into our database.
+ *
+ * @param cls closure
+ * @param id identifier of the instance
+ * @param token value of the token
+ * @param creation_time the current time
+ * @param expiration_time when does the token expire
+ * @param validity_scope scope of the token
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_login_token)(
+ void *cls,
+ const char *id,
+ const struct TALER_MERCHANTDB_LoginTokenP *token,
+ struct GNUNET_TIME_Timestamp creation_time,
+ struct GNUNET_TIME_Timestamp expiration_time,
+ uint32_t validity_scope);
+
+
+ /**
+ * Lookup information about a login token from database.
+ *
+ * @param cls closure
+ * @param id identifier of the instance
+ * @param token value of the token
+ * @param[out] expiration_time set to expiration time
+ * @param[out] validity_scope set to scope of the token
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_login_token)(
+ void *cls,
+ const char *id,
+ const struct TALER_MERCHANTDB_LoginTokenP *token,
+ struct GNUNET_TIME_Timestamp *expiration_time,
+ uint32_t *validity_scope);
+
+
+ /**
+ * Delete login token from database.
+ *
+ * @param cls closure
+ * @param id identifier of the instance
+ * @param token value of the token
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*delete_login_token)(
+ void *cls,
+ const char *id,
+ const struct TALER_MERCHANTDB_LoginTokenP *token);
+
+
+ /**
+ * Update information about an instance's account into our database.
+ *
+ * @param cls closure
+ * @param id identifier of the instance
+ * @param h_wire which account to update
+ * @param credit_facade_url new facade URL, can be NULL
+ * @param credit_facade_credentials new credentials, can be NULL
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_account)(
+ void *cls,
+ const char *id,
+ const struct TALER_MerchantWireHashP *h_wire,
+ const char *credit_facade_url,
+ const json_t *credit_facade_credentials);
+
+
+ /**
+ * Obtain information about an instance's accounts.
+ *
+ * @param cls closure
+ * @param id identifier of the instance
+ * @param cb function to call on each account
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_accounts)(
+ void *cls,
+ const char *id,
+ TALER_MERCHANTDB_AccountCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Obtain detailed information about an instance's account.
+ *
+ * @param cls closure
+ * @param id identifier of the instance
+ * @param h_wire wire hash of the account
+ * @param[out] ad account details returned
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_account)(
+ void *cls,
+ const char *id,
+ const struct TALER_MerchantWireHashP *h_wire,
+ struct TALER_MERCHANTDB_AccountDetails *ad);
+
+
+ /**
+ * Obtain detailed information about an instance's account.
+ *
+ * @param cls closure
+ * @param id identifier of the instance
+ * @param payto_uri URI of the account
+ * @param[out] ad account details returned
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_account_by_uri)(
+ void *cls,
+ const char *id,
+ const char *payto_uri,
+ struct TALER_MERCHANTDB_AccountDetails *ad);
+
+
/**
* Delete private key of an instance from our database.
*
@@ -1250,6 +1583,7 @@ struct TALER_MERCHANTDB_Plugin
* @param exchange_pub public key of the exchange, or NULL for none
* @param timestamp timestamp to store
* @param kyc_ok current KYC status (true for satisfied)
+ * @param aml_decision current AML decision state at the exchange
* @return database result code
*/
enum GNUNET_DB_QueryStatus
@@ -1261,7 +1595,8 @@ struct TALER_MERCHANTDB_Plugin
const struct TALER_ExchangeSignatureP *exchange_sig,
const struct TALER_ExchangePublicKeyP *exchange_pub,
struct GNUNET_TIME_Timestamp timestamp,
- bool kyc_ok);
+ bool kyc_ok,
+ enum TALER_AmlDecisionState aml_decision);
/**
@@ -1269,6 +1604,9 @@ struct TALER_MERCHANTDB_Plugin
*
* @param cls closure
* @param instance_id instance to lookup products for
+ * @param offset transfer_serial number of the transfer we want to offset from
+ * @param limit number of entries to return, negative for descending,
+ * positive for ascending
* @param cb function to call on all products found
* @param cb_cls closure for @a cb
* @return database result code
@@ -1276,6 +1614,8 @@ struct TALER_MERCHANTDB_Plugin
enum GNUNET_DB_QueryStatus
(*lookup_products)(void *cls,
const char *instance_id,
+ uint64_t offset,
+ int64_t limit,
TALER_MERCHANTDB_ProductsCallback cb,
void *cb_cls);
@@ -1378,8 +1718,9 @@ struct TALER_MERCHANTDB_Plugin
* instances.
*
* @param cls closure
+ * @return database result code
*/
- void
+ enum GNUNET_DB_QueryStatus
(*expire_locks)(void *cls);
@@ -1465,20 +1806,26 @@ struct TALER_MERCHANTDB_Plugin
* @param cls closure
* @param instance_id identifies the instance responsible for the order
* @param order_id alphanumeric string that uniquely identifies the order
+ * @param session_id session ID for the order
* @param h_post_data hash of the POST data for idempotency checks
* @param pay_deadline how long does the customer have to pay for the order
* @param claim_token token to use for access control
* @param contract_terms proposal data to store
+ * @param pos_key encoded key for payment verification
+ * @param pos_algorithm algorithm to compute the payment verification
* @return transaction status
*/
enum GNUNET_DB_QueryStatus
(*insert_order)(void *cls,
const char *instance_id,
const char *order_id,
+ const char *session_id,
const struct TALER_MerchantPostDataHashP *h_post_data,
struct GNUNET_TIME_Timestamp pay_deadline,
const struct TALER_ClaimTokenP *claim_token,
- const json_t *contract_terms);
+ const json_t *contract_terms,
+ const char *pos_key,
+ enum TALER_MerchantConfirmationAlgorithm pos_algorithm);
/**
@@ -1526,16 +1873,71 @@ struct TALER_MERCHANTDB_Plugin
* @param[out] order_serial set to the order's serial number
* @param[out] paid set to true if the order is fully paid
* @param[out] claim_token set to the claim token, NULL to only check for existence
+ * @param[out] pos_key encoded key for payment verification
+ * @param[out] pos_algorithm set to algorithm to compute the payment verification
* @return transaction status
*/
enum GNUNET_DB_QueryStatus
- (*lookup_contract_terms)(void *cls,
- const char *instance_id,
- const char *order_id,
- json_t **contract_terms,
- uint64_t *order_serial,
- bool *paid,
- struct TALER_ClaimTokenP *claim_token);
+ (*lookup_contract_terms2)(
+ void *cls,
+ const char *instance_id,
+ const char *order_id,
+ json_t **contract_terms,
+ uint64_t *order_serial,
+ bool *paid,
+ struct TALER_ClaimTokenP *claim_token,
+ char **pos_key,
+ enum TALER_MerchantConfirmationAlgorithm *pricing_algorithm);
+
+
+ /**
+ * Retrieve contract terms given its @a order_id
+ *
+ * @param cls closure
+ * @param instance_id instance's identifier
+ * @param order_id order_id used to lookup
+ * @param session_id session_id to compare, can be NULL
+ * @param[out] contract_terms where to store the result, NULL to only check for existence
+ * @param[out] order_serial set to the order's serial number
+ * @param[out] paid set to true if the order is fully paid
+ * @param[out] wired set to true if the exchange wired the funds
+ * @param[out] session_matches set to true if @a session_id matches session stored for this contract
+ * @param[out] claim_token set to the claim token, NULL to only check for existence
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_contract_terms3)(
+ void *cls,
+ const char *instance_id,
+ const char *order_id,
+ const char *session_id,
+ json_t **contract_terms,
+ uint64_t *order_serial,
+ bool *paid,
+ bool *wired,
+ bool *session_matches,
+ struct TALER_ClaimTokenP *claim_token);
+
+
+ /**
+ * Retrieve contract terms given its @a order_id
+ *
+ * @param cls closure
+ * @param instance_id instance's identifier
+ * @param order_id order_id used to lookup.
+ * @param[out] contract_terms where to store the result, NULL to only check for existence
+ * @param[out] order_serial set to the order's serial number
+ * @param[out] claim_token set to the claim token, NULL to only check for existence
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_contract_terms)(
+ void *cls,
+ const char *instance_id,
+ const char *order_id,
+ json_t **contract_terms,
+ uint64_t *order_serial,
+ struct TALER_ClaimTokenP *claim_token);
/**
@@ -1555,11 +1957,12 @@ struct TALER_MERCHANTDB_Plugin
* is malformed
*/
enum GNUNET_DB_QueryStatus
- (*insert_contract_terms)(void *cls,
- const char *instance_id,
- const char *order_id,
- json_t *contract_terms,
- uint64_t *order_serial);
+ (*insert_contract_terms)(
+ void *cls,
+ const char *instance_id,
+ const char *order_id,
+ json_t *contract_terms,
+ uint64_t *order_serial);
/**
@@ -1646,36 +2049,62 @@ struct TALER_MERCHANTDB_Plugin
/**
- * Insert payment confirmation from the exchange into the database.
+ * Insert deposit confirmation from the exchange into the database.
*
* @param cls closure
* @param instance_id instance to lookup deposits for
* @param deposit_timestamp time when the exchange generated the deposit confirmation
* @param h_contract_terms proposal data's hashcode
- * @param coin_pub public key of the coin
* @param exchange_url URL of the exchange that issued @a coin_pub
- * @param amount_with_fee amount the exchange will deposit for this coin
- * @param deposit_fee fee the exchange will charge for this coin
+ * @param wire_transfer_deadline when do we expect the wire transfer from the exchange
+ * @param total_without_fees deposited total in the batch without fees
* @param wire_fee wire fee the exchange charges
* @param h_wire hash of the wire details of the target account of the merchant
* @param exchange_sig signature from exchange that coin was accepted
* @param exchange_pub signing key that was used for @a exchange_sig
+ * @param[out] batch_deposit_serial_id set to the table row
* @return transaction status
*/
enum GNUNET_DB_QueryStatus
- (*insert_deposit)(void *cls,
- const char *instance_id,
- struct GNUNET_TIME_Timestamp deposit_timestamp,
- const struct TALER_PrivateContractHashP *h_contract_terms,
- const struct TALER_CoinSpendPublicKeyP *coin_pub,
- const char *exchange_url,
- const struct TALER_Amount *amount_with_fee,
- const struct TALER_Amount *deposit_fee,
- const struct TALER_Amount *refund_fee,
- const struct TALER_Amount *wire_fee,
- const struct TALER_MerchantWireHashP *h_wire,
- const struct TALER_ExchangeSignatureP *exchange_sig,
- const struct TALER_ExchangePublicKeyP *exchange_pub);
+ (*insert_deposit_confirmation)(
+ void *cls,
+ const char *instance_id,
+ struct GNUNET_TIME_Timestamp deposit_timestamp,
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ const char *exchange_url,
+ struct GNUNET_TIME_Timestamp wire_transfer_deadline,
+ const struct TALER_Amount *total_without_fees,
+ const struct TALER_Amount *wire_fee,
+ const struct TALER_MerchantWireHashP *h_wire,
+ const struct TALER_ExchangeSignatureP *exchange_sig,
+ const struct TALER_ExchangePublicKeyP *exchange_pub,
+ uint64_t *batch_deposit_serial_id);
+
+
+ /**
+ * Insert information about coin deposited as part of
+ * a batch into the database.
+ *
+ * @param cls closure
+ * @param offset offset of the coin in the batch
+ * @param deposit_confirmation_serial_id deposit confirmation for the batch the coin is part of
+ * @param coin_pub public key of the coin
+ * @param coin_sig deposit signature of the coin
+ * @param amount_with_fee amount the exchange will deposit for this coin
+ * @param deposit_fee fee the exchange will charge for this coin
+ * @param refund_fee fee the exchange will charge for refunds of coin
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_deposit)(
+ void *cls,
+ uint32_t offset,
+ uint64_t deposit_confirmation_serial_id,
+ const struct TALER_CoinSpendPublicKeyP *coin_pub,
+ const struct TALER_CoinSpendSignatureP *coin_sig,
+ const struct TALER_Amount *amount_with_fee,
+ const struct TALER_Amount *deposit_fee,
+ const struct TALER_Amount *refund_fee);
/**
@@ -1778,25 +2207,6 @@ struct TALER_MERCHANTDB_Plugin
/**
- * Retrieve payment and wire status for a given @a order_serial and
- * session ID.
- *
- * @param cls closure
- * @param order_serial identifies the order
- * @param session_id session for which to check the payment status, NULL for any
- * @param[out] paid set to the payment status of the contract
- * @param[out] wired set to the wire transfer status of the exchange payment
- * @return transaction status
- */
- enum GNUNET_DB_QueryStatus
- (*lookup_payment_status)(void *cls,
- uint64_t order_serial,
- const char *session_id,
- bool *paid,
- bool *wired);
-
-
- /**
* Retrieve details about coins that were deposited for an order.
*
* @param cls closure
@@ -1831,6 +2241,47 @@ struct TALER_MERCHANTDB_Plugin
/**
+ * Update transfer status.
+ *
+ * @param cls closure
+ * @param exchange_url the exchange that made the transfer
+ * @param wtid wire transfer subject
+ * @param next_attempt when should we try again (if ever)
+ * @param ec current error state of checking the transfer
+ * @param failed true if validation has failed for good
+ * @param verified true if validation has succeeded for good
+ * @return database transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_transfer_status)(
+ void *cls,
+ const char *exchange_url,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ struct GNUNET_TIME_Absolute next_attempt,
+ enum TALER_ErrorCode ec,
+ bool failed,
+ bool verified);
+
+ /**
+ * Retrieve wire transfer details of wire details
+ * that taler-merchant-exchange still needs to
+ * investigate.
+ *
+ * @param cls closure
+ * @param limit maximum number of results to return
+ * @param cb function called with the wire transfer data
+ * @param cb_cls closure for @a cb
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_open_transfers)(
+ void *cls,
+ uint64_t limit,
+ TALER_MERCHANTDB_OpenTransferCallback cb,
+ void *cb_cls);
+
+
+ /**
* Insert wire transfer details for a deposit.
*
* @param cls closure
@@ -1941,6 +2392,7 @@ struct TALER_MERCHANTDB_Plugin
* @param fulfillment_url URL that canonically identifies the resource
* being paid for
* @param session_id session id
+ * @param allow_refunded_for_repurchase true to include refunded orders in repurchase detection
* @param[out] order_id location to store the order ID that was used when
* paying for the resource URL
* @return transaction status
@@ -1950,9 +2402,42 @@ struct TALER_MERCHANTDB_Plugin
const char *instance_id,
const char *fulfillment_url,
const char *session_id,
+ bool allow_refunded_for_repurchase,
char **order_id);
/**
+ * Update information about progress made by taler-merchant-wirewatch.
+ *
+ * @param cls closure
+ * @param instance which instance does the account belong to
+ * @param payto_uri which account is this about
+ * @param last_serial last serial imported from the bank
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_wirewatch_progress)(
+ void *cls,
+ const char *instance,
+ const char *payto_uri,
+ uint64_t last_serial);
+
+
+ /**
+ * Select information about accounts which taler-merchant-wirewatch should work on.
+ *
+ * @param cls closure
+ * @param cb function to call with results
+ * @param cb_cls closure for @a cb
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_wirewatch_accounts)(
+ void *cls,
+ TALER_MERCHANTDB_WirewatchWorkCallback cb,
+ void *cb_cls);
+
+
+ /**
* Insert information about a wire transfer the merchant has received.
*
* @param cls closure
@@ -2127,20 +2612,22 @@ struct TALER_MERCHANTDB_Plugin
/**
- * Set transfer status to verified.
+ * Set transfer status to confirmed.
*
* @param cls closure
* @param instance_id instance to lookup payments for
* @param exchange_url the exchange that made the transfer
- * @param payto_uri account that received the transfer
* @param wtid wire transfer subject
+ * @param amount confirmed amount of the wire transfer
* @return transaction status
*/
enum GNUNET_DB_QueryStatus
- (*set_transfer_status_to_verified)(
+ (*set_transfer_status_to_confirmed)(
void *cls,
+ const char *instance_id,
const char *exchange_url,
- const struct TALER_WireTransferIdentifierRawP *wtid);
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ const struct TALER_Amount *amount);
/**
@@ -2219,402 +2706,236 @@ struct TALER_MERCHANTDB_Plugin
* including signature (so we have proof).
*
* @param cls closure
- * @param exchange_pub public key of the exchange
+ * @param master_pub master public key of the exchange
* @param h_wire_method hash of wire method
* @param fees wire fees charged
* @param start_date start of fee being used
* @param end_date end of fee being used
- * @param exchange_sig signature of exchange over fee structure
+ * @param master_sig signature of exchange over fee structure
* @return transaction status code
*/
enum GNUNET_DB_QueryStatus
(*store_wire_fee_by_exchange)(
void *cls,
- const struct TALER_MasterPublicKeyP *exchange_pub,
+ const struct TALER_MasterPublicKeyP *master_pub,
const struct GNUNET_HashCode *h_wire_method,
const struct TALER_WireFeeSet *fees,
struct GNUNET_TIME_Timestamp start_date,
struct GNUNET_TIME_Timestamp end_date,
- const struct TALER_MasterSignatureP *exchange_sig);
-
-
- /**
- * Add @a credit to a reserve to be used for tipping. Note that
- * this function does not actually perform any wire transfers to
- * credit the reserve, it merely tells the merchant backend that
- * a reserve now exists. This has to happen before tips can be
- * authorized.
- *
- * @param cls closure, typically a connection to the db
- * @param instance_id which instance is the reserve tied to
- * @param reserve_priv which reserve is topped up or created
- * @param reserve_pub which reserve is topped up or created
- * @param exchange_url what URL is the exchange reachable at where the reserve is located
- * @param payto_uri URI to fund the reserve
- * @param initial_balance how much money will be added to the reserve
- * @param expiration when does the reserve expire?
- * @return transaction status, usually
- * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT for success
- */
- enum TALER_ErrorCode
- (*insert_reserve)(void *cls,
- const char *instance_id,
- const struct TALER_ReservePrivateKeyP *reserve_priv,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- const char *exchange_url,
- const char *payto_uri,
- const struct TALER_Amount *initial_balance,
- struct GNUNET_TIME_Timestamp expiration);
+ const struct TALER_MasterSignatureP *master_sig);
/**
- * Confirms @a credit as the amount the exchange claims to have received and
- * thus really 'activates' the reserve. This has to happen before tips can
- * be authorized.
+ * Delete information about wire accounts of an exchange. (Used when we got new account data.)
*
- * @param cls closure, typically a connection to the db
- * @param instance_id which instance is the reserve tied to
- * @param reserve_pub which reserve is topped up or created
- * @param initial_exchange_balance how much money was be added to the reserve
- * according to the exchange
- * @return transaction status, usually
- * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT for success
+ * @param cls closure
+ * @param master_pub public key of the exchange
+ * @return transaction status code
*/
enum GNUNET_DB_QueryStatus
- (*activate_reserve)(void *cls,
- const char *instance_id,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- const struct TALER_Amount *initial_exchange_balance);
+ (*delete_exchange_accounts)(
+ void *cls,
+ const struct TALER_MasterPublicKeyP *master_pub);
/**
- * Lookup reserves.
+ * Return information about wire accounts of an exchange.
*
* @param cls closure
- * @param instance_id instance to lookup payments for
- * @param created_after filter by reserves created after this date
- * @param active filter by active reserves
- * @param failures filter by reserves with a disagreement on the initial balance
- * @param cb function to call with reserve summary data
+ * @param master_pub public key of the exchange
+ * @param cb function to call on each account
* @param cb_cls closure for @a cb
- * @return transaction status
+ * @return transaction status code
*/
enum GNUNET_DB_QueryStatus
- (*lookup_reserves)(void *cls,
- const char *instance_id,
- struct GNUNET_TIME_Timestamp created_after,
- enum TALER_EXCHANGE_YesNoAll active,
- enum TALER_EXCHANGE_YesNoAll failures,
- TALER_MERCHANTDB_ReservesCallback cb,
- void *cb_cls);
+ (*select_accounts_by_exchange)(
+ void *cls,
+ const struct TALER_MasterPublicKeyP *master_pub,
+ TALER_MERCHANTDB_ExchangeAccountCallback cb,
+ void *cb_cls);
/**
- * Lookup reserves pending activation across all instances.
+ * Insert information about a wire account of an exchange.
*
* @param cls closure
- * @param cb function to call with reserve data
- * @param cb_cls closure for @a cb
- * @return transaction status
+ * @param master_pub public key of the exchange
+ * @param payto_uri URI of the bank account
+ * @param conversion_url conversion service, NULL if there is no conversion required
+ * @param debit_restrictions JSON array of debit restrictions on the account
+ * @param credit_restrictions JSON array of debit restrictions on the account
+ * @param master_sig signature affirming the account of the exchange
+ * @return transaction status code
*/
enum GNUNET_DB_QueryStatus
- (*lookup_pending_reserves)(void *cls,
- TALER_MERCHANTDB_PendingReservesCallback cb,
- void *cb_cls);
+ (*insert_exchange_account)(
+ void *cls,
+ const struct TALER_MasterPublicKeyP *master_pub,
+ const char *payto_uri,
+ const char *conversion_url,
+ const json_t *debit_restrictions,
+ const json_t *credit_restrictions,
+ const struct TALER_MasterSignatureP *master_sig);
/**
- * Lookup reserve details.
+ * Lookup all of the templates the given instance has configured.
*
* @param cls closure
- * @param instance_id instance to lookup payments for
- * @param reserve_pub public key of the reserve to inspect
- * @param fetch_tips if true, also return information about tips
- * @param cb function to call with reserve summary data
+ * @param instance_id instance to lookup template for
+ * @param cb function to call on all template found
* @param cb_cls closure for @a cb
- * @return transaction status
+ * @return database result code
*/
enum GNUNET_DB_QueryStatus
- (*lookup_reserve)(void *cls,
- const char *instance_id,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- bool fetch_tips,
- TALER_MERCHANTDB_ReserveDetailsCallback cb,
- void *cb_cls);
+ (*lookup_templates)(void *cls,
+ const char *instance_id,
+ TALER_MERCHANTDB_TemplatesCallback cb,
+ void *cb_cls);
/**
- * Delete private key of a reserve.
+ * Lookup details about a particular template.
*
* @param cls closure
- * @param instance_id instance to lookup payments for
- * @param reserve_pub public key of the reserve to delete
- * @return transaction status
+ * @param instance_id instance to lookup template for
+ * @param template_id template to lookup
+ * @param[out] td set to the template details on success, can be NULL
+ * (in that case we only want to check if the template exists)
+ * @return database result code
*/
enum GNUNET_DB_QueryStatus
- (*delete_reserve)(void *cls,
- const char *instance_id,
- const struct TALER_ReservePublicKeyP *reserve_pub);
+ (*lookup_template)(void *cls,
+ const char *instance_id,
+ const char *template_id,
+ struct TALER_MERCHANTDB_TemplateDetails *td);
/**
- * Purge all information about a reserve (including tips from it).
+ * Delete information about a template.
*
* @param cls closure
- * @param instance_id instance to lookup payments for
- * @param reserve_pub public key of the reserve to purge
- * @return transaction status
+ * @param instance_id instance to delete template of
+ * @param template_id template to delete
+ * @return DB status code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS
+ * if template unknown.
*/
enum GNUNET_DB_QueryStatus
- (*purge_reserve)(void *cls,
- const char *instance_id,
- const struct TALER_ReservePublicKeyP *reserve_pub);
-
-
- /**
- * Authorize a tip over @a amount from reserve @a reserve_pub. Remember
- * the authorization under @a tip_id for later, together with the
- * @a justification.
- *
- * @param cls closure, typically a connection to the db
- * @param instance_id which instance should generate the tip
- * @param reserve_pub which reserve is debited, NULL to pick one in the DB
- * @param amount how high is the tip (with fees)
- * @param justification why was the tip approved
- * @param next_url where to send the URL post tip pickup
- * @param[out] tip_id set to the unique ID for the tip
- * @param[out] expiration set to when the tip expires
- * @return transaction status,
- * #TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_RESERVE_EXPIRED if the reserve is known but has expired
- * #TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_RESERVE_NOT_FOUND if the reserve is not known
- * #TALER_EC_MERCHANT_PRIVATE_POST_TIP_AUTHORIZE_INSUFFICIENT_FUNDS if the reserve has insufficient funds left
- * #TALER_EC_GENERIC_DB_START_FAILED on hard DB errors
- * #TALER_EC_GENERIC_DB_FETCH_FAILED on hard DB errors
- * #TALER_EC_GENERIC_DB_STORE_FAILED on hard DB errors
- * #TALER_EC_GENERIC_DB_INVARIANT_FAILURE on hard DB errors
- * #TALER_EC_GENERIC_DB_SOFT_FAILURE on soft DB errors (client should retry)
- * #TALER_EC_NONE upon success
- */
- enum TALER_ErrorCode
- (*authorize_tip)(void *cls,
- const char *instance_id,
- const struct TALER_ReservePublicKeyP *reserve_pub,
- const struct TALER_Amount *amount,
- const char *justification,
- const char *next_url,
- struct TALER_TipIdentifierP *tip_id,
- struct GNUNET_TIME_Timestamp *expiration);
+ (*delete_template)(void *cls,
+ const char *instance_id,
+ const char *template_id);
/**
- * Lookup pickup details for pickup @a pickup_id.
+ * Insert details about a particular template.
*
- * @param cls closure, typically a connection to the db
- * @param instance_id which instance should we lookup tip details for
- * @param tip_id which tip should we lookup details on
- * @param pickup_id which pickup should we lookup details on
- * @param[out] exchange_url which exchange is the tip withdrawn from
- * @param[out] reserve_priv private key the tip is withdrawn from (set if still available!)
- * @param sigs_length length of the @a sigs array
- * @param[out] sigs set to the (blind) signatures we have for this @a pickup_id,
- * those that are unavailable are left at NULL
- * @return transaction status
+ * @param cls closure
+ * @param instance_id instance to insert template for
+ * @param template_id template identifier of template to insert
+ * @param otp_serial_id 0 if no OTP device is associated
+ * @param td the template details to insert
+ * @return database result code
*/
enum GNUNET_DB_QueryStatus
- (*lookup_pickup)(void *cls,
- const char *instance_id,
- const struct TALER_TipIdentifierP *tip_id,
- const struct TALER_PickupIdentifierP *pickup_id,
- char **exchange_url,
- struct TALER_ReservePrivateKeyP *reserve_priv,
- unsigned int sigs_length,
- struct TALER_BlindedDenominationSignature sigs[]);
+ (*insert_template)(void *cls,
+ const char *instance_id,
+ const char *template_id,
+ uint64_t otp_serial_id,
+ const struct TALER_MERCHANTDB_TemplateDetails *td);
/**
- * Lookup tip details for tip @a tip_id.
+ * Delete information about an OTP device.
*
- * @param cls closure, typically a connection to the db
- * @param instance_id which instance should we lookup tip details for
- * @param tip_id which tip should we lookup details on
- * @param[out] total_authorized amount how high is the tip (with fees)
- * @param[out] total_picked_up how much of the tip was so far picked up (with fees)
- * @param[out] expiration set to when the tip expires
- * @param[out] exchange_url set to the exchange URL where the reserve is
- * @param[out] reserve_priv set to private key of reserve to be debited
- * @return transaction status
+ * @param cls closure
+ * @param instance_id instance to delete OTP device of
+ * @param otp_id otp device to delete
+ * @return DB status code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS
+ * if template unknown.
*/
enum GNUNET_DB_QueryStatus
- (*lookup_tip)(void *cls,
+ (*delete_otp)(void *cls,
const char *instance_id,
- const struct TALER_TipIdentifierP *tip_id,
- struct TALER_Amount *total_authorized,
- struct TALER_Amount *total_picked_up,
- struct GNUNET_TIME_Timestamp *expiration,
- char **exchange_url,
- struct TALER_ReservePrivateKeyP *reserve_priv);
-
+ const char *otp_id);
/**
- * Lookup tips
+ * Insert details about a particular OTP device.
*
- * @param cls closure, typically a connection to the db
- * @param instance_id which instance should we lookup tips for
- * @param expired should we include expired tips?
- * @param limit maximum number of results to return, positive for
- * ascending row id, negative for descending
- * @param offset row id to start returning results from
- * @param cb function to call with tip data
- * @param cb_cls closure for @a cb
- * @return transaction status
- */
- enum GNUNET_DB_QueryStatus
- (*lookup_tips)(void *cls,
- const char *instance_id,
- enum TALER_EXCHANGE_YesNoAll expired,
- int64_t limit,
- uint64_t offset,
- TALER_MERCHANTDB_TipsCallback cb,
- void *cb_cls);
-
-
- /**
- * Lookup tip details for tip @a tip_id.
- *
- * @param cls closure, typically a connection to the db
- * @param instance_id which instance should we lookup tip details for
- * @param tip_id which tip should we lookup details on
- * @param fpu should we fetch details about individual pickups
- * @param[out] total_authorized amount how high is the tip (with fees)
- * @param[out] total_picked_up how much of the tip was so far picked up (with fees)
- * @param[out] justification why was the tip approved
- * @param[out] expiration set to when the tip expires
- * @param[out] reserve_pub set to which reserve is debited
- * @param[out] pickups_length set to the length of @e pickups
- * @param[out] pickups if @a fpu is true, set to details about the pickup operations
- * @return transaction status
- */
- enum GNUNET_DB_QueryStatus
- (*lookup_tip_details)(void *cls,
- const char *instance_id,
- const struct TALER_TipIdentifierP *tip_id,
- bool fpu,
- struct TALER_Amount *total_authorized,
- struct TALER_Amount *total_picked_up,
- char **justification,
- struct GNUNET_TIME_Timestamp *expiration,
- struct TALER_ReservePublicKeyP *reserve_pub,
- unsigned int *pickups_length,
- struct TALER_MERCHANTDB_PickupDetails **pickups);
-
-
- /**
- * Insert details about a tip pickup operation. The @a total_picked_up
- * UPDATES the total amount under the @a tip_id, while the @a total_requested
- * is the amount to be associated with this @a pickup_id.
- * While there is usually only one pickup event that picks up the entire
- * amount, our schema allows for wallets to pick up the amount incrementally
- * over multiple pick up operations.
- *
- * @param cls closure, typically a connection to the db
- * @param tip_id the unique ID for the tip
- * @param total_picked_up how much was picked up overall at this
- * point (includes @a total_requested)
- * @param pickup_id unique ID for the operation
- * @param total_requested how much is being picked up in this operation
- * @return transaction status, usually
- * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT for success
- * #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if @a credit_uuid already known
+ * @param cls closure
+ * @param instance_id instance to insert OTP device for
+ * @param otp_id otp identifier of OTP device to insert
+ * @param td the OTP device details to insert
+ * @return database result code
*/
enum GNUNET_DB_QueryStatus
- (*insert_pickup)(void *cls,
- const char *instance_id,
- const struct TALER_TipIdentifierP *tip_id,
- const struct TALER_Amount *total_picked_up,
- const struct TALER_PickupIdentifierP *pickup_id,
- const struct TALER_Amount *total_requested);
+ (*insert_otp)(void *cls,
+ const char *instance_id,
+ const char *otp_id,
+ const struct TALER_MERCHANTDB_OtpDeviceDetails *td);
/**
- * Insert blind signature obtained from the exchange during a
- * tip pickup operation.
+ * Update details about a particular OTP device.
*
- * @param cls closure, typically a connection to the db
- * @param pickup_id unique ID for the operation
- * @param offset offset of the blind signature for the pickup
- * @param blind_sig the blind signature
- * @return transaction status, usually
- * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT for success
- * #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if @a credit_uuid already known
+ * @param cls closure
+ * @param instance_id instance to update OTP device for
+ * @param otp_id OTP device to update
+ * @param td update to the OTP device details on success, can be NULL
+ * (in that case we only want to check if the template exists)
+ * @return database result code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if the template
+ * does not yet exist.
*/
enum GNUNET_DB_QueryStatus
- (*insert_pickup_blind_signature)(
- void *cls,
- const struct TALER_PickupIdentifierP *pickup_id,
- uint32_t offset,
- const struct TALER_BlindedDenominationSignature *blind_sig);
-
+ (*update_otp)(void *cls,
+ const char *instance_id,
+ const char *otp_id,
+ const struct TALER_MERCHANTDB_OtpDeviceDetails *td);
/**
- * Lookup all of the templates the given instance has configured.
+ * Lookup all of the OTP devices the given instance has configured.
*
* @param cls closure
- * @param instance_id instance to lookup template for
- * @param cb function to call on all template found
+ * @param instance_id instance to lookup OTP devices for
+ * @param cb function to call on all OTP devices found
* @param cb_cls closure for @a cb
* @return database result code
*/
enum GNUNET_DB_QueryStatus
- (*lookup_templates)(void *cls,
- const char *instance_id,
- TALER_MERCHANTDB_TemplatesCallback cb,
- void *cb_cls);
+ (*lookup_otp_devices)(void *cls,
+ const char *instance_id,
+ TALER_MERCHANTDB_OtpDeviceCallback cb,
+ void *cb_cls);
/**
- * Lookup details about a particular template.
+ * Lookup details about an OTP device.
*
* @param cls closure
* @param instance_id instance to lookup template for
- * @param template_id template to lookup
- * @param[out] td set to the template details on success, can be NULL
+ * @param otp_id OTP device to lookup
+ * @param[out] td set to the OTP device details on success, can be NULL
* (in that case we only want to check if the template exists)
* @return database result code
*/
enum GNUNET_DB_QueryStatus
- (*lookup_template)(void *cls,
- const char *instance_id,
- const char *template_id,
- struct TALER_MERCHANTDB_TemplateDetails *td);
-
- /**
- * Delete information about a template.
- *
- * @param cls closure
- * @param instance_id instance to delete template of
- * @param template_id template to delete
- * @return DB status code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS
- * if template unknown.
- */
- enum GNUNET_DB_QueryStatus
- (*delete_template)(void *cls,
- const char *instance_id,
- const char *template_id);
+ (*select_otp)(void *cls,
+ const char *instance_id,
+ const char *otp_id,
+ struct TALER_MERCHANTDB_OtpDeviceDetails *td);
/**
- * Insert details about a particular template.
+ * Lookup serial number of an OTP device.
*
* @param cls closure
- * @param instance_id instance to insert template for
- * @param template_id template identifier of template to insert
- * @param td the template details to insert
- * @return database result code
+ * @param instance_id instance to lookup template for
+ * @param otp_id OTP device to lookup
+ * @param[out] serial set to the OTP device serial number * @return database result code
*/
enum GNUNET_DB_QueryStatus
- (*insert_template)(void *cls,
- const char *instance_id,
- const char *template_id,
- const struct TALER_MERCHANTDB_TemplateDetails *td);
+ (*select_otp_serial)(void *cls,
+ const char *instance_id,
+ const char *otp_id,
+ uint64_t *serial);
/**
@@ -2752,22 +3073,6 @@ struct TALER_MERCHANTDB_Plugin
const char *http_method,
const char *header,
const char *body);
-
- /**
- * Lookup details about a particular pending webhook.
- *
- * @param cls closure
- * @param instance_id instance to lookup webhook for
- * @param webhook_serial webhook to lookup
- * @param[out] pwb set to the pending webhook details on success, can be NULL
- * (in that case we only want to check if the webhook exists)
- * @return database result code
- */
- enum GNUNET_DB_QueryStatus
- (*lookup_pending_webhook)(void *cls,
- const char *instance_id,
- uint64_t *webhook_serial,
- struct TALER_MERCHANTDB_PendingWebhookDetails *pwb);
/**
* Lookup the webhook that need to be send in priority. These webhooks are not successfully
* send.
@@ -2827,9 +3132,9 @@ struct TALER_MERCHANTDB_Plugin
*/
enum GNUNET_DB_QueryStatus
(*update_pending_webhook)(void *cls,
- uint64_t webhook_serial,
+ uint64_t webhook_pending_serial,
struct GNUNET_TIME_Absolute next_attempt);
- // maybe add: http status of failure?
+ // maybe add: http status of failure?
/**
@@ -2842,8 +3147,197 @@ struct TALER_MERCHANTDB_Plugin
*/
enum GNUNET_DB_QueryStatus
(*delete_pending_webhook)(void *cls,
- uint64_t webhook_serial);
+ uint64_t webhook_pending_serial);
+
+ /**
+ * Retrieve exchange's keys from the database.
+ *
+ * @param cls plugin closure
+ * @param exchange_url base URL of the exchange
+ * @param[out] keys set to the keys of the exchange
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*select_exchange_keys)(void *cls,
+ const char *exchange_url,
+ struct TALER_EXCHANGE_Keys **keys);
+
+
+ /**
+ * Insert or update @a keys into the database.
+ *
+ * @param cls plugin closure
+ * @param keys data to store
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_exchange_keys)(void *cls,
+ const struct TALER_EXCHANGE_Keys *keys);
+
+
+ /**
+ * Lookup all of the token families the given instance has configured.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup token families for
+ * @param cb function to call on all token families found
+ * @param cb_cls closure for @a cb
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_token_families)(void *cls,
+ const char *instance_id,
+ TALER_MERCHANTDB_TokenFamiliesCallback cb,
+ void *cb_cls);
+
+ /**
+ * Lookup details about a particular token family.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup token family for
+ * @param token_family_slug token family to lookup
+ * @param[out] details set to the token family details on success, can be NULL
+ * (in that case we only want to check if the token family exists)
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_token_family)(void *cls,
+ const char *instance_id,
+ const char *token_family_slug,
+ struct TALER_MERCHANTDB_TokenFamilyDetails *details);
+
+ /**
+ * Delete information about a token family.
+ *
+ * @param cls closure
+ * @param instance_id instance to delete token family of
+ * @param token_family_slug slug of token family to delete
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*delete_token_family)(void *cls,
+ const char *instance_id,
+ const char *token_family_slug);
+
+ /**
+ * Update details about a particular token family.
+ *
+ * @param cls closure
+ * @param instance_id instance to update token family for
+ * @param token_family_slug slug of token family to update
+ * @param details set to the updated token family on success, can be NULL
+ * (in that case we only want to check if the token family exists)
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_token_family)(
+ void *cls,
+ const char *instance_id,
+ const char *token_family_slug,
+ const struct TALER_MERCHANTDB_TokenFamilyDetails *details);
+
+
+ /**
+ * Insert details about a particular token family.
+ *
+ * @param cls closure
+ * @param instance_id instance to insert token family for
+ * @param token_family_slug slug of token family to insert
+ * @param details the token family details to insert
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_token_family)(
+ void *cls,
+ const char *instance_id,
+ const char *token_family_slug,
+ const struct TALER_MERCHANTDB_TokenFamilyDetails *details);
+
+
+ /**
+ * Lookup details about a particular token family key.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup token family key for
+ * @param token_family_slug slug of token family to lookup
+ * @param min_valid_after lower bound of the start of the key validation period
+ * @param max_valid_after upper bound of the start of the key validation period
+ * @param[out] details set to the token family key details on success, can be NULL
+ * (in that case we only want to check if the token family key exists)
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_token_family_key) (
+ void *cls,
+ const char *instance_id,
+ const char *token_family_slug,
+ struct GNUNET_TIME_Timestamp min_valid_after,
+ struct GNUNET_TIME_Timestamp max_valid_after,
+ struct TALER_MERCHANTDB_TokenFamilyKeyDetails *details);
+
+
+ /**
+ * Insert details a key pair for a token family.
+ *
+ * @param cls closure
+ * @param token_family_slug slug of token family to insert the key pair for
+ * @param pub token family public key
+ * @param priv token family private key
+ * @param valid_after start of the key validation period
+ * @param valid_before end of the key validation period
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_token_family_key)(
+ void *cls,
+ const char *token_family_slug,
+ const struct TALER_TokenFamilyPublicKey *pub,
+ const struct TALER_TokenFamilyPrivateKey *priv,
+ struct GNUNET_TIME_Timestamp valid_after,
+ struct GNUNET_TIME_Timestamp valid_before);
+
+ /**
+ * Lookup deposits that are finished and awaiting a wire transfer.
+ *
+ * @param cls closure
+ * @param exchange_url exchange to filter deposits by
+ * @param limit maximum number of deposits to return
+ * @param allow_future true to allow deposits with wire deadline in the future
+ * @param cb function to call with deposit data
+ * @param cb_cls closure for @a cb
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_pending_deposits)(
+ void *cls,
+ const char *exchange_url,
+ uint64_t limit,
+ bool allow_future,
+ TALER_MERCHANTDB_PendingDepositsCallback cb,
+ void *cb_cls);
+
+
+ /**
+ * Update the deposit confirmation status associated with
+ * the given @a deposit_serial.
+ *
+ * @param cls closure
+ * @param deposit_serial deposit to update status for
+ * @param wire_pending should we keep checking for the wire status with the exchange?
+ * @param future_retry when should we ask the exchange again
+ * @param retry_backoff current value for the retry backoff
+ * @param emsg error message to record
+ * @return database result code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*update_deposit_confirmation_status)(
+ void *cls,
+ uint64_t deposit_serial,
+ bool wire_pending,
+ struct GNUNET_TIME_Timestamp future_retry,
+ struct GNUNET_TIME_Relative retry_backoff,
+ const char *emsg);
};
#endif