Merge branch 'age-withdraw' of ssh://git.kesim.org/taler/exchange into age-withdraw
This commit is contained in:
commit
9f1f069cea
@ -466,10 +466,12 @@ batch_withdraw_transaction (void *cls,
|
||||
return qs;
|
||||
}
|
||||
wc->kyc.ok = true;
|
||||
|
||||
qs = TEH_plugin->do_batch_withdraw (TEH_plugin->cls,
|
||||
wc->now,
|
||||
wc->reserve_pub,
|
||||
&wc->batch_total,
|
||||
/* TODO[oec]: add parameter for maximum age and [out]parameter for required age */
|
||||
&found,
|
||||
&balance_ok,
|
||||
&ruuid);
|
||||
@ -493,6 +495,9 @@ batch_withdraw_transaction (void *cls,
|
||||
NULL);
|
||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||
}
|
||||
|
||||
/* TODO[oec]: add error handling for age restriction requirements */
|
||||
|
||||
if (! balance_ok)
|
||||
{
|
||||
TEH_plugin->rollback (TEH_plugin->cls);
|
||||
|
@ -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
|
||||
$$;
|
||||
|
||||
|
@ -27,14 +27,11 @@ BEGIN
|
||||
'CREATE TABLE %I'
|
||||
'(age_withdraw_revealed_coins_id BIGINT GENERATED BY DEFAULT AS IDENTITY' -- UNIQUE
|
||||
',h_commitment BYTEA NOT NULL CHECK (LENGTH(h_commitment)=64)'
|
||||
',freshcoin_index INT4 NOT NULL'
|
||||
',denominations_serial INT8 NOT NULL'
|
||||
',coin_ev BYTEA NOT NULL'
|
||||
',coin_index INT4 NOT NULL'
|
||||
',h_coin_ev BYTEA CHECK (LENGTH(h_coin_ev)=64)'
|
||||
',ev_sig BYTEA NOT NULL'
|
||||
') %s ;'
|
||||
,table_name
|
||||
,'PARTITION BY HASH (h_commitment)'
|
||||
,'PARTITION BY HASH (h_coin_ev)'
|
||||
,partition_suffix
|
||||
);
|
||||
PERFORM comment_partitioned_table(
|
||||
@ -49,35 +46,17 @@ BEGIN
|
||||
,partition_suffix
|
||||
);
|
||||
PERFORM comment_partitioned_column(
|
||||
'Index of the coin in the withdraw-age request, which is implicitly a batch request'
|
||||
,'freshcoin_index'
|
||||
'Index of the coin in the age-withdraw request, which is implicitly a batch request'
|
||||
,'coin_index'
|
||||
,table_name
|
||||
,partition_suffix
|
||||
);
|
||||
PERFORM comment_partitioned_column(
|
||||
'Foreign key reference to the denominations'
|
||||
,'denominations_serial'
|
||||
,table_name
|
||||
,partition_suffix
|
||||
);
|
||||
PERFORM comment_partitioned_column(
|
||||
'Envelope of the new coin to be signed'
|
||||
,'coin_ev'
|
||||
,table_name
|
||||
,partition_suffix
|
||||
);
|
||||
PERFORM comment_partitioned_column(
|
||||
'Hash of the envelope of the new coin to be signed (for lookups)'
|
||||
'Hash of the envelope of the new coin to be signed (for lookups). The corresponding signatures are stores in age_withdraw_commitments.denom_sigs.'
|
||||
,'h_coin_ev'
|
||||
,table_name
|
||||
,partition_suffix
|
||||
);
|
||||
PERFORM comment_partitioned_column(
|
||||
'Exchange signature over the envelope'
|
||||
,'ev_sig'
|
||||
,table_name
|
||||
,partition_suffix
|
||||
);
|
||||
END
|
||||
$$;
|
||||
|
||||
@ -118,12 +97,6 @@ BEGIN
|
||||
' FOREIGN KEY (h_commitment)'
|
||||
' REFERENCES age_withdraw_commitments (h_commitment) ON DELETE CASCADE;'
|
||||
);
|
||||
EXECUTE FORMAT (
|
||||
'ALTER TABLE ' || table_name ||
|
||||
' ADD CONSTRAINT ' || table_name || '_foreign_denominations_serial'
|
||||
' FOREIGN KEY (denominations_serial) '
|
||||
' REFERENCES denominations (denominations_serial) ON DELETE CASCADE;'
|
||||
);
|
||||
END
|
||||
$$;
|
||||
|
||||
|
@ -20,6 +20,7 @@ CREATE OR REPLACE FUNCTION exchange_do_batch_withdraw(
|
||||
IN rpub BYTEA,
|
||||
IN now INT8,
|
||||
IN min_reserve_gc INT8,
|
||||
-- TODO[oec]: add [IN] parameter for maximum age and [OUT] parameter for required age
|
||||
OUT reserve_found BOOLEAN,
|
||||
OUT balance_ok BOOLEAN,
|
||||
OUT ruuid INT8)
|
||||
@ -38,11 +39,13 @@ BEGIN
|
||||
-- reserves_in by reserve_pub (SELECT)
|
||||
-- wire_targets by wire_target_h_payto
|
||||
|
||||
|
||||
SELECT
|
||||
current_balance_val
|
||||
,current_balance_frac
|
||||
,gc_date
|
||||
,reserve_uuid
|
||||
-- TODO[oec]: get age requirements
|
||||
INTO
|
||||
reserve_val
|
||||
,reserve_frac
|
||||
@ -60,6 +63,8 @@ THEN
|
||||
RETURN;
|
||||
END IF;
|
||||
|
||||
-- TODO[oec]: check age requirements
|
||||
|
||||
-- Check reserve balance is sufficient.
|
||||
IF (reserve_val > amount_val)
|
||||
THEN
|
||||
@ -99,6 +104,7 @@ balance_ok=TRUE;
|
||||
|
||||
END $$;
|
||||
|
||||
-- TODO[oec]: Update comment re: age requirements are implemented
|
||||
COMMENT ON FUNCTION exchange_do_batch_withdraw(INT8, INT4, BYTEA, INT8, INT8)
|
||||
IS 'Checks whether the reserve has sufficient balance for a withdraw operation (or the request is repeated and was previously approved) and if so updates the database with the result. Excludes storing the planchets.';
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
--
|
||||
|
||||
|
||||
|
||||
-- TODO[oec]: add min. age requirements handling
|
||||
|
||||
CREATE OR REPLACE FUNCTION exchange_do_batch_withdraw_insert(
|
||||
IN cs_nonce BYTEA,
|
||||
|
@ -31,6 +31,7 @@ TEH_PG_do_batch_withdraw (
|
||||
void *cls,
|
||||
struct GNUNET_TIME_Timestamp now,
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
/* TODO[oec]: add parameter for maximum age and [out]parameter for required age */
|
||||
const struct TALER_Amount *amount,
|
||||
bool *found,
|
||||
bool *balance_ok,
|
||||
@ -68,6 +69,7 @@ TEH_PG_do_batch_withdraw (
|
||||
" reserve_found"
|
||||
",balance_ok"
|
||||
",ruuid"
|
||||
/* TODO[oec]: add parameter for maximum age and [out] parameter for required age */
|
||||
" FROM exchange_do_batch_withdraw"
|
||||
" ($1,$2,$3,$4,$5);");
|
||||
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
|
||||
|
Loading…
Reference in New Issue
Block a user