donau

Donation authority for GNU Taler (experimental)
Log | Files | Refs | Submodules | README | LICENSE

commit 331456a2671351009192f9f857a6969a5be00df2
parent 2d9f9c201ce7a6264a87b825e541834870495155
Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch>
Date:   Sun, 14 Jan 2024 14:37:04 +0100

Merge remote-tracking branch 'refs/remotes/origin/master'

Diffstat:
Dsrc/donau/donau-httpd_csr.c | 133-------------------------------------------------------------------------------
Dsrc/donau/donau-httpd_csr.h | 42------------------------------------------
Msrc/donaudb/0002-donation_units.sql | 2+-
Msrc/donaudb/pg_add_donation_unit_key.c | 2+-
Msrc/donaudb/pg_get_donation_units.c | 4++--
Msrc/donaudb/pg_lookup_donation_unit.c | 4++--
6 files changed, 6 insertions(+), 181 deletions(-)

diff --git a/src/donau/donau-httpd_csr.c b/src/donau/donau-httpd_csr.c @@ -1,133 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2014-2022 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation; either version 3, - or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty - of CHARITYABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General - Public License along with TALER; see the file COPYING. If not, - see <http://www.gnu.org/licenses/> -*/ -/** - * @file donau-httpd_csr.c - * @brief Handle /csr requests - * @author Lucien Heuzeveldt - * @author Gian Demarmles - */ -#include "taler/platform.h" -#include <gnunet/gnunet_util_lib.h> -#include <jansson.h> -#include "taler/taler_json_lib.h" -#include "taler/taler_mhd_lib.h" -#include "donau-httpd_csr.h" -#include "donau-httpd_responses.h" -#include "donau-httpd_keys.h" - - -MHD_RESULT -DH_handler_csr_withdraw (struct DH_RequestContext *rc, - const json_t *root, - const char *const args[]) -{ - struct TALER_CsNonce nonce; - struct TALER_DenominationHashP denom_pub_hash; - struct TALER_DonauWithdrawValues ewv = { - .cipher = TALER_DENOMINATION_CS - }; - struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_fixed_auto ("nonce", - &nonce), - GNUNET_JSON_spec_fixed_auto ("denom_pub_hash", - &denom_pub_hash), - GNUNET_JSON_spec_end () - }; - struct DH_DenominationKey *dk; - - (void) args; - { - enum GNUNET_GenericReturnValue res; - - res = TALER_MHD_parse_json_data (rc->connection, - root, - spec); - if (GNUNET_OK != res) - return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; - } - - { - struct DH_KeyStateHandle *ksh; - - ksh = DH_keys_get_state (); - if (NULL == ksh) - { - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_DONAU_GENERIC_KEYS_MISSING, - NULL); - } - dk = DH_keys_denomination_by_hash_from_state (ksh, - &denom_pub_hash, - NULL, - NULL); - if (NULL == dk) - { - return DH_RESPONSE_reply_unknown_denom_pub_hash ( - rc->connection, - &denom_pub_hash); - } - if (GNUNET_TIME_absolute_is_future (dk->meta.start.abs_time)) - { - /* This denomination is not yet valid, no need to check - for idempotency! */ - return DH_RESPONSE_reply_expired_denom_pub_hash ( - rc->connection, - &denom_pub_hash, - TALER_EC_DONAU_GENERIC_DENOMINATION_VALIDITY_IN_FUTURE, - "csr-withdraw"); - } - if (TALER_DENOMINATION_CS != dk->denom_pub.cipher) - { - /* denomination is valid but not for CS */ - return DH_RESPONSE_reply_invalid_denom_cipher_for_operation ( - rc->connection, - &denom_pub_hash); - } - } - - /* derive r_pub */ - { - enum TALER_ErrorCode ec; - const struct DH_CsDeriveData cdd = { - .h_denom_pub = &denom_pub_hash, - .nonce = &nonce - }; - - ec = DH_keys_denomination_cs_r_pub (&cdd, - false, - &ewv.details.cs_values); - if (TALER_EC_NONE != ec) - { - GNUNET_break (0); - return TALER_MHD_reply_with_ec (rc->connection, - ec, - NULL); - } - } - - return TALER_MHD_REPLY_JSON_PACK ( - rc->connection, - MHD_HTTP_OK, - TALER_JSON_pack_donau_withdraw_values ("ewv", - &ewv)); -} - - -/* end of donau-httpd_csr.c */ diff --git a/src/donau/donau-httpd_csr.h b/src/donau/donau-httpd_csr.h @@ -1,42 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2014-2021 Taler Systems SA - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU Affero General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of CHARITYABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License along with - TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -*/ -/** - * @file donau-httpd_csr.h - * @brief Handle /csr-* requests - * @author Lucien Heuzeveldt - * @author Gian Demarmles - */ -#ifndef DONAU_HTTPD_CSR_H -#define DONAU_HTTPD_CSR_H - -#include <microhttpd.h> -#include "donau-httpd.h" - - -/** - * Handle a "/csr-withdraw" request. - * - * @param rc request context - * @param root uploaded JSON data - * @param args empty array - * @return MHD result code - */ -MHD_RESULT -DH_handler_csr_withdraw (struct DH_RequestContext *rc, - const json_t *root, - const char *const args[]); - -#endif diff --git a/src/donaudb/0002-donation_units.sql b/src/donaudb/0002-donation_units.sql @@ -19,7 +19,7 @@ CREATE TABLE donation_units ,donation_unit_hash BYTEA PRIMARY KEY CHECK (LENGTH(donation_unit_hash)=64) ,donation_unit_pub BYTEA UNIQUE NOT NULL ,validity_year INT4 NOT NULL - ,donation_unit taler_amount NOT NULL + ,value taler_amount NOT NULL ); COMMENT ON TABLE donation_units IS 'Main donation_unit table. All the valid donation units the Donau knows about.'; diff --git a/src/donaudb/pg_add_donation_unit_key.c b/src/donaudb/pg_add_donation_unit_key.c @@ -48,7 +48,7 @@ DH_PG_add_donation_unit_key ( "(donation_unit_hash" ",donation_unit_pub" ",validity_year" - ",taler_amount" + ",value" ") VALUES " "($1, $2, $3, $4);"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, diff --git a/src/donaudb/pg_get_donation_units.c b/src/donaudb/pg_get_donation_units.c @@ -37,7 +37,7 @@ DH_PG_get_donation_units ( struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("validity_year", &meta->validity_year), - TALER_PQ_RESULT_SPEC_AMOUNT ("amount", + TALER_PQ_RESULT_SPEC_AMOUNT ("value", &meta->value), GNUNET_PQ_result_spec_end }; @@ -46,7 +46,7 @@ DH_PG_get_donation_units ( "get_donation_units", "SELECT" " validity_year" - ",amount" + ",value" " FROM donation_units"); return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "get_donation_units", diff --git a/src/donaudb/pg_lookup_donation_unit.c b/src/donaudb/pg_lookup_donation_unit.c @@ -39,7 +39,7 @@ DH_PG_lookup_donation_unit ( struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("validity_year", &meta->validity_year), - TALER_PQ_RESULT_SPEC_AMOUNT ("amount", + TALER_PQ_RESULT_SPEC_AMOUNT ("value", &meta->value), GNUNET_PQ_result_spec_end }; @@ -48,7 +48,7 @@ DH_PG_lookup_donation_unit ( "lookup_donation_unit", "SELECT" " validity_year" - ",amount" + ",value" " FROM donation_units" " WHERE donation_unit_hash=$1;"); return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,