summaryrefslogtreecommitdiff
path: root/src/backenddb/merchant-0001.sql
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-05-03 20:17:36 +0200
committerChristian Grothoff <christian@grothoff.org>2020-05-03 20:17:36 +0200
commitdbee9e5a7f8160b94b3b5242f2284b0dbb8b21d3 (patch)
tree451d730cdac766364c0f9d4719dac799934ab5a6 /src/backenddb/merchant-0001.sql
parent607c8d8a015c677f9a4f2aa5cc46285c57ebb714 (diff)
downloadmerchant-dbee9e5a7f8160b94b3b5242f2284b0dbb8b21d3.tar.gz
merchant-dbee9e5a7f8160b94b3b5242f2284b0dbb8b21d3.tar.bz2
merchant-dbee9e5a7f8160b94b3b5242f2284b0dbb8b21d3.zip
revise GET /private/orders API
Diffstat (limited to 'src/backenddb/merchant-0001.sql')
-rw-r--r--src/backenddb/merchant-0001.sql45
1 files changed, 34 insertions, 11 deletions
diff --git a/src/backenddb/merchant-0001.sql b/src/backenddb/merchant-0001.sql
index e54e4781..36eb67bf 100644
--- a/src/backenddb/merchant-0001.sql
+++ b/src/backenddb/merchant-0001.sql
@@ -339,7 +339,7 @@ COMMENT ON TABLE merchant_refund_proofs
-------------------- Wire transfers ---------------------------
-CREATE TABLE IF NOT EXISTS merchant_credits
+CREATE TABLE IF NOT EXISTS merchant_transfers
(credit_serial BIGSERIAL PRIMARY KEY
,exchange_url VARCHAR NOT NULL
,wtid BYTEA CHECK (LENGTH(wtid)=32)
@@ -348,16 +348,19 @@ CREATE TABLE IF NOT EXISTS merchant_credits
,account_serial BIGINT NOT NULL
REFERENCES merchant_accounts (account_serial) ON DELETE CASCADE
,verified BOOLEAN NOT NULL DEFAULT FALSE
+ ,confirmed BOOLEAN NOT NULL DEFAULT FALSE
,UNIQUE (wtid, exchange_url)
);
-COMMENT ON TABLE merchant_credits
+COMMENT ON TABLE merchant_transfers
IS 'table represents the information provided by the (trusted) merchant about incoming wire transfers';
-COMMENT ON COLUMN merchant_credits.verified
+COMMENT ON COLUMN merchant_transfers.verified
IS 'true once we got an acceptable response from the exchange for this transfer';
+COMMENT ON COLUMN merchant_transfers.confirmed
+ IS 'true once the merchant confirmed that this transfer was received';
CREATE TABLE IF NOT EXISTS merchant_transfer_signatures
(credit_serial BIGINT PRIMARY KEY
- REFERENCES merchant_credits (credit_serial) ON DELETE CASCADE
+ REFERENCES merchant_transfers (credit_serial) ON DELETE CASCADE
,account_serial BIGINT NOT NULL
REFERENCES merchant_accounts (account_serial) ON DELETE CASCADE
,signkey_serial BIGINT NOT NULL
@@ -367,12 +370,14 @@ CREATE TABLE IF NOT EXISTS merchant_transfer_signatures
);
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';
-CREATE TABLE IF NOT EXISTS merchant_transfer_by_coin
+CREATE TABLE IF NOT EXISTS merchant_transfer_to_coin
(deposit_serial BIGINT UNIQUE NOT NULL
REFERENCES merchant_deposits (deposit_serial) ON DELETE CASCADE
,credit_serial BIGINT NOT NULL
- REFERENCES merchant_credits (credit_serial) ON DELETE CASCADE
+ REFERENCES merchant_transfers (credit_serial) ON DELETE CASCADE
,offset_in_exchange_list INT8 NOT NULL
,exchange_deposit_value_val INT8 NOT NULL
,exchange_deposit_value_frac INT4 NOT NULL
@@ -380,15 +385,33 @@ CREATE TABLE IF NOT EXISTS merchant_transfer_by_coin
,exchange_deposit_fee_frac INT4 NOT NULL
);
CREATE INDEX IF NOT EXISTS merchant_transfers_by_credit
- ON merchant_transfer_by_coin
+ ON merchant_transfer_to_coin
(credit_serial);
-COMMENT ON TABLE merchant_transfer_by_coin
- IS 'Mapping of deposits to wire transfers and vice versa';
-COMMENT ON COLUMN merchant_transfer_by_coin.exchange_deposit_value_val
+COMMENT ON TABLE merchant_transfer_to_coin
+ IS 'Mapping of (credit) transfers to (deposited) coins';
+COMMENT ON COLUMN merchant_transfer_to_coin.exchange_deposit_value_val
IS 'Deposit value as claimed by the exchange, should match our values in merchant_deposits minus refunds';
-COMMENT ON COLUMN merchant_transfer_by_coin.exchange_deposit_fee_val
+COMMENT ON COLUMN merchant_transfer_to_coin.exchange_deposit_fee_val
IS 'Deposit value as claimed by the exchange, should match our values in merchant_deposits';
+CREATE TABLE IF NOT EXISTS merchant_deposit_to_transfer
+ (deposit_serial BIGINT NOT NULL
+ REFERENCES merchant_deposits (deposit_serial) ON DELETE CASCADE
+ ,coin_contribution_value_val INT8 NOT NULL
+ ,coin_contribution_value_frac INT4 NOT NULL
+ ,credit_serial BIGINT NOT NULL
+ REFERENCES merchant_transfers (credit_serial)
+ ,execution_time INT8 NOT NULL
+ ,signkey_serial BIGINT NOT NULL
+ REFERENCES merchant_exchange_signing_keys (signkey_serial) ON DELETE CASCADE
+ ,exchange_sig BYTEA NOT NULL CHECK (LENGTH(exchange_sig)=64)
+ ,UNIQUE(coin_pub,wtid)
+);
+COMMENT ON TABLE merchant_deposit_to_transfer
+ IS 'Mapping of deposits to (possibly unconfirmed) wire transfers';
+COMMENT ON COLUMN merchant_deposit_to_transfer.execution_time
+ IS 'Execution time as claimed by the exchange, roughly matches time seen by merchant';
+
-------------------------- Tipping ---------------------------