diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-11-01 22:02:34 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-11-01 22:02:34 +0100 |
commit | 8d5bb82d189de0263dbd7d572cab3e58bd676fcc (patch) | |
tree | a4e9b9a3526bd0bbd2a02c2f8f2f9d1c9d59b986 /src | |
parent | cdc85dd9f8f84f22daf882c7d5152ccfc04a2d2c (diff) |
handle wire transfer deadline like pay deadline
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/taler-merchant-httpd.c | 4 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd.h | 2 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_pay.c | 37 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_proposal.c | 16 |
4 files changed, 22 insertions, 37 deletions
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c index da1c7b45..ef7b6502 100644 --- a/src/backend/taler-merchant-httpd.c +++ b/src/backend/taler-merchant-httpd.c @@ -77,7 +77,7 @@ static long long unsigned port; * This value tells the exchange by which date this merchant would like * to receive the funds for a deposited payment */ -struct GNUNET_TIME_Relative wire_transfer_delay; +struct GNUNET_TIME_Relative default_wire_transfer_delay; /** * Locations from the configuration. Mapping from @@ -1489,7 +1489,7 @@ run (void *cls, GNUNET_CONFIGURATION_get_value_time (config, "merchant", "WIRE_TRANSFER_DELAY", - &wire_transfer_delay)) + &default_wire_transfer_delay)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "merchant", diff --git a/src/backend/taler-merchant-httpd.h b/src/backend/taler-merchant-httpd.h index c166efb4..bc53bbc6 100644 --- a/src/backend/taler-merchant-httpd.h +++ b/src/backend/taler-merchant-httpd.h @@ -366,7 +366,7 @@ extern struct TALER_MERCHANTDB_Plugin *db; * executing the wire transfer? This delay is added to the current * time when we generate the advisory execution time for the exchange. */ -extern struct GNUNET_TIME_Relative wire_transfer_delay; +extern struct GNUNET_TIME_Relative default_wire_transfer_delay; /** * If the frontend does NOT specify a payment deadline, how long should diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c index 4e19e6f0..1bd68d31 100644 --- a/src/backend/taler-merchant-httpd_pay.c +++ b/src/backend/taler-merchant-httpd_pay.c @@ -287,8 +287,7 @@ struct PayContext /** * Wire transfer deadline. How soon would the merchant like the - * wire transfer to be executed? (Can be given by the frontend - * or be determined by our configuration via #wire_transfer_delay.) + * wire transfer to be executed? */ struct GNUNET_TIME_Absolute wire_transfer_deadline; @@ -1445,7 +1444,6 @@ parse_pay (struct MHD_Connection *connection, }; enum GNUNET_DB_QueryStatus qs; const char *session_id; - struct GNUNET_TIME_Relative used_wire_transfer_delay; res = TMH_PARSE_json_data (connection, root, @@ -1551,6 +1549,8 @@ parse_pay (struct MHD_Connection *connection, &pc->refund_deadline), GNUNET_JSON_spec_absolute_time ("pay_deadline", &pc->pay_deadline), + GNUNET_JSON_spec_absolute_time ("wire_transfer_deadline", + &pc->wire_transfer_deadline), GNUNET_JSON_spec_absolute_time ("timestamp", &pc->timestamp), TALER_JSON_spec_amount ("max_fee", @@ -1576,39 +1576,10 @@ parse_pay (struct MHD_Connection *connection, pc->fulfillment_url = GNUNET_strdup (fulfillment_url); - /* Use the value from config as default. */ - used_wire_transfer_delay = wire_transfer_delay; - - if (NULL != json_object_get (pc->contract_terms, - "wire_transfer_delay")) - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Frontend specified wire transfer delay\n"); - - struct GNUNET_JSON_Specification wspec[] = { - GNUNET_JSON_spec_relative_time ("wire_transfer_delay", - &used_wire_transfer_delay), - GNUNET_JSON_spec_end () - }; - - res = TMH_PARSE_json_data (connection, - pc->contract_terms, - wspec); - if (GNUNET_YES != res) - { - GNUNET_JSON_parse_free (spec); - GNUNET_break (0); - return (GNUNET_NO == res) ? MHD_YES : MHD_NO; - } - } - - pc->wire_transfer_deadline - = GNUNET_TIME_absolute_add (pc->timestamp, - used_wire_transfer_delay); - if (pc->wire_transfer_deadline.abs_value_us < pc->refund_deadline.abs_value_us) { + /* This should already have been checked when creating the order! */ GNUNET_break (0); GNUNET_JSON_parse_free (spec); return TMH_RESPONSE_reply_external_error (connection, diff --git a/src/backend/taler-merchant-httpd_proposal.c b/src/backend/taler-merchant-httpd_proposal.c index bc7dd0e2..bb9ccbb0 100644 --- a/src/backend/taler-merchant-httpd_proposal.c +++ b/src/backend/taler-merchant-httpd_proposal.c @@ -202,11 +202,13 @@ make_merchant_base_url (struct MHD_Connection *connection, const * of a MHD connection. * * @param connection connection to write the result or error to + * @param root root of the request * @param order[in] order to process (can be modified) * @return MHD result code */ static int proposal_put (struct MHD_Connection *connection, + json_t *root, json_t *order, const struct MerchantInstance *mi) { @@ -316,6 +318,18 @@ proposal_put (struct MHD_Connection *connection, } if (NULL == json_object_get (order, + "wire_transfer_deadline")) + { + struct GNUNET_TIME_Absolute t; + + t = GNUNET_TIME_relative_to_absolute (default_wire_transfer_delay); + (void) GNUNET_TIME_round_abs (&t); + json_object_set_new (order, + "wire_transfer_deadline", + GNUNET_JSON_from_time_abs (t)); + } + + if (NULL == json_object_get (order, "max_wire_fee")) { json_object_set_new (order, @@ -656,7 +670,7 @@ MH_handler_proposal_put (struct TMH_RequestHandler *rh, "order"); } else - res = proposal_put (connection, order, mi); + res = proposal_put (connection, root, order, mi); json_decref (root); return res; } |