diff options
Diffstat (limited to 'src/backend/anastasis-httpd_policy_upload.c')
-rw-r--r-- | src/backend/anastasis-httpd_policy_upload.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/backend/anastasis-httpd_policy_upload.c b/src/backend/anastasis-httpd_policy_upload.c index 11f15e2..0bef15f 100644 --- a/src/backend/anastasis-httpd_policy_upload.c +++ b/src/backend/anastasis-httpd_policy_upload.c | |||
@@ -574,6 +574,10 @@ begin_payment (struct PolicyUploadContext *puc) | |||
574 | order_id = GNUNET_STRINGS_data_to_string_alloc ( | 574 | order_id = GNUNET_STRINGS_data_to_string_alloc ( |
575 | &puc->payment_identifier, | 575 | &puc->payment_identifier, |
576 | sizeof(struct ANASTASIS_PaymentSecretP)); | 576 | sizeof(struct ANASTASIS_PaymentSecretP)); |
577 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
578 | "Creating order for %u years with payment of %s\n", | ||
579 | puc->years_to_pay, | ||
580 | TALER_amount2s (&upload_fee)); | ||
577 | order = json_pack ("{s:o, s:s, s:[{s:s,s:I,s:s}], s:s }", | 581 | order = json_pack ("{s:o, s:s, s:[{s:s,s:I,s:s}], s:s }", |
578 | "amount", TALER_JSON_from_amount (&upload_fee), | 582 | "amount", TALER_JSON_from_amount (&upload_fee), |
579 | "summary", "Anastasis policy storage fee", | 583 | "summary", "Anastasis policy storage fee", |
@@ -846,7 +850,7 @@ AH_handler_policy_post ( | |||
846 | } | 850 | } |
847 | else | 851 | else |
848 | { | 852 | { |
849 | years = 0; | 853 | years = 1; |
850 | } | 854 | } |
851 | puc->end_date = GNUNET_TIME_relative_to_timestamp ( | 855 | puc->end_date = GNUNET_TIME_relative_to_timestamp ( |
852 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, | 856 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, |
@@ -865,6 +869,10 @@ AH_handler_policy_post ( | |||
865 | / GNUNET_TIME_UNIT_YEARS.rel_value_us; | 869 | / GNUNET_TIME_UNIT_YEARS.rel_value_us; |
866 | if (0 != (rem.rel_value_us % GNUNET_TIME_UNIT_YEARS.rel_value_us)) | 870 | if (0 != (rem.rel_value_us % GNUNET_TIME_UNIT_YEARS.rel_value_us)) |
867 | puc->years_to_pay++; | 871 | puc->years_to_pay++; |
872 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
873 | "Calculated years to pay to be %u until %s\n", | ||
874 | puc->years_to_pay, | ||
875 | GNUNET_TIME_absolute2s (puc->end_date.abs_time)); | ||
868 | 876 | ||
869 | if (puc->payment_identifier_provided) | 877 | if (puc->payment_identifier_provided) |
870 | { | 878 | { |
@@ -905,18 +913,14 @@ AH_handler_policy_post ( | |||
905 | 913 | ||
906 | if (! puc->payment_identifier_provided) | 914 | if (! puc->payment_identifier_provided) |
907 | { | 915 | { |
908 | struct TALER_Amount zero_amount; | ||
909 | enum GNUNET_DB_QueryStatus qs; | 916 | enum GNUNET_DB_QueryStatus qs; |
910 | struct GNUNET_TIME_Relative rel; | 917 | struct GNUNET_TIME_Relative rel; |
911 | 918 | ||
912 | TALER_amount_set_zero (AH_currency, | ||
913 | &zero_amount); | ||
914 | /* generate fresh payment identifier */ | 919 | /* generate fresh payment identifier */ |
915 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, | 920 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, |
916 | &puc->payment_identifier, | 921 | &puc->payment_identifier, |
917 | sizeof (struct ANASTASIS_PaymentSecretP)); | 922 | sizeof (struct ANASTASIS_PaymentSecretP)); |
918 | if (0 != TALER_amount_cmp (&AH_annual_fee, | 923 | if (! TALER_amount_is_zero (&AH_annual_fee)) |
919 | &zero_amount)) | ||
920 | { | 924 | { |
921 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 925 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
922 | "No payment identifier, requesting payment\n"); | 926 | "No payment identifier, requesting payment\n"); |
@@ -940,8 +944,8 @@ AH_handler_policy_post ( | |||
940 | ANASTASIS_MAX_YEARS_STORAGE); | 944 | ANASTASIS_MAX_YEARS_STORAGE); |
941 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 945 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
942 | "Policy lifetime is %s (%u years)\n", | 946 | "Policy lifetime is %s (%u years)\n", |
943 | GNUNET_STRINGS_relative_time_to_string (rel, | 947 | GNUNET_TIME_relative2s (rel, |
944 | GNUNET_YES), | 948 | true), |
945 | ANASTASIS_MAX_YEARS_STORAGE); | 949 | ANASTASIS_MAX_YEARS_STORAGE); |
946 | puc->paid_until = GNUNET_TIME_relative_to_timestamp (rel); | 950 | puc->paid_until = GNUNET_TIME_relative_to_timestamp (rel); |
947 | qs = db->update_lifetime (db->cls, | 951 | qs = db->update_lifetime (db->cls, |
@@ -983,7 +987,10 @@ AH_handler_policy_post ( | |||
983 | / GNUNET_TIME_UNIT_YEARS.rel_value_us; | 987 | / GNUNET_TIME_UNIT_YEARS.rel_value_us; |
984 | if (0 != (rem.rel_value_us % GNUNET_TIME_UNIT_YEARS.rel_value_us)) | 988 | if (0 != (rem.rel_value_us % GNUNET_TIME_UNIT_YEARS.rel_value_us)) |
985 | puc->years_to_pay++; | 989 | puc->years_to_pay++; |
986 | 990 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | |
991 | "Calculated years to pay to be %u until %s\n", | ||
992 | puc->years_to_pay, | ||
993 | GNUNET_TIME_absolute2s (puc->end_date.abs_time)); | ||
987 | if ( (ANASTASIS_DB_ACCOUNT_STATUS_VALID_HASH_RETURNED == as) && | 994 | if ( (ANASTASIS_DB_ACCOUNT_STATUS_VALID_HASH_RETURNED == as) && |
988 | (0 != puc->years_to_pay) ) | 995 | (0 != puc->years_to_pay) ) |
989 | { | 996 | { |