[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated (fb99888 -> bc90519)
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated (fb99888 -> bc90519) |
Date: |
Tue, 01 Sep 2020 18:47:13 +0200 |
This is an automated email from the git hooks/post-receive script.
dennis-neufeld pushed a change to branch master
in repository anastasis.
from fb99888 fix linker invocation
new 9b19a4d fixed Makefile (because error with gtk)
new c955643 better debugging message
new 4d530fd fix some payment logic
new bc90519 Merge branch 'master' of ssh://git.taler.net/anastasis into
master
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/backend/anastasis-httpd_policy_upload.c | 109 +++++++++++++++++-----------
src/cli/anastasis-cli-splitter.c | 3 +-
src/lib/Makefile.am | 1 +
src/stasis/plugin_anastasis_postgres.c | 44 ++++++++---
4 files changed, 103 insertions(+), 54 deletions(-)
diff --git a/src/backend/anastasis-httpd_policy_upload.c
b/src/backend/anastasis-httpd_policy_upload.c
index e12506a..ca7f33b 100644
--- a/src/backend/anastasis-httpd_policy_upload.c
+++ b/src/backend/anastasis-httpd_policy_upload.c
@@ -669,6 +669,12 @@ AH_handler_policy_post (struct MHD_Connection *connection,
{
struct PolicyUploadContext *puc;
struct ANASTASIS_CRYPTO_AccountPublicKeyP accountPubP;
+ struct TALER_Amount zero_amount;
+ bool zero_cost = false;
+
+ TALER_amount_get_zero (AH_currency, &zero_amount);
+ if (0 == TALER_amount_cmp (&AH_annual_fee, &zero_amount))
+ zero_cost = true;
puc = *con_cls;
if (NULL == puc)
@@ -796,7 +802,9 @@ AH_handler_policy_post (struct MHD_Connection *connection,
"Anastasis-Policy-Signature does
not include a base32-encoded EdDSA signature");
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Account Signature to save: %s\n",
+ "At %s:%d Account Signature to save is: %s\n",
+ __FILE__,
+ __LINE__,
TALER_B2S (&puc->account_sig));
}
{
@@ -848,10 +856,34 @@ AH_handler_policy_post (struct MHD_Connection *connection,
{
struct GNUNET_HashCode hc;
enum ANASTASIS_DB_QueryStatus qs;
- struct TALER_Amount zero_cost;
+ const char *pay_id;
+
+ pay_id = MHD_lookup_connection_value (connection,
+ MHD_HEADER_KIND,
+ "Payment-Identifier");
+ if ( pay_id &&
+ (GNUNET_OK !=
+ GNUNET_STRINGS_string_to_data (pay_id,
+ strlen (pay_id),
+ &puc->payment_identifier,
+ sizeof (struct
+ ANASTASIS_PaymentSecretP)))
)
+ {
+ GNUNET_break_op (0);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_BAD_REQUEST,
+ // FIXME: find error code
+ TALER_EC_SYNC_BAD_IF_MATCH,
+ "Payment-Identifier does not
include a base32-encoded Payment-Identifier");
+ }
+ if (pay_id)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "At %s:%d Payment-Identifier from header is: %s\n",
+ __FILE__,
+ __LINE__,
+ TALER_B2S (&puc->payment_identifier));
- TALER_amount_get_zero (AH_currency, &zero_cost);
- if (0 == TALER_amount_cmp (&AH_annual_fee, &zero_cost))
+ if (! pay_id)
{
// generate new payment identifier
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
@@ -859,22 +891,41 @@ AH_handler_policy_post (struct MHD_Connection *connection,
sizeof (
struct ANASTASIS_PaymentSecretP));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Payment-Identifier generated: %s\n",
+ "At %s:%d Payment-Identifier generated is: %s\n",
+ __FILE__,
+ __LINE__,
TALER_B2S (&puc->payment_identifier));
- int post_counter = 10;
+ if (zero_cost)
+ {
+ /** FIXME: not really reasonable */
+ int post_counter = 10;
+
+ qs = db->record_payment (db->cls,
+ &accountPubP,
+ post_counter,
+ &puc->payment_identifier,
+ &AH_annual_fee);
+ if (qs >= 0)
+ {
+ qs = db->increment_lifetime (db->cls,
+ &accountPubP,
+ &puc->payment_identifier,
+ GNUNET_TIME_UNIT_YEARS);
+ }
+ if (qs < 0)
+ return handle_database_error (puc,
+ qs);
+ }
- qs = db->record_payment (db->cls,
- &accountPubP,
- post_counter,
- &puc->payment_identifier,
- &AH_annual_fee);
- if (qs >= 0)
+ else
{
- qs = db->increment_lifetime (db->cls,
- &accountPubP,
- &puc->payment_identifier,
- GNUNET_TIME_UNIT_YEARS);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "At %s:%d Payment is required, starting payment
process\n",
+ __FILE__,
+ __LINE__);
+ return begin_payment (puc,
+ GNUNET_NO);
}
}
@@ -939,32 +990,6 @@ AH_handler_policy_post (struct MHD_Connection *connection,
"Upload starting\n");
return MHD_YES;
}
- {
- // Check if header contains Payment-Identifier
- const char *pay_id;
-
- pay_id = MHD_lookup_connection_value (connection,
- MHD_HEADER_KIND,
- "Payment-Identifier");
- if ( (NULL != pay_id) &&
- (GNUNET_OK !=
- GNUNET_STRINGS_string_to_data (pay_id,
- strlen (pay_id),
- &puc->payment_identifier,
- sizeof (struct
- ANASTASIS_PaymentSecretP))) )
- {
- GNUNET_break_op (0);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_BAD_REQUEST,
- // FIXME: find error code
- TALER_EC_SYNC_BAD_IF_MATCH,
- "Payment-Identifier does not include
a base32-encoded Payment-Identifier");
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Payment-Identifier from header: %s\n",
- TALER_B2S (&puc->payment_identifier));
- }
/* handle upload */
if (0 != *recovery_data_size)
diff --git a/src/cli/anastasis-cli-splitter.c b/src/cli/anastasis-cli-splitter.c
index 34bca71..5c0ef46 100644
--- a/src/cli/anastasis-cli-splitter.c
+++ b/src/cli/anastasis-cli-splitter.c
@@ -383,7 +383,8 @@ secret_share_payment_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"At %s:%d we are in SPC\n",
__FILE__, __LINE__);
- if (sss->http_status != MHD_HTTP_PAYMENT_REQUIRED)
+ if (! ((sss->http_status == MHD_HTTP_PAYMENT_REQUIRED)
+ || (sss->http_status == MHD_HTTP_NO_CONTENT) ))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d in %s:%u\n",
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 0e2eac1..3bf9ac8 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -31,6 +31,7 @@ libanastasisrest_la_LIBADD = \
-ljansson \
-ltalerjson \
-ltalerutil \
+ -ltalerjson
$(XLIB)
if HAVE_LIBCURL
diff --git a/src/stasis/plugin_anastasis_postgres.c
b/src/stasis/plugin_anastasis_postgres.c
index 0fe5831..412b2f4 100644
--- a/src/stasis/plugin_anastasis_postgres.c
+++ b/src/stasis/plugin_anastasis_postgres.c
@@ -426,7 +426,9 @@ postgres_store_recovery_document (void *cls,
/* get the version for the recoverydocument */
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Public key used to query db: %s\n",
+ "At %s:%d Public key used to query db is: %s\n",
+ __FILE__,
+ __LINE__,
TALER_B2S (anastasis_pub));
struct GNUNET_PQ_QueryParam params[] = {
@@ -467,7 +469,9 @@ postgres_store_recovery_document (void *cls,
/* First, check if account exists */
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Public key used to query db: %s\n",
+ "At %s:%d Public key used to query db is: %s\n",
+ __FILE__,
+ __LINE__,
TALER_B2S (anastasis_pub));
struct GNUNET_PQ_QueryParam params[] = {
@@ -502,7 +506,9 @@ postgres_store_recovery_document (void *cls,
// lookup if the user has enough uploads left and decrement
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Payment-Identifier to query db: %s\n",
+ "At %s:%d Payment-Identifier used to query db is: %s\n",
+ __FILE__,
+ __LINE__,
TALER_B2S (payment_secret));
{
struct GNUNET_PQ_QueryParam params[] = {
@@ -536,7 +542,9 @@ postgres_store_recovery_document (void *cls,
return ANASTASIS_DB_STATUS_HARD_ERROR;
case ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Post counter from db: %i\n",
+ "At %s:%d Post counter from db is: %u\n",
+ __FILE__,
+ __LINE__,
postcounter);
break;
default:
@@ -589,7 +597,9 @@ postgres_store_recovery_document (void *cls,
/* check if existing recovery_data conflicts */
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Public key used to query db: %s\n",
+ "At %s:%d Public key used to query db is: %s\n",
+ __FILE__,
+ __LINE__,
TALER_B2S (anastasis_pub));
struct GNUNET_PQ_QueryParam params[] = {
@@ -717,7 +727,9 @@ postgres_increment_lifetime (void *cls,
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Public key used to query db: %s\n",
+ "At %s:%d Public key used to query db is: %s\n",
+ __FILE__,
+ __LINE__,
TALER_B2S (anastasis_pub));
struct GNUNET_PQ_QueryParam params[] = {
@@ -748,7 +760,9 @@ postgres_increment_lifetime (void *cls,
{
// user does not exist, create new one
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Public key to be saved to user db: %s\n",
+ "At %s:%d Public key to be saved to user db is: %s\n",
+ __FILE__,
+ __LINE__,
TALER_B2S (anastasis_pub));
struct GNUNET_PQ_QueryParam params[] = {
@@ -842,7 +856,9 @@ postgres_record_payment (void *cls,
const struct TALER_Amount *amount)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Post counter to save: %i\n",
+ "At %s:%d Post counter to save is: %u\n",
+ __FILE__,
+ __LINE__,
post_counter);
struct PostgresClosure *pg = cls;
@@ -865,7 +881,9 @@ postgres_record_payment (void *cls,
// if user exists, otherwise we have to create one
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Public key used to query user db: %s\n",
+ "At %s:%d Public key used to query user db is: %s\n",
+ __FILE__,
+ __LINE__,
TALER_B2S (anastasis_pub));
struct GNUNET_PQ_QueryParam params[] = {
@@ -895,7 +913,9 @@ postgres_record_payment (void *cls,
{
// create new user
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Public key to be saved to user db: %s\n",
+ "At %s:%d Public key to be saved to user db is: %s\n",
+ __FILE__,
+ __LINE__,
TALER_B2S (anastasis_pub));
struct GNUNET_PQ_QueryParam params[] = {
@@ -1138,7 +1158,9 @@ postgres_lookup_account (void *cls,
struct GNUNET_HashCode *recovery_data_hash)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Public key used to query db: %s\n",
+ "At %s:%d Public key used to query db is: %s\n",
+ __FILE__,
+ __LINE__,
TALER_B2S (anastasis_pub));
struct PostgresClosure *pg = cls;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-anastasis] branch master updated (fb99888 -> bc90519),
gnunet <=