summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/taler-merchant-wirewatch.c53
1 files changed, 46 insertions, 7 deletions
diff --git a/src/backend/taler-merchant-wirewatch.c b/src/backend/taler-merchant-wirewatch.c
index f273aaec..6242ddbc 100644
--- a/src/backend/taler-merchant-wirewatch.c
+++ b/src/backend/taler-merchant-wirewatch.c
@@ -351,6 +351,7 @@ credit_cb (
enum GNUNET_DB_QueryStatus qs;
char *exchange_url;
struct TALER_WireTransferIdentifierRawP wtid;
+ char *credit_payto;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Received wire transfer `%s' over %s\n",
@@ -372,22 +373,60 @@ credit_cb (
/* FIXME: consider grouping multiple inserts
into one bigger transaction with just one
notify! */
+ credit_payto = TALER_payto_normalize (details->credit_account_uri);
qs = db_plugin->insert_transfer (db_plugin->cls,
w->instance_id,
exchange_url,
&wtid,
&details->amount,
- details->credit_account_uri,
+ credit_payto,
true /* confirmed */);
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
{
- /* FIXME: this *also* logs if the entry simply
- already exists. Modify code to distinguish! */
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Inserting transfer for %s into database failed. Is the credit account %s configured correctly?\n",
- w->instance_id,
- details->credit_account_uri);
+ struct TALER_Amount total;
+ struct TALER_Amount wfee;
+ struct TALER_Amount eamount;
+ struct GNUNET_TIME_Timestamp timestamp;
+ bool have_esig;
+ bool verified;
+
+ qs = db_plugin->lookup_transfer (db_plugin->cls,
+ w->instance_id,
+ exchange_url,
+ &wtid,
+ &total,
+ &wfee,
+ &eamount,
+ &timestamp,
+ &have_esig,
+ &verified);
+ if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Inserting transfer for %s into database failed. Is the credit account %s configured correctly?\n",
+ w->instance_id,
+ credit_payto);
+ }
+ if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
+ {
+ if (0 !=
+ TALER_amount_cmp (&total,
+ &details->amount))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Inserting transfer for %s into database failed. An entry exists for a different transfer amount (%s)!\n",
+ w->instance_id,
+ TALER_amount2s (&total));
+ }
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Inserting transfer for %s into database failed. An equivalent entry already exists.\n",
+ w->instance_id);
+ }
+ }
}
+ GNUNET_free (credit_payto);
GNUNET_free (exchange_url);
if (qs < 0)
{