summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-10-28 21:06:23 +0100
committerChristian Grothoff <christian@grothoff.org>2015-10-28 21:06:23 +0100
commitc2a40aa83924fd88b9c1ec0084f87109b01a8324 (patch)
tree18376f785528df6997502d51a6a361d4ebec29f6
parent3fd22d4b6fdcb470dcbd11b35b20c0ddcf771939 (diff)
downloadexchange-c2a40aa83924fd88b9c1ec0084f87109b01a8324.tar.gz
exchange-c2a40aa83924fd88b9c1ec0084f87109b01a8324.tar.bz2
exchange-c2a40aa83924fd88b9c1ec0084f87109b01a8324.zip
fix #4032: move wire deadline form wire details to advisory field in /deposit request
-rw-r--r--src/include/taler_mint_service.h3
-rw-r--r--src/include/taler_mintdb_plugin.h11
-rw-r--r--src/mint-lib/mint_api_deposit.c8
-rw-r--r--src/mint-lib/test_mint_api.c3
-rw-r--r--src/mint/taler-mint-httpd_deposit.c1
-rw-r--r--src/mintdb/Makefile.am4
-rw-r--r--src/mintdb/plugin_mintdb_postgres.c15
-rw-r--r--src/util/test_wireformats.c4
-rw-r--r--src/util/wireformats.c3
9 files changed, 40 insertions, 12 deletions
diff --git a/src/include/taler_mint_service.h b/src/include/taler_mint_service.h
index e36dcf692..0222437ba 100644
--- a/src/include/taler_mint_service.h
+++ b/src/include/taler_mint_service.h
@@ -505,6 +505,8 @@ typedef void
*
* @param mint the mint handle; the mint must be ready to operate
* @param amount the amount to be deposited
+ * @param wire_deadline execution date, until which the merchant would like the mint to settle the balance (advisory, the mint cannot be
+ * forced to settle in the past or upon very short notice, but of course a well-behaved mint will limit aggregation based on the advice received)
* @param wire_details the merchant’s account details, in a format supported by the mint
* @param h_contract hash of the contact of the merchant with the customer (further details are never disclosed to the mint)
* @param coin_pub coin’s public key
@@ -523,6 +525,7 @@ typedef void
struct TALER_MINT_DepositHandle *
TALER_MINT_deposit (struct TALER_MINT_Handle *mint,
const struct TALER_Amount *amount,
+ struct GNUNET_TIME_Absolute wire_deadline,
json_t *wire_details,
const struct GNUNET_HashCode *h_contract,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
diff --git a/src/include/taler_mintdb_plugin.h b/src/include/taler_mintdb_plugin.h
index c8013acc3..d83cf9d44 100644
--- a/src/include/taler_mintdb_plugin.h
+++ b/src/include/taler_mintdb_plugin.h
@@ -276,6 +276,14 @@ struct TALER_MINTDB_Deposit
struct GNUNET_TIME_Absolute refund_deadline;
/**
+ * How much time does the merchant have to execute the wire transfer?
+ * This time is advisory for aggregating transactions, not a hard
+ * constraint (as the merchant can theoretically pick any time,
+ * including one in the past).
+ */
+ struct GNUNET_TIME_Absolute wire_deadline;
+
+ /**
* Fraction of the coin's remaining value to be deposited, including
* depositing fee (if any). The coin is identified by @e coin_pub.
*/
@@ -528,6 +536,8 @@ struct TALER_MINTDB_Session;
* @param deposit_fee amount the mint gets to keep as transaction fees
* @param transaction_id unique transaction ID chosen by the merchant
* @param h_contract hash of the contract between merchant and customer
+ * @param wire_deadline by which the merchant adviced that he would like the
+ * wire transfer to be executed
* @param wire wire details for the merchant
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
*/
@@ -538,6 +548,7 @@ typedef int
const struct TALER_Amount *deposit_fee,
uint64_t transaction_id,
const struct GNUNET_HashCode *h_contract,
+ struct GNUNET_TIME_Absolute wire_deadline,
const json_t *wire);
diff --git a/src/mint-lib/mint_api_deposit.c b/src/mint-lib/mint_api_deposit.c
index 3da9d0ae4..541317763 100644
--- a/src/mint-lib/mint_api_deposit.c
+++ b/src/mint-lib/mint_api_deposit.c
@@ -358,6 +358,8 @@ verify_signatures (const struct TALER_MINT_DenomPublicKey *dki,
*
* @param mint the mint handle; the mint must be ready to operate
* @param amount the amount to be deposited
+ * @param wire_deadline date until which the merchant would like the mint to settle the balance (advisory, the mint cannot be
+ * forced to settle in the past or upon very short notice, but of course a well-behaved mint will limit aggregation based on the advice received)
* @param wire_details the merchant’s account details, in a format supported by the mint
* @param h_contract hash of the contact of the merchant with the customer (further details are never disclosed to the mint)
* @param coin_pub coin’s public key
@@ -376,6 +378,7 @@ verify_signatures (const struct TALER_MINT_DenomPublicKey *dki,
struct TALER_MINT_DepositHandle *
TALER_MINT_deposit (struct TALER_MINT_Handle *mint,
const struct TALER_Amount *amount,
+ struct GNUNET_TIME_Absolute wire_deadline,
json_t *wire_details,
const struct GNUNET_HashCode *h_contract,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
@@ -398,6 +401,7 @@ TALER_MINT_deposit (struct TALER_MINT_Handle *mint,
struct GNUNET_HashCode h_wire;
struct TALER_Amount amount_without_fee;
+ (void) TALER_round_abs_time (&wire_deadline);
if (GNUNET_YES !=
MAH_handle_is_ready (mint))
{
@@ -444,7 +448,8 @@ TALER_MINT_deposit (struct TALER_MINT_Handle *mint,
" s:o, s:o," /* coin_pub, denom_pub */
" s:o, s:o," /* ub_sig, timestamp */
" s:I, s:o," /* transaction id, merchant_pub */
- " s:o, s:o}", /* refund_deadline, coin_sig */
+ " s:o, s:o," /* refund_deadline, wire_deadline */
+ " s:o}", /* coin_sig */
"f", TALER_json_from_amount (amount),
"wire", wire_details,
"H_wire", TALER_json_from_data (&h_wire,
@@ -460,6 +465,7 @@ TALER_MINT_deposit (struct TALER_MINT_Handle *mint,
"merchant_pub", TALER_json_from_data (merchant_pub,
sizeof (*merchant_pub)),
"refund_deadline", TALER_json_from_abs (refund_deadline),
+ "edate", TALER_json_from_abs (wire_deadline),
"coin_sig", TALER_json_from_data (coin_sig,
sizeof (*coin_sig))
);
diff --git a/src/mint-lib/test_mint_api.c b/src/mint-lib/test_mint_api.c
index 7b96f657c..5f465363e 100644
--- a/src/mint-lib/test_mint_api.c
+++ b/src/mint-lib/test_mint_api.c
@@ -1399,6 +1399,7 @@ interpreter_run (void *cls,
struct TALER_CoinSpendPublicKeyP coin_pub;
struct TALER_CoinSpendSignatureP coin_sig;
struct GNUNET_TIME_Absolute refund_deadline;
+ struct GNUNET_TIME_Absolute wire_deadline;
struct GNUNET_TIME_Absolute timestamp;
struct TALER_MerchantPublicKeyP merchant_pub;
json_t *wire;
@@ -1474,6 +1475,7 @@ interpreter_run (void *cls,
{
refund_deadline = GNUNET_TIME_UNIT_ZERO_ABS;
}
+ wire_deadline = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_DAYS);
timestamp = GNUNET_TIME_absolute_get ();
TALER_round_abs_time (&timestamp);
{
@@ -1502,6 +1504,7 @@ interpreter_run (void *cls,
cmd->details.deposit.dh
= TALER_MINT_deposit (mint,
&amount,
+ wire_deadline,
wire,
&h_contract,
&coin_pub,
diff --git a/src/mint/taler-mint-httpd_deposit.c b/src/mint/taler-mint-httpd_deposit.c
index f62e9ed3c..0aef4775c 100644
--- a/src/mint/taler-mint-httpd_deposit.c
+++ b/src/mint/taler-mint-httpd_deposit.c
@@ -148,6 +148,7 @@ parse_and_handle_deposit_request (struct MHD_Connection *connection,
TMH_PARSE_member_uint64 ("transaction_id", &deposit.transaction_id),
TMH_PARSE_member_time_abs ("timestamp", &deposit.timestamp),
TMH_PARSE_member_time_abs ("refund_deadline", &deposit.refund_deadline),
+ TMH_PARSE_member_time_abs ("edate", &deposit.wire_deadline),
TMH_PARSE_MEMBER_END
};
diff --git a/src/mintdb/Makefile.am b/src/mintdb/Makefile.am
index d9cc8b855..54f865429 100644
--- a/src/mintdb/Makefile.am
+++ b/src/mintdb/Makefile.am
@@ -49,12 +49,12 @@ check_PROGRAMS = \
test-mintdb-deposits \
test-mintdb-keyio \
test-mintdb-postgres \
- test-perf-taler-mintdb \
+ test-perf-taler-mintdb \
perf-mintdb
TESTS = \
test-mintdb-postgres \
- test-perf-taler-mintdb
+ test-perf-taler-mintdb
test_mintdb_deposits_SOURCES = \
test_mintdb_deposits.c
diff --git a/src/mintdb/plugin_mintdb_postgres.c b/src/mintdb/plugin_mintdb_postgres.c
index 1347875e3..f2d652b2e 100644
--- a/src/mintdb/plugin_mintdb_postgres.c
+++ b/src/mintdb/plugin_mintdb_postgres.c
@@ -439,6 +439,7 @@ postgres_create_tables (void *cls,
",deposit_fee_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
",timestamp INT8 NOT NULL"
",refund_deadline INT8 NOT NULL"
+ ",wire_deadline INT8 NOT NULL"
",merchant_pub BYTEA NOT NULL CHECK (LENGTH(merchant_pub)=32)"
",h_contract BYTEA NOT NULL CHECK (LENGTH(h_contract)=64)"
",h_wire BYTEA NOT NULL CHECK (LENGTH(h_wire)=64)"
@@ -821,6 +822,7 @@ postgres_prepare (PGconn *db_conn)
",deposit_fee_curr"
",timestamp"
",refund_deadline"
+ ",wire_deadline"
",merchant_pub"
",h_contract"
",h_wire"
@@ -828,8 +830,8 @@ postgres_prepare (PGconn *db_conn)
",wire"
") VALUES "
"($1, $2, $3, $4, $5, $6, $7, $8, $9, $10,"
- " $11, $12, $13, $14, $15, $16, $17);",
- 17, NULL);
+ " $11, $12, $13, $14, $15, $16, $17, $18);",
+ 18, NULL);
/* Fetch an existing deposit request, used to ensure idempotency
during /deposit processing. Used in #postgres_have_deposit(). */
PREPARE ("get_deposit",
@@ -839,6 +841,7 @@ postgres_prepare (PGconn *db_conn)
",amount_with_fee_curr"
",timestamp"
",refund_deadline"
+ ",wire_deadline"
",h_contract"
",h_wire"
" FROM deposits"
@@ -859,6 +862,7 @@ postgres_prepare (PGconn *db_conn)
",deposit_fee_val"
",deposit_fee_frac"
",deposit_fee_curr"
+ ",wire_deadline"
",transaction_id"
",h_contract"
",wire"
@@ -1880,6 +1884,8 @@ postgres_have_deposit (void *cls,
&deposit2.timestamp),
TALER_PQ_result_spec_absolute_time ("refund_deadline",
&deposit2.refund_deadline),
+ TALER_PQ_result_spec_absolute_time ("wire_deadline",
+ &deposit2.wire_deadline),
TALER_PQ_result_spec_auto_from_type ("h_contract",
&deposit2.h_contract),
TALER_PQ_result_spec_auto_from_type ("h_wire",
@@ -1987,6 +1993,7 @@ postgres_iterate_deposits (void *cls,
{
struct TALER_Amount amount_with_fee;
struct TALER_Amount deposit_fee;
+ struct GNUNET_TIME_Absolute wire_deadline;
struct GNUNET_HashCode h_contract;
json_t *wire;
uint64_t transaction_id;
@@ -2001,6 +2008,8 @@ postgres_iterate_deposits (void *cls,
&amount_with_fee),
TALER_PQ_result_spec_amount ("deposit_fee",
&deposit_fee),
+ TALER_PQ_result_spec_absolute_time ("wire_deadline",
+ &wire_deadline),
TALER_PQ_result_spec_auto_from_type ("h_contract",
&h_contract),
TALER_PQ_result_spec_json ("wire",
@@ -2021,6 +2030,7 @@ postgres_iterate_deposits (void *cls,
&deposit_fee,
transaction_id,
&h_contract,
+ wire_deadline,
wire);
TALER_PQ_cleanup_result (rs);
PQclear (result);
@@ -2058,6 +2068,7 @@ postgres_insert_deposit (void *cls,
TALER_PQ_query_param_amount (&deposit->deposit_fee),
TALER_PQ_query_param_absolute_time (&deposit->timestamp),
TALER_PQ_query_param_absolute_time (&deposit->refund_deadline),
+ TALER_PQ_query_param_absolute_time (&deposit->wire_deadline),
TALER_PQ_query_param_auto_from_type (&deposit->merchant_pub),
TALER_PQ_query_param_auto_from_type (&deposit->h_contract),
TALER_PQ_query_param_auto_from_type (&deposit->h_wire),
diff --git a/src/util/test_wireformats.c b/src/util/test_wireformats.c
index e4bd238f7..7e0e5bbc4 100644
--- a/src/util/test_wireformats.c
+++ b/src/util/test_wireformats.c
@@ -30,7 +30,6 @@ static const char * const valid_wire_str =
\"IBAN\":\"DE67830654080004822650\", \
\"name\":\"GNUnet e.V.\", \
\"bic\":\"GENODEF1SLR\", \
-\"edate\":\"1449930207000\", \
\"r\":123456789, \
\"address\": \"foobar\"}";
@@ -40,7 +39,6 @@ static const char * const invalid_wire_str =
\"IBAN\":\"XX67830654080004822650\", \
\"name\":\"GNUnet e.V.\", \
\"bic\":\"GENODEF1SLR\", \
-\"edate\":\"1449930207000\", \
\"r\":123456789, \
\"address\": \"foobar\"}";
@@ -50,7 +48,6 @@ static const char * const invalid_wire_str2 =
\"IBAN\":\"DE67830654080004822651\", \
\"name\":\"GNUnet e.V.\", \
\"bic\":\"GENODEF1SLR\", \
-\"edate\":\"1449930207000\", \
\"r\":123456789, \
\"address\": \"foobar\"}";
@@ -60,7 +57,6 @@ static const char * const unsupported_wire_str =
\"IBAN\":\"DE67830654080004822650\", \
\"name\":\"GNUnet e.V.\", \
\"bic\":\"GENODEF1SLR\", \
-\"edate\":\"1449930207000\", \
\"r\":123456789, \
\"address\": \"foobar\"}";
diff --git a/src/util/wireformats.c b/src/util/wireformats.c
index 5f9678526..594eaf426 100644
--- a/src/util/wireformats.c
+++ b/src/util/wireformats.c
@@ -322,7 +322,6 @@ validate_sepa (const json_t *wire)
const char *iban;
const char *name;
const char *bic;
- const char *edate;
uint64_t r;
const char *address;
@@ -334,7 +333,6 @@ validate_sepa (const json_t *wire)
"s:s " /* IBAN: iban */
"s:s " /* name: beneficiary name */
"s:s " /* BIC: beneficiary bank's BIC */
- "s:s " /* edate: transfer execution date */
"s:i " /* r: random 64-bit integer nounce */
"s?s " /* address: address of the beneficiary */
"}",
@@ -342,7 +340,6 @@ validate_sepa (const json_t *wire)
"IBAN", &iban,
"name", &name,
"bic", &bic,
- "edate", &edate,
"r", &r,
"address", &address));
if (1 != validate_iban (iban))