0002-auditor_deposit_confirmations.sql (2506B)
1 -- 2 -- This file is part of TALER 3 -- Copyright (C) 2014--2022 Taler Systems SA 4 -- 5 -- TALER is free software; you can redistribute it and/or modify it under the 6 -- terms of the GNU General Public License as published by the Free Software 7 -- Foundation; either version 3, or (at your option) any later version. 8 -- 9 -- TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 -- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 -- A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 -- 13 -- You should have received a copy of the GNU General Public License along with 14 -- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 -- 16 17 CREATE TABLE auditor_deposit_confirmations 18 (row_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE 19 ,h_contract_terms BYTEA NOT NULL CHECK (LENGTH(h_contract_terms)=64) 20 ,h_policy BYTEA NOT NULL CHECK (LENGTH(h_policy)=64) 21 ,h_wire BYTEA NOT NULL CHECK (LENGTH(h_wire)=64) 22 ,exchange_timestamp BIGINT NOT NULL 23 ,refund_deadline BIGINT NOT NULL 24 ,wire_deadline BIGINT NOT NULL 25 ,total_without_fee taler_amount NOT NULL 26 ,coin_pubs BYTEA[] NOT NULL CHECK (CARDINALITY(coin_pubs)>0) 27 ,coin_sigs BYTEA[] NOT NULL CHECK (CARDINALITY(coin_sigs)=CARDINALITY(coin_pubs)) 28 ,merchant_pub BYTEA NOT NULL CHECK (LENGTH(merchant_pub)=32) 29 ,exchange_sig BYTEA NOT NULL CHECK (LENGTH(exchange_sig)=64) 30 ,exchange_pub BYTEA NOT NULL CHECK (LENGTH(exchange_pub)=32) 31 ,master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64) 32 ,suppressed BOOLEAN NOT NULL DEFAULT FALSE 33 ,ancient BOOLEAN NOT NULL DEFAULT FALSE 34 ,PRIMARY KEY (h_contract_terms,h_wire,merchant_pub,exchange_sig,exchange_pub,master_sig) 35 ); 36 COMMENT ON TABLE auditor_deposit_confirmations 37 IS 'deposit confirmation sent to us by merchants; we must check that the exchange reported these properly.'; 38 39 CREATE INDEX IF NOT EXISTS auditor_deposit_confirmations_not_ancient 40 ON auditor_deposit_confirmations 41 (exchange_timestamp ASC) 42 WHERE NOT ancient; 43 44 CREATE OR REPLACE FUNCTION auditor_new_transactions_trigger() 45 RETURNS trigger 46 LANGUAGE plpgsql 47 AS $$ 48 BEGIN 49 NOTIFY XX81AFHF88YGN6ESNH39KR5VQE9MHD7GSSNMTCXB82SZ6T99ARHE0; 50 RETURN NEW; 51 END $$; 52 COMMENT ON FUNCTION auditor_new_transactions_trigger() 53 IS 'Call auditor_call_db_notify on new entry'; 54 55 CREATE TRIGGER auditor_notify_helper_deposits 56 AFTER INSERT 57 ON auditor.auditor_deposit_confirmations 58 EXECUTE PROCEDURE auditor_new_transactions_trigger();