exchange-0020.sql (2281B)
1 -- 2 -- This file is part of TALER 3 -- Copyright (C) 2026 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 18 BEGIN; 19 20 SELECT _v.register_patch('exchange-0020', NULL, NULL); 21 22 SET search_path TO exchange; 23 24 25 -- Record which version of the refresh commitment (see #11862 and 26 -- enum TALER_RefreshCommitmentVersion) the client used for the melt, 27 -- so that the reveal can recompute the commitment the same way: 28 -- 29 -- 0 v27 clients, without transfer public keys 30 -- 1 vDOLDPLUS clients that sent the transfer public keys but did 31 -- not include them in the hash 32 -- 2 current version, with the transfer public keys in the hash 33 -- 34 -- Existing rows are from v27 clients (no transfer public keys) or from 35 -- vDOLDPLUS clients before the fix; new rows default to the current 36 -- version. 37 38 CREATE FUNCTION alter_table_refresh20() 39 RETURNS void 40 LANGUAGE plpgsql 41 AS $$ 42 BEGIN 43 ALTER TABLE refresh 44 ADD COLUMN rc_version INT4 NOT NULL DEFAULT (1); 45 COMMENT ON COLUMN refresh.rc_version 46 IS 'Version of the refresh commitment rc: 0 for v27 (no transfer public keys), 1 for vDOLDPLUS without the transfer public keys in the hash, 2 with them'; 47 UPDATE refresh 48 SET rc_version=0 49 WHERE transfer_pubs IS NULL; 50 ALTER TABLE refresh 51 ALTER COLUMN rc_version SET DEFAULT (2); 52 53 -- Auditor sync revisits pending melts and incomplete replica rows. 54 CREATE INDEX refresh_pending_reveal_idx ON refresh (refresh_id) 55 WHERE NOT revealed OR (rc_version <> 0 AND transfer_pubs IS NULL); 56 END 57 $$; 58 59 INSERT INTO exchange_tables 60 (name 61 ,version 62 ,action 63 ,partitioned 64 ,by_range) 65 VALUES 66 ('refresh20' 67 ,'exchange-0020' 68 ,'alter' 69 ,TRUE 70 ,FALSE); 71 72 COMMIT;