summaryrefslogtreecommitdiff
path: root/src/exchange
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-07-22 13:28:48 +0200
committerChristian Grothoff <christian@grothoff.org>2019-07-22 13:28:48 +0200
commita83aa1f70ec66b468c3498251ea55f3ab89f6b0e (patch)
tree0356f217d55c5b9457f797e144d6c8000677e6b7 /src/exchange
parentc0c80d4a6709fbf1a92417a66635b2b5b5703da7 (diff)
downloadexchange-a83aa1f70ec66b468c3498251ea55f3ab89f6b0e.tar.gz
exchange-a83aa1f70ec66b468c3498251ea55f3ab89f6b0e.tar.bz2
exchange-a83aa1f70ec66b468c3498251ea55f3ab89f6b0e.zip
include new payback-refresh possibilities in coin history generation
Diffstat (limited to 'src/exchange')
-rw-r--r--src/exchange/taler-exchange-httpd_db.c26
-rw-r--r--src/exchange/taler-exchange-httpd_payback.c20
-rw-r--r--src/exchange/taler-exchange-httpd_refund.c6
-rw-r--r--src/exchange/taler-exchange-httpd_responses.c88
4 files changed, 118 insertions, 22 deletions
diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c
index 1f47f8e1..3b9dc36b 100644
--- a/src/exchange/taler-exchange-httpd_db.c
+++ b/src/exchange/taler-exchange-httpd_db.c
@@ -168,8 +168,8 @@ TEH_DB_run_transaction (struct MHD_Connection *connection,
// FIXME: maybe move to another module, i.e. exchangedb???
int
TEH_DB_calculate_transaction_list_totals (struct TALER_EXCHANGEDB_TransactionList *tl,
- const struct TALER_Amount *off,
- struct TALER_Amount *ret)
+ const struct TALER_Amount *off,
+ struct TALER_Amount *ret)
{
struct TALER_Amount spent = *off;
struct TALER_Amount refunded;
@@ -222,6 +222,17 @@ TEH_DB_calculate_transaction_list_totals (struct TALER_EXCHANGEDB_TransactionLis
return GNUNET_SYSERR;
}
break;
+ case TALER_EXCHANGEDB_TT_OLD_COIN_PAYBACK:
+ /* refunded += pos->value */
+ if (GNUNET_OK !=
+ TALER_amount_add (&refunded,
+ &refunded,
+ &pos->details.old_coin_payback->value))
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ break;
case TALER_EXCHANGEDB_TT_PAYBACK:
/* spent += pos->value */
if (GNUNET_OK !=
@@ -233,6 +244,17 @@ TEH_DB_calculate_transaction_list_totals (struct TALER_EXCHANGEDB_TransactionLis
return GNUNET_SYSERR;
}
break;
+ case TALER_EXCHANGEDB_TT_PAYBACK_REFRESH:
+ /* spent += pos->value */
+ if (GNUNET_OK !=
+ TALER_amount_add (&spent,
+ &spent,
+ &pos->details.payback_refresh->value))
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ break;
}
}
/* spent = spent - refunded */
diff --git a/src/exchange/taler-exchange-httpd_payback.c b/src/exchange/taler-exchange-httpd_payback.c
index 232c639e..2f1a2dde 100644
--- a/src/exchange/taler-exchange-httpd_payback.c
+++ b/src/exchange/taler-exchange-httpd_payback.c
@@ -285,26 +285,6 @@ payback_transaction (void *cls,
}
return qs;
}
- /* increment reserve balance */
- qs = TEH_plugin->increment_reserve_balance (TEH_plugin->cls,
- session,
- &pc->reserve_pub,
- pc->coin,
- pc->coin_sig,
- pc->coin_bks,
- &pc->amount,
- &pc->h_blind,
- pc->now);
- if (0 > qs)
- {
- if (GNUNET_DB_STATUS_HARD_ERROR == qs)
- {
- TALER_LOG_WARNING ("Failed to store /payback information in database\n");
- *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection,
- TALER_EC_PAYBACK_DB_PUT_FAILED);
- }
- return qs;
- }
return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
}
diff --git a/src/exchange/taler-exchange-httpd_refund.c b/src/exchange/taler-exchange-httpd_refund.c
index ee6aac1b..69b5cae9 100644
--- a/src/exchange/taler-exchange-httpd_refund.c
+++ b/src/exchange/taler-exchange-httpd_refund.c
@@ -236,9 +236,15 @@ refund_transaction (void *cls,
}
}
break;
+ case TALER_EXCHANGEDB_TT_OLD_COIN_PAYBACK:
+ /* Paybacks cannot be refunded, ignore here */
+ break;
case TALER_EXCHANGEDB_TT_PAYBACK:
/* Paybacks cannot be refunded, ignore here */
break;
+ case TALER_EXCHANGEDB_TT_PAYBACK_REFRESH:
+ /* Paybacks cannot be refunded, ignore here */
+ break;
}
}
/* handle if deposit was NOT found */
diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c
index 5881cbe5..3cf3e781 100644
--- a/src/exchange/taler-exchange-httpd_responses.c
+++ b/src/exchange/taler-exchange-httpd_responses.c
@@ -632,6 +632,50 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact
}
}
break;
+ case TALER_EXCHANGEDB_TT_OLD_COIN_PAYBACK:
+ {
+ struct TALER_EXCHANGEDB_PaybackRefresh *pr = pos->details.old_coin_payback;
+ struct TALER_PaybackRefreshConfirmationPS pc;
+ struct TALER_ExchangePublicKeyP epub;
+ struct TALER_ExchangeSignatureP esig;
+
+ pc.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_PAYBACK_REFRESH);
+ pc.purpose.size = htonl (sizeof (pc));
+ pc.timestamp = GNUNET_TIME_absolute_hton (pr->timestamp);
+ TALER_amount_hton (&pc.payback_amount,
+ &pr->value);
+ pc.coin_pub = pr->coin.coin_pub;
+ pc.old_coin_pub = pr->old_coin_pub;
+ if (GNUNET_OK !=
+ TEH_KS_sign (&pc.purpose,
+ &epub,
+ &esig))
+ {
+ GNUNET_break (0);
+ json_decref (history);
+ return NULL;
+ }
+ /* NOTE: we could also provide coin_pub's coin_sig, denomination key hash and
+ the denomination key's RSA signature over coin_pub, but as the
+ wallet should really already have this information (and cannot
+ check or do anything with it anyway if it doesn't), it seems
+ strictly unnecessary. */
+ if (0 !=
+ json_array_append_new (history,
+ json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}",
+ "type", "OLD-COIN-PAYBACK",
+ "amount", TALER_JSON_from_amount (&pr->value),
+ "exchange_sig", GNUNET_JSON_from_data_auto (&esig),
+ "exchange_pub", GNUNET_JSON_from_data_auto (&epub),
+ "coin_pub", GNUNET_JSON_from_data_auto (&pr->coin.coin_pub),
+ "timestamp", GNUNET_JSON_from_time_abs (pr->timestamp))))
+ {
+ GNUNET_break (0);
+ json_decref (history);
+ return NULL;
+ }
+ break;
+ }
case TALER_EXCHANGEDB_TT_PAYBACK:
{
const struct TALER_EXCHANGEDB_Payback *payback = pos->details.payback;
@@ -671,6 +715,50 @@ TEH_RESPONSE_compile_transaction_history (const struct TALER_EXCHANGEDB_Transact
}
}
break;
+ case TALER_EXCHANGEDB_TT_PAYBACK_REFRESH:
+ {
+ struct TALER_EXCHANGEDB_PaybackRefresh *pr = pos->details.payback_refresh;
+ struct TALER_PaybackRefreshConfirmationPS pc;
+ struct TALER_ExchangePublicKeyP epub;
+ struct TALER_ExchangeSignatureP esig;
+
+ pc.purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_PAYBACK_REFRESH);
+ pc.purpose.size = htonl (sizeof (pc));
+ pc.timestamp = GNUNET_TIME_absolute_hton (pr->timestamp);
+ TALER_amount_hton (&pc.payback_amount,
+ &pr->value);
+ pc.coin_pub = pr->coin.coin_pub;
+ pc.old_coin_pub = pr->old_coin_pub;
+ if (GNUNET_OK !=
+ TEH_KS_sign (&pc.purpose,
+ &epub,
+ &esig))
+ {
+ GNUNET_break (0);
+ json_decref (history);
+ return NULL;
+ }
+ /* NOTE: we could also provide coin_pub's coin_sig, denomination key
+ hash and the denomination key's RSA signature over coin_pub, but as
+ the wallet should really already have this information (and cannot
+ check or do anything with it anyway if it doesn't), it seems
+ strictly unnecessary. */
+ if (0 !=
+ json_array_append_new (history,
+ json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}",
+ "type", "PAYBACK-REFRESH",
+ "amount", TALER_JSON_from_amount (&pr->value),
+ "exchange_sig", GNUNET_JSON_from_data_auto (&esig),
+ "exchange_pub", GNUNET_JSON_from_data_auto (&epub),
+ "old_coin_pub", GNUNET_JSON_from_data_auto (&pr->old_coin_pub),
+ "timestamp", GNUNET_JSON_from_time_abs (pr->timestamp))))
+ {
+ GNUNET_break (0);
+ json_decref (history);
+ return NULL;
+ }
+ break;
+ }
default:
GNUNET_assert (0);
}