remove unused/unusable coin_sig, return correct coin_pub in recoup-reveal failure context

This commit is contained in:
Christian Grothoff 2020-07-10 22:33:04 +02:00
parent d01c6fd902
commit ddf95c491a
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
6 changed files with 78 additions and 32 deletions

View File

@ -250,7 +250,7 @@ TEH_RESPONSE_compile_transaction_history (
TALER_SIGNATURE_EXCHANGE_CONFIRM_RECOUP_REFRESH), TALER_SIGNATURE_EXCHANGE_CONFIRM_RECOUP_REFRESH),
.purpose.size = htonl (sizeof (pc)), .purpose.size = htonl (sizeof (pc)),
.timestamp = GNUNET_TIME_absolute_hton (pr->timestamp), .timestamp = GNUNET_TIME_absolute_hton (pr->timestamp),
.coin_pub = *coin_pub, .coin_pub = pr->coin.coin_pub,
.old_coin_pub = pr->old_coin_pub .old_coin_pub = pr->old_coin_pub
}; };
@ -273,7 +273,7 @@ TEH_RESPONSE_compile_transaction_history (
if (0 != if (0 !=
json_array_append_new ( json_array_append_new (
history, history,
json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o, s:o}", json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}",
"type", "type",
"OLD-COIN-RECOUP", "OLD-COIN-RECOUP",
"amount", "amount",
@ -284,8 +284,6 @@ TEH_RESPONSE_compile_transaction_history (
GNUNET_JSON_from_data_auto (&epub), GNUNET_JSON_from_data_auto (&epub),
"coin_pub", "coin_pub",
GNUNET_JSON_from_data_auto (&pr->coin.coin_pub), GNUNET_JSON_from_data_auto (&pr->coin.coin_pub),
"coin_sig",
GNUNET_JSON_from_data_auto (&pr->coin_sig),
"timestamp", "timestamp",
GNUNET_JSON_from_time_abs (pr->timestamp)))) GNUNET_JSON_from_time_abs (pr->timestamp))))
{ {

View File

@ -4553,6 +4553,11 @@ postgres_get_coin_transactions (
params, params,
work[i].cb, work[i].cb,
&chc); &chc);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Coin %s yielded %d transactions of type %s\n",
TALER_B2S (coin_pub),
qs,
work[i].statement);
if ( (0 > qs) || if ( (0 > qs) ||
(chc.failed) ) (chc.failed) )
{ {
@ -6913,6 +6918,9 @@ postgres_insert_recoup_request (
GNUNET_break (0); GNUNET_break (0);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Inserting recoup for coin %s\n",
TALER_B2S (&coin->coin_pub));
expiry = GNUNET_TIME_absolute_add (timestamp, expiry = GNUNET_TIME_absolute_add (timestamp,
pg->legal_reserve_expiration_time); pg->legal_reserve_expiration_time);
reserve.gc = GNUNET_TIME_absolute_max (expiry, reserve.gc = GNUNET_TIME_absolute_max (expiry,
@ -6976,6 +6984,9 @@ postgres_insert_recoup_refresh_request (
(void) cls; (void) cls;
/* now store actual recoup information */ /* now store actual recoup information */
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Inserting recoup-refresh for coin %s\n",
TALER_B2S (&coin->coin_pub));
qs = GNUNET_PQ_eval_prepared_non_select (session->conn, qs = GNUNET_PQ_eval_prepared_non_select (session->conn,
"recoup_refresh_insert", "recoup_refresh_insert",
params); params);

View File

@ -373,7 +373,7 @@ struct TALER_EXCHANGEDB_RecoupRefreshListEntry
/** /**
* Blinding factor supplied to prove to the exchange that * Blinding factor supplied to prove to the exchange that
* the coin came from this reserve. * the coin came from this @e old_coin_pub.
*/ */
struct TALER_DenominationBlindingKeyP coin_blind; struct TALER_DenominationBlindingKeyP coin_blind;

View File

@ -1219,7 +1219,7 @@ struct TALER_RecoupRequestPS
struct TALER_CoinSpendPublicKeyP coin_pub; struct TALER_CoinSpendPublicKeyP coin_pub;
/** /**
* Hash of the denomination public key of the coin. * Hash of the (revoked) denomination public key of the coin.
*/ */
struct GNUNET_HashCode h_denom_pub; struct GNUNET_HashCode h_denom_pub;

View File

@ -876,10 +876,11 @@ TALER_EXCHANGE_verify_coin_history (
TALER_amount_hton (&pc.recoup_amount, TALER_amount_hton (&pc.recoup_amount,
&amount); &amount);
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_CONFIRM_RECOUP, GNUNET_CRYPTO_eddsa_verify (
&pc, TALER_SIGNATURE_EXCHANGE_CONFIRM_RECOUP_REFRESH,
&exchange_sig.eddsa_signature, &pc,
&exchange_pub.eddsa_pub)) &exchange_sig.eddsa_signature,
&exchange_pub.eddsa_pub))
{ {
GNUNET_break_op (0); GNUNET_break_op (0);
return GNUNET_SYSERR; return GNUNET_SYSERR;
@ -890,6 +891,9 @@ TALER_EXCHANGE_verify_coin_history (
{ {
/* signature not supported, new version on server? */ /* signature not supported, new version on server? */
GNUNET_break_op (0); GNUNET_break_op (0);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected type `%s' in response\n",
type);
GNUNET_assert (GNUNET_SYSERR == add); GNUNET_assert (GNUNET_SYSERR == add);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }

View File

@ -675,28 +675,61 @@ run (void *cls,
"recoup-reveal-coin-1b", "recoup-reveal-coin-1b",
"recoup-melt-coin-1b", "recoup-melt-coin-1b",
"EUR:5"), "EUR:5"),
#if 1 /* melt 10 EUR coin *again* to get 1 EUR refreshed coin */
/* "over-spend" 10 EUR recoup-refreshed coin */ TALER_TESTING_cmd_melt ("recoup-remelt-coin-1a",
TALER_TESTING_cmd_deposit ("recoup-refresh-deposit-failing", "recoup-withdraw-coin-1b",
"recoup-withdraw-coin-1b", MHD_HTTP_OK,
0, "EUR:1",
bc.user42_payto, NULL),
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}", TALER_TESTING_cmd_refresh_reveal ("recoup-reveal-coin-1a",
GNUNET_TIME_UNIT_ZERO, "recoup-remelt-coin-1a",
"EUR:11.5", MHD_HTTP_OK),
MHD_HTTP_OK), /* Try melting for more than the residual value to provoke an error */
// FIXME: yes, we expect 'CONFLICT', but the TALER_TESTING_cmd_melt ("recoup-remelt-coin-1b",
// coin history we get is totally wrong! "recoup-withdraw-coin-1b",
/* "spend" 10 EUR recoup-refreshed coin */ MHD_HTTP_OK,
TALER_TESTING_cmd_deposit ("recoup-refresh-deposit-ok", "EUR:1",
"recoup-withdraw-coin-1b", NULL),
0, TALER_TESTING_cmd_melt ("recoup-remelt-coin-1c",
bc.user42_payto, "recoup-withdraw-coin-1b",
"{\"items\":[{\"name\":\"more ice cream\",\"value\":1}]}", MHD_HTTP_OK,
GNUNET_TIME_UNIT_ZERO, "EUR:1",
"EUR:9.5", /* FIXME: pick 'right' amount! */ NULL),
MHD_HTTP_OK), TALER_TESTING_cmd_melt ("recoup-remelt-coin-1d",
#endif "recoup-withdraw-coin-1b",
MHD_HTTP_OK,
"EUR:1",
NULL),
TALER_TESTING_cmd_melt ("recoup-remelt-coin-1e",
"recoup-withdraw-coin-1b",
MHD_HTTP_OK,
"EUR:1",
NULL),
TALER_TESTING_cmd_melt ("recoup-remelt-coin-1f",
"recoup-withdraw-coin-1b",
MHD_HTTP_OK,
"EUR:1",
NULL),
TALER_TESTING_cmd_melt ("recoup-remelt-coin-1g",
"recoup-withdraw-coin-1b",
MHD_HTTP_OK,
"EUR:1",
NULL),
TALER_TESTING_cmd_melt ("recoup-remelt-coin-1h",
"recoup-withdraw-coin-1b",
MHD_HTTP_OK,
"EUR:1",
NULL),
TALER_TESTING_cmd_melt ("recoup-remelt-coin-1i",
"recoup-withdraw-coin-1b",
MHD_HTTP_OK,
"EUR:1",
NULL),
TALER_TESTING_cmd_melt ("recoup-remelt-coin-1b-failing",
"recoup-withdraw-coin-1b",
MHD_HTTP_CONFLICT,
"EUR:1",
NULL),
/* Re-withdraw from this reserve */ /* Re-withdraw from this reserve */
TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-2", TALER_TESTING_cmd_withdraw_amount ("recoup-withdraw-coin-2",
"recoup-create-reserve-1", "recoup-create-reserve-1",