aboutsummaryrefslogtreecommitdiff
path: root/src/backend/merchant_db.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/merchant_db.h')
-rw-r--r--src/backend/merchant_db.h98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/backend/merchant_db.h b/src/backend/merchant_db.h
new file mode 100644
index 00000000..bf334989
--- /dev/null
+++ b/src/backend/merchant_db.h
@@ -0,0 +1,98 @@
1/*
2 This file is part of TALER
3 (C) 2014 Christian Grothoff (and other contributing authors)
4
5 TALER is free software; you can redistribute it and/or modify it under the
6 terms of the GNU General Public License as published by the Free Software
7 Foundation; either version 3, or (at your option) any later version.
8
9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License along with
14 TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
15*/
16
17/**
18 * @file merchant/merchant_db.h
19 * @brief database helper functions used by the merchant
20 * @author Sree Harsha Totakura <sreeharsha@totakura.in>
21 */
22
23#ifndef MERCHANT_DB_H
24#define MERCHANT_DB_H
25
26#include <gnunet/gnunet_postgres_lib.h>
27#include <taler/taler_util.h>
28
29/**
30 * Connect to postgresql database
31 *
32 * @param cfg the configuration handle
33 * @return connection to the postgresql database; NULL upon error
34 */
35PGconn *
36MERCHANT_DB_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
37
38
39/**
40 * Disconnect from the database
41 *
42 * @param conn database handle to close
43 */
44void
45MERCHANT_DB_disconnect (PGconn *conn);
46
47
48/**
49 * Initialize merchant tables
50 *
51 * @param conn the connection handle to postgres db.
52 * @param tmp GNUNET_YES if the tables are to be made temporary i.e. their
53 * contents are dropped when the @a conn is closed
54 * @return GNUNET_OK upon success; GNUNET_SYSERR upon failure
55 */
56int
57MERCHANT_DB_initialize (PGconn *conn, int tmp);
58
59
60/**
61 * Inserts a contract record into the database and if successfull returns the
62 * serial number of the inserted row.
63 *
64 * @param conn the database connection
65 * @param expiry the time when the contract will expire
66 * @param amount the taler amount corresponding to the contract
67 * @param desc descripition of the contract
68 * @param nounce a random 64-bit nounce
69 * @param product description to identify a product
70 * @return -1 upon error; the serial id of the inserted contract upon success
71 */
72long long
73MERCHANT_DB_contract_create (PGconn *conn,
74 struct GNUNET_TIME_Absolute expiry,
75 struct TALER_Amount *amount,
76 const char *desc,
77 uint64_t nounce,
78 uint64_t product);
79
80long long
81MERCHANT_DB_get_contract_product (PGconn *conn,
82 uint64_t contract_id);
83
84unsigned int
85MERCHANT_DB_checkout_create (PGconn *conn,
86 struct GNUNET_CRYPTO_rsa_PublicKey *coin_pub,
87 uint64_t transaction_id,
88 struct TALER_Amount *amount,
89 struct GNUNET_CRYPTO_rsa_Signature *coin_sig);
90
91
92long long
93MERCHANT_DB_get_checkout_product (PGconn *conn,
94 struct GNUNET_CRYPTO_rsa_PublicKey *coin_pub);
95
96#endif /* MERCHANT_DB_H */
97
98/* end of merchant-db.h */