aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb/0003-age_withdraw_commitments.sql
diff options
context:
space:
mode:
Diffstat (limited to 'src/exchangedb/0003-age_withdraw_commitments.sql')
-rw-r--r--src/exchangedb/0003-age_withdraw_commitments.sql42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/exchangedb/0003-age_withdraw_commitments.sql b/src/exchangedb/0003-age_withdraw_commitments.sql
index d74a697c3..2ee462ecc 100644
--- a/src/exchangedb/0003-age_withdraw_commitments.sql
+++ b/src/exchangedb/0003-age_withdraw_commitments.sql
@@ -26,20 +26,22 @@ BEGIN
PERFORM create_partitioned_table(
'CREATE TABLE %I'
'(age_withdraw_commitment_id BIGINT GENERATED BY DEFAULT AS IDENTITY'
- ',h_commitment BYTEA CHECK (LENGTH(h_commitment)=64)'
- ',amount_with_fee_val INT8 NOT NULL'
- ',amount_with_fee_frac INT4 NOT NULL'
- ',max_age INT2 NOT NULL'
- ',reserve_pub BYTEA CHECK (LENGTH(reserve_pub)=32)'
- ',reserve_sig BYTEA NOT NULL CHECK (LENGTH(reserve_sig)=64)'
- ',noreveal_index INT4 NOT NULL'
+ ',h_commitment BYTEA NOT NULL CONSTRAINT h_commitment_length CHECK(LENGTH(h_commitment)=64)'
+ ',max_age SMALLINT NOT NULL CONSTRAINT max_age_positive CHECK(max_age>=0)'
+ ',reserve_pub BYTEA NOT NULL CONSTRAINT reserve_pub_length CHECK(LENGTH(reserve_pub)=32)'
+ ',reserve_sig BYTEA NOT NULL CONSTRAINT reserve_sig_length CHECK(LENGTH(reserve_sig)=64)'
+ ',num_coins SMALLINT NOT NULL CONSTRAINT num_coins_positive CHECK(num_coins>0)'
+ ',denominations_serials INT8[] NOT NULL CONSTRAINT denominations_serial_array_length CHECK(cardinality(denominations_serials)=num_coins)'
+ ',denom_sigs BYTEA[] NOT NULL CONSTRAINT denom_sigs_array_length CHECK(cardinality(denom_sigs)=num_coins)'
+ ',noreveal_index SMALLINT NOT NULL CONSTRAINT noreveal_index_positive CHECK(noreveal_index>=0)'
') %s ;'
,table_name
,'PARTITION BY HASH (reserve_pub)'
,partition_suffix
);
PERFORM comment_partitioned_table(
- 'Commitments made when withdrawing coins with age restriction and the gamma value chosen by the exchange.'
+ 'Commitments made when withdrawing coins with age restriction and the gamma value chosen by the exchange. '
+ 'It also contains the blindly signed coins and related denominations.'
,table_name
,partition_suffix
);
@@ -68,11 +70,29 @@ BEGIN
,partition_suffix
);
PERFORM comment_partitioned_column(
- 'Signature of the reserve''s private key over the withdraw-age request'
+ 'Signature of the reserve''s private key over the age-withdraw request'
,'reserve_sig'
,table_name
,partition_suffix
);
+ PERFORM comment_partinioned_column(
+ 'Number of coins to be withdrawn'
+ ,'num_coins'
+ ,table_name
+ ,partition_suffix
+ );
+ PERFORM comment_partitioned_column(
+ 'Array of #num_coins of references to the denominations'
+ ,'denominations_serials'
+ ,table_name
+ ,partition_suffix
+ );
+ PERFORM comment_partitioned_column(
+ 'Array of #num_coins signatures over the blinded envelopes'
+ ,'denom_sigs'
+ ,table_name
+ ,partition_suffix
+ );
END
$$;
@@ -122,13 +142,13 @@ END
$$;
-INSERT INTO exchange_tables
+INSERT INTO exchange_tables
(name
,version
,action
,partitioned
,by_range)
-VALUES
+VALUES
('age_withdraw_commitments', 'exchange-0003', 'create', TRUE ,FALSE),
('age_withdraw_commitments', 'exchange-0003', 'constrain',TRUE ,FALSE),
('age_withdraw_commitments', 'exchange-0003', 'foreign', TRUE ,FALSE);