fix #4032: move wire deadline form wire details to advisory field in /deposit request

This commit is contained in:
Christian Grothoff 2015-10-28 21:06:23 +01:00
parent 3fd22d4b6f
commit c2a40aa839
9 changed files with 40 additions and 12 deletions

View File

@ -505,6 +505,8 @@ typedef void
* *
* @param mint the mint handle; the mint must be ready to operate * @param mint the mint handle; the mint must be ready to operate
* @param amount the amount to be deposited * @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 merchants account details, in a format supported by the mint * @param wire_details the merchants 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 h_contract hash of the contact of the merchant with the customer (further details are never disclosed to the mint)
* @param coin_pub coins public key * @param coin_pub coins public key
@ -523,6 +525,7 @@ typedef void
struct TALER_MINT_DepositHandle * struct TALER_MINT_DepositHandle *
TALER_MINT_deposit (struct TALER_MINT_Handle *mint, TALER_MINT_deposit (struct TALER_MINT_Handle *mint,
const struct TALER_Amount *amount, const struct TALER_Amount *amount,
struct GNUNET_TIME_Absolute wire_deadline,
json_t *wire_details, json_t *wire_details,
const struct GNUNET_HashCode *h_contract, const struct GNUNET_HashCode *h_contract,
const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_CoinSpendPublicKeyP *coin_pub,

View File

@ -275,6 +275,14 @@ struct TALER_MINTDB_Deposit
*/ */
struct GNUNET_TIME_Absolute refund_deadline; 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 * Fraction of the coin's remaining value to be deposited, including
* depositing fee (if any). The coin is identified by @e coin_pub. * 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 deposit_fee amount the mint gets to keep as transaction fees
* @param transaction_id unique transaction ID chosen by the merchant * @param transaction_id unique transaction ID chosen by the merchant
* @param h_contract hash of the contract between merchant and customer * @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 * @param wire wire details for the merchant
* @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop
*/ */
@ -538,6 +548,7 @@ typedef int
const struct TALER_Amount *deposit_fee, const struct TALER_Amount *deposit_fee,
uint64_t transaction_id, uint64_t transaction_id,
const struct GNUNET_HashCode *h_contract, const struct GNUNET_HashCode *h_contract,
struct GNUNET_TIME_Absolute wire_deadline,
const json_t *wire); const json_t *wire);

View File

