summaryrefslogtreecommitdiff
path: root/design-documents
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-05-06 15:33:52 +0200
committerChristian Grothoff <christian@grothoff.org>2021-05-06 15:33:52 +0200
commit7214412a05e38b8b957257c3ee99d8acb6571179 (patch)
tree84fa76c18e484cf9d232abe1f513c34d04ff60bb /design-documents
parent20d68685eee8a3e99b59ed913ad3389f487e3e4b (diff)
downloaddocs-7214412a05e38b8b957257c3ee99d8acb6571179.tar.gz
docs-7214412a05e38b8b957257c3ee99d8acb6571179.tar.bz2
docs-7214412a05e38b8b957257c3ee99d8acb6571179.zip
work on w2w spec
Diffstat (limited to 'design-documents')
-rw-r--r--design-documents/013-peer-to-peer-payments.rst102
1 files changed, 100 insertions, 2 deletions
diff --git a/design-documents/013-peer-to-peer-payments.rst b/design-documents/013-peer-to-peer-payments.rst
index 0d3a767c..3a998c78 100644
--- a/design-documents/013-peer-to-peer-payments.rst
+++ b/design-documents/013-peer-to-peer-payments.rst
@@ -19,7 +19,7 @@ This will be used for payments via e-mail and other messaging apps, as well as
possibly for transfers via NFC/QR code between mobile phones.
Invoice Flow User Experience
-----------------------------------
+----------------------------
.. graphviz::
@@ -69,7 +69,7 @@ Invoice Flow User Experience
}
Donation Flow User Experience
--------------------------------------
+-----------------------------
.. graphviz::
@@ -618,6 +618,104 @@ Additional considerations
Taler's "one-hop withdrawal loohole".
+Exchange database schema changes
+--------------------------------
+
+We need to exchange the existing reserves table to include bits for KYC-needed
+and KYC-passed. Also, we need to store the payto://-URI of the bank account.
+
+Finally, we may need to keep some link to the KYC data, even though the
+exchange technically does not need it, but likely there might be regulatory
+reasons to have that association for legal inquiries. (However, it would
+also be possible to keep that link only in the external KYC service's
+database.)
+
+
+
+.. sourcecode:: sql
+
+ -- Everything in one big transaction
+ BEGIN;
+ -- Check patch versioning is in place.
+ SELECT _v.register_patch('exchange-TBD', NULL, NULL);
+ --
+ ALTER TABLE reserves
+ ADD COLUMN kyc_needed BOOLEAN NOT NULL DEFAULT (false)
+ ADD COLUMN kyc_passed BOOLEAN NOT NULL DEFAULT (false)
+ ADD COLUMN payto_uri TEXT DEFAULT (NULL)
+ ADD COLUMN kyc_link TEXT DEFAULT (NULL);
+ COMMENT ON COLUMN reserves.kyc_needed
+ IS 'set to true once a reserve was merged with a purse';
+ COMMENT ON COLUMN reserves.kyc_passed
+ IS 'set to true once the user performed the KYC check';
+ COMMENT ON COLUMN reserves.payto_uri
+ IS 'bank account details to use in case reserve is closed';
+ COMMENT ON COLUMN reserves.kyc_link
+ IS 'optional link to KYC data';
+ --
+ CREATE TABLE IF NOT EXISTS kyc_requests
+ (kyc_request_serial_id BIGSERIAL UNIQUE
+ ,reserve_pub BYTEA NOT NULL REFERENCES reserves (reserve_pub) ON DELETE CASCADE
+ ,kyc_date INT8 NOT NULL
+ ,kyc_fee_val INT8 NOT NULL
+ ,kyc_fee_frac INT4 NOT NULL
+ ,payto_uri TEXT NOT NULL
+ ,reserve_sig BYTEA NOT NULL CHECK (LENGTH(reserve_sig)=64))
+ ,PRIMARY KEY (reserve_pub, kyc_date)
+ );
+ CREATE TABLE IF NOT EXISTS mergers
+ (merge_request_serial_id BIGSERIAL UNIQUE
+ ,reserve_pub BYTEA NOT NULL REFERENCES reserves (reserve_pub) ON DELETE CASCADE
+ ,purse_url TEXT NOT NULL,
+ ,purse_pub BYTEA NOT NULL CHECK (LENGTH(purse_pub)=32),
+ ,reserve_sig BYTEA NOT NULL CHECK (LENGTH(reserve_sig)=64))
+ ,purse_sig BYTEA NOT NULL CHECK (LENGTH(reserve_sig)=64))
+ ,merge_timestamp INT8 NOT NULL
+ ,purse_expiration INT8 NOT NULL
+ ,h_contract_terms BYTEA NOT NULL CHECK (LENGTH(h_contract_terms)=64))
+ ,h_wire BYTEA NOT NULL CHECK (LENGTH(h_contract_terms)=64))
+ ,purse_val INT8 NOT NULL
+ ,purse_frac INT4 NOT NULL
+ ,PRIMARY KEY (purse_pub)
+ );
+ CREATE TABLE IF NOT EXISTS contracts
+ (contract_serial_id BIGSERIAL UNIQUE
+ ,purse_pub BYTEA NOT NULL CHECK (LENGTH(purse_pub)=32),
+ ,pub_ckey BYTEA NOT NULL CHECK (LENGTH(pub_ckey)=32)),
+ ,e_contract BYTEA NOT NULL,
+ ,PRIMARY KEY (purse_pub)
+ );
+ CREATE TABLE IF NOT EXISTS history_requests
+ (reserve_pub BYTEA NOT NULL CHECK (LENGTH(purse_pub)=32),
+ ,request_timestamp INT8 NOT NULL
+ ,reserve_sig BYTEA NOT NULL CHECK (LENGTH(reserve_sig)=64))
+ ,PRIMARY KEY (reserve_pub,request_timestamp)
+ );
+ CREATE TABLE IF NOT EXISTS purse_deposits
+ (purse_deposit_serial_id BIGSERIAL UNIQUE
+ ,purse_pub BYTEA NOT NULL CHECK (LENGTH(purse_pub)=32),
+ ,purse_expiration INT8 NOT NULL
+ ,coin_pub BYTEA NOT NULL REFERENCES known_coins (coin_pub) ON DELETE CASCADE
+ ,amount_with_fee_val INT8 NOT NULL
+ ,amount_with_fee_frac INT4 NOT NULL
+ ,coin_sig BYTEA NOT NULL CHECK(LENGTH(coin_sig)=64)
+ ,PRIMARY KEY (purse_pub,coin_pub)
+ );
+ CREATE TABLE IF NOT EXISTS wads
+ (wad_serial_id BIGSERIAL UNIQUE
+ ,reserve_pub BYTEA NOT NULL REFERENCES reserves (reserve_pub) ON DELETE CASCADE
+ ,kyc_date INT8 NOT NULL
+ ,kyc_fee_val INT8 NOT NULL
+ ,kyc_fee_frac INT4 NOT NULL
+ ,payto_uri TEXT NOT NULL
+ ,reserve_sig BYTEA NOT NULL CHECK (LENGTH(reserve_sig)=64))
+ ,PRIMARY KEY (reserve_pub, kyc_date)
+ );
+ -- Complete transaction
+ COMMIT;
+
+
+
Alternatives
============