summaryrefslogtreecommitdiff
path: root/src/exchangedb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-10-30 21:26:40 +0200
committerChristian Grothoff <christian@grothoff.org>2021-10-30 21:26:40 +0200
commit2faf102a05865b68e90ef48f292678dd1da6356e (patch)
tree5196e22766c0d5f0692d30121bda0b0e25527aa2 /src/exchangedb
parentbc57abc3daa56178378b5184b9ec987c860c5f62 (diff)
downloadexchange-2faf102a05865b68e90ef48f292678dd1da6356e.tar.gz
exchange-2faf102a05865b68e90ef48f292678dd1da6356e.tar.bz2
exchange-2faf102a05865b68e90ef48f292678dd1da6356e.zip
-more dB work
Diffstat (limited to 'src/exchangedb')
-rw-r--r--src/exchangedb/exchange-0001.sql4
-rw-r--r--src/exchangedb/irbt_callbacks.c55
-rw-r--r--src/exchangedb/lrbt_callbacks.c99
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c7
4 files changed, 105 insertions, 60 deletions
diff --git a/src/exchangedb/exchange-0001.sql b/src/exchangedb/exchange-0001.sql
index 905b5450c..e82d82b4b 100644
--- a/src/exchangedb/exchange-0001.sql
+++ b/src/exchangedb/exchange-0001.sql
@@ -143,8 +143,8 @@ CREATE INDEX IF NOT EXISTS reserves_in_exchange_account_serial
reserve_in_serial_id DESC
);
-
-CREATE TABLE IF NOT EXISTS reserves_close
+qq
+CREATE TABLE IF NOT EXISTS reserves_closeq
(close_uuid BIGSERIAL PRIMARY KEY
,reserve_uuid INT8 NOT NULL REFERENCES reserves (reserve_uuid) ON DELETE CASCADE
,execution_date INT8 NOT NULL
diff --git a/src/exchangedb/irbt_callbacks.c b/src/exchangedb/irbt_callbacks.c
index fe0df26b2..f008a2fe4 100644
--- a/src/exchangedb/irbt_callbacks.c
+++ b/src/exchangedb/irbt_callbacks.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet
- Copyright (C) 2020 Taler Systems SA
+ Copyright (C) 2020, 2021 Taler Systems SA
GNUnet is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
@@ -100,6 +100,37 @@ irbt_cb_table_denomination_revocations (
/**
+ * Function called with denominations records to insert into table.
+ *
+ * @param pg plugin context
+ * @param td record to insert
+ */
+static enum GNUNET_DB_QueryStatus
+irbt_cb_table_wire_targets (struct PostgresClosure *pg,
+ const struct TALER_EXCHANGEDB_TableData *td)
+{
+ struct TALER_PaytoHash payto_hash;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_auto_from_type (&payto_hash),
+ GNUNET_PQ_query_param_string (
+ td->details.wire_targets.payto_uri),
+ GNUNET_PQ_query_param_auto_from_type (
+ &td->details.wire_targets.kyc_ok),
+ GNUNET_PQ_query_param_string (
+ td->details.wire_targets.oauth_username),
+ GNUNET_PQ_query_param_end
+ };
+
+ TALER_payto_hash (
+ td->details.wire_targets.payto_uri,
+ &payto_hash);
+ return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+ "insert_into_table_wire_targets",
+ params);
+}
+
+
+/**
* Function called with reserves records to insert into table.
*
* @param pg plugin context
@@ -112,7 +143,6 @@ irbt_cb_table_reserves (struct PostgresClosure *pg,
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_auto_from_type (&td->details.reserves.reserve_pub),
- GNUNET_PQ_query_param_string (td->details.reserves.account_details),
TALER_PQ_query_param_amount (&td->details.reserves.current_balance),
TALER_PQ_query_param_absolute_time (&td->details.reserves.expiration_date),
TALER_PQ_query_param_absolute_time (&td->details.reserves.gc_date),
@@ -139,8 +169,7 @@ irbt_cb_table_reserves_in (struct PostgresClosure *pg,
GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_uint64 (&td->details.reserves_in.wire_reference),
TALER_PQ_query_param_amount (&td->details.reserves_in.credit),
- GNUNET_PQ_query_param_string (
- td->details.reserves_in.sender_account_details),
+ GNUNET_PQ_query_param_uint64 (&td->details.reserves_in.sender_account),
GNUNET_PQ_query_param_string (
td->details.reserves_in.exchange_account_section),
TALER_PQ_query_param_absolute_time (
@@ -170,7 +199,8 @@ irbt_cb_table_reserves_close (struct PostgresClosure *pg,
TALER_PQ_query_param_absolute_time (
&td->details.reserves_close.execution_date),
GNUNET_PQ_query_param_auto_from_type (&td->details.reserves_close.wtid),
- GNUNET_PQ_query_param_string (td->details.reserves_close.receiver_account),
+ GNUNET_PQ_query_param_uint64 (
+ &td->details.reserves_close.wire_target_serial_id),
TALER_PQ_query_param_amount (&td->details.reserves_close.amount),
TALER_PQ_query_param_amount (&td->details.reserves_close.closing_fee),
GNUNET_PQ_query_param_uint64 (&td->details.reserves_close.reserve_uuid),
@@ -462,9 +492,11 @@ irbt_cb_table_deposits (struct PostgresClosure *pg,
{
uint8_t tiny = td->details.deposits.tiny ? 1 : 0;
uint8_t done = td->details.deposits.done ? 1 : 0;
- struct TALER_MerchantWireHash h_wire;
+ uint8_t extension_blocked = td->details.deposits.extension_blocked ? 1 : 0;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&td->serial),
+ GNUNET_PQ_query_param_uint64 (&td->details.deposits.shard),
+ GNUNET_PQ_query_param_uint64 (&td->details.deposits.known_coin_id),
TALER_PQ_query_param_amount (&td->details.deposits.amount_with_fee),
TALER_PQ_query_param_absolute_time (&td->details.deposits.wallet_timestamp),
TALER_PQ_query_param_absolute_time (
@@ -474,17 +506,16 @@ irbt_cb_table_deposits (struct PostgresClosure *pg,
GNUNET_PQ_query_param_auto_from_type (&td->details.deposits.merchant_pub),
GNUNET_PQ_query_param_auto_from_type (
&td->details.deposits.h_contract_terms),
- GNUNET_PQ_query_param_auto_from_type (&h_wire),
GNUNET_PQ_query_param_auto_from_type (&td->details.deposits.coin_sig),
- TALER_PQ_query_param_json (td->details.deposits.wire),
+ GNUNET_PQ_query_param_auto_from_type (&td->details.deposits.wire_salt),
+ GNUNET_PQ_query_param_uint64 (&td->details.deposits.wire_target_serial_id),
GNUNET_PQ_query_param_auto_from_type (&tiny),
GNUNET_PQ_query_param_auto_from_type (&done),
- GNUNET_PQ_query_param_uint64 (&td->details.deposits.known_coin_id),
+ GNUNET_PQ_query_param_auto_from_type (&extension_blocked),
+ TALER_PQ_query_param_json (td->details.deposits.extension_options),
GNUNET_PQ_query_param_end
};
- TALER_JSON_merchant_wire_signature_hash (td->details.deposits.wire,
- &h_wire);
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"insert_into_table_deposits",
params);
@@ -530,7 +561,7 @@ irbt_cb_table_wire_out (struct PostgresClosure *pg,
GNUNET_PQ_query_param_uint64 (&td->serial),
TALER_PQ_query_param_absolute_time (&td->details.wire_out.execution_date),
GNUNET_PQ_query_param_auto_from_type (&td->details.wire_out.wtid_raw),
- TALER_PQ_query_param_json (td->details.wire_out.wire_target),
+ GNUNET_PQ_query_param_uint64 (&td->details.wire_out.wire_target_serial_id),
GNUNET_PQ_query_param_string (
td->details.wire_out.exchange_account_section),
TALER_PQ_query_param_amount (&td->details.wire_out.amount),
diff --git a/src/exchangedb/lrbt_callbacks.c b/src/exchangedb/lrbt_callbacks.c
index 2edff5584..f52fc3ab5 100644
--- a/src/exchangedb/lrbt_callbacks.c
+++ b/src/exchangedb/lrbt_callbacks.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet
- Copyright (C) 2020 Taler Systems SA
+ Copyright (C) 2020, 2021 Taler Systems SA
GNUnet is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
@@ -156,7 +156,6 @@ lrbt_cb_table_wire_targets (void *cls,
unsigned int num_results)
{
struct LookupRecordsByTableContext *ctx = cls;
- struct PostgresClosure *pg = ctx->pg;
struct TALER_EXCHANGEDB_TableData td = {
.table = TALER_EXCHANGEDB_RT_WIRE_TARGETS
};
@@ -216,8 +215,6 @@ lrbt_cb_table_reserves (void *cls,
&td.serial),
GNUNET_PQ_result_spec_auto_from_type ("reserve_pub",
&td.details.reserves.reserve_pub),
- GNUNET_PQ_result_spec_string ("account_details",
- &td.details.reserves.account_details),
TALER_PQ_RESULT_SPEC_AMOUNT ("current_balance",
&td.details.reserves.current_balance),
TALER_PQ_result_spec_absolute_time ("expiration_date",
@@ -270,12 +267,11 @@ lrbt_cb_table_reserves_in (void *cls,
&td.details.reserves_in.wire_reference),
TALER_PQ_RESULT_SPEC_AMOUNT ("credit",
&td.details.reserves_in.credit),
- GNUNET_PQ_result_spec_string ("sender_account_details",
- &td.details.reserves_in.
- sender_account_details),
- GNUNET_PQ_result_spec_string ("exchange_account_section",
- &td.details.reserves_in.
- exchange_account_section),
+ GNUNET_PQ_result_spec_uint64 ("sender_account",
+ &td.details.reserves_in.sender_account),
+ GNUNET_PQ_result_spec_string (
+ "exchange_account_section",
+ &td.details.reserves_in.exchange_account_section),
TALER_PQ_result_spec_absolute_time ("execution_date",
&td.details.reserves_in.execution_date),
GNUNET_PQ_result_spec_uint64 ("reserve_uuid",
@@ -322,21 +318,20 @@ lrbt_cb_table_reserves_close (void *cls,
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("serial",
&td.serial),
+ GNUNET_PQ_result_spec_uint64 ("reserve_uuid",
+ &td.details.reserves_close.reserve_uuid),
TALER_PQ_result_spec_absolute_time (
"execution_date",
&td.details.reserves_close.execution_date),
GNUNET_PQ_result_spec_auto_from_type ("wtid",
&td.details.reserves_close.wtid),
- GNUNET_PQ_result_spec_string (
- "receiver_account",
- &td.details.reserves_close.receiver_account),
+ GNUNET_PQ_result_spec_uint64 (
+ "wire_target_serial_id",
+ &td.details.reserves_close.wire_target_serial_id),
TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
&td.details.reserves_close.amount),
TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee",
&td.details.reserves_close.closing_fee),
- GNUNET_PQ_result_spec_uint64 ("reserve_uuid",
- &td.details.reserves_close.reserve_uuid),
-
GNUNET_PQ_result_spec_end
};
@@ -377,25 +372,30 @@ lrbt_cb_table_reserves_out (void *cls,
for (unsigned int i = 0; i<num_results; i++)
{
struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_uint64 ("serial",
- &td.serial),
- GNUNET_PQ_result_spec_auto_from_type ("h_blind_ev",
- &td.details.reserves_out.h_blind_ev),
+ GNUNET_PQ_result_spec_uint64 (
+ "serial",
+ &td.serial),
+ GNUNET_PQ_result_spec_auto_from_type (
+ "h_blind_ev",
+ &td.details.reserves_out.h_blind_ev),
+ GNUNET_PQ_result_spec_uint64 (
+ "denominations_serial",
+ &td.details.reserves_out.denominations_serial),
TALER_PQ_result_spec_denom_sig (
"denom_sig",
&td.details.reserves_out.denom_sig),
- GNUNET_PQ_result_spec_auto_from_type ("reserve_sig",
- &td.details.reserves_out.reserve_sig),
+ GNUNET_PQ_result_spec_uint64 (
+ "reserve_uuid",
+ &td.details.reserves_out.reserve_uuid),
+ GNUNET_PQ_result_spec_auto_from_type (
+ "reserve_sig",
+ &td.details.reserves_out.reserve_sig),
TALER_PQ_result_spec_absolute_time (
"execution_date",
&td.details.reserves_out.execution_date),
- TALER_PQ_RESULT_SPEC_AMOUNT ("amount_with_fee",
- &td.details.reserves_out.amount_with_fee),
- GNUNET_PQ_result_spec_uint64 ("reserve_uuid",
- &td.details.reserves_out.reserve_uuid),
- GNUNET_PQ_result_spec_uint64 ("denominations_serial",
- &td.details.reserves_out.
- denominations_serial),
+ TALER_PQ_RESULT_SPEC_AMOUNT (
+ "amount_with_fee",
+ &td.details.reserves_out.amount_with_fee),
GNUNET_PQ_result_spec_end
};
@@ -883,6 +883,9 @@ lrbt_cb_table_deposits (void *cls,
GNUNET_PQ_result_spec_uint64 (
"shard",
&td.details.deposits.shard),
+ GNUNET_PQ_result_spec_uint64 (
+ "known_coin_id",
+ &td.details.deposits.known_coin_id),
TALER_PQ_RESULT_SPEC_AMOUNT (
"amount_with_fee",
&td.details.deposits.amount_with_fee),
@@ -907,24 +910,24 @@ lrbt_cb_table_deposits (void *cls,
GNUNET_PQ_result_spec_auto_from_type (
"coin_sig",
&td.details.deposits.coin_sig),
+ GNUNET_PQ_result_spec_auto_from_type (
+ "wire_salt",
+ &td.details.deposits.wire_salt),
GNUNET_PQ_result_spec_uint64 (
"wire_target_serial_id",
&td.details.deposits.wire_target_serial_id),
- GNUNET_PQ_result_spec_json (
- "extension_options",
- &td.details.deposits.extension_options),
- GNUNET_PQ_result_spec_auto_from_type (
- "extension_blocked",
- &td.details.deposits.extension_blocked),
GNUNET_PQ_result_spec_auto_from_type (
"tiny",
&td.details.deposits.tiny),
GNUNET_PQ_result_spec_auto_from_type (
"done",
&td.details.deposits.done),
- GNUNET_PQ_result_spec_uint64 (
- "known_coin_id",
- &td.details.deposits.known_coin_id),
+ GNUNET_PQ_result_spec_auto_from_type (
+ "extension_blocked",
+ &td.details.deposits.extension_blocked),
+ TALER_PQ_result_spec_json (
+ "extension_options",
+ &td.details.deposits.extension_options),
GNUNET_PQ_result_spec_end
};
@@ -1019,17 +1022,21 @@ lrbt_cb_table_wire_out (void *cls,
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("serial",
&td.serial),
- TALER_PQ_result_spec_absolute_time ("execution_date",
- &td.details.wire_out.execution_date),
- GNUNET_PQ_result_spec_auto_from_type ("wtid_raw",
- &td.details.wire_out.wtid_raw),
- TALER_PQ_result_spec_json ("wire_target",
- &td.details.wire_out.wire_target),
+ TALER_PQ_result_spec_absolute_time (
+ "execution_date",
+ &td.details.wire_out.execution_date),
+ GNUNET_PQ_result_spec_auto_from_type (
+ "wtid_raw",
+ &td.details.wire_out.wtid_raw),
+ GNUNET_PQ_result_spec_uint64 (
+ "wire_target_serial_id",
+ &td.details.wire_out.wire_target_serial_id),
GNUNET_PQ_result_spec_string (
"exchange_account_section",
&td.details.wire_out.exchange_account_section),
- TALER_PQ_RESULT_SPEC_AMOUNT ("amount",
- &td.details.wire_out.amount),
+ TALER_PQ_RESULT_SPEC_AMOUNT (
+ "amount",
+ &td.details.wire_out.amount),
GNUNET_PQ_result_spec_end
};
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index 846b59b01..fe21b9d30 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -10729,6 +10729,10 @@ postgres_lookup_records_by_table (void *cls,
statement = "select_above_serial_by_table_denomination_revocations";
rh = &lrbt_cb_table_denomination_revocations;
break;
+ case TALER_EXCHANGEDB_RT_WIRE_TARGETS:
+ statement = "select_above_serial_by_table_wire_targets";
+ rh = &lrbt_cb_table_wire_targets;
+ break;
case TALER_EXCHANGEDB_RT_RESERVES:
statement = "select_above_serial_by_table_reserves";
rh = &lrbt_cb_table_reserves;
@@ -10862,6 +10866,9 @@ postgres_insert_records_by_table (void *cls,
case TALER_EXCHANGEDB_RT_DENOMINATION_REVOCATIONS:
rh = &irbt_cb_table_denomination_revocations;
break;
+ case TALER_EXCHANGEDB_RT_WIRE_TARGETS:
+ rh = &irbt_cb_table_wire_targets;
+ break;
case TALER_EXCHANGEDB_RT_RESERVES:
rh = &irbt_cb_table_reserves;
break;