From 02faacad3cd56e3266be625980920e420f61250f Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 6 May 2020 21:41:59 +0200 Subject: db work for POST /transfers --- .../taler-merchant-httpd_private-post-transfers.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/backend/taler-merchant-httpd_private-post-transfers.c') diff --git a/src/backend/taler-merchant-httpd_private-post-transfers.c b/src/backend/taler-merchant-httpd_private-post-transfers.c index 2f22d051..5c3a0e3e 100644 --- a/src/backend/taler-merchant-httpd_private-post-transfers.c +++ b/src/backend/taler-merchant-httpd_private-post-transfers.c @@ -1013,6 +1013,7 @@ TMH_private_post_transfers (const struct TMH_RequestHandler *rh, /* reply not in database, ensure the POST is in the database, and start work to obtain the reply from the exchange */ qs = TMH_db->insert_transfer (TMH_db->cls, + rctx->hc->instance->settings.id, rctx->exchange_url, &rctx->wtid, &rctx->amount, @@ -1029,6 +1030,23 @@ TMH_private_post_transfers (const struct TMH_RequestHandler *rh, TALER_EC_POST_TRANSFER_DB_STORE_ERROR, "Fail to update database with transfer record"); } + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) + { + uint64_t account_serial; + + /* Either the record already exists (we should ignore this), or + the INSERT failed because we did not find the account based on + the given payto-URI and the instance. */ + qs = TMH_db->lookup_account (TMH_db->cls, + rctx->hc->instance->settings.id, + rctx->payto_uri, + &account_serial); + if (0 >= qs) + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_POST_TRANSFER_ACCOUNT_NOT_FOUND, + "Instance does not have this bank account"); + } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suspending POST /private/transfers handling while working with exchange\n"); -- cgit v1.2.3