[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-exchange] branch master updated (39a9045 -> fffaf61)
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-exchange] branch master updated (39a9045 -> fffaf61) |
Date: |
Fri, 18 May 2018 17:25:12 +0200 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a change to branch master
in repository exchange.
from 39a9045 comment
new 8ad9077 Withdraw after payback.
new 76381cf double-check reserve is well-behaved.
new c9758f7 Annotation; error management.
new e746e0b diagnostics
new 5019bd6 Ask to withdraw on a expired reserve.
new b86a358 Make a "payback" bit appear into the history.
new fffaf61 set right expected http code.
The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/exchange-lib/exchange_api_reserve.c | 21 +++-----
.../test_exchange_api_expire_reserve_now.conf | 4 ++
src/exchange-lib/test_exchange_api_new.c | 61 ++++++++++++++++++++++
src/exchange/taler-exchange-aggregator.c | 2 +
.../taler-exchange-httpd_reserve_withdraw.c | 27 +++++++++-
src/exchange/taler-exchange-httpd_responses.c | 11 +++-
src/include/taler_exchange_service.h | 2 +-
7 files changed, 112 insertions(+), 16 deletions(-)
create mode 100644 src/exchange-lib/test_exchange_api_expire_reserve_now.conf
diff --git a/src/exchange-lib/exchange_api_reserve.c
b/src/exchange-lib/exchange_api_reserve.c
index 86a83fd..e6da8cf 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 0000000..05bca95
--- /dev/null
+++ b/src/exchange-lib/test_exchange_api_expire_reserve_now.conf
@@ -0,0 +1,4 @@
address@hidden@ 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 c5e62a0..0ef442e 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
@@ -625,6 +627,65 @@ run (void *cls,
"EUR:5.0",
MHD_HTTP_OK),
+ /* Re-withdraw from this reserve */
+ TALER_TESTING_cmd_withdraw_amount ("payback-withdraw-coin-2",
+ is->exchange,
+ "payback-create-reserve-1",
+ "EUR:1",
+ MHD_HTTP_OK),
+
+ /* This withdrawal will test the logic to create
+ * a "payback" element to insert into the reserve's history. */
+ TALER_TESTING_cmd_withdraw_amount ("payback-withdraw-coin-2-over",
+ is->exchange,
+ "payback-create-reserve-1",
+ "EUR:10",
+ MHD_HTTP_FORBIDDEN),
+
+ TALER_TESTING_cmd_status ("payback-reserve-status-2",
+ is->exchange,
+ "payback-create-reserve-1",
+ "EUR:3.99",
+ 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),
+
+ 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
diff --git a/src/exchange/taler-exchange-aggregator.c
b/src/exchange/taler-exchange-aggregator.c
index 805577a..6d36369 100644
--- a/src/exchange/taler-exchange-aggregator.c
+++ b/src/exchange/taler-exchange-aggregator.c
@@ -1124,6 +1124,7 @@ expired_reserve_cb (void *cls,
reserve_pub,
GNUNET_MIN (sizeof (wtid),
sizeof (*reserve_pub)));
+
qs = db_plugin->insert_reserve_closed (db_plugin->cls,
session,
reserve_pub,
@@ -1132,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_reserve_withdraw.c
b/src/exchange/taler-exchange-httpd_reserve_withdraw.c
index 3f2bc31..ec1a768 100644
--- a/src/exchange/taler-exchange-httpd_reserve_withdraw.c
+++ b/src/exchange/taler-exchange-httpd_reserve_withdraw.c
@@ -48,11 +48,15 @@ reply_reserve_withdraw_insufficient_funds (struct
MHD_Connection *connection,
json_history = TEH_RESPONSE_compile_reserve_history (rh,
&balance);
- if (NULL == json_history)
+ if ((NULL == json_history)
+ /* Address the case where the ptr is not null, but
+ * it fails "internally" to dump as string (= corrupted). */
+ || (0 == json_dumpb (json_history, NULL, 0, 0)))
return TEH_RESPONSE_reply_internal_error (connection,
TALER_EC_WITHDRAW_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS,
"balance calculation failure");
json_balance = TALER_JSON_from_amount (&balance);
+
return TEH_RESPONSE_reply_json_pack (connection,
MHD_HTTP_FORBIDDEN,
"{s:s, s:I, s:o, s:o}",
@@ -279,6 +283,25 @@ withdraw_transaction (void *cls,
TALER_EC_WITHDRAW_AMOUNT_WITHDRAWALS_OVERFLOW);
return GNUNET_DB_STATUS_HARD_ERROR;
}
+
+ #if 0
+ /**
+ * WARNING:
+ *
+ * This check below is useless, as when a reserve gets
+ * closed, the database records that operation's amount
+ * as the _entire_ amount that was left into the reserve.
+ * This means that the closing fee is _included_ in what
+ * the database has, so it makes no sense to further
+ * subtract it from the 'withdraw_total'. On the other
+ * hand, the reserve-closing logic is careful to NOT wire
+ * transfer all the reserve amount back to the bank, but
+ * it does subtract the closing fee first from it.
+ *
+ * NOTE: this if-0'd out chunk of code is left around for
+ * internal review.
+ */
+
if (GNUNET_OK !=
TALER_amount_add (&withdraw_total,
&withdraw_total,
@@ -288,6 +311,7 @@ withdraw_transaction (void *cls,
TALER_EC_WITHDRAW_AMOUNT_WITHDRAWALS_OVERFLOW);
return GNUNET_DB_STATUS_HARD_ERROR;
}
+ #endif
res |= 2;
break;
@@ -323,6 +347,7 @@ withdraw_transaction (void *cls,
if (0 < TALER_amount_cmp (&wc->amount_required,
&balance))
{
+ GNUNET_break_op (0);
*mhd_ret = reply_reserve_withdraw_insufficient_funds (connection,
rh);
TEH_plugin->free_reserve_history (TEH_plugin->cls,
diff --git a/src/exchange/taler-exchange-httpd_responses.c
b/src/exchange/taler-exchange-httpd_responses.c
index 99ee08a..d5d7e94 100644
--- a/src/exchange/taler-exchange-httpd_responses.c
+++ b/src/exchange/taler-exchange-httpd_responses.c
@@ -148,6 +148,13 @@ TEH_RESPONSE_reply_json (struct MHD_Connection *connection,
JSON_INDENT(2));
if (NULL == json_str)
{
+ /**
+ * This log helps to figure out which
+ * function called this one and assert-failed.
+ */
+ TALER_LOG_ERROR ("Aborting json-packing for HTTP code: %u\n",
+ response_code);
+
GNUNET_assert (0);
return MHD_NO;
}
@@ -828,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;
@@ -873,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),
@@ -886,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 e5a26e2..98223fa 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.
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [taler-exchange] branch master updated (39a9045 -> fffaf61),
gnunet <=
- [GNUnet-SVN] [taler-exchange] 06/07: Make a "payback" bit appear into the history., gnunet, 2018/05/18
- [GNUnet-SVN] [taler-exchange] 01/07: Withdraw after payback., gnunet, 2018/05/18
- [GNUnet-SVN] [taler-exchange] 03/07: Annotation; error management., gnunet, 2018/05/18
- [GNUnet-SVN] [taler-exchange] 02/07: double-check reserve is well-behaved., gnunet, 2018/05/18
- [GNUnet-SVN] [taler-exchange] 07/07: set right expected http code., gnunet, 2018/05/18
- [GNUnet-SVN] [taler-exchange] 04/07: diagnostics, gnunet, 2018/05/18
- [GNUnet-SVN] [taler-exchange] 05/07: Ask to withdraw on a expired reserve., gnunet, 2018/05/18