exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit 5521d156af02e11cf36b384a78e85c4e1a3f486b
parent 1ad546c050fe4c0c222d66d7d6ff8fed3b675f83
Author: Christian Grothoff <grothoff@gnunet.org>
Date:   Wed,  7 May 2025 17:23:21 +0200

merge 5-reserves_in, drop legi requirements

Diffstat:
Dsrc/exchangedb/0002-legitimization_requirements.sql | 104-------------------------------------------------------------------------------
Msrc/exchangedb/0002-reserves_in.sql | 7+++++++
Dsrc/exchangedb/0005-legitimization_requirements.sql | 45---------------------------------------------
Dsrc/exchangedb/0005-reserves_in.sql | 45---------------------------------------------
Msrc/exchangedb/exchange-0002.sql.in | 1-
Msrc/exchangedb/exchange-0005.sql.in | 1-
6 files changed, 7 insertions(+), 196 deletions(-)

diff --git a/src/exchangedb/0002-legitimization_requirements.sql b/src/exchangedb/0002-legitimization_requirements.sql @@ -1,104 +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 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 MERCHANTABILITY or FITNESS FOR --- A PARTICULAR PURPOSE. See the GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License along with --- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> --- - -CREATE FUNCTION create_table_legitimization_requirements( - IN partition_suffix TEXT DEFAULT NULL -) -RETURNS VOID -LANGUAGE plpgsql -AS $$ -BEGIN - PERFORM create_partitioned_table( - 'CREATE TABLE %I' - '(legitimization_requirement_serial_id INT8 GENERATED BY DEFAULT AS IDENTITY' - ',h_payto BYTEA NOT NULL CHECK (LENGTH(h_payto)=32)' - ',reserve_pub BYTEA' - ',required_checks TEXT NOT NULL' - ',UNIQUE (h_payto, required_checks)' - ') %s ;' - ,'legitimization_requirements' - ,'PARTITION BY HASH (h_payto)' - ,partition_suffix - ); - PERFORM comment_partitioned_table( - 'List of required legitimizations by account' - ,'legitimization_requirements' - ,partition_suffix - ); - PERFORM comment_partitioned_column( - 'unique ID for this legitimization requirement at the exchange' - ,'legitimization_requirement_serial_id' - ,'legitimization_requirements' - ,partition_suffix - ); - PERFORM comment_partitioned_column( - 'foreign key linking the entry to the wire_targets table, NOT a primary key (multiple legitimizations are possible per wire target)' - ,'h_payto' - ,'legitimization_requirements' - ,partition_suffix - ); - PERFORM comment_partitioned_column( - 'if h_payto refers to a reserve, this is its public key, NULL otherwise. It allows to lookup the corresponding reserve when the KYC process is done.' - ,'reserve_pub' - ,'legitimization_requirements' - ,partition_suffix - ); - PERFORM comment_partitioned_column( - 'space-separated list of required checks' - ,'required_checks' - ,'legitimization_requirements' - ,partition_suffix - ); -END -$$; - --- We need a separate function for this, as we call create_table only once but need to add --- those constraints to each partition which gets created -CREATE FUNCTION constrain_table_legitimization_requirements( - IN partition_suffix TEXT -) -RETURNS void -LANGUAGE plpgsql -AS $$ -DECLARE - partition_name TEXT; -BEGIN - partition_name = concat_ws('_', 'legitimization_requirements', partition_suffix); - EXECUTE FORMAT ( - 'ALTER TABLE ' || partition_name || ' ' - 'ADD CONSTRAINT ' || partition_name || '_serial_id_key ' - 'UNIQUE (legitimization_requirement_serial_id)'); -END -$$; - - -INSERT INTO exchange_tables - (name - ,version - ,action - ,partitioned - ,by_range) - VALUES - ('legitimization_requirements' - ,'exchange-0002' - ,'create' - ,TRUE - ,FALSE), - ('legitimization_requirements' - ,'exchange-0002' - ,'constrain' - ,TRUE - ,FALSE); diff --git a/src/exchangedb/0002-reserves_in.sql b/src/exchangedb/0002-reserves_in.sql @@ -111,6 +111,13 @@ BEGIN ' FOREIGN KEY (reserve_pub) ' ' REFERENCES reserves(reserve_pub) ON DELETE CASCADE' ); + EXECUTE FORMAT ( + 'ALTER TABLE ' || table_name || + ' ADD CONSTRAINT ' || table_name || '_wire_target_h_payto_foreign' + ' FOREIGN KEY (wire_source_h_payto)' + ' REFERENCES wire_targets (wire_target_h_payto)' + ' ON DELETE RESTRICT' + ); END $$; diff --git a/src/exchangedb/0005-legitimization_requirements.sql b/src/exchangedb/0005-legitimization_requirements.sql @@ -1,45 +0,0 @@ --- --- This file is part of TALER --- Copyright (C) 2024 Taler Systems SA --- --- TALER is free software; you can redistribute it and/or modify it under the --- terms of the GNU 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 MERCHANTABILITY or FITNESS FOR --- A PARTICULAR PURPOSE. See the GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License along with --- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> --- - -CREATE FUNCTION alter_table_legitimization_requirements5( - IN partition_suffix TEXT DEFAULT NULL -) -RETURNS VOID -LANGUAGE plpgsql -AS $$ -BEGIN - PERFORM create_partitioned_table( - 'DROP TABLE %I;' - ,'legitimization_requirements' - ,'' - ,partition_suffix - ); -END -$$; - - -INSERT INTO exchange_tables - (name - ,version - ,action - ,partitioned - ,by_range) - VALUES - ('legitimization_requirements5' - ,'exchange-0005' - ,'alter' - ,TRUE - ,FALSE); diff --git a/src/exchangedb/0005-reserves_in.sql b/src/exchangedb/0005-reserves_in.sql @@ -1,45 +0,0 @@ --- --- This file is part of TALER --- Copyright (C) 2024 Taler Systems SA --- --- TALER is free software; you can redistribute it and/or modify it under the --- terms of the GNU 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 MERCHANTABILITY or FITNESS FOR --- A PARTICULAR PURPOSE. See the GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License along with --- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> --- - -CREATE FUNCTION foreign_table_reserves_in5() -RETURNS void -LANGUAGE plpgsql -AS $$ -DECLARE - table_name TEXT DEFAULT 'reserves_in'; -BEGIN - EXECUTE FORMAT ( - 'ALTER TABLE ' || table_name || - ' ADD CONSTRAINT ' || table_name || '_wire_target_h_payto_foreign' - ' FOREIGN KEY (wire_source_h_payto)' - ' REFERENCES wire_targets (wire_target_h_payto)' - ' ON DELETE RESTRICT' - ); -END -$$; - -INSERT INTO exchange_tables - (name - ,version - ,action - ,partitioned - ,by_range) - VALUES - ('reserves_in5' - ,'exchange-0005' - ,'foreign' - ,TRUE - ,FALSE); diff --git a/src/exchangedb/exchange-0002.sql.in b/src/exchangedb/exchange-0002.sql.in @@ -69,7 +69,6 @@ COMMENT ON TYPE exchange_do_select_deposits_missing_wire_return_type #include "0002-legitimization_measures.sql" #include "0002-legitimization_outcomes.sql" #include "0002-legitimization_processes.sql" -#include "0002-legitimization_requirements.sql" #include "0002-reserves.sql" #include "0002-reserve_history.sql" #include "0002-reserves_in.sql" diff --git a/src/exchangedb/exchange-0005.sql.in b/src/exchangedb/exchange-0005.sql.in @@ -26,7 +26,6 @@ SET search_path TO exchange; #include "0005-aml_history.sql" #include "0005-kyc_events.sql" #include "0005-kycauths_in.sql" -#include "0005-reserves_in.sql" -- drops: #include "0005-aml_status.sql"