aboutsummaryrefslogtreecommitdiff
path: root/src/auditordb
diff options
context:
space:
mode:
authornic <nic@eigel.ch>2023-09-25 23:13:08 +0200
committernic <nic@eigel.ch>2023-09-25 23:13:08 +0200
commit732ba9c860b1e7cace1d582bcaf891dbc48f6200 (patch)
tree22458dba6e0074e14ac55e877be387bc7ae34b3e /src/auditordb
parent0a87c2d89bb7c971e2097cbdd45dfe5972c16e85 (diff)
Splitted auditor-0001 and removed master_pub
Diffstat (limited to 'src/auditordb')
-rw-r--r--src/auditordb/0002-auditor_balance_summary.sql40
-rw-r--r--src/auditordb/0002-auditor_denomination_pending.sql38
-rw-r--r--src/auditordb/0002-auditor_exchange_signkeys.sql25
-rw-r--r--src/auditordb/0002-auditor_historic_denomination_revenue.sql28
-rw-r--r--src/auditordb/0002-auditor_historic_reserve_summary.sql28
-rw-r--r--src/auditordb/0002-auditor_predicted_result.sql24
-rw-r--r--src/auditordb/0002-auditor_progress_aggregation.sql23
-rw-r--r--src/auditordb/0002-auditor_progress_coin.sql31
-rw-r--r--src/auditordb/0002-auditor_progress_deposit_confirmation.sql23
-rw-r--r--src/auditordb/0002-auditor_progress_purse.sql27
-rw-r--r--src/auditordb/0002-auditor_progress_reserve.sql24
-rw-r--r--src/auditordb/0002-auditor_purse_summary.sql23
-rw-r--r--src/auditordb/0002-auditor_purses.sql31
-rw-r--r--src/auditordb/0002-auditor_reserve_balance.sql34
-rw-r--r--src/auditordb/0002-auditor_reserves.sql42
-rw-r--r--src/auditordb/0002-auditor_wire_fee_balance.sql22
-rw-r--r--src/auditordb/0002-deposit_confirmations.sql35
-rw-r--r--src/auditordb/0002-wire_auditor_account_progress.sql27
-rw-r--r--src/auditordb/0002-wire_auditor_progress.sql21
-rw-r--r--src/auditordb/auditor-0002.sql39
-rw-r--r--src/auditordb/auditor-0002.sql.in42
21 files changed, 627 insertions, 0 deletions
diff --git a/src/auditordb/0002-auditor_balance_summary.sql b/src/auditordb/0002-auditor_balance_summary.sql
new file mode 100644
index 000000000..ffb8e4fae
--- /dev/null
+++ b/src/auditordb/0002-auditor_balance_summary.sql
@@ -0,0 +1,40 @@
+--
+-- 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 TABLE IF NOT EXISTS auditor_balance_summary
+ ,denom_balance_val INT8 NOT NULL
+ ,denom_balance_frac INT4 NOT NULL
+ ,deposit_fee_balance_val INT8 NOT NULL
+ ,deposit_fee_balance_frac INT4 NOT NULL
+ ,melt_fee_balance_val INT8 NOT NULL
+ ,melt_fee_balance_frac INT4 NOT NULL
+ ,refund_fee_balance_val INT8 NOT NULL
+ ,refund_fee_balance_frac INT4 NOT NULL
+ ,purse_fee_balance_val INT8 NOT NULL
+ ,purse_fee_balance_frac INT4 NOT NULL
+ ,open_deposit_fee_balance_val INT8 NOT NULL
+ ,open_deposit_fee_balance_frac INT4 NOT NULL
+ ,risk_val INT8 NOT NULL
+ ,risk_frac INT4 NOT NULL
+ ,loss_val INT8 NOT NULL
+ ,loss_frac INT4 NOT NULL
+ ,irregular_loss_val INT8 NOT NULL
+ ,irregular_loss_frac INT4 NOT NULL
+ );
+COMMENT ON TABLE auditor_balance_summary
+ IS 'the sum of the outstanding coins from auditor_denomination_pending (denom_pubs must belong to the respectives exchange master public key); it represents the auditor_balance_summary of the exchange at this point (modulo unexpected historic_loss-style events where denomination keys are compromised)';
+COMMENT ON COLUMN auditor_balance_summary.denom_balance_frac
+ IS 'total amount we should have in escrow for all denominations'; \ No newline at end of file
diff --git a/src/auditordb/0002-auditor_denomination_pending.sql b/src/auditordb/0002-auditor_denomination_pending.sql
new file mode 100644
index 000000000..e03febfec
--- /dev/null
+++ b/src/auditordb/0002-auditor_denomination_pending.sql
@@ -0,0 +1,38 @@
+--
+-- 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 TABLE IF NOT EXISTS auditor_denomination_pending
+(denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64)
+ ,denom_balance_val INT8 NOT NULL
+ ,denom_balance_frac INT4 NOT NULL
+ ,denom_loss_val INT8 NOT NULL
+ ,denom_loss_frac INT4 NOT NULL
+ ,num_issued INT8 NOT NULL
+ ,denom_risk_val INT8 NOT NULL
+ ,denom_risk_frac INT4 NOT NULL
+ ,recoup_loss_val INT8 NOT NULL
+ ,recoup_loss_frac INT4 NOT NULL
+ );
+COMMENT ON TABLE auditor_denomination_pending
+ IS 'outstanding denomination coins that the exchange is aware of and what the respective balances are (outstanding as well as issued overall which implies the maximum value at risk).';
+COMMENT ON COLUMN auditor_denomination_pending.num_issued
+ IS 'counts the number of coins issued (withdraw, refresh) of this denomination';
+COMMENT ON COLUMN auditor_denomination_pending.denom_risk_val
+ IS 'amount that could theoretically be lost in the future due to recoup operations';
+COMMENT ON COLUMN auditor_denomination_pending.denom_loss_val
+ IS 'amount that was lost due to failures by the exchange';
+COMMENT ON COLUMN auditor_denomination_pending.recoup_loss_val
+ IS 'amount actually lost due to recoup operations after a revocation'; \ No newline at end of file
diff --git a/src/auditordb/0002-auditor_exchange_signkeys.sql b/src/auditordb/0002-auditor_exchange_signkeys.sql
new file mode 100644
index 000000000..dbd15cf71
--- /dev/null
+++ b/src/auditordb/0002-auditor_exchange_signkeys.sql
@@ -0,0 +1,25 @@
+--
+-- 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 TABLE IF NOT EXISTS auditor_exchange_signkeys
+ ,ep_start INT8 NOT NULL
+ ,ep_expire INT8 NOT NULL
+ ,ep_end INT8 NOT NULL
+ ,exchange_pub BYTEA NOT NULL CHECK (LENGTH(exchange_pub)=32)
+ ,master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64)
+ );
+COMMENT ON TABLE auditor_exchange_signkeys
+ IS 'list of the online signing keys of exchanges we are auditing'; \ No newline at end of file
diff --git a/src/auditordb/0002-auditor_historic_denomination_revenue.sql b/src/auditordb/0002-auditor_historic_denomination_revenue.sql
new file mode 100644
index 000000000..ac8b9c9fc
--- /dev/null
+++ b/src/auditordb/0002-auditor_historic_denomination_revenue.sql
@@ -0,0 +1,28 @@
+--
+-- 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 TABLE IF NOT EXISTS auditor_historic_denomination_revenue
+ ,denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64)
+ ,revenue_timestamp INT8 NOT NULL
+ ,revenue_balance_val INT8 NOT NULL
+ ,revenue_balance_frac INT4 NOT NULL
+ ,loss_balance_val INT8 NOT NULL
+ ,loss_balance_frac INT4 NOT NULL
+ );
+COMMENT ON TABLE auditor_historic_denomination_revenue
+ IS 'Table with historic profits; basically, when a denom_pub has expired and everything associated with it is garbage collected, the final profits end up in here; note that the denom_pub here is not a foreign key, we just keep it as a reference point.';
+COMMENT ON COLUMN auditor_historic_denomination_revenue.revenue_balance_val
+ IS 'the sum of all of the profits we made on the coin except for withdraw fees (which are in historic_reserve_revenue); so this includes the deposit, melt and refund fees';
diff --git a/src/auditordb/0002-auditor_historic_reserve_summary.sql b/src/auditordb/0002-auditor_historic_reserve_summary.sql
new file mode 100644
index 000000000..78bffd325
--- /dev/null
+++ b/src/auditordb/0002-auditor_historic_reserve_summary.sql
@@ -0,0 +1,28 @@
+--
+-- 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 TABLE IF NOT EXISTS auditor_historic_reserve_summary
+ ,start_date INT8 NOT NULL
+ ,end_date INT8 NOT NULL
+ ,reserve_profits_val INT8 NOT NULL
+ ,reserve_profits_frac INT4 NOT NULL
+ );
+COMMENT ON TABLE auditor_historic_reserve_summary
+ IS 'historic profits from reserves; we eventually GC auditor_historic_reserve_revenue, and then store the totals in here (by time intervals).';
+
+CREATE INDEX IF NOT EXISTS auditor_historic_reserve_summary_by_master_pub_start_date
+ ON auditor_historic_reserve_summary
+ (start_date); \ No newline at end of file
diff --git a/src/auditordb/0002-auditor_predicted_result.sql b/src/auditordb/0002-auditor_predicted_result.sql
new file mode 100644
index 000000000..cc39afb1c
--- /dev/null
+++ b/src/auditordb/0002-auditor_predicted_result.sql
@@ -0,0 +1,24 @@
+--
+-- 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 TABLE IF NOT EXISTS auditor_predicted_result
+ ,balance_val INT8 NOT NULL
+ ,balance_frac INT4 NOT NULL
+ ,drained_val INT8 NOT NULL
+ ,drained_frac INT4 NOT NULL
+ );
+COMMENT ON TABLE auditor_predicted_result
+ IS 'Table with the sum of the ledger, auditor_historic_revenue and the auditor_reserve_balance and the drained profits. This is the final amount that the exchange should have in its bank account right now (and the total amount drained as profits to non-escrow accounts).';
diff --git a/src/auditordb/0002-auditor_progress_aggregation.sql b/src/auditordb/0002-auditor_progress_aggregation.sql
new file mode 100644
index 000000000..033d63be7
--- /dev/null
+++ b/src/auditordb/0002-auditor_progress_aggregation.sql
@@ -0,0 +1,23 @@
+--
+-- 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 TABLE IF NOT EXISTS auditor_progress_aggregation
+ ,last_wire_out_serial_id INT8 NOT NULL DEFAULT 0
+ -- ,PRIMARY KEY (master_pub)
+ );
+COMMENT ON TABLE auditor_progress_aggregation
+ IS 'information as to which transactions the auditor has processed in the exchange database. Used for SELECTing the
+ statements to process. The indices include the last serial ID from the respective tables that we have processed. Thus, we need to select those table entries that are strictly larger (and process in monotonically increasing order).';
diff --git a/src/auditordb/0002-auditor_progress_coin.sql b/src/auditordb/0002-auditor_progress_coin.sql
new file mode 100644
index 000000000..8f555164f
--- /dev/null
+++ b/src/auditordb/0002-auditor_progress_coin.sql
@@ -0,0 +1,31 @@
+--
+-- 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 TABLE IF NOT EXISTS auditor_progress_coin
+ ,last_withdraw_serial_id INT8 NOT NULL DEFAULT 0
+ ,last_deposit_serial_id INT8 NOT NULL DEFAULT 0
+ ,last_melt_serial_id INT8 NOT NULL DEFAULT 0
+ ,last_refund_serial_id INT8 NOT NULL DEFAULT 0
+ ,last_recoup_serial_id INT8 NOT NULL DEFAULT 0
+ ,last_recoup_refresh_serial_id INT8 NOT NULL DEFAULT 0
+ ,last_open_deposits_serial_id INT8 NOT NULL DEFAULT 0
+ ,last_purse_deposits_serial_id INT8 NOT NULL DEFAULT 0
+ ,last_purse_decision_serial_id INT8 NOT NULL DEFAULT 0
+ -- ,PRIMARY KEY (master_pub)
+ );
+COMMENT ON TABLE auditor_progress_coin
+ IS 'information as to which transactions the auditor has processed in the exchange database. Used for SELECTing the
+ statements to process. The indices include the last serial ID from the respective tables that we have processed. Thus, we need to select those table entries that are strictly larger (and process in monotonically increasing order).';
diff --git a/src/auditordb/0002-auditor_progress_deposit_confirmation.sql b/src/auditordb/0002-auditor_progress_deposit_confirmation.sql
new file mode 100644
index 000000000..73d3c09db
--- /dev/null
+++ b/src/auditordb/0002-auditor_progress_deposit_confirmation.sql
@@ -0,0 +1,23 @@
+--
+-- 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 TABLE IF NOT EXISTS auditor_progress_deposit_confirmation
+ ,last_deposit_confirmation_serial_id INT8 NOT NULL DEFAULT 0
+ --,PRIMARY KEY (master_pub)
+ );
+COMMENT ON TABLE auditor_progress_deposit_confirmation
+ IS 'information as to which transactions the auditor has processed in the exchange database. Used for SELECTing the
+ statements to process. The indices include the last serial ID from the respective tables that we have processed. Thus, we need to select those table entries that are strictly larger (and process in monotonically increasing order).';
diff --git a/src/auditordb/0002-auditor_progress_purse.sql b/src/auditordb/0002-auditor_progress_purse.sql
new file mode 100644
index 000000000..29e14dc98
--- /dev/null
+++ b/src/auditordb/0002-auditor_progress_purse.sql
@@ -0,0 +1,27 @@
+--
+-- 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 TABLE IF NOT EXISTS auditor_progress_purse
+ ,last_purse_request_serial_id INT8 NOT NULL DEFAULT 0
+ ,last_purse_decision_serial_id INT8 NOT NULL DEFAULT 0
+ ,last_purse_merges_serial_id INT8 NOT NULL DEFAULT 0
+ ,last_account_merges_serial_id INT8 NOT NULL DEFAULT 0
+ ,last_purse_deposits_serial_id INT8 NOT NULL DEFAULT 0
+ -- ,PRIMARY KEY (master_pub)
+ );
+COMMENT ON TABLE auditor_progress_purse
+ IS 'information as to which purses the purse auditor has processed in the exchange database. Used for SELECTing the
+ statements to process. The indices include the last serial ID from the respective tables that we have processed. Thus, we need to select those table entries that are strictly larger (and process in monotonically increasing order).';
diff --git a/src/auditordb/0002-auditor_progress_reserve.sql b/src/auditordb/0002-auditor_progress_reserve.sql
new file mode 100644
index 000000000..5b392f42e
--- /dev/null
+++ b/src/auditordb/0002-auditor_progress_reserve.sql
@@ -0,0 +1,24 @@
+--
+-- 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 TABLE IF NOT EXISTS auditor_progress_reserve
+ ,reserve_name TEXT NOT NULL
+ ,serial_id INT8 NOT NULL
+ -- ,PRIMARY KEY (master_pub)
+ );
+COMMENT ON TABLE auditor_progress_reserve
+ IS 'information as to which transactions the reserve auditor has processed in the exchange database. Used for SELECTing the
+ statements to process. The indices include the last serial ID from the respective tables that we have processed. Thus, we need to select those table entries that are strictly larger (and process in monotonically increasing order).';
diff --git a/src/auditordb/0002-auditor_purse_summary.sql b/src/auditordb/0002-auditor_purse_summary.sql
new file mode 100644
index 000000000..7a3a1bda7
--- /dev/null
+++ b/src/auditordb/0002-auditor_purse_summary.sql
@@ -0,0 +1,23 @@
+--
+-- 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 TABLE IF NOT EXISTS auditor_purse_summary
+ ,balance_val INT8 NOT NULL
+ ,balance_frac INT4 NOT NULL
+ ,open_purses INT8 NOT NULL
+ );
+COMMENT ON TABLE auditor_purse_summary
+ IS 'sum of the balances in open purses'; \ No newline at end of file
diff --git a/src/auditordb/0002-auditor_purses.sql b/src/auditordb/0002-auditor_purses.sql
new file mode 100644
index 000000000..9dd1286f3
--- /dev/null
+++ b/src/auditordb/0002-auditor_purses.sql
@@ -0,0 +1,31 @@
+--
+-- 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 TABLE IF NOT EXISTS auditor_purses
+(purse_pub BYTEA NOT NULL CHECK(LENGTH(purse_pub)=32)
+ ,balance_val INT8 NOT NULL DEFAULT(0)
+ ,balance_frac INT4 NOT NULL DEFAULT(0)
+ ,target_val INT8 NOT NULL
+ ,target_frac INT4 NOT NULL
+ ,expiration_date INT8 NOT NULL
+ ,auditor_purses_rowid BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE
+ );
+COMMENT ON TABLE auditor_purses
+ IS 'all of the purses and their respective balances that the auditor is aware of';
+
+CREATE INDEX IF NOT EXISTS auditor_purses_by_purse_pub
+ ON auditor_purses
+ (purse_pub); \ No newline at end of file
diff --git a/src/auditordb/0002-auditor_reserve_balance.sql b/src/auditordb/0002-auditor_reserve_balance.sql
new file mode 100644
index 000000000..8267a3a28
--- /dev/null
+++ b/src/auditordb/0002-auditor_reserve_balance.sql
@@ -0,0 +1,34 @@
+--
+-- 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 TABLE IF NOT EXISTS auditor_reserve_balance
+ ,reserve_balance_val INT8 NOT NULL
+ ,reserve_balance_frac INT4 NOT NULL
+ ,reserve_loss_val INT8 NOT NULL
+ ,reserve_loss_frac INT4 NOT NULL
+ ,withdraw_fee_balance_val INT8 NOT NULL
+ ,withdraw_fee_balance_frac INT4 NOT NULL
+ ,close_fee_balance_val INT8 NOT NULL
+ ,close_fee_balance_frac INT4 NOT NULL
+ ,purse_fee_balance_val INT8 NOT NULL
+ ,purse_fee_balance_frac INT4 NOT NULL
+ ,open_fee_balance_val INT8 NOT NULL
+ ,open_fee_balance_frac INT4 NOT NULL
+ ,history_fee_balance_val INT8 NOT NULL
+ ,history_fee_balance_frac INT4 NOT NULL
+ );
+COMMENT ON TABLE auditor_reserve_balance
+ IS 'sum of the balances of all customer reserves'; \ No newline at end of file
diff --git a/src/auditordb/0002-auditor_reserves.sql b/src/auditordb/0002-auditor_reserves.sql
new file mode 100644
index 000000000..5da886dce
--- /dev/null
+++ b/src/auditordb/0002-auditor_reserves.sql
@@ -0,0 +1,42 @@
+--
+-- 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 TABLE IF NOT EXISTS auditor_reserves
+(reserve_pub BYTEA NOT NULL CHECK(LENGTH(reserve_pub)=32)
+ ,reserve_balance_val INT8 NOT NULL
+ ,reserve_balance_frac INT4 NOT NULL
+ ,reserve_loss_val INT8 NOT NULL
+ ,reserve_loss_frac INT4 NOT NULL
+ ,withdraw_fee_balance_val INT8 NOT NULL
+ ,withdraw_fee_balance_frac INT4 NOT NULL
+ ,close_fee_balance_val INT8 NOT NULL
+ ,close_fee_balance_frac INT4 NOT NULL
+ ,purse_fee_balance_val INT8 NOT NULL
+ ,purse_fee_balance_frac INT4 NOT NULL
+ ,open_fee_balance_val INT8 NOT NULL
+ ,open_fee_balance_frac INT4 NOT NULL
+ ,history_fee_balance_val INT8 NOT NULL
+ ,history_fee_balance_frac INT4 NOT NULL
+ ,expiration_date INT8 NOT NULL
+ ,auditor_reserves_rowid BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE
+ ,origin_account TEXT
+ );
+COMMENT ON TABLE auditor_reserves
+ IS 'all of the customer reserves and their respective balances that the auditor is aware of';
+
+CREATE INDEX IF NOT EXISTS auditor_reserves_by_reserve_pub
+ ON auditor_reserves
+ (reserve_pub); \ No newline at end of file
diff --git a/src/auditordb/0002-auditor_wire_fee_balance.sql b/src/auditordb/0002-auditor_wire_fee_balance.sql
new file mode 100644
index 000000000..85e5f710f
--- /dev/null
+++ b/src/auditordb/0002-auditor_wire_fee_balance.sql
@@ -0,0 +1,22 @@
+--
+-- 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 TABLE IF NOT EXISTS auditor_wire_fee_balance
+ ,wire_fee_balance_val INT8 NOT NULL
+ ,wire_fee_balance_frac INT4 NOT NULL
+ );
+COMMENT ON TABLE auditor_wire_fee_balance
+ IS 'sum of the balances of all wire fees'; \ No newline at end of file
diff --git a/src/auditordb/0002-deposit_confirmations.sql b/src/auditordb/0002-deposit_confirmations.sql
new file mode 100644
index 000000000..340799cd5
--- /dev/null
+++ b/src/auditordb/0002-deposit_confirmations.sql
@@ -0,0 +1,35 @@
+--
+-- 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 TABLE IF NOT EXISTS deposit_confirmations
+ ,serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE
+ ,h_contract_terms BYTEA NOT NULL CHECK (LENGTH(h_contract_terms)=64)
+ ,h_policy BYTEA NOT NULL CHECK (LENGTH(h_policy)=64)
+ ,h_wire BYTEA NOT NULL CHECK (LENGTH(h_wire)=64)
+ ,exchange_timestamp INT8 NOT NULL
+ ,refund_deadline INT8 NOT NULL
+ ,wire_deadline INT8 NOT NULL
+ ,amount_without_fee_val INT8 NOT NULL
+ ,amount_without_fee_frac INT4 NOT NULL
+ ,coin_pub BYTEA NOT NULL CHECK (LENGTH(coin_pub)=32)
+ ,merchant_pub BYTEA NOT NULL CHECK (LENGTH(merchant_pub)=32)
+ ,exchange_sig BYTEA NOT NULL CHECK (LENGTH(exchange_sig)=64)
+ ,exchange_pub BYTEA NOT NULL CHECK (LENGTH(exchange_pub)=32)
+ ,master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64)
+ ,PRIMARY KEY (h_contract_terms,h_wire,coin_pub,merchant_pub,exchange_sig,exchange_pub,master_sig)
+ );
+COMMENT ON TABLE deposit_confirmations
+ IS 'deposit confirmation sent to us by merchants; we must check that the exchange reported these properly.';
diff --git a/src/auditordb/0002-wire_auditor_account_progress.sql b/src/auditordb/0002-wire_auditor_account_progress.sql
new file mode 100644
index 000000000..9b346a102
--- /dev/null
+++ b/src/auditordb/0002-wire_auditor_account_progress.sql
@@ -0,0 +1,27 @@
+--
+-- 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 TABLE IF NOT EXISTS wire_auditor_account_progress
+ ,account_name TEXT NOT NULL
+ ,last_wire_reserve_in_serial_id INT8 NOT NULL DEFAULT 0
+ ,last_wire_wire_out_serial_id INT8 NOT NULL DEFAULT 0
+ ,wire_in_off INT8 NOT NULL
+ ,wire_out_off INT8 NOT NULL
+ ,PRIMARY KEY (account_name)
+ );
+COMMENT ON TABLE wire_auditor_account_progress
+ IS 'information as to which transactions the auditor has processed in the exchange database. Used for SELECTing the
+ statements to process. The indices include the last serial ID from the respective tables that we have processed. Thus, we need to select those table entries that are strictly larger (and process in monotonically increasing order).';
diff --git a/src/auditordb/0002-wire_auditor_progress.sql b/src/auditordb/0002-wire_auditor_progress.sql
new file mode 100644
index 000000000..05887e6c5
--- /dev/null
+++ b/src/auditordb/0002-wire_auditor_progress.sql
@@ -0,0 +1,21 @@
+--
+-- 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 TABLE IF NOT EXISTS wire_auditor_progress
+ ,last_timestamp INT8 NOT NULL
+ ,last_reserve_close_uuid INT8 NOT NULL
+ --,PRIMARY KEY (master_pub)
+ );
diff --git a/src/auditordb/auditor-0002.sql b/src/auditordb/auditor-0002.sql
new file mode 100644
index 000000000..dcffbd028
--- /dev/null
+++ b/src/auditordb/auditor-0002.sql
@@ -0,0 +1,39 @@
+--
+-- 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/>
+--
+
+-- Everything in one big transaction
+BEGIN;
+
+-- Check patch versioning is in place.
+SELECT _v.register_patch('auditor-0001', NULL, NULL);
+
+
+CREATE SCHEMA auditor;
+COMMENT ON SCHEMA auditor IS 'taler-auditor data';
+
+SET search_path TO auditor;
+
+-- Not needed anymore because no longer multitenant
+/*CREATE TABLE IF NOT EXISTS auditor_exchanges
+ (master_pub BYTEA PRIMARY KEY CHECK (LENGTH(master_pub)=32)
+ ,exchange_url VARCHAR NOT NULL
+ );
+COMMENT ON TABLE auditor_exchanges
+ IS 'list of the exchanges we are auditing';*/
+
+#include "0002-denominations.sql"
+-- Finally, commit everything
+COMMIT;
diff --git a/src/auditordb/auditor-0002.sql.in b/src/auditordb/auditor-0002.sql.in
new file mode 100644
index 000000000..d662bbad8
--- /dev/null
+++ b/src/auditordb/auditor-0002.sql.in
@@ -0,0 +1,42 @@
+--
+-- 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/>
+--
+
+BEGIN;
+
+SELECT _v.register_patch('auditor-0002', NULL, NULL);
+SET search_path TO auditordb;
+
+#include "0002-auditor_denomination_pending.sql"
+#include "0002-auditor_wire_fee_balance.sql"
+#include "0002-auditor_balance_summary.sql"
+#include "0002-auditor_exchange_signkeys.sql"
+#include "0002-auditor_historic_denomination_revenue.sql"
+#include "0002-auditor_historic_reserve_summary.sql"
+#include "0002-auditor_predicted_result.sql"
+#include "0002-auditor_progress_aggregation.sql"
+#include "0002-auditor_progress_coin.sql"
+#include "0002-auditor_progress_deposit_confirmation.sql"
+#include "0002-auditor_progress_purse.sql"
+#include "0002-auditor_progress_reserve.sql"
+#include "0002-auditor_purse_summary.sql"
+#include "0002-auditor_purses.sql"
+#include "0002-auditor_reserve_balance.sql"
+#include "0002-auditor_reserves.sql"
+#include "0002-deposit_confirmations.sql"
+#include "0002-wire_auditor_account_progress.sql"
+#include "0002-wire_auditor_progress.sql"
+
+COMMIT; \ No newline at end of file