summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/taler-merchant-httpd_exchanges.c3
-rw-r--r--src/backend/taler-merchant-httpd_private-post-transfers.c14
-rw-r--r--src/backenddb/drop0001.sql4
-rw-r--r--src/backenddb/merchant-0001.sql60
-rw-r--r--src/backenddb/merchant-0002.sql66
-rw-r--r--src/backenddb/merchant-0003.sql43
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c35
-rw-r--r--src/backenddb/test_merchantdb.c90
-rw-r--r--src/include/taler_merchantdb_plugin.h14
9 files changed, 124 insertions, 205 deletions
diff --git a/src/backend/taler-merchant-httpd_exchanges.c b/src/backend/taler-merchant-httpd_exchanges.c
index 65971eee..be29cfcc 100644
--- a/src/backend/taler-merchant-httpd_exchanges.c
+++ b/src/backend/taler-merchant-httpd_exchanges.c
@@ -410,8 +410,7 @@ process_wire_fees (struct Exchange *exchange,
qs = TMH_db->store_wire_fee_by_exchange (TMH_db->cls,
master_pub,
&h_wire_method,
- &af->fees.wire,
- &af->fees.closing,
+ &af->fees,
af->start_date,
af->end_date,
&af->master_sig);
diff --git a/src/backend/taler-merchant-httpd_private-post-transfers.c b/src/backend/taler-merchant-httpd_private-post-transfers.c
index 83742d01..15efeb3c 100644
--- a/src/backend/taler-merchant-httpd_private-post-transfers.c
+++ b/src/backend/taler-merchant-httpd_private-post-transfers.c
@@ -380,8 +380,7 @@ check_wire_fee (struct PostTransfersContext *ptc,
struct GNUNET_TIME_Timestamp execution_time,
const struct TALER_Amount *wire_fee)
{
- struct TALER_Amount expected_fee;
- struct TALER_Amount closing_fee;
+ struct TALER_WireFeeSet fees;
struct TALER_MasterSignatureP master_sig;
struct GNUNET_TIME_Timestamp start_date;
struct GNUNET_TIME_Timestamp end_date;
@@ -393,8 +392,7 @@ check_wire_fee (struct PostTransfersContext *ptc,
&ptc->master_pub,
wire_method,
execution_time,
- &expected_fee,
- &closing_fee,
+ &fees,
&start_date,
&end_date,
&master_sig);
@@ -421,7 +419,7 @@ check_wire_fee (struct PostTransfersContext *ptc,
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
break;
}
- if (0 <= TALER_amount_cmp (&expected_fee,
+ if (0 <= TALER_amount_cmp (&fees.wire,
wire_fee))
{
GNUNET_free (wire_method);
@@ -438,9 +436,11 @@ check_wire_fee (struct PostTransfersContext *ptc,
GNUNET_JSON_pack_timestamp ("execution_time",
execution_time),
TALER_JSON_pack_amount ("expected_wire_fee",
- &expected_fee),
+ &fees.wire),
TALER_JSON_pack_amount ("expected_closing_fee",
- &closing_fee),
+ &fees.closing),
+ TALER_JSON_pack_amount ("expected_wad_fee",
+ &fees.wad),
GNUNET_JSON_pack_timestamp ("start_date",
start_date),
GNUNET_JSON_pack_timestamp ("end_date",
diff --git a/src/backenddb/drop0001.sql b/src/backenddb/drop0001.sql
index d7171e9d..cc24f059 100644
--- a/src/backenddb/drop0001.sql
+++ b/src/backenddb/drop0001.sql
@@ -24,10 +24,10 @@ BEGIN;
-- latest requirements for dropping tables.
-- Unregister patch (0003.sql)
-SELECT _v.unregister_patch('merchant-0003');
+--SELECT _v.unregister_patch('merchant-0003');
-- Unregister patch (0002.sql)
-SELECT _v.unregister_patch('merchant-0002');
+--SELECT _v.unregister_patch('merchant-0002');
-- Unregister patch (0001.sql)
SELECT _v.unregister_patch('merchant-0001');
diff --git a/src/backenddb/merchant-0001.sql b/src/backenddb/merchant-0001.sql
index 4a458259..96e29e5b 100644
--- a/src/backenddb/merchant-0001.sql
+++ b/src/backenddb/merchant-0001.sql
@@ -1,6 +1,6 @@
--
-- This file is part of TALER
--- Copyright (C) 2014--2020 Taler Systems SA
+-- Copyright (C) 2014--2022 Taler Systems SA
--
-- TALER is free software; you can redistribute it and/or modify it under the
-- terms of the GNU General Public License as published by the Free Software
@@ -32,6 +32,8 @@ CREATE TABLE IF NOT EXISTS merchant_exchange_wire_fees
,wire_fee_frac INT4 NOT NULL
,closing_fee_val INT8 NOT NULL
,closing_fee_frac INT4 NOT NULL
+ ,wad_fee_val INT8 NOT NULL
+ ,wad_fee_frac INT4 NOT NULL
,master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64)
,UNIQUE (master_pub,h_wire_method,start_date)
);
@@ -61,6 +63,8 @@ COMMENT ON COLUMN merchant_exchange_signing_keys.master_pub
CREATE TABLE IF NOT EXISTS merchant_instances
(merchant_serial BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY
,merchant_pub BYTEA NOT NULL UNIQUE CHECK (LENGTH(merchant_pub)=32)
+ ,auth_hash BYTEA CHECK(LENGTH(auth_hash)=64)
+ ,auth_salt BYTEA CHECK(LENGTH(auth_salt)=32)
,merchant_id VARCHAR NOT NULL UNIQUE
,merchant_name VARCHAR NOT NULL
,address BYTEA NOT NULL
@@ -83,6 +87,12 @@ COMMENT ON COLUMN merchant_instances.address
IS 'physical address of the merchant as a Location in JSON format (required)';
COMMENT ON COLUMN merchant_instances.jurisdiction
IS 'jurisdiction of the merchant as a Location in JSON format (required)';
+COMMENT ON COLUMN merchant_instances.auth_hash
+ IS 'hash used for merchant back office Authorization, NULL for no check';
+COMMENT ON COLUMN merchant_instances.auth_salt
+ IS 'salt to use when hashing Authorization header before comparing with auth_hash';
+
+
CREATE TABLE IF NOT EXISTS merchant_keys
(merchant_priv BYTEA NOT NULL UNIQUE CHECK (LENGTH(merchant_priv)=32),
@@ -134,6 +144,7 @@ CREATE TABLE IF NOT EXISTS merchant_inventory
,total_lost BIGINT NOT NULL DEFAULT 0
,address BYTEA NOT NULL
,next_restock INT8 NOT NULL
+ ,minimum_age INT4 NOT NULL DEFAULT 0
,UNIQUE (merchant_serial, product_id)
);
COMMENT ON TABLE merchant_inventory
@@ -160,6 +171,8 @@ COMMENT ON COLUMN merchant_inventory.address
IS 'JSON formatted Location of where the product is stocked';
COMMENT ON COLUMN merchant_inventory.next_restock
IS 'GNUnet absolute time indicating when the next restock is expected. 0 for unknown.';
+COMMENT ON COLUMN merchant_inventory.minimum_age
+ IS 'Minimum age of the customer in years, to be used if an exchange supports the age restriction extension.';
CREATE TABLE IF NOT EXISTS merchant_inventory_locks
@@ -245,6 +258,7 @@ CREATE TABLE IF NOT EXISTS merchant_contract_terms
,wired BOOLEAN DEFAULT FALSE NOT NULL
,fulfillment_url VARCHAR
,session_id VARCHAR DEFAULT '' NOT NULL
+ ,claim_token BYTEA NOT NULL CHECK (LENGTH(claim_token)=16)
,UNIQUE (merchant_serial, order_id)
,UNIQUE (merchant_serial, h_contract_terms)
);
@@ -270,6 +284,9 @@ COMMENT ON COLUMN merchant_contract_terms.session_id
IS 'last session_id from we confirmed the paying client to use, empty string for none';
COMMENT ON COLUMN merchant_contract_terms.pay_deadline
IS 'How long is the offer valid. After this time, the order can be garbage collected';
+COMMENT ON COLUMN merchant_contract_terms.claim_token
+ IS 'Token optionally used to access the status of the order. All zeros (not NULL) if not used';
+
CREATE INDEX IF NOT EXISTS merchant_contract_terms_by_merchant_and_expiration
ON merchant_contract_terms
(merchant_serial,pay_deadline);
@@ -385,6 +402,8 @@ CREATE TABLE IF NOT EXISTS merchant_transfer_signatures
REFERENCES merchant_exchange_signing_keys (signkey_serial) ON DELETE CASCADE
,wire_fee_val INT8 NOT NULL
,wire_fee_frac INT4 NOT NULL
+ ,credit_amount_val INT8 NOT NULL
+ ,credit_amount_frac INT4 NOT NULL
,execution_time INT8 NOT NULL
,exchange_sig BYTEA NOT NULL CHECK (LENGTH(exchange_sig)=64)
);
@@ -392,6 +411,9 @@ COMMENT ON TABLE merchant_transfer_signatures
IS 'table represents the main information returned from the /transfer request to the exchange.';
COMMENT ON COLUMN merchant_transfer_signatures.execution_time
IS 'Execution time as claimed by the exchange, roughly matches time seen by merchant';
+COMMENT ON COLUMN merchant_transfer_signatures.credit_amount_val
+ IS 'actual value of the (aggregated) wire transfer, excluding the wire fee, according to the exchange';
+
CREATE TABLE IF NOT EXISTS merchant_transfer_to_coin
(deposit_serial BIGINT UNIQUE NOT NULL
@@ -480,9 +502,13 @@ CREATE TABLE IF NOT EXISTS merchant_tip_reserve_keys
REFERENCES merchant_tip_reserves (reserve_serial) ON DELETE CASCADE
,reserve_priv BYTEA NOT NULL UNIQUE CHECK (LENGTH(reserve_priv)=32)
,exchange_url VARCHAR NOT NULL
+ ,payto_uri VARCHAR
);
COMMENT ON TABLE merchant_tip_reserves
IS 'private keys of reserves that have not been deleted';
+COMMENT ON COLUMN merchant_tip_reserve_keys.payto_uri
+ IS 'payto:// URI used to fund the reserve, may be NULL once reserve is funded';
+
CREATE TABLE IF NOT EXISTS merchant_tips
(tip_serial BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY
@@ -536,5 +562,37 @@ COMMENT ON TABLE merchant_tip_pickup_signatures
IS 'blind signatures we got from the exchange during the tip pickup';
+
+
+CREATE TABLE IF NOT EXISTS merchant_kyc
+(kyc_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE
+,kyc_timestamp INT8 NOT NULL
+,kyc_ok BOOLEAN NOT NULL DEFAULT (FALSE)
+,exchange_sig BYTEA CHECK(LENGTH(exchange_sig)=64)
+,exchange_pub BYTEA CHECK(LENGTH(exchange_pub)=32)
+,exchange_kyc_serial INT8 NOT NULL DEFAULT(0)
+,account_serial INT8 NOT NULL
+ REFERENCES merchant_accounts (account_serial) ON DELETE CASCADE
+,exchange_url VARCHAR NOT NULL
+,PRIMARY KEY (account_serial,exchange_url)
+);
+COMMENT ON TABLE merchant_kyc
+ IS 'Status of the KYC process of a merchant account at an exchange';
+COMMENT ON COLUMN merchant_kyc.kyc_timestamp
+ IS 'Last time we checked our KYC status at the exchange. Useful to re-check if the status is very stale. Also the timestamp used for the exchange signature (if present).';
+COMMENT ON COLUMN merchant_kyc.exchange_kyc_serial
+ IS 'Number to use in the KYC-endpoints of the exchange to check the KYC status or begin the KYC process. 0 if we do not know it yet.';
+COMMENT ON COLUMN merchant_kyc.kyc_ok
+ IS 'true if the KYC check was passed successfully';
+COMMENT ON COLUMN merchant_kyc.exchange_sig
+ IS 'signature of the exchange affirming the KYC passed (or NULL if exchange does not require KYC or not kyc_ok)';
+COMMENT ON COLUMN merchant_kyc.exchange_pub
+ IS 'public key used with exchange_sig (or NULL if exchange_sig is NULL)';
+COMMENT ON COLUMN merchant_kyc.account_serial
+ IS 'Which bank account of the merchant is the KYC status for';
+COMMENT ON COLUMN merchant_kyc.exchange_url
+ IS 'Which exchange base URL is this KYC status valid for';
+
+
-- Complete transaction
COMMIT;
diff --git a/src/backenddb/merchant-0002.sql b/src/backenddb/merchant-0002.sql
index 2656fedb..87ccd220 100644
--- a/src/backenddb/merchant-0002.sql
+++ b/src/backenddb/merchant-0002.sql
@@ -14,75 +14,11 @@
-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
--
--- This file includes migrations up to 0.8.2.
--- All migrations after that release should
--- to into a different file.
-
-- Everything in one big transaction
BEGIN;
-- Check patch versioning is in place.
-SELECT _v.register_patch('merchant-0002', NULL, NULL);
-
-
--- need serial IDs on various tables for exchange-auditor replication
-ALTER TABLE merchant_instances
- ADD COLUMN auth_hash BYTEA CHECK(LENGTH(auth_hash)=64),
- ADD COLUMN auth_salt BYTEA CHECK(LENGTH(auth_salt)=32);
-COMMENT ON COLUMN merchant_instances.auth_hash
- IS 'hash used for merchant back office Authorization, NULL for no check';
-COMMENT ON COLUMN merchant_instances.auth_salt
- IS 'salt to use when hashing Authorization header before comparing with auth_hash';
-
-
-
--- need to preserve payto_uri for extended reserve API (easier than to reconstruct)
-ALTER TABLE merchant_tip_reserve_keys
- ADD COLUMN payto_uri VARCHAR;
-COMMENT ON COLUMN merchant_tip_reserve_keys.payto_uri
- IS 'payto:// URI used to fund the reserve, may be NULL once reserve is funded';
-
-
--- need serial IDs on various tables for exchange-auditor replication
-ALTER TABLE merchant_transfer_signatures
- ADD COLUMN credit_amount_val INT8,
- ADD COLUMN credit_amount_frac INT4;
-COMMENT ON COLUMN merchant_transfers.credit_amount_val
- IS 'actual value of the (aggregated) wire transfer, excluding the wire fee, according to the exchange';
-
-
--- support different amounts claimed by exchange and merchant about wire transfers,
--- add column to tell when this happens; but "believe" existing amounts match, as
--- otherwise earlier version of the code would have failed hard.
-UPDATE merchant_transfer_signatures
- SET credit_amount_val=mt.credit_amount_val,
- credit_amount_frac=mt.credit_amount_frac
- FROM merchant_transfer_signatures mts
- INNER JOIN merchant_transfers mt USING(credit_serial);
-ALTER TABLE merchant_transfer_signatures
- ALTER COLUMN credit_amount_val SET NOT NULL,
- ALTER COLUMN credit_amount_frac SET NOT NULL;
-
--- contract terms now also need to check the claim_token,
--- as we consider the fulfillment_url private
-ALTER TABLE merchant_contract_terms
- ADD COLUMN claim_token BYTEA;
-UPDATE merchant_contract_terms mct
- SET claim_token=ord.claim_token
- FROM merchant_orders ord
- WHERE mct.order_serial=ord.order_serial;
--- If the merchant_orders row already has been GCed,
--- we can't migrate to the correct claim_token anymore.
--- Instead of setting it to all zeroes (no auth),
--- we set it to a prefix of the h_contract_terms.
-UPDATE merchant_contract_terms
- SET claim_token = substring(h_contract_terms for 16)
- WHERE claim_token IS NULL;
-ALTER TABLE merchant_contract_terms
- ALTER COLUMN claim_token SET NOT NULL,
- ADD CHECK (LENGTH(claim_token)=16);
-COMMENT ON COLUMN merchant_contract_terms.claim_token
- IS 'Token optionally used to access the status of the order. All zeros (not NULL) if not used';
+-- SELECT _v.register_patch('merchant-0002', NULL, NULL);
-- Complete transaction
COMMIT;
diff --git a/src/backenddb/merchant-0003.sql b/src/backenddb/merchant-0003.sql
index 1c9bff57..f57112f8 100644
--- a/src/backenddb/merchant-0003.sql
+++ b/src/backenddb/merchant-0003.sql
@@ -14,52 +14,11 @@
-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
--
--- This file includes migrations up to 0.8.5.
--- All migrations after that release should
--- to into a different file.
-
-- Everything in one big transaction
BEGIN;
-- Check patch versioning is in place.
-SELECT _v.register_patch('merchant-0003', NULL, NULL);
-
-CREATE TABLE IF NOT EXISTS merchant_kyc
-(kyc_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE
-,kyc_timestamp INT8 NOT NULL
-,kyc_ok BOOLEAN NOT NULL DEFAULT (FALSE)
-,exchange_sig BYTEA CHECK(LENGTH(exchange_sig)=64)
-,exchange_pub BYTEA CHECK(LENGTH(exchange_pub)=32)
-,exchange_kyc_serial INT8 NOT NULL DEFAULT(0)
-,account_serial INT8 NOT NULL
- REFERENCES merchant_accounts (account_serial) ON DELETE CASCADE
-,exchange_url VARCHAR NOT NULL
-,PRIMARY KEY (account_serial,exchange_url)
-);
-COMMENT ON TABLE merchant_kyc
- IS 'Status of the KYC process of a merchant account at an exchange';
-COMMENT ON COLUMN merchant_kyc.kyc_timestamp
- IS 'Last time we checked our KYC status at the exchange. Useful to re-check if the status is very stale. Also the timestamp used for the exchange signature (if present).';
-COMMENT ON COLUMN merchant_kyc.exchange_kyc_serial
- IS 'Number to use in the KYC-endpoints of the exchange to check the KYC status or begin the KYC process. 0 if we do not know it yet.';
-COMMENT ON COLUMN merchant_kyc.kyc_ok
- IS 'true if the KYC check was passed successfully';
-COMMENT ON COLUMN merchant_kyc.exchange_sig
- IS 'signature of the exchange affirming the KYC passed (or NULL if exchange does not require KYC or not kyc_ok)';
-COMMENT ON COLUMN merchant_kyc.exchange_pub
- IS 'public key used with exchange_sig (or NULL if exchange_sig is NULL)';
-COMMENT ON COLUMN merchant_kyc.account_serial
- IS 'Which bank account of the merchant is the KYC status for';
-COMMENT ON COLUMN merchant_kyc.exchange_url
- IS 'Which exchange base URL is this KYC status valid for';
-
-
--- add age restriction column to product
-ALTER TABLE merchant_inventory
- ADD COLUMN minimum_age INT4 NOT NULL DEFAULT 0;
-COMMENT ON COLUMN merchant_inventory.minimum_age
- IS 'Minimum age of the customer in years, to be used if an exchange supports the age restriction extension.';
-
+-- SELECT _v.register_patch('merchant-0003', NULL, NULL);
-- Complete transaction
COMMIT;
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index 834b73a3..39f42aef 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -4210,9 +4210,7 @@ RETRY:
* @param master_pub public key of the exchange
* @param wire_method the wire method
* @param contract_date date of the contract to use for the lookup
- * @param[out] wire_fee wire fee charged
- * @param[out] closing_fee closing fee charged (irrelevant for us,
- * but needed to check signature)
+ * @param[out] fees wire fees charged
* @param[out] start_date start of fee being used
* @param[out] end_date end of fee being used
* @param[out] master_sig signature of exchange over fee structure
@@ -4223,8 +4221,7 @@ postgres_lookup_wire_fee (void *cls,
const struct TALER_MasterPublicKeyP *master_pub,
const char *wire_method,
struct GNUNET_TIME_Timestamp contract_date,
- struct TALER_Amount *wire_fee,
- struct TALER_Amount *closing_fee,
+ struct TALER_WireFeeSet *fees,
struct GNUNET_TIME_Timestamp *start_date,
struct GNUNET_TIME_Timestamp *end_date,
struct TALER_MasterSignatureP *master_sig)
@@ -4239,9 +4236,11 @@ postgres_lookup_wire_fee (void *cls,
};
struct GNUNET_PQ_ResultSpec rs[] = {
TALER_PQ_RESULT_SPEC_AMOUNT ("wire_fee",
- wire_fee),
+ &fees->wire),
TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee",
- closing_fee),
+ &fees->closing),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("wad_fee",
+ &fees->wad),
GNUNET_PQ_result_spec_timestamp ("start_date",
start_date),
GNUNET_PQ_result_spec_timestamp ("end_date",
@@ -5036,9 +5035,7 @@ postgres_lookup_transfers (void *cls,
* @param cls closure
* @param master_pub public key of the exchange
* @param h_wire_method hash of wire method
- * @param wire_fee wire fee charged
- * @param closing_fee closing fee charged (irrelevant for us,
- * but needed to check signature)
+ * @param fees the fee charged
* @param start_date start of fee being used
* @param end_date end of fee being used
* @param master_sig signature of exchange over fee structure
@@ -5049,8 +5046,7 @@ postgres_store_wire_fee_by_exchange (
void *cls,
const struct TALER_MasterPublicKeyP *master_pub,
const struct GNUNET_HashCode *h_wire_method,
- const struct TALER_Amount *wire_fee,
- const struct TALER_Amount *closing_fee,
+ const struct TALER_WireFeeSet *fees,
struct GNUNET_TIME_Timestamp start_date,
struct GNUNET_TIME_Timestamp end_date,
const struct TALER_MasterSignatureP *master_sig)
@@ -5059,8 +5055,9 @@ postgres_store_wire_fee_by_exchange (
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_auto_from_type (h_wire_method),
- TALER_PQ_query_param_amount (wire_fee),
- TALER_PQ_query_param_amount (closing_fee),
+ TALER_PQ_query_param_amount (&fees->wire),
+ TALER_PQ_query_param_amount (&fees->closing),
+ TALER_PQ_query_param_amount (&fees->wad),
GNUNET_PQ_query_param_timestamp (&start_date),
GNUNET_PQ_query_param_timestamp (&end_date),
GNUNET_PQ_query_param_auto_from_type (master_sig),
@@ -5073,7 +5070,7 @@ postgres_store_wire_fee_by_exchange (
"Storing wire fee for %s starting at %s of %s\n",
TALER_B2S (master_pub),
GNUNET_TIME_timestamp2s (start_date),
- TALER_amount2s (wire_fee));
+ TALER_amount2s (&fees->wire));
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
"insert_wire_fee",
params);
@@ -8567,6 +8564,8 @@ postgres_connect (void *cls)
",wire_fee_frac"
",closing_fee_val"
",closing_fee_frac"
+ ",wad_fee_val"
+ ",wad_fee_frac"
",start_date"
",end_date"
",master_sig"
@@ -8879,12 +8878,14 @@ postgres_connect (void *cls)
",wire_fee_frac"
",closing_fee_val"
",closing_fee_frac"
+ ",wad_fee_val"
+ ",wad_fee_frac"
",start_date"
",end_date"
",master_sig)"
" VALUES "
- "($1, $2, $3, $4, $5, $6, $7, $8, $9)",
- 9),
+ "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)",
+ 11),
/* For postgres_insert_reserve() */
GNUNET_PQ_make_prepare ("insert_reserve",
"INSERT INTO merchant_tip_reserves"
diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c
index b30c88eb..57b38899 100644
--- a/src/backenddb/test_merchantdb.c
+++ b/src/backenddb/test_merchantdb.c
@@ -3219,14 +3219,9 @@ struct WireFeeData
struct GNUNET_HashCode h_wire_method;
/**
- * Wire fee charged.
+ * Wire fees charged.
*/
- struct TALER_Amount wire_fee;
-
- /**
- * Closing fee charged.
- */
- struct TALER_Amount closing_fee;
+ struct TALER_WireFeeSet fees;
/**
* Start date of the wire fee.
@@ -3255,38 +3250,29 @@ static void
make_wire_fee (const struct ExchangeSignkeyData *signkey,
struct WireFeeData *wire_fee)
{
- struct TALER_MasterWireFeePS fee_sign = {
- .purpose = {
- .size = htonl (sizeof (struct TALER_MasterWireFeePS)),
- .purpose = htonl (TALER_SIGNATURE_MASTER_WIRE_FEES)
- }
-
-
- };
-
wire_fee->wire_method = "wire-method";
GNUNET_CRYPTO_hash (wire_fee->wire_method,
strlen (wire_fee->wire_method) + 1,
&wire_fee->h_wire_method);
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount ("EUR:0.49",
- &wire_fee->wire_fee));
+ &wire_fee->fees.wire));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount ("EUR:0.49",
+ &wire_fee->fees.closing));
GNUNET_assert (GNUNET_OK ==
TALER_string_to_amount ("EUR:0.49",
- &wire_fee->closing_fee));
+ &wire_fee->fees.wad));
wire_fee->wire_fee_start = GNUNET_TIME_timestamp_get ();
wire_fee->wire_fee_end = GNUNET_TIME_relative_to_timestamp (
GNUNET_TIME_UNIT_MONTHS);
- fee_sign.h_wire_method = wire_fee->h_wire_method;
- TALER_amount_hton (&fee_sign.wire_fee,
- &wire_fee->wire_fee);
- TALER_amount_hton (&fee_sign.closing_fee,
- &wire_fee->closing_fee);
- fee_sign.start_date = GNUNET_TIME_timestamp_hton (wire_fee->wire_fee_start);
- fee_sign.end_date = GNUNET_TIME_timestamp_hton (wire_fee->wire_fee_end);
- GNUNET_CRYPTO_eddsa_sign (&signkey->master_priv.eddsa_priv,
- &fee_sign,
- &wire_fee->fee_sig.eddsa_signature);
+ TALER_exchange_offline_wire_fee_sign (
+ wire_fee->wire_method,
+ wire_fee->wire_fee_start,
+ wire_fee->wire_fee_end,
+ &wire_fee->fees,
+ &signkey->master_priv,
+ &wire_fee->fee_sig);
}
@@ -3820,18 +3806,13 @@ test_insert_wire_fee (const struct ExchangeSignkeyData *signkey,
enum GNUNET_DB_QueryStatus expected_result)
{
TEST_COND_RET_ON_FAIL (expected_result ==
- plugin->store_wire_fee_by_exchange (plugin->cls,
- &signkey->
- master_pub,
- &wire_fee->
- h_wire_method,
- &wire_fee->wire_fee,
- &wire_fee->
- closing_fee,
- wire_fee->
- wire_fee_start,
- wire_fee->
- wire_fee_end,
+ plugin->store_wire_fee_by_exchange (
+ plugin->cls,
+ &signkey->master_pub,
+ &wire_fee->h_wire_method,
+ &wire_fee->fees,
+ wire_fee->wire_fee_start,
+ wire_fee->wire_fee_end,
&wire_fee->fee_sig),
"Store wire fee by exchange failed\n");
return 0;
@@ -3849,8 +3830,7 @@ static int
test_lookup_wire_fee (const struct ExchangeSignkeyData *signkey,
const struct WireFeeData *wire_fee_data)
{
- struct TALER_Amount wire_fee;
- struct TALER_Amount closing_fee;
+ struct TALER_WireFeeSet fees;
struct GNUNET_TIME_Timestamp start_date;
struct GNUNET_TIME_Timestamp end_date;
struct TALER_MasterSignatureP master_sig;
@@ -3858,8 +3838,7 @@ test_lookup_wire_fee (const struct ExchangeSignkeyData *signkey,
&signkey->master_pub,
wire_fee_data->wire_method,
GNUNET_TIME_timestamp_get (),
- &wire_fee,
- &closing_fee,
+ &fees,
&start_date,
&end_date,
&master_sig))
@@ -3868,16 +3847,9 @@ test_lookup_wire_fee (const struct ExchangeSignkeyData *signkey,
"Lookup wire fee failed\n");
return 1;
}
- if ((GNUNET_OK !=
- TALER_amount_cmp_currency (&wire_fee_data->wire_fee,
- &wire_fee)) ||
- (0 != TALER_amount_cmp (&wire_fee_data->wire_fee,
- &wire_fee)) ||
- (GNUNET_OK !=
- TALER_amount_cmp_currency (&wire_fee_data->closing_fee,
- &closing_fee)) ||
- (0 != TALER_amount_cmp (&wire_fee_data->closing_fee,
- &closing_fee)) ||
+ if ((0 !=
+ TALER_wire_fee_set_cmp (&wire_fee_data->fees,
+ &fees)) ||
(GNUNET_TIME_timestamp_cmp (wire_fee_data->wire_fee_start,
!=,
start_date)) ||
@@ -4248,6 +4220,7 @@ static int
run_test_transfers (struct TestTransfers_Closure *cls)
{
uint64_t order_serial;
+ struct TALER_WireFeeSet fees;
/* Test lookup wire fee fails when it isn't in the db */
TEST_COND_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS ==
@@ -4255,8 +4228,7 @@ run_test_transfers (struct TestTransfers_Closure *cls)
&cls->signkey.master_pub,
cls->wire_fee[0].wire_method,
GNUNET_TIME_timestamp_get (),
- NULL,
- NULL,
+ &fees,
NULL,
NULL,
NULL),
@@ -5931,9 +5903,9 @@ lookup_refunds_detailed_cb (void *cls,
* @return 0 on success, 1 otherwise.
*/
static int
-test_lookup_refunds_detailed (const struct InstanceData *instance,
- const struct
- TALER_PrivateContractHash *h_contract_terms,
+test_lookup_refunds_detailed (
+ const struct InstanceData *instance,
+ const struct TALER_PrivateContractHashP *h_contract_terms,
bool cmp_timestamps,
unsigned int refunds_length,
const struct RefundData *refunds)
diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h
index fcd62fb3..adbea0a9 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -1867,9 +1867,7 @@ struct TALER_MERCHANTDB_Plugin
* @param master_pub master public key of the exchange
* @param h_wire_method hash of wire method
* @param contract_date date of the contract to use for the lookup
- * @param[out] wire_fee wire fee charged
- * @param[out] closing_fee closing fee charged (irrelevant for us,
- * but needed to check signature)
+ * @param[out] fees set to wire fees charged
* @param[out] start_date start of fee being used
* @param[out] end_date end of fee being used
* @param[out] master_sig signature of exchange over fee structure
@@ -1880,8 +1878,7 @@ struct TALER_MERCHANTDB_Plugin
const struct TALER_MasterPublicKeyP *master_pub,
const char *wire_method,
struct GNUNET_TIME_Timestamp contract_date,
- struct TALER_Amount *wire_fee,
- struct TALER_Amount *closing_fee,
+ struct TALER_WireFeeSet *fees,
struct GNUNET_TIME_Timestamp *start_date,
struct GNUNET_TIME_Timestamp *end_date,
struct TALER_MasterSignatureP *master_sig);
@@ -2036,9 +2033,7 @@ struct TALER_MERCHANTDB_Plugin
* @param cls closure
* @param exchange_pub public key of the exchange
* @param h_wire_method hash of wire method
- * @param wire_fee wire fee charged
- * @param closing_fee closing fee charged (irrelevant for us,
- * but needed to check signature)
+ * @param fees wire fees charged
* @param start_date start of fee being used
* @param end_date end of fee being used
* @param exchange_sig signature of exchange over fee structure
@@ -2049,8 +2044,7 @@ struct TALER_MERCHANTDB_Plugin
void *cls,
const struct TALER_MasterPublicKeyP *exchange_pub,
const struct GNUNET_HashCode *h_wire_method,
- const struct TALER_Amount *wire_fee,
- const struct TALER_Amount *closing_fee,
+ const struct TALER_WireFeeSet *fees,
struct GNUNET_TIME_Timestamp start_date,
struct GNUNET_TIME_Timestamp end_date,
const struct TALER_MasterSignatureP *exchange_sig);