diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-02-09 23:21:55 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-02-09 23:21:55 +0100 |
commit | feed3903671edc872c5fb8cfaad677727047d203 (patch) | |
tree | c6332c55de5d4d12d5843a76799bb448698ce237 /src/backend/taler-merchant-wirewatch.c | |
parent | ba18887d6277134f090649cabbe753a86abab716 (diff) |
trying again on #8348 fix
Diffstat (limited to 'src/backend/taler-merchant-wirewatch.c')
-rw-r--r-- | src/backend/taler-merchant-wirewatch.c | 53 |
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, + ×tamp, + &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) { |