summaryrefslogtreecommitdiff
path: root/src/auditordb
diff options
context:
space:
mode:
Diffstat (limited to 'src/auditordb')
-rw-r--r--src/auditordb/auditor-0001.sql50
-rw-r--r--src/auditordb/plugin_auditordb_postgres.c25
-rw-r--r--src/auditordb/test_auditordb.c45
3 files changed, 68 insertions, 52 deletions
diff --git a/src/auditordb/auditor-0001.sql b/src/auditordb/auditor-0001.sql
index 3a0d7dd9..0faa890d 100644
--- a/src/auditordb/auditor-0001.sql
+++ b/src/auditordb/auditor-0001.sql
@@ -30,7 +30,7 @@ COMMENT ON TABLE auditor_exchanges
CREATE TABLE IF NOT EXISTS auditor_exchange_signkeys
- (master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
+ (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
,ep_start INT8 NOT NULL
,ep_expire INT8 NOT NULL
,ep_end INT8 NOT NULL
@@ -42,7 +42,7 @@ COMMENT ON TABLE auditor_exchange_signkeys
CREATE TABLE IF NOT EXISTS auditor_progress_reserve
- (master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
+ (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
,last_reserve_in_serial_id INT8 NOT NULL DEFAULT 0
,last_reserve_out_serial_id INT8 NOT NULL DEFAULT 0
,last_reserve_recoup_serial_id INT8 NOT NULL DEFAULT 0
@@ -65,7 +65,7 @@ COMMENT ON TABLE auditor_progress_aggregation
CREATE TABLE IF NOT EXISTS auditor_progress_deposit_confirmation
- (master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
+ (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
,last_deposit_confirmation_serial_id INT8 NOT NULL DEFAULT 0
,PRIMARY KEY (master_pub)
);
@@ -75,7 +75,7 @@ COMMENT ON TABLE auditor_progress_deposit_confirmation
CREATE TABLE IF NOT EXISTS auditor_progress_coin
- (master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
+ (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
,last_withdraw_serial_id INT8 NOT NULL DEFAULT 0
,last_deposit_serial_id INT8 NOT NULL DEFAULT 0
,last_melt_serial_id INT8 NOT NULL DEFAULT 0
@@ -90,12 +90,12 @@ COMMENT ON TABLE auditor_progress_coin
CREATE TABLE IF NOT EXISTS wire_auditor_account_progress
- (master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
+ (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
,account_name TEXT NOT NULL
,last_wire_reserve_in_serial_id INT8 NOT NULL DEFAULT 0
,last_wire_wire_out_serial_id INT8 NOT NULL DEFAULT 0
- ,wire_in_off INT8
- ,wire_out_off INT8
+ ,wire_in_off INT8 NOT NULL
+ ,wire_out_off INT8 NOT NULL
,PRIMARY KEY (master_pub,account_name)
);
COMMENT ON TABLE wire_auditor_account_progress
@@ -104,7 +104,7 @@ COMMENT ON TABLE wire_auditor_account_progress
CREATE TABLE IF NOT EXISTS wire_auditor_progress
- (master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
+ (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
,last_timestamp INT8 NOT NULL
,last_reserve_close_uuid INT8 NOT NULL
,PRIMARY KEY (master_pub)
@@ -113,7 +113,7 @@ CREATE TABLE IF NOT EXISTS wire_auditor_progress
CREATE TABLE IF NOT EXISTS auditor_reserves
(reserve_pub BYTEA NOT NULL CHECK(LENGTH(reserve_pub)=32)
- ,master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
+ ,master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
,reserve_balance_val INT8 NOT NULL
,reserve_balance_frac INT4 NOT NULL
,withdraw_fee_balance_val INT8 NOT NULL
@@ -131,7 +131,7 @@ CREATE INDEX IF NOT EXISTS auditor_reserves_by_reserve_pub
CREATE TABLE IF NOT EXISTS auditor_reserve_balance
- (master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
+ (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
,reserve_balance_val INT8 NOT NULL
,reserve_balance_frac INT4 NOT NULL
,withdraw_fee_balance_val INT8 NOT NULL
@@ -142,7 +142,7 @@ COMMENT ON TABLE auditor_reserve_balance
CREATE TABLE IF NOT EXISTS auditor_wire_fee_balance
- (master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
+ (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
,wire_fee_balance_val INT8 NOT NULL
,wire_fee_balance_frac INT4 NOT NULL
);
@@ -173,7 +173,7 @@ COMMENT ON COLUMN auditor_denomination_pending.recoup_loss_val
CREATE TABLE IF NOT EXISTS auditor_balance_summary
- (master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
+ (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
,denom_balance_val INT8 NOT NULL
,denom_balance_frac INT4 NOT NULL
,deposit_fee_balance_val INT8 NOT NULL
@@ -194,7 +194,7 @@ COMMENT ON TABLE auditor_balance_summary
CREATE TABLE IF NOT EXISTS auditor_historic_denomination_revenue
- (master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
+ (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
,denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64)
,revenue_timestamp INT8 NOT NULL
,revenue_balance_val INT8 NOT NULL
@@ -209,7 +209,7 @@ COMMENT ON COLUMN auditor_historic_denomination_revenue.revenue_balance_val
CREATE TABLE IF NOT EXISTS auditor_historic_reserve_summary
- (master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
+ (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
,start_date INT8 NOT NULL
,end_date INT8 NOT NULL
,reserve_profits_val INT8 NOT NULL
@@ -225,19 +225,21 @@ CREATE INDEX IF NOT EXISTS auditor_historic_reserve_summary_by_master_pub_start_
CREATE TABLE IF NOT EXISTS deposit_confirmations
- (master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
- ,serial_id BIGSERIAL UNIQUE
- ,h_contract_terms BYTEA CHECK (LENGTH(h_contract_terms)=64)
- ,h_wire BYTEA CHECK (LENGTH(h_wire)=64)
+ (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
+ ,serial_id BIGSERIAL NOT NULL UNIQUE
+ ,h_contract_terms BYTEA NOT NULL CHECK (LENGTH(h_contract_terms)=64)
+ ,h_extensions BYTEA NOT NULL CHECK (LENGTH(h_contract_terms)=64)
+ ,h_wire BYTEA NOT NULL CHECK (LENGTH(h_wire)=64)
,exchange_timestamp INT8 NOT NULL
,refund_deadline INT8 NOT NULL
+ ,wire_deadline INT8 NOT NULL
,amount_without_fee_val INT8 NOT NULL
,amount_without_fee_frac INT4 NOT NULL
- ,coin_pub BYTEA CHECK (LENGTH(coin_pub)=32)
- ,merchant_pub BYTEA CHECK (LENGTH(merchant_pub)=32)
- ,exchange_sig BYTEA CHECK (LENGTH(exchange_sig)=64)
- ,exchange_pub BYTEA CHECK (LENGTH(exchange_pub)=32)
- ,master_sig BYTEA CHECK (LENGTH(master_sig)=64)
+ ,coin_pub BYTEA NOT NULL CHECK (LENGTH(coin_pub)=32)
+ ,merchant_pub BYTEA NOT NULL CHECK (LENGTH(merchant_pub)=32)
+ ,exchange_sig BYTEA NOT NULL CHECK (LENGTH(exchange_sig)=64)
+ ,exchange_pub BYTEA NOT NULL CHECK (LENGTH(exchange_pub)=32)
+ ,master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64)
,PRIMARY KEY (h_contract_terms,h_wire,coin_pub,merchant_pub,exchange_sig,exchange_pub,master_sig)
);
COMMENT ON TABLE deposit_confirmations
@@ -245,7 +247,7 @@ COMMENT ON TABLE deposit_confirmations
CREATE TABLE IF NOT EXISTS auditor_predicted_result
- (master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
+ (master_pub BYTEA NOT NULL CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
,balance_val INT8 NOT NULL
,balance_frac INT4 NOT NULL
);
diff --git a/src/auditordb/plugin_auditordb_postgres.c b/src/auditordb/plugin_auditordb_postgres.c
index be221a8b..5817c880 100644
--- a/src/auditordb/plugin_auditordb_postgres.c
+++ b/src/auditordb/plugin_auditordb_postgres.c
@@ -188,8 +188,10 @@ setup_connection (struct PostgresClosure *pg)
"INSERT INTO deposit_confirmations "
"(master_pub"
",h_contract_terms"
+ ",h_extensions"
",h_wire"
",exchange_timestamp"
+ ",wire_deadline"
",refund_deadline"
",amount_without_fee_val"
",amount_without_fee_frac"
@@ -198,15 +200,17 @@ setup_connection (struct PostgresClosure *pg)
",exchange_sig"
",exchange_pub"
",master_sig" /* master_sig could be normalized... */
- ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12);",
- 12),
+ ") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14);",
+ 14),
/* Used in #postgres_get_deposit_confirmations() */
GNUNET_PQ_make_prepare ("auditor_deposit_confirmation_select",
"SELECT"
" serial_id"
",h_contract_terms"
+ ",h_extensions"
",h_wire"
",exchange_timestamp"
+ ",wire_deadline"
",refund_deadline"
",amount_without_fee_val"
",amount_without_fee_frac"
@@ -1029,8 +1033,10 @@ postgres_insert_deposit_confirmation (
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (&dc->master_public_key),
GNUNET_PQ_query_param_auto_from_type (&dc->h_contract_terms),
+ GNUNET_PQ_query_param_auto_from_type (&dc->h_extensions),
GNUNET_PQ_query_param_auto_from_type (&dc->h_wire),
TALER_PQ_query_param_absolute_time (&dc->exchange_timestamp),
+ TALER_PQ_query_param_absolute_time (&dc->wire_deadline),
TALER_PQ_query_param_absolute_time (&dc->refund_deadline),
TALER_PQ_query_param_amount (&dc->amount_without_fee),
GNUNET_PQ_query_param_auto_from_type (&dc->coin_pub),
@@ -1108,12 +1114,16 @@ deposit_confirmation_cb (void *cls,
&serial_id),
GNUNET_PQ_result_spec_auto_from_type ("h_contract_terms",
&dc.h_contract_terms),
+ GNUNET_PQ_result_spec_auto_from_type ("h_extensions",
+ &dc.h_extensions),
GNUNET_PQ_result_spec_auto_from_type ("h_wire",
&dc.h_wire),
GNUNET_PQ_result_spec_absolute_time ("exchange_timestamp",
&dc.exchange_timestamp),
GNUNET_PQ_result_spec_absolute_time ("refund_deadline",
&dc.refund_deadline),
+ GNUNET_PQ_result_spec_absolute_time ("wire_deadline",
+ &dc.wire_deadline),
TALER_PQ_RESULT_SPEC_AMOUNT ("amount_without_fee",
&dc.amount_without_fee),
GNUNET_PQ_result_spec_auto_from_type ("coin_pub",
@@ -2153,7 +2163,7 @@ postgres_get_wire_fee_summary (void *cls,
static enum GNUNET_DB_QueryStatus
postgres_insert_denomination_balance (
void *cls,
- const struct GNUNET_HashCode *denom_pub_hash,
+ const struct TALER_DenominationHash *denom_pub_hash,
const struct TALER_Amount *denom_balance,
const struct TALER_Amount *denom_loss,
const struct TALER_Amount *denom_risk,
@@ -2193,7 +2203,7 @@ postgres_insert_denomination_balance (
static enum GNUNET_DB_QueryStatus
postgres_update_denomination_balance (
void *cls,
- const struct GNUNET_HashCode *denom_pub_hash,
+ const struct TALER_DenominationHash *denom_pub_hash,
const struct TALER_Amount *denom_balance,
const struct TALER_Amount *denom_loss,
const struct TALER_Amount *denom_risk,
@@ -2231,7 +2241,8 @@ postgres_update_denomination_balance (
*/
static enum GNUNET_DB_QueryStatus
postgres_get_denomination_balance (void *cls,
- const struct GNUNET_HashCode *denom_pub_hash,
+ const struct
+ TALER_DenominationHash *denom_pub_hash,
struct TALER_Amount *denom_balance,
struct TALER_Amount *denom_loss,
struct TALER_Amount *denom_risk,
@@ -2428,7 +2439,7 @@ static enum GNUNET_DB_QueryStatus
postgres_insert_historic_denom_revenue (
void *cls,
const struct TALER_MasterPublicKeyP *master_pub,
- const struct GNUNET_HashCode *denom_pub_hash,
+ const struct TALER_DenominationHash *denom_pub_hash,
struct GNUNET_TIME_Absolute revenue_timestamp,
const struct TALER_Amount *revenue_balance,
const struct TALER_Amount *loss_balance)
@@ -2495,7 +2506,7 @@ historic_denom_revenue_cb (void *cls,
for (unsigned int i = 0; i < num_results; i++)
{
- struct GNUNET_HashCode denom_pub_hash;
+ struct TALER_DenominationHash denom_pub_hash;
struct GNUNET_TIME_Absolute revenue_timestamp;
struct TALER_Amount revenue_balance;
struct TALER_Amount loss;
diff --git a/src/auditordb/test_auditordb.c b/src/auditordb/test_auditordb.c
index 237d8ec8..38f0c24f 100644
--- a/src/auditordb/test_auditordb.c
+++ b/src/auditordb/test_auditordb.c
@@ -130,23 +130,28 @@ run (void *cls)
struct TALER_MasterPublicKeyP master_pub;
struct TALER_ReservePublicKeyP reserve_pub;
- struct GNUNET_HashCode rnd_hash;
- RND_BLK (&master_pub);
- RND_BLK (&reserve_pub);
- RND_BLK (&rnd_hash);
-
+ struct TALER_DenominationHash rnd_hash;
struct TALER_DenominationPrivateKey denom_priv;
struct TALER_DenominationPublicKey denom_pub;
- struct GNUNET_HashCode denom_pub_hash;
+ struct TALER_DenominationHash denom_pub_hash;
+ struct GNUNET_TIME_Absolute now;
+ struct GNUNET_TIME_Absolute past;
+ struct GNUNET_TIME_Absolute future;
+ struct GNUNET_TIME_Absolute date;
- denom_priv.rsa_private_key = GNUNET_CRYPTO_rsa_private_key_create (1024);
- denom_pub.rsa_public_key = GNUNET_CRYPTO_rsa_private_key_get_public (
- denom_priv.rsa_private_key);
- GNUNET_CRYPTO_rsa_public_key_hash (denom_pub.rsa_public_key, &denom_pub_hash);
- GNUNET_CRYPTO_rsa_private_key_free (denom_priv.rsa_private_key);
- GNUNET_CRYPTO_rsa_public_key_free (denom_pub.rsa_public_key);
+ RND_BLK (&master_pub);
+ RND_BLK (&reserve_pub);
+ RND_BLK (&rnd_hash);
+ GNUNET_assert (GNUNET_OK ==
+ TALER_denom_priv_create (&denom_priv,
+ &denom_pub,
+ TALER_DENOMINATION_RSA,
+ 1024));
+ TALER_denom_pub_hash (&denom_pub,
+ &denom_pub_hash);
+ TALER_denom_priv_free (&denom_priv);
+ TALER_denom_pub_free (&denom_pub);
- struct GNUNET_TIME_Absolute now, past, future, date;
now = GNUNET_TIME_absolute_get ();
(void) GNUNET_TIME_round_abs (&now);
past = GNUNET_TIME_absolute_subtract (now,
@@ -480,14 +485,12 @@ run (void *cls)
"Test: select_historic_denom_revenue\n");
int
- select_historic_denom_revenue_result (void *cls,
- const struct
- GNUNET_HashCode *denom_pub_hash2,
- struct GNUNET_TIME_Absolute
- revenue_timestamp2,
- const struct
- TALER_Amount *revenue_balance2,
- const struct TALER_Amount *loss2)
+ select_historic_denom_revenue_result (
+ void *cls,
+ const struct TALER_DenominationHash *denom_pub_hash2,
+ struct GNUNET_TIME_Absolute revenue_timestamp2,
+ const struct TALER_Amount *revenue_balance2,
+ const struct TALER_Amount *loss2)
{
static int n = 0;