diff options
Diffstat (limited to 'src/backenddb/merchant-0001.sql')
-rw-r--r-- | src/backenddb/merchant-0001.sql | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/src/backenddb/merchant-0001.sql b/src/backenddb/merchant-0001.sql index 4a458259..96e29e5b 100644 --- a/src/backenddb/merchant-0001.sql +++ b/src/backenddb/merchant-0001.sql @@ -1,6 +1,6 @@ -- -- This file is part of TALER --- Copyright (C) 2014--2020 Taler Systems SA +-- 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 @@ -32,6 +32,8 @@ CREATE TABLE IF NOT EXISTS merchant_exchange_wire_fees ,wire_fee_frac INT4 NOT NULL ,closing_fee_val INT8 NOT NULL ,closing_fee_frac INT4 NOT NULL + ,wad_fee_val INT8 NOT NULL + ,wad_fee_frac INT4 NOT NULL ,master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64) ,UNIQUE (master_pub,h_wire_method,start_date) ); @@ -61,6 +63,8 @@ COMMENT ON COLUMN merchant_exchange_signing_keys.master_pub CREATE TABLE IF NOT EXISTS merchant_instances (merchant_serial BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY ,merchant_pub BYTEA NOT NULL UNIQUE CHECK (LENGTH(merchant_pub)=32) + ,auth_hash BYTEA CHECK(LENGTH(auth_hash)=64) + ,auth_salt BYTEA CHECK(LENGTH(auth_salt)=32) ,merchant_id VARCHAR NOT NULL UNIQUE ,merchant_name VARCHAR NOT NULL ,address BYTEA NOT NULL @@ -83,6 +87,12 @@ COMMENT ON COLUMN merchant_instances.address IS 'physical address of the merchant as a Location in JSON format (required)'; COMMENT ON COLUMN merchant_instances.jurisdiction IS 'jurisdiction of the merchant as a Location in JSON format (required)'; +COMMENT ON COLUMN merchant_instances.auth_hash + IS 'hash used for merchant back office Authorization, NULL for no check'; +COMMENT ON COLUMN merchant_instances.auth_salt + IS 'salt to use when hashing Authorization header before comparing with auth_hash'; + + CREATE TABLE IF NOT EXISTS merchant_keys (merchant_priv BYTEA NOT NULL UNIQUE CHECK (LENGTH(merchant_priv)=32), @@ -134,6 +144,7 @@ CREATE TABLE IF NOT EXISTS merchant_inventory ,total_lost BIGINT NOT NULL DEFAULT 0 ,address BYTEA NOT NULL ,next_restock INT8 NOT NULL + ,minimum_age INT4 NOT NULL DEFAULT 0 ,UNIQUE (merchant_serial, product_id) ); COMMENT ON TABLE merchant_inventory @@ -160,6 +171,8 @@ COMMENT ON COLUMN merchant_inventory.address IS 'JSON formatted Location of where the product is stocked'; COMMENT ON COLUMN merchant_inventory.next_restock IS 'GNUnet absolute time indicating when the next restock is expected. 0 for unknown.'; +COMMENT ON COLUMN merchant_inventory.minimum_age + IS 'Minimum age of the customer in years, to be used if an exchange supports the age restriction extension.'; CREATE TABLE IF NOT EXISTS merchant_inventory_locks @@ -245,6 +258,7 @@ CREATE TABLE IF NOT EXISTS merchant_contract_terms ,wired BOOLEAN DEFAULT FALSE NOT NULL ,fulfillment_url VARCHAR ,session_id VARCHAR DEFAULT '' NOT NULL + ,claim_token BYTEA NOT NULL CHECK (LENGTH(claim_token)=16) ,UNIQUE (merchant_serial, order_id) ,UNIQUE (merchant_serial, h_contract_terms) ); @@ -270,6 +284,9 @@ COMMENT ON COLUMN merchant_contract_terms.session_id IS 'last session_id from we confirmed the paying client to use, empty string for none'; COMMENT ON COLUMN merchant_contract_terms.pay_deadline IS 'How long is the offer valid. After this time, the order can be garbage collected'; +COMMENT ON COLUMN merchant_contract_terms.claim_token + IS 'Token optionally used to access the status of the order. All zeros (not NULL) if not used'; + CREATE INDEX IF NOT EXISTS merchant_contract_terms_by_merchant_and_expiration ON merchant_contract_terms (merchant_serial,pay_deadline); @@ -385,6 +402,8 @@ CREATE TABLE IF NOT EXISTS merchant_transfer_signatures REFERENCES merchant_exchange_signing_keys (signkey_serial) ON DELETE CASCADE ,wire_fee_val INT8 NOT NULL ,wire_fee_frac INT4 NOT NULL + ,credit_amount_val INT8 NOT NULL + ,credit_amount_frac INT4 NOT NULL ,execution_time INT8 NOT NULL ,exchange_sig BYTEA NOT NULL CHECK (LENGTH(exchange_sig)=64) ); @@ -392,6 +411,9 @@ COMMENT ON TABLE merchant_transfer_signatures IS 'table represents the main information returned from the /transfer request to the exchange.'; COMMENT ON COLUMN merchant_transfer_signatures.execution_time IS 'Execution time as claimed by the exchange, roughly matches time seen by merchant'; +COMMENT ON COLUMN merchant_transfer_signatures.credit_amount_val + IS 'actual value of the (aggregated) wire transfer, excluding the wire fee, according to the exchange'; + CREATE TABLE IF NOT EXISTS merchant_transfer_to_coin (deposit_serial BIGINT UNIQUE NOT NULL @@ -480,9 +502,13 @@ CREATE TABLE IF NOT EXISTS merchant_tip_reserve_keys REFERENCES merchant_tip_reserves (reserve_serial) ON DELETE CASCADE ,reserve_priv BYTEA NOT NULL UNIQUE CHECK (LENGTH(reserve_priv)=32) ,exchange_url VARCHAR NOT NULL + ,payto_uri VARCHAR ); COMMENT ON TABLE merchant_tip_reserves IS 'private keys of reserves that have not been deleted'; +COMMENT ON COLUMN merchant_tip_reserve_keys.payto_uri + IS 'payto:// URI used to fund the reserve, may be NULL once reserve is funded'; + CREATE TABLE IF NOT EXISTS merchant_tips (tip_serial BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY @@ -536,5 +562,37 @@ COMMENT ON TABLE merchant_tip_pickup_signatures IS 'blind signatures we got from the exchange during the tip pickup'; + + +CREATE TABLE IF NOT EXISTS merchant_kyc +(kyc_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE +,kyc_timestamp INT8 NOT NULL +,kyc_ok BOOLEAN NOT NULL DEFAULT (FALSE) +,exchange_sig BYTEA CHECK(LENGTH(exchange_sig)=64) +,exchange_pub BYTEA CHECK(LENGTH(exchange_pub)=32) +,exchange_kyc_serial INT8 NOT NULL DEFAULT(0) +,account_serial INT8 NOT NULL + REFERENCES merchant_accounts (account_serial) ON DELETE CASCADE +,exchange_url VARCHAR NOT NULL +,PRIMARY KEY (account_serial,exchange_url) +); +COMMENT ON TABLE merchant_kyc + IS 'Status of the KYC process of a merchant account at an exchange'; +COMMENT ON COLUMN merchant_kyc.kyc_timestamp + IS 'Last time we checked our KYC status at the exchange. Useful to re-check if the status is very stale. Also the timestamp used for the exchange signature (if present).'; +COMMENT ON COLUMN merchant_kyc.exchange_kyc_serial + IS 'Number to use in the KYC-endpoints of the exchange to check the KYC status or begin the KYC process. 0 if we do not know it yet.'; +COMMENT ON COLUMN merchant_kyc.kyc_ok + IS 'true if the KYC check was passed successfully'; +COMMENT ON COLUMN merchant_kyc.exchange_sig + IS 'signature of the exchange affirming the KYC passed (or NULL if exchange does not require KYC or not kyc_ok)'; +COMMENT ON COLUMN merchant_kyc.exchange_pub + IS 'public key used with exchange_sig (or NULL if exchange_sig is NULL)'; +COMMENT ON COLUMN merchant_kyc.account_serial + IS 'Which bank account of the merchant is the KYC status for'; +COMMENT ON COLUMN merchant_kyc.exchange_url + IS 'Which exchange base URL is this KYC status valid for'; + + -- Complete transaction COMMIT; |