[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: db changes payment
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: db changes payment |
Date: |
Fri, 25 Sep 2020 20:40:31 +0200 |
This is an automated email from the git hooks/post-receive script.
ds-meister pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new e0c39ed db changes payment
e0c39ed is described below
commit e0c39edb508006c15144ec24cc3a60e4b65f765b
Author: Dominik Meister <dominik.meister@hotmail.ch>
AuthorDate: Fri Sep 25 20:40:27 2020 +0200
db changes payment
---
src/backend/anastasis-httpd.c | 1 +
src/backend/anastasis-httpd_truth.c | 8 +-
src/include/anastasis_database_plugin.h | 84 ++++++-
src/lib/test_anastasis.c | 39 ++--
src/lib/test_anastasis_api.conf | 1 +
src/stasis/plugin_anastasis_postgres.c | 380 ++++++++++++++++++++++++++++----
src/stasis/test_anastasis_db.c | 11 +-
7 files changed, 453 insertions(+), 71 deletions(-)
diff --git a/src/backend/anastasis-httpd.c b/src/backend/anastasis-httpd.c
index 30f3eff..e014923 100644
--- a/src/backend/anastasis-httpd.c
+++ b/src/backend/anastasis-httpd.c
@@ -726,6 +726,7 @@ main (int argc,
"force HTTP connections to be closed after each
request",
&TMH_anastasis_connection_close),
+
GNUNET_GETOPT_OPTION_END
};
diff --git a/src/backend/anastasis-httpd_truth.c
b/src/backend/anastasis-httpd_truth.c
index 3b1a39a..c28b744 100644
--- a/src/backend/anastasis-httpd_truth.c
+++ b/src/backend/anastasis-httpd_truth.c
@@ -28,7 +28,10 @@
#include <gnunet/gnunet_rest_lib.h>
#include <anastasis_authorization_plugin.h>
-
+/**
+ * Authentication plugin which is used to verify code based authentication
+ * like SMS, E-Mail.
+ */
struct AuthPlugin
{
struct AuthPlugin *next;
@@ -225,6 +228,9 @@ AH_handler_truth_get (struct MHD_Connection *connection,
{
enum ANASTASIS_AUTHORIZATION_Result ret;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "authorization process started \n");
+
/* second/third call, continue processing */
GNUNET_assert (NULL != gc->as);
ret = gc->authorization->process (gc->as,
diff --git a/src/include/anastasis_database_plugin.h
b/src/include/anastasis_database_plugin.h
index 96283ac..7d00280 100644
--- a/src/include/anastasis_database_plugin.h
+++ b/src/include/anastasis_database_plugin.h
@@ -48,6 +48,16 @@ struct ANASTASIS_DB_Truth
const char *method;
};
+/**
+ * @brief Specification for a challenge payment object.
+ */
+struct ANASTASIS_DB_ChallengePayment
+{
+ const char *payment_identifier;
+ const struct TALER_Amount *amount;
+};
+
+
/**
* Function called on all pending payments for an account.
*
@@ -342,6 +352,21 @@ struct ANASTASIS_DatabasePlugin
ANASTASIS_PaymentSecretP *payment_secret,
bool *paid,
bool *valid_counter);
+/**
+ * Check payment identifier. Used to check if a payment identifier given by
+ * the user is valid (existing and paid).
+ *
+ * @param cls closure
+ * @param payment_secret payment secret which the user must provide with every
upload
+ * @param paid[OUT] bool value to show if payment is paid
+ * @param valid_counter[OUT] bool value to show if post_counter is > 0
+ * @return transaction status
+ */
+ enum ANASTASIS_DB_QueryStatus
+ (*check_challenge_payment)(void *cls,
+ const struct
+ ANASTASIS_PaymentSecretP *payment_secret,
+ bool *paid);
/**
* Increment account lifetime.
@@ -374,12 +399,13 @@ struct ANASTASIS_DatabasePlugin
* @return transaction status
*/
enum ANASTASIS_DB_QueryStatus
- (*record_payment)(void *cls,
- const struct
- ANASTASIS_CRYPTO_AccountPublicKeyP *anastasis_pub,
- uint32_t post_counter,
- const struct ANASTASIS_PaymentSecretP *payment_secret,
- const struct TALER_Amount *amount);
+ (*record_recdoc_payment)(void *cls,
+ const struct
+ ANASTASIS_CRYPTO_AccountPublicKeyP *anastasis_pub,
+ uint32_t post_counter,
+ const struct
+ ANASTASIS_PaymentSecretP *payment_secret,
+ const struct TALER_Amount *amount);
/**
* Verify the provided code with the code on the server.
@@ -418,6 +444,52 @@ struct ANASTASIS_DatabasePlugin
struct GNUNET_TIME_Relative expiration_time,
unsigned int retry_counter);
+ /**
+ * Store payment for challenge.
+ *
+ * @param cls closure
+ * @param truth_key identifier of the challenge to pay
+ * @param payment_secret payment secret which the user must provide with
every upload
+ * @param amount how much we asked for
+ * @return transaction status
+ */
+ enum ANASTASIS_DB_QueryStatus
+ (*record_challenge_payment)(void *cls,
+ const struct
+ ANASTASIS_CRYPTO_TruthKeyP *truth_public_key,
+ const struct
+ ANASTASIS_PaymentSecretP *payment_secret,
+ const struct TALER_Amount *amount);
+
+ /**
+ * Lookup for a pending payment for a certain challenge
+ *
+ * @param cls closure
+ * @param truth_public_key identification of the challenge
+ * @param cp returns a challenge payment struct
+ * @return transaction status
+ */
+ enum ANASTASIS_DB_QueryStatus
+ (*lookup_challenge_payment)(void *cls,
+ const struct
+ ANASTASIS_CRYPTO_TruthPublicKeyP
+ *truth_public_key,
+ struct
+ ANASTASIS_DB_ChallengePayment *cp);
+ /**
+ * Update payment status of challenge
+ *
+ * @param cls closure
+ * @param truth_public_key which challenge received a payment
+ * @param payment_identifier proof of payment, must be unique and match
pending payment
+ * @return transaction status
+ */
+ enum ANASTASIS_DB_QueryStatus
+ (*update_challenge_payment)(void *cls,
+ const struct
+ ANASTASIS_CRYPTO_TruthPublicKeyP
*truth_public_key,
+ const struct
+ ANASTASIS_PaymentSecretP *payment_identifier);
/**
* FIXME maybe implemented in the postgres_gc but want it seperate first
* Function called to remove all expired codes in the database
diff --git a/src/lib/test_anastasis.c b/src/lib/test_anastasis.c
index 67df647..1eb3dd9 100644
--- a/src/lib/test_anastasis.c
+++ b/src/lib/test_anastasis.c
@@ -299,25 +299,24 @@ run (void *cls,
"salt-request-1",
"secret-share-2"),
- // ANASTASIS_TESTING_cmd_challenge_answer ("challenge-answer-1",
- // MHD_HTTP_OK,
- // "recover-secret-1",
- // 0,
- // "HashOfSomeTruth1",
- // strlen ("HashOfSomeTruth1")),
- // ANASTASIS_TESTING_cmd_challenge_answer ("challenge-answer-2",
- // MHD_HTTP_OK,
- // "recover-secret-1",
- // 1,
- // "HashOfSomeTruth2",
- // strlen ("HashOfSomeTruth2")),
- // ANASTASIS_TESTING_cmd_challenge_answer ("challenge-answer-3",
- // MHD_HTTP_OK,
- // "recover-secret-1",
- // 2,
- // "HashOfSomeTruth3",
- // strlen ("HashOfSomeTruth3")),
-
+ ANASTASIS_TESTING_cmd_challenge_answer ("challenge-answer-1",
+ MHD_HTTP_OK,
+ "recover-secret-1",
+ 0,
+ "HashOfSomeTruth1",
+ strlen ("HashOfSomeTruth1")),
+ ANASTASIS_TESTING_cmd_challenge_answer ("challenge-answer-2",
+ MHD_HTTP_OK,
+ "recover-secret-1",
+ 1,
+ "HashOfSomeTruth2",
+ strlen ("HashOfSomeTruth2")),
+ ANASTASIS_TESTING_cmd_challenge_answer ("challenge-answer-3",
+ MHD_HTTP_OK,
+ "recover-secret-1",
+ 2,
+ "HashOfSomeTruth3",
+ strlen ("HashOfSomeTruth3")),
TALER_TESTING_cmd_end ()
};
@@ -420,4 +419,4 @@ main (int argc,
}
-/* end of test_anastasis.c */
\ No newline at end of file
+/* end of test_anastasis.c */
diff --git a/src/lib/test_anastasis_api.conf b/src/lib/test_anastasis_api.conf
index 93c6f06..3362397 100644
--- a/src/lib/test_anastasis_api.conf
+++ b/src/lib/test_anastasis_api.conf
@@ -46,6 +46,7 @@ ANNUAL_FEE = EUR:4.99
# Cost of authentication by question
#QUESTION_COST = EUR:0
+
QUESTION_COST = EUR:0
# Upload limit
diff --git a/src/stasis/plugin_anastasis_postgres.c
b/src/stasis/plugin_anastasis_postgres.c
index 6eb054f..1ac779f 100644
--- a/src/stasis/plugin_anastasis_postgres.c
+++ b/src/stasis/plugin_anastasis_postgres.c
@@ -75,11 +75,17 @@ postgres_drop_tables (void *cls)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_ExecuteStatement es[] = {
- GNUNET_PQ_make_try_execute ("DROP TABLE IF EXISTS anastasis_truth;"),
+ GNUNET_PQ_make_try_execute (
+ "DROP TABLE IF EXISTS anastasis_truth CASCADE;"),
GNUNET_PQ_make_try_execute ("DROP TABLE IF EXISTS anastasis_user
CASCADE;"),
- GNUNET_PQ_make_try_execute ("DROP TABLE IF EXISTS anastasis_payment;"),
+ GNUNET_PQ_make_try_execute (
+ "DROP TABLE IF EXISTS anastasis_recdoc_payment;"),
GNUNET_PQ_make_try_execute (
"DROP TABLE IF EXISTS anastasis_recoverydocument;"),
+ GNUNET_PQ_make_try_execute (
+ "DROP TABLE IF EXISTS anastasis_challengecode;"),
+ GNUNET_PQ_make_try_execute (
+ "DROP TABLE IF EXISTS anastasis_challenge_payment;"),
GNUNET_PQ_EXECUTE_STATEMENT_END
};
return GNUNET_PQ_exec_statements (pg->conn,
@@ -256,7 +262,7 @@ postgres_gc (void *cls,
if (qs < 0)
return qs;
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "gc_pending_payments",
+ "gc_recdoc_pending_payments",
params2);
}
@@ -376,7 +382,7 @@ postgres_lookup_pending_payments_by_account (void *cls,
check_connection (pg);
postgres_preflight (pg);
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
- "payments_select_by_account",
+
"recdoc_payments_select_by_account",
params,
&payment_by_account_cb,
&pic);
@@ -715,7 +721,7 @@ postgres_increment_lifetime (void *cls,
};
qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "payment_done",
+ "recdoc_payment_done",
params);
if (0 >= qs)
{
@@ -848,12 +854,14 @@ postgres_increment_lifetime (void *cls,
* @return transaction status
*/
static enum ANASTASIS_DB_QueryStatus
-postgres_record_payment (void *cls,
- const struct
- ANASTASIS_CRYPTO_AccountPublicKeyP *anastasis_pub,
- uint32_t post_counter,
- const struct ANASTASIS_PaymentSecretP *payment_secret,
- const struct TALER_Amount *amount)
+postgres_record_recdoc_payment (void *cls,
+ const struct
+ ANASTASIS_CRYPTO_AccountPublicKeyP *
+ anastasis_pub,
+ uint32_t post_counter,
+ const struct
+ ANASTASIS_PaymentSecretP *payment_secret,
+ const struct TALER_Amount *amount)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"At %s:%d Post counter to save is: %u\n",
@@ -956,7 +964,7 @@ postgres_record_payment (void *cls,
}
qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "payment_insert",
+ "recdoc_payment_insert",
params);
switch (qs)
{
@@ -977,6 +985,128 @@ postgres_record_payment (void *cls,
}
}
+/**
+ * Store payment for challenge.
+ *
+ * @param cls closure
+ * @param truth_key identifier of the challenge to pay
+ * @param payment_secret payment secret which the user must provide with every
upload
+ * @param amount how much we asked for
+ * @return transaction status
+ */
+static enum ANASTASIS_DB_QueryStatus
+postgres_record_challenge_payment (void *cls,
+ const struct
+ ANASTASIS_CRYPTO_TruthKeyP
*truth_public_key,
+ const struct
+ ANASTASIS_PaymentSecretP *payment_secret,
+ const struct TALER_Amount *amount)
+{
+ struct PostgresClosure *pg = cls;
+ enum ANASTASIS_DB_QueryStatus qs;
+ struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
+ check_connection (pg);
+ postgres_preflight (pg);
+ /*dummy funcion to check if truth is available*/
+ void *truth;
+ size_t truth_size;
+ char *truth_mime;
+ char *method;
+
+
+ {
+ // because of constraint at truth_id, first we have to verify
+ // if the challenge exists
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_auto_from_type (truth_public_key),
+ GNUNET_PQ_query_param_end
+ };
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_variable_size ("encrypted_truth",
+ &truth,
+ &truth_size),
+ GNUNET_PQ_result_spec_string ("truth_mime",
+ &truth_mime),
+ GNUNET_PQ_result_spec_string ("method",
+ &method),
+ GNUNET_PQ_result_spec_end
+ };
+ qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+ "truth_select",
+ params,
+ rs);
+ if (qs < 0)
+ {
+ return qs;
+ }
+ }
+
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_auto_from_type (truth_public_key),
+ TALER_PQ_query_param_amount (amount),
+ GNUNET_PQ_query_param_auto_from_type (payment_secret),
+ GNUNET_PQ_query_param_absolute_time (&now),
+ GNUNET_PQ_query_param_end
+ };
+
+ qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
+ "challenge_payment_insert",
+ params);
+ switch (qs)
+ {
+ case GNUNET_DB_STATUS_SOFT_ERROR:
+ GNUNET_break (0);
+ return ANASTASIS_DB_STATUS_SOFT_ERROR;
+ case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
+ GNUNET_break (0);
+ return ANASTASIS_DB_STATUS_NO_RESULTS;
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
+ return ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT;
+ case GNUNET_DB_STATUS_HARD_ERROR:
+ GNUNET_break (0);
+ return ANASTASIS_DB_STATUS_HARD_ERROR;
+ default:
+ GNUNET_break (0);
+ return ANASTASIS_DB_STATUS_HARD_ERROR;
+ }
+}
+/**
+ * Check payment identifier. Used to check if a payment identifier given by
+ * the user is valid (existing and paid).
+ *
+ * @param cls closure
+ * @param payment_secret payment secret which the user must provide with every
upload
+ * @param paid[OUT] bool value to show if payment is paid
+ * @param valid_counter[OUT] bool value to show if post_counter is > 0
+ * @return transaction status
+ */
+static enum ANASTASIS_DB_QueryStatus
+postgres_check_challenge_payment (void *cls,
+ const struct
+ ANASTASIS_PaymentSecretP *payment_secret,
+ bool *paid)
+{
+ struct PostgresClosure *pg = cls;
+ enum ANASTASIS_DB_QueryStatus qs;
+
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_auto_from_type (payment_secret),
+ GNUNET_PQ_query_param_end
+ };
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_auto_from_type ("paid",
+ paid),
+ GNUNET_PQ_result_spec_end
+ };
+
+ check_connection (pg);
+ qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+ "challenge_payment_select",
+ params,
+ rs);
+ return qs;
+}
+
/**
* Check payment identifier. Used to check if a payment identifier given by
@@ -1012,7 +1142,7 @@ postgres_check_payment_identifier (void *cls,
};
check_connection (pg);
qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "payment_select",
+ "recdoc_payment_select",
params,
rs);
@@ -1529,6 +1659,117 @@ postgres_verify_challenge_code (void *cls,
}
+/**
+ * Lookup for a pending payment for a certain challenge
+ *
+ * @param cls closure
+ * @param truth_public_key identification of the challenge
+ * @param cp returns a challenge payment struct
+ * @return transaction status
+ */
+enum ANASTASIS_DB_QueryStatus
+postgres_lookup_challenge_payment (void *cls,
+ const struct
+ ANASTASIS_CRYPTO_TruthPublicKeyP
+ *truth_public_key,
+ struct
+ ANASTASIS_DB_ChallengePayment *cp)
+{
+ struct PostgresClosure *pg = cls;
+ enum ANASTASIS_DB_QueryStatus qs;
+ struct ANASTASIS_PaymentSecretP payment_identifier;
+ struct TALER_Amount amount;
+
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_auto_from_type (truth_public_key),
+ GNUNET_PQ_query_param_end
+ };
+
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ GNUNET_PQ_result_spec_auto_from_type ("payment_identifier",
+ &payment_identifier),
+ TALER_PQ_result_spec_amount ("amount",
+ pg->currency,
+ &amount),
+ GNUNET_PQ_result_spec_end
+ };
+
+ qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+
"challenge_pending_payment_select",
+ params,
+ rs);
+ switch (qs)
+ {
+ case GNUNET_DB_STATUS_HARD_ERROR:
+ return ANASTASIS_DB_STATUS_HARD_ERROR;
+ case GNUNET_DB_STATUS_SOFT_ERROR:
+ return ANASTASIS_DB_STATUS_SOFT_ERROR;
+ case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
+ return ANASTASIS_DB_STATUS_NO_RESULTS;
+ case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
+ break;
+ default:
+ GNUNET_break (0);
+ return ANASTASIS_DB_STATUS_HARD_ERROR;
+ }
+
+ char *order_id;
+ order_id = GNUNET_STRINGS_data_to_string_alloc (&payment_identifier,
+ sizeof (struct
+
ANASTASIS_PaymentSecretP));
+ cp->payment_identifier = order_id;
+ cp->amount = &amount;
+ return ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT;
+}
+
+/**
+ * Update payment status of challenge
+ *
+ * @param cls closure
+ * @param truth_public_key which challenge received a payment
+ * @param payment_identifier proof of payment, must be unique and match
pending payment
+ * @return transaction status
+ */
+enum ANASTASIS_DB_QueryStatus
+postgres_update_challenge_payment (void *cls,
+ const struct
+ ANASTASIS_CRYPTO_TruthPublicKeyP *
+ truth_public_key,
+ const struct
+ ANASTASIS_PaymentSecretP
*payment_identifier)
+{
+ struct PostgresClosure *pg = cls;
+ enum ANASTASIS_DB_QueryStatus qs;
+
+ check_connection (pg);
+ if (GNUNET_OK !=
+ begin_transaction (pg,
+ "update_challenge_payment"))
+ {
+ GNUNET_break (0);
+ return GNUNET_DB_STATUS_HARD_ERROR;
+ }
+
+ {
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_auto_from_type (payment_identifier),
+ GNUNET_PQ_query_param_auto_from_type (truth_public_key),
+ GNUNET_PQ_query_param_end
+ };
+
+ qs = GNUNET_PQ_eval_prepared_non_select (pg->conn,
+ "challenge_payment_done",
+ params);
+ if (0 >= qs)
+ {
+ /* payment made before, or unknown, or error => no further action! */
+ rollback (pg);
+ return qs;
+ }
+ }
+ return qs;
+}
+
/**
* Insert a new challenge code for a given challenge identified by the
challenge
* public key. The function will first check if there is already a valid code
@@ -1702,16 +1943,27 @@ libanastasis_plugin_db_postgres_init (void *cls)
"( user_id BYTEA PRIMARY KEY
CHECK(LENGTH(user_id)=32),"
" expiration_date TIMESTAMP NOT NULL"
");"),
- GNUNET_PQ_make_execute ("CREATE TABLE IF NOT EXISTS anastasis_payment"
- "(payment_id BIGSERIAL PRIMARY KEY,"
- " user_id BYTEA NOT NULL REFERENCES
anastasis_user(user_id),"
- " post_counter INT4 NOT NULL DEFAULT 0
CHECK(post_counter >= 0),"
- " amount_val INT8 NOT NULL," /* amount we were
paid */
- " amount_frac INT4 NOT NULL,"
- " payment_identifier BYTEA NOT NULL
CHECK(LENGTH(payment_identifier)=32),"
- " timestamp TIMESTAMP NOT NULL DEFAULT NOW(),"
- " paid BOOLEAN NOT NULL DEFAULT FALSE"
- ");"),
+ GNUNET_PQ_make_execute (
+ "CREATE TABLE IF NOT EXISTS anastasis_recdoc_payment"
+ "(payment_id BIGSERIAL PRIMARY KEY,"
+ " user_id BYTEA NOT NULL REFERENCES anastasis_user(user_id),"
+ " post_counter INT4 NOT NULL DEFAULT 0 CHECK(post_counter >= 0),"
+ " amount_val INT8 NOT NULL," /* amount we were
paid */
+ " amount_frac INT4 NOT NULL,"
+ " payment_identifier BYTEA NOT NULL
CHECK(LENGTH(payment_identifier)=32),"
+ " timestamp TIMESTAMP NOT NULL DEFAULT NOW(),"
+ " paid BOOLEAN NOT NULL DEFAULT FALSE"
+ ");"),
+ GNUNET_PQ_make_execute (
+ "CREATE TABLE IF NOT EXISTS anastasis_challenge_payment"
+ "(payment_id BIGSERIAL PRIMARY KEY,"
+ " truth_public_key BYTEA NOT NULL REFERENCES
anastasis_truth(truth_public_key),"
+ " amount_val INT8 NOT NULL," /* amount we were
paid */
+ " amount_frac INT4 NOT NULL,"
+ " payment_identifier BYTEA NOT NULL
CHECK(LENGTH(payment_identifier)=32),"
+ " timestamp TIMESTAMP NOT NULL DEFAULT NOW(),"
+ " paid BOOLEAN NOT NULL DEFAULT FALSE"
+ ");"),
GNUNET_PQ_make_execute (
"CREATE TABLE IF NOT EXISTS anastasis_recoverydocument"
"( user_id BYTEA NOT NULL REFERENCES anastasis_user(user_id),"
@@ -1755,8 +2007,8 @@ libanastasis_plugin_db_postgres_init (void *cls)
" expiration_date=$1"
" WHERE user_id=$2;",
2),
- GNUNET_PQ_make_prepare ("payment_insert",
- "INSERT INTO anastasis_payment "
+ GNUNET_PQ_make_prepare ("recdoc_payment_insert",
+ "INSERT INTO anastasis_recdoc_payment "
"(user_id"
",post_counter"
",amount_val"
@@ -1766,8 +2018,18 @@ libanastasis_plugin_db_postgres_init (void *cls)
") VALUES "
"($1, $2, $3, $4, $5, $6);",
4),
- GNUNET_PQ_make_prepare ("payment_done",
- "UPDATE anastasis_payment "
+ GNUNET_PQ_make_prepare ("challenge_payment_insert",
+ "INSERT INTO anastasis_challenge_payment "
+ "(truth_public_key"
+ ",amount_val"
+ ",amount_frac"
+ ",payment_identifier"
+ ",timestamp"
+ ") VALUES "
+ "($1, $2, $3, $4, $5);",
+ 5),
+ GNUNET_PQ_make_prepare ("recdoc_payment_done",
+ "UPDATE anastasis_recdoc_payment "
"SET"
" paid=TRUE "
"WHERE"
@@ -1777,32 +2039,63 @@ libanastasis_plugin_db_postgres_init (void *cls)
" AND"
" paid=FALSE;",
2),
- GNUNET_PQ_make_prepare ("payment_select",
+ GNUNET_PQ_make_prepare ("challenge_payment_done",
+ "UPDATE anastasis_challenge_payment "
+ "SET"
+ " paid=TRUE "
+ "WHERE"
+ " payment_identifier=$1"
+ " AND"
+ " truth_public_key=$2"
+ " AND"
+ " paid=FALSE;",
+ 2),
+ GNUNET_PQ_make_prepare ("recdoc_payment_select",
"SELECT"
" timestamp"
",post_counter"
",amount_val"
",amount_frac"
",paid"
- " FROM anastasis_payment"
+ " FROM anastasis_recdoc_payment"
+ " WHERE payment_identifier=$1;",
+ 1),
+ GNUNET_PQ_make_prepare ("challenge_payment_select",
+ "SELECT"
+ " timestamp"
+ ",amount_val"
+ ",amount_frac"
+ ",paid"
+ " FROM anastasis_challenge_payment"
" WHERE payment_identifier=$1;",
1),
- GNUNET_PQ_make_prepare ("payments_select",
+ GNUNET_PQ_make_prepare ("challenge_pending_payment_select",
+ "SELECT"
+ " payment_identifier"
+ ",amount_val"
+ ",amount_frac"
+ " FROM anastasis_challenge_payment"
+ " WHERE"
+ " paid=FALSE"
+ " AND"
+ " truth_public_key=$1;",
+ 1),
+ GNUNET_PQ_make_prepare ("recdoc_payments_select",
"SELECT"
" user_id"
",payment_identifier"
",amount_val"
",amount_frac"
- " FROM anastasis_payment"
+ " FROM anastasis_recdoc_payment"
" WHERE paid=FALSE;",
0),
- GNUNET_PQ_make_prepare ("payments_select_by_account",
+ GNUNET_PQ_make_prepare ("recdoc_payments_select_by_account",
"SELECT"
" timestamp"
",payment_identifier"
",amount_val"
",amount_frac"
- " FROM anastasis_payment"
+ " FROM anastasis_recdoc_payment"
" WHERE"
" paid=FALSE"
" AND"
@@ -1813,8 +2106,15 @@ libanastasis_plugin_db_postgres_init (void *cls)
"WHERE"
" expiration_date < $1;",
1),
- GNUNET_PQ_make_prepare ("gc_pending_payments",
- "DELETE FROM anastasis_payment "
+ GNUNET_PQ_make_prepare ("gc_recdoc_pending_payments",
+ "DELETE FROM anastasis_recdoc_payment "
+ "WHERE"
+ " paid=FALSE"
+ " AND"
+ " timestamp < $1;",
+ 1),
+ GNUNET_PQ_make_prepare ("gc_challenge_pending_payments",
+ "DELETE FROM anastasis_challenge_payment "
"WHERE"
" paid=FALSE"
" AND"
@@ -1883,13 +2183,13 @@ libanastasis_plugin_db_postgres_init (void *cls)
GNUNET_PQ_make_prepare ("postcounter_select",
"SELECT"
" post_counter"
- " FROM anastasis_payment"
+ " FROM anastasis_recdoc_payment"
" WHERE user_id=$1"
" AND payment_identifier=$2;",
2),
GNUNET_PQ_make_prepare ("postcounter_update",
"UPDATE "
- "anastasis_payment "
+ "anastasis_recdoc_payment "
"SET "
"post_counter=$1 "
"WHERE user_id =$2 "
@@ -1980,7 +2280,7 @@ libanastasis_plugin_db_postgres_init (void *cls)
plugin->rollback = &rollback;
plugin->commit = &commit_transaction;
plugin->store_recovery_document = &postgres_store_recovery_document;
- plugin->record_payment = &postgres_record_payment;
+ plugin->record_recdoc_payment = &postgres_record_recdoc_payment;
plugin->store_truth = &postgres_store_truth;
plugin->get_escrow_challenge = &postgres_get_escrow_challenge;
plugin->get_key_share = &postgres_get_key_share;
@@ -1996,6 +2296,10 @@ libanastasis_plugin_db_postgres_init (void *cls)
plugin->verify_challenge_code = &postgres_verify_challenge_code;
plugin->store_challenge_code = &postgres_store_challenge_code;
plugin->challenge_gc = &postgres_challenge_gc;
+ plugin->record_challenge_payment = &postgres_record_challenge_payment;
+ plugin->check_challenge_payment = &postgres_check_challenge_payment;
+ plugin->lookup_challenge_payment = &postgres_lookup_challenge_payment;
+ plugin->update_challenge_payment = &postgres_update_challenge_payment;
return plugin;
}
diff --git a/src/stasis/test_anastasis_db.c b/src/stasis/test_anastasis_db.c
index 7e20a82..e52447e 100644
--- a/src/stasis/test_anastasis_db.c
+++ b/src/stasis/test_anastasis_db.c
@@ -243,12 +243,11 @@ run (void *cls)
&valid_counter));
FAILIF (ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->record_payment (plugin->cls,
- &accountPubP,
- post_counter,
- &paymentSecretP,
- &amount));
-
+ plugin->record_recdoc_payment (plugin->cls,
+ &accountPubP,
+ post_counter,
+ &paymentSecretP,
+ &amount));
FAILIF (ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->increment_lifetime (plugin->cls,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: db changes payment,
gnunet <=