diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-11-24 13:36:17 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-11-24 13:36:17 +0100 |
commit | ddcf679493a0a49cf4e8be94d29cd3216b7880ea (patch) | |
tree | d6c385be5f507ce8efc1d4c68c9a3280199fea25 /src/exchangedb | |
parent | b9b38cdc477e1eae7c3cd079a5beb7f6cb5a4bd6 (diff) | |
download | exchange-ddcf679493a0a49cf4e8be94d29cd3216b7880ea.tar.xz |
database schema change for #6175
Diffstat (limited to 'src/exchangedb')
-rw-r--r-- | src/exchangedb/exchange-0001.sql | 2 | ||||
-rw-r--r-- | src/exchangedb/exchange-0002.sql | 87 |
2 files changed, 88 insertions, 1 deletions
diff --git a/src/exchangedb/exchange-0001.sql b/src/exchangedb/exchange-0001.sql index 25b778238..8428a94b4 100644 --- a/src/exchangedb/exchange-0001.sql +++ b/src/exchangedb/exchange-0001.sql @@ -42,7 +42,7 @@ CREATE TABLE IF NOT EXISTS denominations ,fee_refund_frac INT4 NOT NULL ); COMMENT ON TABLE denominations - IS 'Main denominations table. All the coins the exchange knows about.'; + IS 'Main denominations table. All the valid denominations the exchange knows about.'; CREATE INDEX IF NOT EXISTS denominations_expire_legal_index ON denominations diff --git a/src/exchangedb/exchange-0002.sql b/src/exchangedb/exchange-0002.sql index 9a2793f1a..a670876af 100644 --- a/src/exchangedb/exchange-0002.sql +++ b/src/exchangedb/exchange-0002.sql @@ -43,6 +43,93 @@ COMMENT ON INDEX prepare_get_index +CREATE TABLE IF NOT EXISTS future_denominations + (denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64) + ,denom_pub BYTEA NOT NULL + ,valid_from INT8 NOT NULL + ,expire_withdraw INT8 NOT NULL + ,expire_deposit INT8 NOT NULL + ,expire_legal INT8 NOT NULL + ,coin_val INT8 NOT NULL + ,coin_frac INT4 NOT NULL + ,fee_withdraw_val INT8 NOT NULL + ,fee_withdraw_frac INT4 NOT NULL + ,fee_deposit_val INT8 NOT NULL + ,fee_deposit_frac INT4 NOT NULL + ,fee_refresh_val INT8 NOT NULL + ,fee_refresh_frac INT4 NOT NULL + ,fee_refund_val INT8 NOT NULL + ,fee_refund_frac INT4 NOT NULL + ); +COMMENT ON TABLE future_denominations + IS 'Future denominations. Moved to denomiations once the master signature is provided. Kept separate (instead of using NULL-able master_sig column) to ensure denomination keys without master signature cannot satisfy foreign key constraints of other tables.'; +COMMENT ON COLUMN future_denominations.valid_from + IS 'Earliest time when the private key can be used to withdraw.'; +COMMENT ON COLUMN future_denominations.expire_withdraw + IS 'Latest time when the private key can be used to withdraw.'; + +CREATE INDEX IF NOT EXISTS future_denominations_expire_withdraw_index + ON future_denominations + (expire_withdraw); +COMMENT ON INDEX future_denominations_expire_withdraw_index + IS 'Future denominations that cannot be withdrawn anymore can be deleted.'; + + + +CREATE TABLE IF NOT EXISTS auditors + (auditor_pub BYTEA PRIMARY KEY CHECK (LENGTH(auditor_pub)=32) + ,auditor_name VARCHAR NOT NULL + ,auditor_url VARCHAR NOT NULL + ,is_active BOOLEAN NOT NULL + ,last_change INT8 NOT NULL + ); +COMMENT ON TABLE auditors + IS 'Table with auditors the exchange uses or has used in the past. Entries never expire as we need to remember the last_change column indefinitely.'; +COMMENT ON COLUMN auditors.auditor_pub + IS 'Public key of the auditor.'; +COMMENT ON COLUMN auditors.auditor_url + IS 'The base URL of the auditor.'; +COMMENT ON COLUMN auditors.is_active + IS 'true if we are currently supporting the use of this auditor.'; +COMMENT ON COLUMN auditors.last_change + IS 'Latest time when active status changed. Used to detect replays of old messages.'; + + +CREATE TABLE IF NOT EXISTS auditor_denom_sigs + (auditor_pub BYTEA NOT NULL REFERENCES auditors (auditor_pub) ON DELETE CASCADE + ,denom_pub_hash BYTEA NOT NULL REFERENCES denominations (denom_pub_hash) ON DELETE CASCADE + ,auditor_sig BYTEA PRIMARY KEY CHECK (LENGTH(auditor_sig)=64) + ); +COMMENT ON TABLE auditor_denom_sigs + IS 'Table with auditor signatures on exchange denomination keys.'; +COMMENT ON COLUMN auditor_denom_sigs.auditor_pub + IS 'Public key of the auditor.'; +COMMENT ON COLUMN auditor_denom_sigs.denom_pub_hash + IS 'Denomination the signature is for.'; +COMMENT ON COLUMN auditor_denom_sigs.auditor_sig + IS 'Signature of the auditor, of purpose TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS.'; +CREATE INDEX IF NOT EXISTS auditor_denom_sigs_denom_hash_index + ON auditor_denom_sigs + (denom_pub_hash); + + +CREATE TABLE IF NOT EXISTS exchange_sign_keys + (exchange_pub BYTEA PRIMARY KEY + ,master_pub BYTEA NOT NULL CHECK (LENGTH(master_pub)=32) + ,master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64) + ,legal_end INT8 NOT NULL + ); +COMMENT ON TABLE exchange_sign_keys + IS 'Table with master public key signatures on exchange online signing keys.'; +COMMENT ON COLUMN exchange_sign_keys.exchange_pub + IS 'Public online signing key of the exchange.'; +COMMENT ON COLUMN exchange_sign_keys.master_pub + IS 'Master public key of the exchange that was used for master_sig.'; +COMMENT ON COLUMN exchange_sign_keys.master_sig + IS 'Signature affirming the validity of the signing key of purpose TALER_SIGNATURE_MASTER_SIGNING_KEY_VALIDITY.'; +COMMENT ON COLUMN exchange_sign_keys.legal_end + IS 'Time when this online signing key legally expires.'; + -- Complete transaction COMMIT; |