aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb
diff options
context:
space:
mode:
authorÖzgür Kesim <oec-taler@kesim.org>2023-07-26 04:04:02 +0200
committerÖzgür Kesim <oec-taler@kesim.org>2023-07-26 04:04:02 +0200
commit1ce9312d0293444e55512bba69265f4671d387e9 (patch)
tree15b58dff705c54fa938cfc34e0a7a6173aee951f /src/exchangedb
parentac462b275300d28f939a9be83c5bd220fbb0d7cd (diff)
downloadexchange-1ce9312d0293444e55512bba69265f4671d387e9.tar.xz
[age-withdraw] WIP - database transaction during reveal works now
The test for age-restriction still fail, but the database transactions, including passing arrays in/out the PQ-helpers works.
Diffstat (limited to 'src/exchangedb')
-rw-r--r--src/exchangedb/0003-age_withdraw.sql2
-rw-r--r--src/exchangedb/exchange_do_age_withdraw.sql4
-rw-r--r--src/exchangedb/pg_do_age_withdraw.c12
-rw-r--r--src/exchangedb/pg_get_age_withdraw.c29
4 files changed, 26 insertions, 21 deletions
diff --git a/src/exchangedb/0003-age_withdraw.sql b/src/exchangedb/0003-age_withdraw.sql
index 1d296b057..9816e466c 100644
--- a/src/exchangedb/0003-age_withdraw.sql
+++ b/src/exchangedb/0003-age_withdraw.sql
@@ -29,6 +29,8 @@ BEGIN
'(age_withdraw_id BIGINT GENERATED BY DEFAULT AS IDENTITY'
',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)'
+ ',amount_with_fee_val INT8 NOT NULL'
+ ',amount_with_fee_frac INT4 NOT NULL'
',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)'
',noreveal_index SMALLINT NOT NULL CONSTRAINT noreveal_index_positive CHECK(noreveal_index>=0)'
diff --git a/src/exchangedb/exchange_do_age_withdraw.sql b/src/exchangedb/exchange_do_age_withdraw.sql
index 2230d4bff..49a1433fd 100644
--- a/src/exchangedb/exchange_do_age_withdraw.sql
+++ b/src/exchangedb/exchange_do_age_withdraw.sql
@@ -143,6 +143,8 @@ WHERE
INSERT INTO exchange.age_withdraw
(h_commitment
,max_age
+ ,amount_with_fee_val
+ ,amount_with_fee_frac
,reserve_pub
,reserve_sig
,noreveal_index
@@ -152,6 +154,8 @@ INSERT INTO exchange.age_withdraw
VALUES
(h_commitment
,maximum_age_committed
+ ,amount_val
+ ,amount_frac
,rpub
,rsig
,noreveal_index
diff --git a/src/exchangedb/pg_do_age_withdraw.c b/src/exchangedb/pg_do_age_withdraw.c
index c79b2b3de..4fb52d466 100644
--- a/src/exchangedb/pg_do_age_withdraw.c
+++ b/src/exchangedb/pg_do_age_withdraw.c
@@ -52,15 +52,15 @@ TEH_PG_do_age_withdraw (
GNUNET_PQ_query_param_auto_from_type (&commitment->h_commitment),
GNUNET_PQ_query_param_uint16 (&commitment->max_age),
GNUNET_PQ_query_param_uint16 (&commitment->noreveal_index),
- GNUNET_PQ_query_param_array_auto_from_type (commitment->num_coins,
- commitment->h_coin_evs,
- pg->conn),
+ TALER_PQ_query_param_array_blinded_coin_hash (commitment->num_coins,
+ commitment->h_coin_evs,
+ pg->conn),
GNUNET_PQ_query_param_array_uint64 (commitment->num_coins,
commitment->denom_serials,
pg->conn),
- GNUNET_PQ_query_param_array_auto_from_type (commitment->num_coins,
- commitment->denom_sigs,
- pg->conn),
+ TALER_PQ_query_param_array_blinded_denom_sig (commitment->num_coins,
+ commitment->denom_sigs,
+ pg->conn),
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
diff --git a/src/exchangedb/pg_get_age_withdraw.c b/src/exchangedb/pg_get_age_withdraw.c
index 5e123ca9a..a66051c71 100644
--- a/src/exchangedb/pg_get_age_withdraw.c
+++ b/src/exchangedb/pg_get_age_withdraw.c
@@ -52,27 +52,26 @@ TEH_PG_get_age_withdraw (
&aw->amount_with_fee),
GNUNET_PQ_result_spec_uint16 ("noreveal_index",
&aw->noreveal_index),
- GNUNET_PQ_result_spec_array_fixed_size (
+ TALER_PQ_result_spec_array_blinded_coin_hash (
pg->conn,
- "h_coin_evs",
- sizeof(struct TALER_BlindedPlanchet),
+ "h_blind_evs",
&aw->num_coins,
- (void **) &aw->h_coin_evs),
- GNUNET_PQ_result_spec_array_fixed_size (
+ &aw->h_coin_evs),
+ TALER_PQ_result_spec_array_blinded_denom_sig (
pg->conn,
"denom_sigs",
- sizeof(struct TALER_DenominationSignature),
- NULL,
- (void **) &aw->denom_sigs),
- GNUNET_PQ_result_spec_array_fixed_size (
+ NULL, /* we assume that this is the same size as h_coin_evs */
+ &aw->denom_sigs),
+ TALER_PQ_result_spec_array_denom_hash (
pg->conn,
"denom_pub_hashes",
- sizeof(struct TALER_DenominationHashP),
- NULL,
- (void **) &aw->denom_pub_hashes),
+ NULL, /* we assume that this is the same size as h_coin_evs */
+ &aw->denom_pub_hashes),
GNUNET_PQ_result_spec_end
};
+ GNUNET_assert (NULL != aw);
+
/* Used in #postgres_get_age_withdraw() to
locate the response for a /reserve/$RESERVE_PUB/age-withdraw request
using the hash of the blinded message. Also needed to ensure
@@ -87,12 +86,12 @@ TEH_PG_get_age_withdraw (
",amount_with_fee_val"
",amount_with_fee_frac"
",noreveal_index"
- ",h_coin_evs"
+ ",h_blind_evs"
",denom_sigs"
",ARRAY("
" SELECT denominations.denom_pub_hash FROM ("
- " SELECT UNNEST(denomination_serials) AS id,"
- " generate_subscripts(denominations_serials, 1) AS nr" /* for order */
+ " SELECT UNNEST(denom_serials) AS id,"
+ " generate_subscripts(denom_serials, 1) AS nr" /* for order */
" ) AS denoms"
" LEFT JOIN denominations ON denominations.denominations_serial=denoms.id"
") AS denom_pub_hashes"