@ -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 mint the mint handle; the mint must be ready to operate
* @param amount the amount to be deposited * @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 merchants account details, in a format supported by the mint * @param wire_details the merchants 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 h_contract hash of the contact of the merchant with the customer (further details are never disclosed to the mint)
* @param coin_pub coins public key * @param coin_pub coins public key
@ -376,6 +378,7 @@ verify_signatures (const struct TALER_MINT_DenomPublicKey *dki,
struct TALER_MINT_DepositHandle * struct TALER_MINT_DepositHandle *
TALER_MINT_deposit (struct TALER_MINT_Handle *mint, TALER_MINT_deposit (struct TALER_MINT_Handle *mint,
const struct TALER_Amount *amount, const struct TALER_Amount *amount,
struct GNUNET_TIME_Absolute wire_deadline,
json_t *wire_details, json_t *wire_details,
const struct GNUNET_HashCode *h_contract, const struct GNUNET_HashCode *h_contract,
const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_CoinSpendPublicKeyP *coin_pub,
@ -398,6 +401,7 @@ TALER_MINT_deposit (struct TALER_MINT_Handle *mint,
struct GNUNET_HashCode h_wire; struct GNUNET_HashCode h_wire;
struct TALER_Amount amount_without_fee; struct TALER_Amount amount_without_fee;
(void) TALER_round_abs_time (&wire_deadline);
if (GNUNET_YES != if (GNUNET_YES !=
MAH_handle_is_ready (mint)) 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," /* coin_pub, denom_pub */
" s:o, s:o," /* ub_sig, timestamp */ " s:o, s:o," /* ub_sig, timestamp */
" s:I, s:o," /* transaction id, merchant_pub */ " 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), "f", TALER_json_from_amount (amount),
"wire", wire_details, "wire", wire_details,
"H_wire", TALER_json_from_data (&h_wire, "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, "merchant_pub", TALER_json_from_data (merchant_pub,
sizeof (*merchant_pub)), sizeof (*merchant_pub)),
"refund_deadline", TALER_json_from_abs (refund_deadline), "refund_deadline", TALER_json_from_abs (refund_deadline),
"edate", TALER_json_from_abs (wire_deadline),
"coin_sig", TALER_json_from_data (coin_sig, "coin_sig", TALER_json_from_data (coin_sig,
sizeof (*coin_sig)) sizeof (*coin_sig))
); );

View File

@ -1399,6 +1399,7 @@ interpreter_run (void *cls,
struct TALER_CoinSpendPublicKeyP coin_pub; struct TALER_CoinSpendPublicKeyP coin_pub;
struct TALER_CoinSpendSignatureP coin_sig; struct TALER_CoinSpendSignatureP coin_sig;
struct GNUNET_TIME_Absolute refund_deadline; struct GNUNET_TIME_Absolute refund_deadline;
struct GNUNET_TIME_Absolute wire_deadline;
struct GNUNET_TIME_Absolute timestamp; struct GNUNET_TIME_Absolute timestamp;
struct TALER_MerchantPublicKeyP merchant_pub; struct TALER_MerchantPublicKeyP merchant_pub;
json_t *wire; json_t *wire;
@ -1474,6 +1475,7 @@ interpreter_run (void *cls,
{ {
refund_deadline = GNUNET_TIME_UNIT_ZERO_ABS; refund_deadline = GNUNET_TIME_UNIT_ZERO_ABS;
} }
wire_deadline = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_DAYS);
timestamp = GNUNET_TIME_absolute_get (); timestamp = GNUNET_TIME_absolute_get ();
TALER_round_abs_time (&timestamp); TALER_round_abs_time (&timestamp);
{ {
@ -1502,6 +1504,7 @@ interpreter_run (void *cls,
cmd->details.deposit.dh cmd->details.deposit.dh
= TALER_MINT_deposit (mint, = TALER_MINT_deposit (mint,
&amount, &amount,
wire_deadline,
wire, wire,
&h_contract, &h_contract,
&coin_pub, &coin_pub,

View File

@ -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_uint64 ("transaction_id", &deposit.transaction_id),
TMH_PARSE_member_time_abs ("timestamp", &deposit.timestamp), TMH_PARSE_member_time_abs ("timestamp", &deposit.timestamp),
TMH_PARSE_member_time_abs ("refund_deadline", &deposit.refund_deadline), TMH_PARSE_member_time_abs ("refund_deadline", &deposit.refund_deadline),
TMH_PARSE_member_time_abs ("edate", &deposit.wire_deadline),
TMH_PARSE_MEMBER_END TMH_PARSE_MEMBER_END
}; };

View File

@ -439,6 +439,7 @@ postgres_create_tables (void *cls,
",deposit_fee_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL" ",deposit_fee_curr VARCHAR("TALER_CURRENCY_LEN_STR") NOT NULL"
",timestamp INT8 NOT NULL" ",timestamp INT8 NOT NULL"
",refund_deadline INT8 NOT NULL" ",refund_deadline INT8 NOT NULL"
",wire_deadline INT8 NOT NULL"
",merchant_pub BYTEA NOT NULL CHECK (LENGTH(merchant_pub)=32)" ",merchant_pub BYTEA NOT NULL CHECK (LENGTH(merchant_pub)=32)"
",h_contract BYTEA NOT NULL CHECK (LENGTH(h_contract)=64)" ",h_contract BYTEA NOT NULL CHECK (LENGTH(h_contract)=64)"
",h_wire BYTEA NOT NULL CHECK (LENGTH(h_wire)=64)" ",h_wire BYTEA NOT NULL CHECK (LENGTH(h_wire)=64)"
@ -821,6 +822,7 @@ postgres_prepare (PGconn *db_conn)
",deposit_fee_curr" ",deposit_fee_curr"
",timestamp" ",timestamp"
",refund_deadline" ",refund_deadline"
",wire_deadline"
",merchant_pub" ",merchant_pub"
",h_contract" ",h_contract"
",h_wire" ",h_wire"
@ -828,8 +830,8 @@ postgres_prepare (PGconn *db_conn)
",wire" ",wire"
") VALUES " ") VALUES "
"($1, $2, $3, $4, $5, $6, $7, $8, $9, $10," "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10,"
" $11, $12, $13, $14, $15, $16, $17);", " $11, $12, $13, $14, $15, $16, $17, $18);",
17, NULL); 18, NULL);
/* Fetch an existing deposit request, used to ensure idempotency /* Fetch an existing deposit request, used to ensure idempotency
during /deposit processing. Used in #postgres_have_deposit(). */ during /deposit processing. Used in #postgres_have_deposit(). */
PREPARE ("get_deposit", PREPARE ("get_deposit",
@ -839,6 +841,7 @@ postgres_prepare (PGconn *db_conn)
",amount_with_fee_curr" ",amount_with_fee_curr"
",timestamp" ",timestamp"
",refund_deadline" ",refund_deadline"
",wire_deadline"
",h_contract" ",h_contract"
",h_wire" ",h_wire"
" FROM deposits" " FROM deposits"
@ -859,6 +862,7 @@ postgres_prepare (PGconn *db_conn)
",deposit_fee_val" ",deposit_fee_val"
",deposit_fee_frac" ",deposit_fee_frac"
",deposit_fee_curr" ",deposit_fee_curr"
",wire_deadline"
",transaction_id" ",transaction_id"
",h_contract" ",h_contract"
",wire" ",wire"
@ -1880,6 +1884,8 @@ postgres_have_deposit (void *cls,
&deposit2.timestamp), &deposit2.timestamp),
TALER_PQ_result_spec_absolute_time ("refund_deadline", TALER_PQ_result_spec_absolute_time ("refund_deadline",
&deposit2.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", TALER_PQ_result_spec_auto_from_type ("h_contract",
&deposit2.h_contract), &deposit2.h_contract),
TALER_PQ_result_spec_auto_from_type ("h_wire", 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 amount_with_fee;
struct TALER_Amount deposit_fee; struct TALER_Amount deposit_fee;
struct GNUNET_TIME_Absolute wire_deadline;
struct GNUNET_HashCode h_contract; struct GNUNET_HashCode h_contract;
json_t *wire; json_t *wire;
uint64_t transaction_id; uint64_t transaction_id;
@ -2001,6 +2008,8 @@ postgres_iterate_deposits (void *cls,
&amount_with_fee), &amount_with_fee),
TALER_PQ_result_spec_amount ("deposit_fee", TALER_PQ_result_spec_amount ("deposit_fee",
&deposit_fee), &deposit_fee),
TALER_PQ_result_spec_absolute_time ("wire_deadline",
&wire_deadline),
TALER_PQ_result_spec_auto_from_type ("h_contract", TALER_PQ_result_spec_auto_from_type ("h_contract",
&h_contract), &h_contract),
TALER_PQ_result_spec_json ("wire", TALER_PQ_result_spec_json ("wire",
@ -2021,6 +2030,7 @@ postgres_iterate_deposits (void *cls,
&deposit_fee, &deposit_fee,
transaction_id, transaction_id,
&h_contract, &h_contract,
wire_deadline,
wire); wire);
TALER_PQ_cleanup_result (rs); TALER_PQ_cleanup_result (rs);
PQclear (result); PQclear (result);
@ -2058,6 +2068,7 @@ postgres_insert_deposit (void *cls,
TALER_PQ_query_param_amount (&deposit->deposit_fee), TALER_PQ_query_param_amount (&deposit->deposit_fee),
TALER_PQ_query_param_absolute_time (&deposit->timestamp), TALER_PQ_query_param_absolute_time (&deposit->timestamp),
TALER_PQ_query_param_absolute_time (&deposit->refund_deadline), 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->merchant_pub),
TALER_PQ_query_param_auto_from_type (&deposit->h_contract), TALER_PQ_query_param_auto_from_type (&deposit->h_contract),
TALER_PQ_query_param_auto_from_type (&deposit->h_wire), TALER_PQ_query_param_auto_from_type (&deposit->h_wire),

View File

@ -30,7 +30,6 @@ static const char * const valid_wire_str =
\"IBAN\":\"DE67830654080004822650\", \ \"IBAN\":\"DE67830654080004822650\", \
\"name\":\"GNUnet e.V.\", \ \"name\":\"GNUnet e.V.\", \
\"bic\":\"GENODEF1SLR\", \ \"bic\":\"GENODEF1SLR\", \
\"edate\":\"1449930207000\", \
\"r\":123456789, \ \"r\":123456789, \
\"address\": \"foobar\"}"; \"address\": \"foobar\"}";
@ -40,7 +39,6 @@ static const char * const invalid_wire_str =
\"IBAN\":\"XX67830654080004822650\", \ \"IBAN\":\"XX67830654080004822650\", \
\"name\":\"GNUnet e.V.\", \ \"name\":\"GNUnet e.V.\", \
\"bic\":\"GENODEF1SLR\", \ \"bic\":\"GENODEF1SLR\", \
\"edate\":\"1449930207000\", \
\"r\":123456789, \ \"r\":123456789, \
\"address\": \"foobar\"}"; \"address\": \"foobar\"}";
@ -50,7 +48,6 @@ static const char * const invalid_wire_str2 =
\"IBAN\":\"DE67830654080004822651\", \ \"IBAN\":\"DE67830654080004822651\", \
\"name\":\"GNUnet e.V.\", \ \"name\":\"GNUnet e.V.\", \
\"bic\":\"GENODEF1SLR\", \ \"bic\":\"GENODEF1SLR\", \
\"edate\":\"1449930207000\", \
\"r\":123456789, \ \"r\":123456789, \
\"address\": \"foobar\"}"; \"address\": \"foobar\"}";
@ -60,7 +57,6 @@ static const char * const unsupported_wire_str =
\"IBAN\":\"DE67830654080004822650\", \ \"IBAN\":\"DE67830654080004822650\", \
\"name\":\"GNUnet e.V.\", \ \"name\":\"GNUnet e.V.\", \
\"bic\":\"GENODEF1SLR\", \ \"bic\":\"GENODEF1SLR\", \
\"edate\":\"1449930207000\", \
\"r\":123456789, \ \"r\":123456789, \
\"address\": \"foobar\"}"; \"address\": \"foobar\"}";

View File

@ -322,7 +322,6 @@ validate_sepa (const json_t *wire)
const char *iban; const char *iban;
const char *name; const char *name;
const char *bic; const char *bic;
const char *edate;
uint64_t r; uint64_t r;
const char *address; const char *address;
@ -334,7 +333,6 @@ validate_sepa (const json_t *wire)
"s:s " /* IBAN: iban */ "s:s " /* IBAN: iban */
"s:s " /* name: beneficiary name */ "s:s " /* name: beneficiary name */
"s:s " /* BIC: beneficiary bank's BIC */ "s:s " /* BIC: beneficiary bank's BIC */
"s:s " /* edate: transfer execution date */
"s:i " /* r: random 64-bit integer nounce */ "s:i " /* r: random 64-bit integer nounce */
"s?s " /* address: address of the beneficiary */ "s?s " /* address: address of the beneficiary */
"}", "}",
@ -342,7 +340,6 @@ validate_sepa (const json_t *wire)
"IBAN", &iban, "IBAN", &iban,
"name", &name, "name", &name,
"bic", &bic, "bic", &bic,
"edate", &edate,
"r", &r, "r", &r,
"address", &address)); "address", &address));
if (1 != validate_iban (iban)) if (1 != validate_iban (iban))