aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2018-05-18 16:54:36 +0200
committerMarcello Stanisci <stanisci.m@gmail.com>2018-05-18 16:54:36 +0200
commit5019bd69146824f3c6ec72e4dec1bb23dddf61ee (patch)
tree83f30ccaaa32f93efc6932388910b34b02fb74e1
parente746e0bbbc4439e07c1217c6f12110638a8ea565 (diff)
Ask to withdraw on a expired reserve.
-rw-r--r--src/exchange-lib/exchange_api_reserve.c21
-rw-r--r--src/exchange-lib/test_exchange_api_expire_reserve_now.conf4
-rw-r--r--src/exchange-lib/test_exchange_api_new.c43
-rw-r--r--src/exchange/taler-exchange-aggregator.c1
-rw-r--r--src/exchange/taler-exchange-httpd_responses.c4
-rw-r--r--src/include/taler_exchange_service.h2
6 files changed, 60 insertions, 15 deletions
diff --git a/src/exchange-lib/exchange_api_reserve.c b/src/exchange-lib/exchange_api_reserve.c
index 86a83fdb0..e6da8cfdb 100644
--- a/src/exchange-lib/exchange_api_reserve.c
+++ b/src/exchange-lib/exchange_api_reserve.c
@@ -333,7 +333,7 @@ parse_reserve_history (struct TALER_EXCHANGE_Handle *exchange,
struct TALER_ReserveCloseConfirmationPS rcc;
struct GNUNET_TIME_Absolute timestamp;
struct GNUNET_JSON_Specification closing_spec[] = {
- GNUNET_JSON_spec_json ("receiver_account_details",
+ GNUNET_JSON_spec_string ("receiver_account_details",
&rhistory[off].details.close_details.receiver_account_details),
GNUNET_JSON_spec_fixed_auto ("wtid",
&rhistory[off].details.close_details.wtid),
@@ -360,13 +360,9 @@ parse_reserve_history (struct TALER_EXCHANGE_Handle *exchange,
}
TALER_amount_hton (&rcc.closing_amount,
&amount);
- if (GNUNET_OK !=
- TALER_JSON_wire_signature_hash (rhistory[off].details.close_details.receiver_account_details,
- &rcc.h_wire))
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
+ GNUNET_CRYPTO_hash (rhistory[off].details.close_details.receiver_account_details,
+ strlen (rhistory[off].details.close_details.receiver_account_details) + 1,
+ &rcc.h_wire);
rcc.wtid = rhistory[off].details.close_details.wtid;
rcc.purpose.size = htonl (sizeof (rcc));
rcc.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_RESERVE_CLOSED);
@@ -377,7 +373,7 @@ parse_reserve_history (struct TALER_EXCHANGE_Handle *exchange,
key_state = TALER_EXCHANGE_get_keys (exchange);
if (GNUNET_OK !=
TALER_EXCHANGE_test_signing_key (key_state,
- &rhistory[off].details.payback_details.exchange_pub))
+ &rhistory[off].details.close_details.exchange_pub))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@@ -385,8 +381,8 @@ parse_reserve_history (struct TALER_EXCHANGE_Handle *exchange,
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_RESERVE_CLOSED,
&rcc.purpose,
- &rhistory[off].details.payback_details.exchange_sig.eddsa_signature,
- &rhistory[off].details.payback_details.exchange_pub.eddsa_pub))
+ &rhistory[off].details.close_details.exchange_sig.eddsa_signature,
+ &rhistory[off].details.close_details.exchange_pub.eddsa_pub))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@@ -447,8 +443,7 @@ free_rhistory (struct TALER_EXCHANGE_ReserveHistory *rhistory,
case TALER_EXCHANGE_RTT_PAYBACK:
break;
case TALER_EXCHANGE_RTT_CLOSE:
- if (NULL != rhistory[i].details.close_details.receiver_account_details)
- json_decref (rhistory[i].details.close_details.receiver_account_details);
+ // should we free "receiver_account_details" ?
break;
}
}
diff --git a/src/exchange-lib/test_exchange_api_expire_reserve_now.conf b/src/exchange-lib/test_exchange_api_expire_reserve_now.conf
new file mode 100644
index 000000000..05bca956b
--- /dev/null
+++ b/src/exchange-lib/test_exchange_api_expire_reserve_now.conf
@@ -0,0 +1,4 @@
+@INLINE@ test_exchange_api.conf
+
+[exchangedb]
+IDLE_RESERVE_EXPIRATION_TIME = 0 s
diff --git a/src/exchange-lib/test_exchange_api_new.c b/src/exchange-lib/test_exchange_api_new.c
index 0e4800002..75f5fe6a1 100644
--- a/src/exchange-lib/test_exchange_api_new.c
+++ b/src/exchange-lib/test_exchange_api_new.c
@@ -42,6 +42,8 @@
*/
#define CONFIG_FILE "test_exchange_api.conf"
+#define CONFIG_FILE_EXPIRE_RESERVE_NOW "test_exchange_api_expire_reserve_now.conf"
+
/**
* Is the configuration file is set to include wire format 'ebics'?
* Requires that EBICS /history function is implemented, which it
@@ -639,6 +641,47 @@ run (void *cls,
MHD_HTTP_OK),
/**
+ * These commands should close the reserve because
+ * the aggregator is given a config file that ovverrides
+ * the reserve expiration time (making it now-ish)
+ */
+ CMD_TRANSFER_TO_EXCHANGE
+ ("short-lived-reserve",
+ "EUR:5.01"),
+
+ TALER_TESTING_cmd_exec_wirewatch
+ ("short-lived-aggregation",
+ CONFIG_FILE_EXPIRE_RESERVE_NOW),
+
+ TALER_TESTING_cmd_exec_aggregator
+ ("close-reserves",
+ CONFIG_FILE_EXPIRE_RESERVE_NOW),
+
+ TALER_TESTING_cmd_withdraw_amount
+ ("expired-withdraw",
+ is->exchange,
+ "short-lived-reserve",
+ "EUR:1",
+ MHD_HTTP_FORBIDDEN),
+
+ /* Should also test a "insufficient funds" error
+ * after payback happened. */
+
+ TALER_TESTING_cmd_check_bank_transfer
+ ("check_bank_short-lived_transfer",
+ exchange_url,
+ "EUR:5.01",
+ 42,
+ 2),
+
+ TALER_TESTING_cmd_check_bank_transfer
+ ("check_bank_short-lived_reimburse",
+ exchange_url,
+ "EUR:5",
+ 2,
+ 42),
+
+ /**
* Fill reserve with EUR:2.02, as withdraw fee is 1 ct per
* config, then withdraw two coin, partially spend one, and
* then have the rest paid back. Check deposit of other coin
diff --git a/src/exchange/taler-exchange-aggregator.c b/src/exchange/taler-exchange-aggregator.c
index b466a8307..6d363692e 100644
--- a/src/exchange/taler-exchange-aggregator.c
+++ b/src/exchange/taler-exchange-aggregator.c
@@ -1133,6 +1133,7 @@ expired_reserve_cb (void *cls,
&wtid,
left,
closing_fee);
+
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Closing reserve %s over %s (%d, %d)\n",
TALER_B2S (reserve_pub),
diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c
index f13352e12..d5d7e9437 100644
--- a/src/exchange/taler-exchange-httpd_responses.c
+++ b/src/exchange/taler-exchange-httpd_responses.c
@@ -835,6 +835,7 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto
break;
case TALER_EXCHANGEDB_RO_EXCHANGE_TO_BANK:
{
+
struct TALER_ReserveCloseConfirmationPS rcc;
struct TALER_ExchangePublicKeyP pub;
struct TALER_ExchangeSignatureP sig;
@@ -880,7 +881,7 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto
}
GNUNET_assert (0 ==
json_array_append_new (json_history,
- json_pack ("{s:s, s:O, s:o, s:o, s:o, s:o, s:o, s:o}",
+ json_pack ("{s:s, s:s, s:o, s:o, s:o, s:o, s:o, s:o}",
"type", "CLOSING",
"receiver_account_details", pos->details.closing->receiver_account_details,
"wtid", GNUNET_JSON_from_data_auto (&pos->details.closing->wtid),
@@ -893,6 +894,7 @@ TEH_RESPONSE_compile_reserve_history (const struct TALER_EXCHANGEDB_ReserveHisto
break;
}
}
+
if (0 == (1 & ret))
{
GNUNET_break (0);
diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h
index e5a26e29c..98223fa6c 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -912,7 +912,7 @@ struct TALER_EXCHANGE_ReserveHistory
/**
* Receiver account information for the outgoing wire transfer.
*/
- json_t *receiver_account_details;
+ const char *receiver_account_details;
/**
* Wire transfer details for the outgoing wire transfer.