gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-merchant] branch master updated (cf9a1478 -> 9487e0fb)


From: gnunet
Subject: [taler-merchant] branch master updated (cf9a1478 -> 9487e0fb)
Date: Sun, 24 Sep 2023 21:34:05 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a change to branch master
in repository merchant.

    from cf9a1478 clean up dist rules
     new 6bf97747 update docs
     new 9487e0fb -add missing files

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 doc/prebuilt                                   |   2 +-
 src/backenddb/pg_insert_deposit_confirmation.c | 110 +++++++++++++++++++++++++
 src/backenddb/pg_insert_deposit_confirmation.h |  58 +++++++++++++
 3 files changed, 169 insertions(+), 1 deletion(-)
 create mode 100644 src/backenddb/pg_insert_deposit_confirmation.c
 create mode 100644 src/backenddb/pg_insert_deposit_confirmation.h

diff --git a/doc/prebuilt b/doc/prebuilt
index 748bf62c..1576678c 160000
--- a/doc/prebuilt
+++ b/doc/prebuilt
@@ -1 +1 @@
-Subproject commit 748bf62c7d3342343092f05bb9c02a1145178864
+Subproject commit 1576678c0f195e07c1e1d84a9952ccd17106c0ec
diff --git a/src/backenddb/pg_insert_deposit_confirmation.c 
b/src/backenddb/pg_insert_deposit_confirmation.c
new file mode 100644
index 00000000..377ba2d8
--- /dev/null
+++ b/src/backenddb/pg_insert_deposit_confirmation.c
@@ -0,0 +1,110 @@
+/*
+   This file is part of TALER
+   Copyright (C) 2022, 2023 Taler Systems SA
+
+   TALER is free software; you can redistribute it and/or modify it under the
+   terms of the GNU General Public License as published by the Free Software
+   Foundation; either version 3, or (at your option) any later version.
+
+   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR
+   A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along with
+   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
+ */
+/**
+ * @file backenddb/pg_insert_deposit_confirmation.c
+ * @brief Implementation of the insert_deposit_confirmation function for 
Postgres
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include <taler/taler_error_codes.h>
+#include <taler/taler_dbevents.h>
+#include <taler/taler_pq_lib.h>
+#include "pg_insert_deposit.h"
+#include "pg_helper.h"
+
+
+enum GNUNET_DB_QueryStatus
+TMH_PG_insert_deposit_confirmation (
+  void *cls,
+  const char *instance_id,
+  struct GNUNET_TIME_Timestamp deposit_timestamp,
+  const struct TALER_PrivateContractHashP *h_contract_terms,
+  const char *exchange_url,
+  const struct TALER_Amount *total_without_fees,
+  const struct TALER_Amount *wire_fee,
+  const struct TALER_MerchantWireHashP *h_wire,
+  const struct TALER_ExchangeSignatureP *exchange_sig,
+  const struct TALER_ExchangePublicKeyP *exchange_pub,
+  uint64_t *deposit_confirmation_serial_id)
+{
+  struct PostgresClosure *pg = cls;
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_string (instance_id),
+    GNUNET_PQ_query_param_auto_from_type (h_contract_terms),
+    GNUNET_PQ_query_param_timestamp (&deposit_timestamp),
+    GNUNET_PQ_query_param_string (exchange_url),
+    TALER_PQ_query_param_amount_with_currency (pg->conn,
+                                               total_without_fees),
+    TALER_PQ_query_param_amount_with_currency (pg->conn,
+                                               wire_fee),
+    GNUNET_PQ_query_param_auto_from_type (h_wire), /* 7 */
+    GNUNET_PQ_query_param_auto_from_type (exchange_sig),
+    GNUNET_PQ_query_param_auto_from_type (exchange_pub),
+    GNUNET_PQ_query_param_end
+  };
+  struct GNUNET_PQ_ResultSpec rs[] = {
+    GNUNET_PQ_result_spec_uint64 ("deposit_confirmation_serial",
+                                  deposit_confirmation_serial_id),
+    GNUNET_PQ_result_spec_end
+  };
+
+  /* no preflight check here, run in transaction by caller! */
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Storing deposit confirmation for instance `%s' h_contract_terms 
`%s', total_without_fees: %s\n",
+              instance_id,
+              GNUNET_h2s (&h_contract_terms->hash),
+              TALER_amount2s (total_without_fees));
+  check_connection (pg);
+  PREPARE (pg,
+           "insert_deposit_confirmation",
+           "WITH md AS"
+           "  (SELECT account_serial, merchant_serial"
+           "   FROM merchant_accounts"
+           "   WHERE h_wire=$7"
+           "    AND merchant_serial="
+           "     (SELECT merchant_serial"
+           "        FROM merchant_instances"
+           "        WHERE merchant_id=$1))"
+           ", ed AS"
+           "  (SELECT signkey_serial"
+           "   FROM merchant_exchange_signing_keys"
+           "   WHERE exchange_pub=$9"
+           "   ORDER BY start_date DESC"
+           "   LIMIT 1)"
+           "INSERT INTO merchant_deposit_confirmations"
+           "(order_serial"
+           ",deposit_timestamp"
+           ",exchange_url"
+           ",total_without_fee"
+           ",wire_fee"
+           ",exchange_sig"
+           ",signkey_serial"
+           ",account_serial)"
+           " SELECT "
+           "   order_serial"
+           "  ,$3, $4, $5, $6, $8"
+           "  ,ed.signkey_serial"
+           "  ,md.account_serial"
+           "  FROM merchant_contract_terms"
+           "   JOIN md USING (merchant_serial)"
+           "   FULL OUTER JOIN ed ON TRUE"
+           "  WHERE h_contract_terms=$2"
+           " RETURNING deposit_confirmation_serial");
+  return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+                                                   
"insert_deposit_confirmation",
+                                                   params,
+                                                   rs);
+}
diff --git a/src/backenddb/pg_insert_deposit_confirmation.h 
b/src/backenddb/pg_insert_deposit_confirmation.h
new file mode 100644
index 00000000..3d9802e2
--- /dev/null
+++ b/src/backenddb/pg_insert_deposit_confirmation.h
@@ -0,0 +1,58 @@
+/*
+   This file is part of TALER
+   Copyright (C) 2022 Taler Systems SA
+
+   TALER is free software; you can redistribute it and/or modify it under the
+   terms of the GNU General Public License as published by the Free Software
+   Foundation; either version 3, or (at your option) any later version.
+
+   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR
+   A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along with
+   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
+ */
+/**
+ * @file backenddb/pg_insert_deposit_confirmation.h
+ * @brief implementation of the insert_deposit_confirmation function for 
Postgres
+ * @author Christian Grothoff
+ */
+#ifndef PG_INSERT_DEPOSIT_CONFIRMATION_H
+#define PG_INSERT_DEPOSIT_CONFIRMATION_H
+
+#include <taler/taler_util.h>
+#include <taler/taler_json_lib.h>
+#include "taler_merchantdb_plugin.h"
+
+/**
+ * Insert deposit confirmation from the exchange into the database.
+ *
+ * @param cls closure
+ * @param instance_id instance to lookup deposits for
+ * @param deposit_timestamp time when the exchange generated the deposit 
confirmation
+ * @param h_contract_terms proposal data's hashcode
+ * @param exchange_url URL of the exchange that issued @a coin_pub
+ * @param total_without_fees deposited total in the batch without fees
+ * @param wire_fee wire fee the exchange charges
+ * @param h_wire hash of the wire details of the target account of the merchant
+ * @param exchange_sig signature from exchange that coin was accepted
+ * @param exchange_pub signing key that was used for @a exchange_sig
+ * @param[out] batch_deposit_serial_id set to the table row
+ * @return transaction status
+ */
+enum GNUNET_DB_QueryStatus
+TMH_PG_insert_deposit_confirmation (
+  void *cls,
+  const char *instance_id,
+  struct GNUNET_TIME_Timestamp deposit_timestamp,
+  const struct TALER_PrivateContractHashP *h_contract_terms,
+  const char *exchange_url,
+  const struct TALER_Amount *total_without_fees,
+  const struct TALER_Amount *wire_fee,
+  const struct TALER_MerchantWireHashP *h_wire,
+  const struct TALER_ExchangeSignatureP *exchange_sig,
+  const struct TALER_ExchangePublicKeyP *exchange_pub,
+  uint64_t *deposit_confirmation_serial_id);
+
+#endif

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]