summaryrefslogtreecommitdiff
path: root/src/backenddb/plugin_merchantdb_postgres.c
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2023-10-17 14:25:11 -0600
committerIván Ávalos <avalos@disroot.org>2023-10-17 14:25:11 -0600
commite5e2e394aaa673e43808b4ee8659079d57ced8e6 (patch)
tree5540eb95641d811a273228d7ff4dd615d8338a88 /src/backenddb/plugin_merchantdb_postgres.c
parent5587ac112392a49a5a7779d198b3e38e6f6569c4 (diff)
downloadmerchant-e5e2e394aaa673e43808b4ee8659079d57ced8e6.tar.gz
merchant-e5e2e394aaa673e43808b4ee8659079d57ced8e6.tar.bz2
merchant-e5e2e394aaa673e43808b4ee8659079d57ced8e6.zip
Factor out 15 new functions (shit job)
Diffstat (limited to 'src/backenddb/plugin_merchantdb_postgres.c')
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c1475
1 files changed, 47 insertions, 1428 deletions
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index c2c99cd1..214902dd 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -97,6 +97,21 @@
#include "pg_lookup_order_status.h"
#include "pg_lookup_order_status_by_serial.h"
#include "pg_lookup_payment_status.h"
+#include "pg_lookup_deposits_by_order.h"
+#include "pg_lookup_transfer_details_by_order.h"
+#include "pg_mark_order_wired.h"
+#include "pg_lookup_refunds_detailed.h"
+#include "pg_insert_refund_proof.h"
+#include "pg_lookup_refund_proof.h"
+#include "pg_lookup_order_by_fulfillment.h"
+#include "pg_delete_transfer.h"
+#include "pg_check_transfer_exists.h"
+#include "pg_lookup_account.h"
+#include "pg_lookup_wire_fee.h"
+#include "pg_lookup_deposits_by_contract_and_coin.h"
+#include "pg_lookup_transfer.h"
+#include "pg_lookup_transfer_summary.h"
+#include "pg_lookup_transfer_details.h"
#include "pg_set_transfer_status_to_confirmed.h"
#include "pg_insert_exchange_keys.h"
#include "pg_select_exchange_keys.h"
@@ -261,1186 +276,6 @@ check_connection (struct PostgresClosure *pg)
/**
- * Closure for lookup_deposits_by_order_cb().
- */
-struct LookupDepositsByOrderContext
-{
-
- /**
- * Plugin context.
- */
- struct PostgresClosure *pg;
-
- /**
- * Function to call with all results.
- */
- TALER_MERCHANTDB_DepositedCoinsCallback cb;
-
- /**
- * Closure for @e cb.
- */
- void *cb_cls;
-
- /**
- * Set to the query result.
- */
- enum GNUNET_DB_QueryStatus qs;
-};
-
-
-/**
- * Function to be called with the results of a SELECT statement
- * that has returned @a num_results results.
- *
- * @param cls of type `struct LookupDepositsByOrderContext *`
- * @param result the postgres result
- * @param num_results the number of results in @a result
- */
-static void
-lookup_deposits_by_order_cb (void *cls,
- PGresult *result,
- unsigned int num_results)
-{
- struct LookupDepositsByOrderContext *ldoc = cls;
-
- for (unsigned int i = 0; i<num_results; i++)
- {
- uint64_t deposit_serial;
- char *exchange_url;
- struct TALER_MerchantWireHashP h_wire;
- struct TALER_CoinSpendPublicKeyP coin_pub;
- struct TALER_Amount amount_with_fee;
- struct TALER_Amount deposit_fee;
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_uint64 ("deposit_serial",
- &deposit_serial),
- GNUNET_PQ_result_spec_string ("exchange_url",
- &exchange_url),
- GNUNET_PQ_result_spec_auto_from_type ("h_wire",
- &h_wire),
- TALER_PQ_result_spec_amount_with_currency ("amount_with_fee",
- &amount_with_fee),
- TALER_PQ_result_spec_amount_with_currency ("deposit_fee",
- &deposit_fee),
- GNUNET_PQ_result_spec_auto_from_type ("coin_pub",
- &coin_pub),
- GNUNET_PQ_result_spec_end
- };
-
- if (GNUNET_OK !=
- GNUNET_PQ_extract_result (result,
- rs,
- i))
- {
- GNUNET_break (0);
- ldoc->qs = GNUNET_DB_STATUS_HARD_ERROR;
- return;
- }
- ldoc->cb (ldoc->cb_cls,
- deposit_serial,
- exchange_url,
- &h_wire,
- &amount_with_fee,
- &deposit_fee,
- &coin_pub);
- GNUNET_PQ_cleanup_result (rs); /* technically useless here */
- }
- ldoc->qs = num_results;
-}
-
-
-/**
- * Retrieve details about coins that were deposited for an order.
- *
- * @param cls closure
- * @param order_serial identifies the order
- * @param cb function to call for each deposited coin
- * @param cb_cls closure for @a cb
- * @return transaction status
- */
-static enum GNUNET_DB_QueryStatus
-postgres_lookup_deposits_by_order (void *cls,
- uint64_t order_serial,
- TALER_MERCHANTDB_DepositedCoinsCallback cb,
- void *cb_cls)
-{
- struct PostgresClosure *pg = cls;
- struct LookupDepositsByOrderContext ldoc = {
- .pg = pg,
- .cb = cb,
- .cb_cls = cb_cls
- };
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_uint64 (&order_serial),
- GNUNET_PQ_query_param_end
- };
- enum GNUNET_DB_QueryStatus qs;
-
- qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
- "lookup_deposits_by_order",
- params,
- &lookup_deposits_by_order_cb,
- &ldoc);
- if (qs < 0)
- return qs;
- return ldoc.qs;
-}
-
-
-/**
- * Closure for lookup_deposits_by_order_cb().
- */
-struct LookupTransferDetailsByOrderContext
-{
-
- /**
- * Plugin context.
- */
- struct PostgresClosure *pg;
-
- /**
- * Function to call with all results.
- */
- TALER_MERCHANTDB_OrderTransferDetailsCallback cb;
-
- /**
- * Closure for @e cb.
- */
- void *cb_cls;
-
- /**
- * Set to the query result.
- */
- enum GNUNET_DB_QueryStatus qs;
-};
-
-
-/**
- * Function to be called with the results of a SELECT statement
- * that has returned @a num_results results.
- *
- * @param cls of type `struct LookupTransferDetailsByOrderContext *`
- * @param result the postgres result
- * @param num_results the number of results in @a result
- */
-static void
-lookup_transfer_details_by_order_cb (void *cls,
- PGresult *result,
- unsigned int num_results)
-{
- struct LookupTransferDetailsByOrderContext *ltdo = cls;
-
- for (unsigned int i = 0; i<num_results; i++)
- {
- struct TALER_WireTransferIdentifierRawP wtid;
- char *exchange_url;
- uint64_t deposit_serial;
- struct GNUNET_TIME_Timestamp execution_time;
- struct TALER_Amount deposit_value;
- struct TALER_Amount deposit_fee;
- uint8_t transfer_confirmed;
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_uint64 ("deposit_serial",
- &deposit_serial),
- GNUNET_PQ_result_spec_timestamp ("deposit_timestamp",
- &execution_time),
- GNUNET_PQ_result_spec_string ("exchange_url",
- &exchange_url),
- GNUNET_PQ_result_spec_auto_from_type ("wtid",
- &wtid),
- TALER_PQ_result_spec_amount_with_currency ("exchange_deposit_value",
- &deposit_value),
- TALER_PQ_result_spec_amount_with_currency ("exchange_deposit_fee",
- &deposit_fee),
- GNUNET_PQ_result_spec_auto_from_type ("transfer_confirmed",
- &transfer_confirmed),
- GNUNET_PQ_result_spec_end
- };
-
- if (GNUNET_OK !=
- GNUNET_PQ_extract_result (result,
- rs,
- i))
- {
- GNUNET_break (0);
- ltdo->qs = GNUNET_DB_STATUS_HARD_ERROR;
- return;
- }
- ltdo->cb (ltdo->cb_cls,
- &wtid,
- exchange_url,
- execution_time,
- &deposit_value,
- &deposit_fee,
- (0 != transfer_confirmed));
- GNUNET_PQ_cleanup_result (rs); /* technically useless here */
- }
- ltdo->qs = num_results;
-}
-
-
-/**
- * Retrieve wire transfer details for all deposits associated with
- * a given @a order_serial.
- *
- * @param cls closure
- * @param order_serial identifies the order
- * @param cb function called with the wire transfer details
- * @param cb_cls closure for @a cb
- * @return transaction status
- */
-static enum GNUNET_DB_QueryStatus
-postgres_lookup_transfer_details_by_order (
- void *cls,
- uint64_t order_serial,
- TALER_MERCHANTDB_OrderTransferDetailsCallback cb,
- void *cb_cls)
-{
- struct PostgresClosure *pg = cls;
- struct LookupTransferDetailsByOrderContext ltdo = {
- .pg = pg,
- .cb = cb,
- .cb_cls = cb_cls
- };
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_uint64 (&order_serial),
- GNUNET_PQ_query_param_end
- };
- enum GNUNET_DB_QueryStatus qs;
-
- qs = GNUNET_PQ_eval_prepared_multi_select (
- pg->conn,
- "lookup_transfer_details_by_order",
- params,
- &lookup_transfer_details_by_order_cb,
- &ltdo);
- if (qs < 0)
- return qs;
- return ltdo.qs;
-}
-
-
-/**
- * Set 'wired' status for an order to 'true'.
- *
- * @param cls closure
- * @param order_serial serial number of the order
- * @return transaction status
- */
-static enum GNUNET_DB_QueryStatus
-postgres_mark_order_wired (void *cls,
- uint64_t order_serial)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_uint64 (&order_serial),
- GNUNET_PQ_query_param_end
- };
-
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "mark_order_wired",
- params);
-}
-
-
-/**
- * Closure for #lookup_refunds_detailed_cb().
- */
-struct LookupRefundsDetailedContext
-{
- /**
- * Function to call for each refund.
- */
- TALER_MERCHANTDB_RefundDetailCallback rc;
-
- /**
- * Closure for @e rc.
- */
- void *rc_cls;
-
- /**
- * Plugin context.
- */
- struct PostgresClosure *pg;
-
- /**
- * Transaction result.
- */
- enum GNUNET_DB_QueryStatus qs;
-};
-
-
-/**
- * Function to be called with the results of a SELECT statement
- * that has returned @a num_results results.
- *
- * @param cls of type `struct GetRefundsContext *`
- * @param result the postgres result
- * @param num_results the number of results in @a result
- */
-static void
-lookup_refunds_detailed_cb (void *cls,
- PGresult *result,
- unsigned int num_results)
-{
- struct LookupRefundsDetailedContext *lrdc = cls;
-
- for (unsigned int i = 0; i<num_results; i++)
- {
- uint64_t refund_serial;
- struct GNUNET_TIME_Timestamp timestamp;
- struct TALER_CoinSpendPublicKeyP coin_pub;
- uint64_t rtransaction_id;
- struct TALER_Amount refund_amount;
- char *reason;
- char *exchange_url;
- uint8_t pending8;
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_uint64 ("refund_serial",
- &refund_serial),
- GNUNET_PQ_result_spec_timestamp ("refund_timestamp",
- &timestamp),
- GNUNET_PQ_result_spec_auto_from_type ("coin_pub",
- &coin_pub),
- GNUNET_PQ_result_spec_string ("exchange_url",
- &exchange_url),
- GNUNET_PQ_result_spec_uint64 ("rtransaction_id",
- &rtransaction_id),
- GNUNET_PQ_result_spec_string ("reason",
- &reason),
- TALER_PQ_result_spec_amount_with_currency ("refund_amount",
- &refund_amount),
- GNUNET_PQ_result_spec_auto_from_type ("pending",
- &pending8),
- GNUNET_PQ_result_spec_end
- };
-
- if (GNUNET_OK !=
- GNUNET_PQ_extract_result (result,
- rs,
- i))
- {
- GNUNET_break (0);
- lrdc->qs = GNUNET_DB_STATUS_HARD_ERROR;
- return;
- }
- lrdc->rc (lrdc->rc_cls,
- refund_serial,
- timestamp,
- &coin_pub,
- exchange_url,
- rtransaction_id,
- reason,
- &refund_amount,
- 0 != pending8);
- GNUNET_PQ_cleanup_result (rs);
- }
- lrdc->qs = num_results;
-}
-
-
-/**
- * Obtain detailed refund data associated with a contract.
- *
- * @param cls closure, typically a connection to the db
- * @param instance_id instance to lookup refunds for
- * @param h_contract_terms hash code of the contract
- * @param rc function to call for each coin on which there is a refund
- * @param rc_cls closure for @a rc
- * @return transaction status
- */
-static enum GNUNET_DB_QueryStatus
-postgres_lookup_refunds_detailed (
- void *cls,
- const char *instance_id,
- const struct TALER_PrivateContractHashP *h_contract_terms,
- TALER_MERCHANTDB_RefundDetailCallback rc,
- void *rc_cls)
-{
- 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_end
- };
- struct LookupRefundsDetailedContext lrdc = {
- .rc = rc,
- .rc_cls = rc_cls,
- .pg = pg
- };
- enum GNUNET_DB_QueryStatus qs;
-
- /* no preflight check here, run in transaction by caller! */
- TALER_LOG_DEBUG ("Looking for refund %s + %s\n",
- GNUNET_h2s (&h_contract_terms->hash),
- instance_id);
- check_connection (pg);
- qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
- "lookup_refunds_detailed",
- params,
- &lookup_refunds_detailed_cb,
- &lrdc);
- if (0 >= qs)
- return qs;
- return lrdc.qs;
-}
-
-
-/**
- * Insert refund proof data from the exchange into the database.
- *
- * @param cls closure
- * @param refund_serial serial number of the refund
- * @param exchange_sig signature from exchange that coin was refunded
- * @param exchange_pub signing key that was used for @a exchange_sig
- * @return transaction status
- */
-static enum GNUNET_DB_QueryStatus
-postgres_insert_refund_proof (
- void *cls,
- uint64_t refund_serial,
- const struct TALER_ExchangeSignatureP *exchange_sig,
- const struct TALER_ExchangePublicKeyP *exchange_pub)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_uint64 (&refund_serial),
- GNUNET_PQ_query_param_auto_from_type (exchange_sig),
- GNUNET_PQ_query_param_auto_from_type (exchange_pub),
- GNUNET_PQ_query_param_end
- };
-
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "insert_refund_proof",
- params);
-}
-
-
-/**
- * Lookup refund proof data.
- *
- * @param cls closure
- * @param refund_serial serial number of the refund
- * @param[out] exchange_sig set to signature from exchange
- * @param[out] exchange_pub signing key that was used for @a exchange_sig
- * @return transaction status
- */
-static enum GNUNET_DB_QueryStatus
-postgres_lookup_refund_proof (void *cls,
- uint64_t refund_serial,
- struct TALER_ExchangeSignatureP *exchange_sig,
- struct TALER_ExchangePublicKeyP *exchange_pub)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_uint64 (&refund_serial),
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_auto_from_type ("exchange_sig",
- exchange_sig),
- GNUNET_PQ_result_spec_auto_from_type ("exchange_pub",
- exchange_pub),
- GNUNET_PQ_result_spec_end
- };
-
- check_connection (pg);
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "lookup_refund_proof",
- params,
- rs);
-}
-
-
-/**
- * Retrieve the order ID that was used to pay for a resource within a session.
- *
- * @param cls closure
- * @param instance_id identifying the instance
- * @param fulfillment_url URL that canonically identifies the resource
- * being paid for
- * @param session_id session id
- * @param[out] order_id where to store the order ID that was used when
- * paying for the resource URL
- * @return transaction status
- */
-enum GNUNET_DB_QueryStatus
-postgres_lookup_order_by_fulfillment (void *cls,
- const char *instance_id,
- const char *fulfillment_url,
- const char *session_id,
- char **order_id)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_string (instance_id),
- GNUNET_PQ_query_param_string (fulfillment_url),
- GNUNET_PQ_query_param_string (session_id),
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_string ("order_id",
- order_id),
- GNUNET_PQ_result_spec_end
- };
-
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "lookup_order_by_fulfillment",
- params,
- rs);
-}
-
-
-/**
- * Delete information about a transfer. Note that transfers
- * confirmed by the exchange cannot be deleted anymore.
- *
- * @param cls closure
- * @param instance_id instance to delete transfer of
- * @param transfer_serial_id transfer to delete
- * @return DB status code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS
- * if deletion is prohibited OR transfer is unknown
- */
-static enum GNUNET_DB_QueryStatus
-postgres_delete_transfer (void *cls,
- const char *instance_id,
- uint64_t transfer_serial_id)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_string (instance_id),
- GNUNET_PQ_query_param_uint64 (&transfer_serial_id),
- GNUNET_PQ_query_param_end
- };
-
- check_connection (pg);
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "delete_transfer",
- params);
-}
-
-
-/**
- * Check if information about a transfer exists with the
- * backend. Returns no data, only the query status.
- *
- * @param cls closure
- * @param instance_id instance to delete transfer of
- * @param transfer_serial_id transfer to delete
- * @return DB status code, #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT
- * if the transfer record exists
- */
-static enum GNUNET_DB_QueryStatus
-postgres_check_transfer_exists (void *cls,
- const char *instance_id,
- uint64_t transfer_serial_id)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_string (instance_id),
- GNUNET_PQ_query_param_uint64 (&transfer_serial_id),
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_end
- };
-
- check_connection (pg);
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "check_transfer_exists",
- params,
- rs);
-}
-
-
-/**
- * Lookup account serial by payto URI.
- *
- * @param cls closure
- * @param instance_id instance to lookup the account from
- * @param payto_uri what is the merchant's bank account to lookup
- * @param[out] account_serial serial number of the account
- * @return transaction status
- */
-static enum GNUNET_DB_QueryStatus
-postgres_lookup_account (void *cls,
- const char *instance_id,
- const char *payto_uri,
- uint64_t *account_serial)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_string (instance_id),
- GNUNET_PQ_query_param_string (payto_uri),
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_uint64 ("account_serial",
- account_serial),
- GNUNET_PQ_result_spec_end
- };
-
- check_connection (pg);
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "lookup_account",
- params,
- rs);
-}
-
-
-/**
- * Obtain information about wire fees charged by an exchange,
- * including signature (so we have proof).
- *
- * @param cls closure
- * @param master_pub public key of the exchange
- * @param wire_method the wire method
- * @param contract_date date of the contract to use for the lookup
- * @param[out] fees wire fees charged
- * @param[out] start_date start of fee being used
- * @param[out] end_date end of fee being used
- * @param[out] master_sig signature of exchange over fee structure
- * @return transaction status code
- */
-static enum GNUNET_DB_QueryStatus
-postgres_lookup_wire_fee (void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const char *wire_method,
- struct GNUNET_TIME_Timestamp contract_date,
- struct TALER_WireFeeSet *fees,
- struct GNUNET_TIME_Timestamp *start_date,
- struct GNUNET_TIME_Timestamp *end_date,
- struct TALER_MasterSignatureP *master_sig)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_HashCode h_wire_method;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (master_pub),
- GNUNET_PQ_query_param_auto_from_type (&h_wire_method),
- GNUNET_PQ_query_param_timestamp (&contract_date),
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- TALER_PQ_result_spec_amount_with_currency ("wire_fee",
- &fees->wire),
- TALER_PQ_result_spec_amount_with_currency ("closing_fee",
- &fees->closing),
- GNUNET_PQ_result_spec_timestamp ("start_date",
- start_date),
- GNUNET_PQ_result_spec_timestamp ("end_date",
- end_date),
- GNUNET_PQ_result_spec_auto_from_type ("master_sig",
- master_sig),
- GNUNET_PQ_result_spec_end
- };
-
- check_connection (pg);
- GNUNET_CRYPTO_hash (wire_method,
- strlen (wire_method) + 1,
- &h_wire_method);
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "lookup_wire_fee",
- params,
- rs);
-}
-
-
-/**
- * Closure for #lookup_deposits_by_contract_and_coin_cb().
- */
-struct LookupDepositsByCnCContext
-{
- /**
- * Function to call for each deposit.
- */
- TALER_MERCHANTDB_CoinDepositCallback cb;
-
- /**
- * Closure for @e cb.
- */
- void *cb_cls;
-
- /**
- * Plugin context.
- */
- struct PostgresClosure *pg;
-
- /**
- * Transaction result.
- */
- enum GNUNET_DB_QueryStatus qs;
-};
-
-
-/**
- * Function to be called with the results of a SELECT statement
- * that has returned @a num_results results.
- *
- * @param cls of type `struct LookupDepositsByCnCContext *`
- * @param result the postgres result
- * @param num_results the number of results in @a result
- */
-static void
-lookup_deposits_by_contract_and_coin_cb (void *cls,
- PGresult *result,
- unsigned int num_results)
-{
- struct LookupDepositsByCnCContext *ldcc = cls;
-
- for (unsigned int i = 0; i<num_results; i++)
- {
- char *exchange_url;
- struct TALER_Amount amount_with_fee;
- struct TALER_Amount deposit_fee;
- struct TALER_Amount refund_fee;
- struct TALER_Amount wire_fee;
- struct TALER_MerchantWireHashP h_wire;
- struct GNUNET_TIME_Timestamp deposit_timestamp;
- struct GNUNET_TIME_Timestamp refund_deadline;
- struct TALER_ExchangeSignatureP exchange_sig;
- struct TALER_ExchangePublicKeyP exchange_pub;
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_string ("exchange_url",
- &exchange_url),
- TALER_PQ_result_spec_amount_with_currency ("amount_with_fee",
- &amount_with_fee),
- TALER_PQ_result_spec_amount_with_currency ("deposit_fee",
- &deposit_fee),
- TALER_PQ_result_spec_amount_with_currency ("refund_fee",
- &refund_fee),
- TALER_PQ_result_spec_amount_with_currency ("wire_fee",
- &wire_fee),
- GNUNET_PQ_result_spec_auto_from_type ("h_wire",
- &h_wire),
- GNUNET_PQ_result_spec_timestamp ("deposit_timestamp",
- &deposit_timestamp),
- GNUNET_PQ_result_spec_timestamp ("refund_deadline",
- &refund_deadline),
- GNUNET_PQ_result_spec_auto_from_type ("exchange_sig",
- &exchange_sig),
- GNUNET_PQ_result_spec_auto_from_type ("exchange_pub",
- &exchange_pub),
- GNUNET_PQ_result_spec_end
- };
-
- if (GNUNET_OK !=
- GNUNET_PQ_extract_result (result,
- rs,
- i))
- {
- GNUNET_break (0);
- ldcc->qs = GNUNET_DB_STATUS_HARD_ERROR;
- return;
- }
- ldcc->cb (ldcc->cb_cls,
- exchange_url,
- &amount_with_fee,
- &deposit_fee,
- &refund_fee,
- &wire_fee,
- &h_wire,
- deposit_timestamp,
- refund_deadline,
- &exchange_sig,
- &exchange_pub);
- GNUNET_PQ_cleanup_result (rs);
- }
- ldcc->qs = num_results;
-}
-
-
-/**
- * Lookup information about coin payments by @a h_contract_terms and
- * @a coin_pub.
- *
- * @param cls closure
- * @param instance_id instance to lookup payments for
- * @param h_contract_terms proposal data's hashcode
- * @param coin_pub public key to use for the search
- * @param cb function to call with payment data
- * @param cb_cls closure for @a cb
- * @return transaction status
- */
-static enum GNUNET_DB_QueryStatus
-postgres_lookup_deposits_by_contract_and_coin (
- void *cls,
- const char *instance_id,
- const struct TALER_PrivateContractHashP *h_contract_terms,
- const struct TALER_CoinSpendPublicKeyP *coin_pub,
- TALER_MERCHANTDB_CoinDepositCallback cb,
- void *cb_cls)
-{
- 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_auto_from_type (coin_pub),
- GNUNET_PQ_query_param_end
- };
- struct LookupDepositsByCnCContext ldcc = {
- .cb = cb,
- .cb_cls = cb_cls,
- .pg = pg
- };
- enum GNUNET_DB_QueryStatus qs;
-
- check_connection (pg);
- qs = GNUNET_PQ_eval_prepared_multi_select (
- pg->conn,
- "lookup_deposits_by_contract_and_coin",
- params,
- &lookup_deposits_by_contract_and_coin_cb,
- &ldcc);
- if (0 >= qs)
- return qs;
- return ldcc.qs;
-}
-
-
-/**
- * Lookup transfer status.
- *
- * @param cls closure
- * @param instance_id at which instance should we resolve the transfer
- * @param exchange_url the exchange that made the transfer
- * @param wtid wire transfer subject
- * @param[out] total_amount amount that was debited from our
- * aggregate balance at the exchange (in total, sum of
- * the wire transfer amount and the @a wire_fee)
- * @param[out] wire_fee the wire fee the exchange charged (only set if @a have_exchange_sig is true)
- * @param[out] exchange_amount the amount the exchange claims was transferred (only set if @a have_exchange_sig is true)
- * @param[out] execution_time when the transfer was executed by the exchange (only set if @a have_exchange_sig is true)
- * @param[out] have_exchange_sig do we have a response from the exchange about this transfer
- * @param[out] verified did we confirm the transfer was OK
- * @return transaction status
- */
-static enum GNUNET_DB_QueryStatus
-postgres_lookup_transfer (
- void *cls,
- const char *instance_id,
- const char *exchange_url,
- const struct TALER_WireTransferIdentifierRawP *wtid,
- struct TALER_Amount *total_amount,
- struct TALER_Amount *wire_fee,
- struct TALER_Amount *exchange_amount,
- struct GNUNET_TIME_Timestamp *execution_time,
- bool *have_exchange_sig,
- bool *verified)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_string (exchange_url),
- GNUNET_PQ_query_param_auto_from_type (wtid),
- GNUNET_PQ_query_param_string (instance_id),
- GNUNET_PQ_query_param_end
- };
- uint8_t verified8;
- /** Amount we got actually credited, _excludes_ the wire fee */
- bool no_sig;
- struct TALER_Amount credit_amount;
- struct GNUNET_PQ_ResultSpec rs[] = {
- TALER_PQ_result_spec_amount_with_currency ("credit_amount",
- &credit_amount),
- GNUNET_PQ_result_spec_allow_null (
- TALER_PQ_result_spec_amount_with_currency ("wire_fee",
- wire_fee),
- &no_sig),
- GNUNET_PQ_result_spec_allow_null (
- TALER_PQ_result_spec_amount_with_currency ("exchange_amount",
- exchange_amount),
- NULL),
- GNUNET_PQ_result_spec_allow_null (
- GNUNET_PQ_result_spec_timestamp ("execution_time",
- execution_time),
- NULL),
- GNUNET_PQ_result_spec_auto_from_type ("verified",
- &verified8),
- GNUNET_PQ_result_spec_end
- };
- enum GNUNET_DB_QueryStatus qs;
-
- check_connection (pg);
- *execution_time = GNUNET_TIME_UNIT_ZERO_TS;
- qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "lookup_transfer",
- params,
- rs);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Lookup transfer returned %d\n",
- qs);
- if (qs > 0)
- {
- *have_exchange_sig = ! no_sig;
- *verified = (0 != verified8);
- if (GNUNET_OK !=
- TALER_amount_cmp_currency (&credit_amount,
- wire_fee))
- {
- GNUNET_break (0);
- return GNUNET_DB_STATUS_HARD_ERROR;
- }
- if ( (! no_sig) &&
- (0 >
- TALER_amount_add (total_amount,
- &credit_amount,
- wire_fee)) )
- {
- GNUNET_break (0);
- return GNUNET_DB_STATUS_HARD_ERROR;
- }
- }
- else
- {
- *verified = false;
- *have_exchange_sig = false;
- }
- return qs;
-}
-
-
-/**
- * Closure for #lookup_transfer_summary_cb().
- */
-struct LookupTransferSummaryContext
-{
- /**
- * Function to call for each order that was aggregated.
- */
- TALER_MERCHANTDB_TransferSummaryCallback cb;
-
- /**
- * Closure for @e cb.
- */
- void *cb_cls;
-
- /**
- * Plugin context.
- */
- struct PostgresClosure *pg;
-
- /**
- * Transaction result.
- */
- enum GNUNET_DB_QueryStatus qs;
-};
-
-
-/**
- * Function to be called with the results of a SELECT statement
- * that has returned @a num_results results.
- *
- * @param cls of type `struct LookupTransferSummaryContext *`
- * @param result the postgres result
- * @param num_results the number of results in @a result
- */
-static void
-lookup_transfer_summary_cb (void *cls,
- PGresult *result,
- unsigned int num_results)
-{
- struct LookupTransferSummaryContext *ltdc = cls;
-
- for (unsigned int i = 0; i<num_results; i++)
- {
- char *order_id;
- struct TALER_Amount deposit_value;
- struct TALER_Amount deposit_fee;
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_string ("order_id",
- &order_id),
- TALER_PQ_result_spec_amount_with_currency ("exchange_deposit_value",
- &deposit_value),
- TALER_PQ_result_spec_amount_with_currency ("exchange_deposit_fee",
- &deposit_fee),
- GNUNET_PQ_result_spec_end
- };
-
- if (GNUNET_OK !=
- GNUNET_PQ_extract_result (result,
- rs,
- i))
- {
- GNUNET_break (0);
- ltdc->qs = GNUNET_DB_STATUS_HARD_ERROR;
- return;
- }
- ltdc->cb (ltdc->cb_cls,
- order_id,
- &deposit_value,
- &deposit_fee);
- GNUNET_PQ_cleanup_result (rs);
- }
- ltdc->qs = num_results;
-}
-
-
-/**
- * Lookup transfer summary.
- *
- * @param cls closure
- * @param exchange_url the exchange that made the transfer
- * @param wtid wire transfer subject
- * @param cb function to call with detailed transfer data
- * @param cb_cls closure for @a cb
- * @return transaction status
- */
-static enum GNUNET_DB_QueryStatus
-postgres_lookup_transfer_summary (
- void *cls,
- const char *exchange_url,
- const struct TALER_WireTransferIdentifierRawP *wtid,
- TALER_MERCHANTDB_TransferSummaryCallback cb,
- void *cb_cls)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_string (exchange_url),
- GNUNET_PQ_query_param_auto_from_type (wtid),
- GNUNET_PQ_query_param_end
- };
- struct LookupTransferSummaryContext ltdc = {
- .cb = cb,
- .cb_cls = cb_cls,
- .pg = pg
- };
- enum GNUNET_DB_QueryStatus qs;
-
- check_connection (pg);
- qs = GNUNET_PQ_eval_prepared_multi_select (
- pg->conn,
- "lookup_transfer_summary",
- params,
- &lookup_transfer_summary_cb,
- &ltdc);
- if (0 >= qs)
- return qs;
- return ltdc.qs;
-}
-
-
-/**
- * Closure for #lookup_transfer_details_cb().
- */
-struct LookupTransferDetailsContext
-{
- /**
- * Function to call for each order that was aggregated.
- */
- TALER_MERCHANTDB_TransferDetailsCallback cb;
-
- /**
- * Closure for @e cb.
- */
- void *cb_cls;
-
- /**
- * Plugin context.
- */
- struct PostgresClosure *pg;
-
- /**
- * Transaction result.
- */
- enum GNUNET_DB_QueryStatus qs;
-};
-
-
-/**
- * Function to be called with the results of a SELECT statement
- * that has returned @a num_results results.
- *
- * @param cls of type `struct LookupTransferDetailsContext *`
- * @param result the postgres result
- * @param num_results the number of results in @a result
- */
-static void
-lookup_transfer_details_cb (void *cls,
- PGresult *result,
- unsigned int num_results)
-{
- struct LookupTransferDetailsContext *ltdc = cls;
-
- for (unsigned int i = 0; i<num_results; i++)
- {
- uint64_t current_offset;
- struct TALER_TrackTransferDetails ttd;
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_uint64 ("offset_in_exchange_list",
- &current_offset),
- GNUNET_PQ_result_spec_auto_from_type ("h_contract_terms",
- &ttd.h_contract_terms),
- GNUNET_PQ_result_spec_auto_from_type ("coin_pub",
- &ttd.coin_pub),
- TALER_PQ_result_spec_amount_with_currency ("exchange_deposit_value",
- &ttd.coin_value),
- TALER_PQ_result_spec_amount_with_currency ("exchange_deposit_fee",
- &ttd.coin_fee),
- GNUNET_PQ_result_spec_end
- };
-
- if (GNUNET_OK !=
- GNUNET_PQ_extract_result (result,
- rs,
- i))
- {
- GNUNET_break (0);
- ltdc->qs = GNUNET_DB_STATUS_HARD_ERROR;
- return;
- }
- ltdc->cb (ltdc->cb_cls,
- (unsigned int) current_offset,
- &ttd);
- GNUNET_PQ_cleanup_result (rs);
- }
- ltdc->qs = num_results;
-}
-
-
-/**
- * Lookup transfer details.
- *
- * @param cls closure
- * @param exchange_url the exchange that made the transfer
- * @param wtid wire transfer subject
- * @param cb function to call with detailed transfer data
- * @param cb_cls closure for @a cb
- * @return transaction status
- */
-static enum GNUNET_DB_QueryStatus
-postgres_lookup_transfer_details (
- void *cls,
- const char *exchange_url,
- const struct TALER_WireTransferIdentifierRawP *wtid,
- TALER_MERCHANTDB_TransferDetailsCallback cb,
- void *cb_cls)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_string (exchange_url),
- GNUNET_PQ_query_param_auto_from_type (wtid),
- GNUNET_PQ_query_param_end
- };
- struct LookupTransferDetailsContext ltdc = {
- .cb = cb,
- .cb_cls = cb_cls,
- .pg = pg
- };
- enum GNUNET_DB_QueryStatus qs;
-
- check_connection (pg);
- qs = GNUNET_PQ_eval_prepared_multi_select (
- pg->conn,
- "lookup_transfer_details",
- params,
- &lookup_transfer_details_cb,
- &ltdc);
- if (0 >= qs)
- return qs;
- return ltdc.qs;
-}
-
-
-/**
* Closure for #lookup_pending_reserves_cb.
*/
struct LookupPendingReservesContext
@@ -3065,235 +1900,6 @@ postgres_connect (void *cls)
struct GNUNET_PQ_PreparedStatement ps[] = {
GNUNET_PQ_make_prepare ("end_transaction",
"COMMIT"),
- /* for postgres_lookup_deposits_by_order() */
- GNUNET_PQ_make_prepare ("lookup_deposits_by_order",
- "SELECT"
- " dep.deposit_serial"
- ",mcon.exchange_url"
- ",acc.h_wire"
- ",dep.amount_with_fee"
- ",dep.deposit_fee"
- ",dep.coin_pub"
- " FROM merchant_deposits dep"
- " JOIN merchant_deposit_confirmations mcon"
- " USING(deposit_confirmation_serial)"
- " JOIN merchant_accounts acc"
- " USING (account_serial)"
- " WHERE mcon.order_serial=$1"),
- /* for postgres_lookup_transfer_details_by_order() */
- GNUNET_PQ_make_prepare ("lookup_transfer_details_by_order",
- "SELECT"
- " md.deposit_serial"
- ",mcon.exchange_url"
- ",mt.wtid"
- ",mtc.exchange_deposit_value"
- ",mtc.exchange_deposit_fee"
- ",mcon.deposit_timestamp"
- ",mt.confirmed AS transfer_confirmed"
- " FROM merchant_transfer_to_coin mtc"
- " JOIN merchant_deposits md"
- " USING (deposit_serial)"
- " JOIN merchant_deposit_confirmations mcon"
- " USING (deposit_confirmation_serial)"
- " JOIN merchant_transfers mt"
- " USING (credit_serial)"
- " JOIN merchant_accounts acc"
- " ON (acc.account_serial = mt.account_serial)"
- /* Check that all this is for the same instance */
- " JOIN merchant_contract_terms contracts"
- " USING (merchant_serial, order_serial)"
- " WHERE mcon.order_serial=$1"),
- /* for postgres_mark_order_wired() */
- GNUNET_PQ_make_prepare ("mark_order_wired",
- "UPDATE merchant_contract_terms SET"
- " wired=TRUE"
- " WHERE order_serial=$1"),
- /* for postgres_lookup_refunds_detailed() */
- GNUNET_PQ_make_prepare ("lookup_refunds_detailed",
- "SELECT"
- " ref.refund_serial"
- ",ref.refund_timestamp"
- ",dep.coin_pub"
- ",mcon.exchange_url"
- ",ref.rtransaction_id"
- ",ref.reason"
- ",ref.refund_amount"
- ",merchant_refund_proofs.exchange_sig IS NULL AS pending"
- " FROM merchant_deposit_confirmations mcon"
- " JOIN merchant_deposits dep"
- " USING (deposit_confirmation_serial)"
- " JOIN merchant_refunds ref"
- " USING (order_serial, coin_pub)"
- " LEFT JOIN merchant_refund_proofs"
- " USING (refund_serial)"
- " WHERE mcon.order_serial="
- " (SELECT order_serial"
- " FROM merchant_contract_terms"
- " WHERE h_contract_terms=$2"
- " AND merchant_serial="
- " (SELECT merchant_serial"
- " FROM merchant_instances"
- " WHERE merchant_id=$1))"),
- /* for postgres_insert_refund_proof() */
- GNUNET_PQ_make_prepare ("insert_refund_proof",
- "INSERT INTO merchant_refund_proofs"
- "(refund_serial"
- ",exchange_sig"
- ",signkey_serial)"
- "SELECT $1, $2, signkey_serial"
- " FROM merchant_exchange_signing_keys"
- " WHERE exchange_pub=$3"
- " ORDER BY start_date DESC"
- " LIMIT 1"),
- /* for postgres_lookup_refund_proof() */
- GNUNET_PQ_make_prepare ("lookup_refund_proof",
- "SELECT"
- " merchant_exchange_signing_keys.exchange_pub"
- ",exchange_sig"
- " FROM merchant_refund_proofs"
- " JOIN merchant_exchange_signing_keys"
- " USING (signkey_serial)"
- " WHERE"
- " refund_serial=$1"),
- /* for postgres_lookup_order_by_fulfillment() */
- GNUNET_PQ_make_prepare ("lookup_order_by_fulfillment",
- "SELECT"
- " order_id"
- " FROM merchant_contract_terms"
- " WHERE fulfillment_url=$2"
- " AND session_id=$3"
- " AND merchant_serial="
- " (SELECT merchant_serial"
- " FROM merchant_instances"
- " WHERE merchant_id=$1)"),
- /* for postgres_delete_transfer() */
- GNUNET_PQ_make_prepare ("delete_transfer",
- "DELETE FROM merchant_transfers"
- " WHERE"
- " credit_serial=$2"
- " AND account_serial IN "
- " (SELECT account_serial "
- " FROM merchant_accounts"
- " WHERE merchant_serial="
- " (SELECT merchant_serial"
- " FROM merchant_instances"
- " WHERE merchant_id=$1))"),
- /* for postgres_check_transfer_exists() */
- GNUNET_PQ_make_prepare ("check_transfer_exists",
- "SELECT"
- " 1"
- " FROM merchant_transfers"
- " JOIN merchant_accounts"
- " USING (account_serial)"
- " WHERE"
- " credit_serial=$2"
- " AND"
- " merchant_serial="
- " (SELECT merchant_serial"
- " FROM merchant_instances"
- " WHERE merchant_id=$1)"),
- /* for postgres_lookup_account() */
- GNUNET_PQ_make_prepare ("lookup_account",
- "SELECT"
- " account_serial"
- " FROM merchant_accounts"
- " WHERE payto_uri=$2"
- " AND merchant_serial="
- " (SELECT merchant_serial"
- " FROM merchant_instances"
- " WHERE merchant_id=$1)"),
- /* for postgres_lookup_wire_fee() */
- GNUNET_PQ_make_prepare ("lookup_wire_fee",
- "SELECT"
- " wire_fee"
- ",closing_fee"
- ",start_date"
- ",end_date"
- ",master_sig"
- " FROM merchant_exchange_wire_fees"
- " WHERE master_pub=$1"
- " AND h_wire_method=$2"
- " AND start_date <= $3"
- " AND end_date > $3"),
- /* for postgres_lookup_deposits_by_contract_and_coin() */
- GNUNET_PQ_make_prepare ("lookup_deposits_by_contract_and_coin",
- "SELECT"
- " mcon.exchange_url"
- ",dep.amount_with_fee"
- ",dep.deposit_fee"
- ",dep.refund_fee"
- ",mcon.wire_fee"
- ",acc.h_wire"
- ",mcon.deposit_timestamp"
- ",mct.refund_deadline"
- ",mcon.exchange_sig"
- ",msig.exchange_pub"
- " FROM merchant_contract_terms mct"
- " JOIN merchant_deposit_confirmations mcon"
- " USING (order_serial)"
- " JOIN merchant_deposits dep"
- " USING (deposit_confirmation_serial)"
- " JOIN merchant_exchange_signing_keys msig"
- " USING (signkey_serial)"
- " JOIN merchant_accounts acc"
- " USING (account_serial)"
- " WHERE h_contract_terms=$2"
- " AND dep.coin_pub=$3"
- " AND mct.merchant_serial="
- " (SELECT merchant_serial"
- " FROM merchant_instances"
- " WHERE merchant_id=$1)"),
- /* for postgres_lookup_transfer() */
- GNUNET_PQ_make_prepare ("lookup_transfer",
- "SELECT"
- " mt.credit_amount AS credit_amount"
- ",mts.credit_amount AS exchange_amount"
- ",wire_fee"
- ",execution_time"
- ",verified"
- " FROM merchant_transfers mt"
- " JOIN merchant_accounts USING (account_serial)"
- " JOIN merchant_instances USING (merchant_serial)"
- " LEFT JOIN merchant_transfer_signatures mts USING (credit_serial)"
- " WHERE wtid=$2"
- " AND exchange_url=$1"
- " AND merchant_id=$3;"),
- /* for postgres_lookup_transfer_summary() */
- GNUNET_PQ_make_prepare ("lookup_transfer_summary",
- "SELECT"
- " mct.order_id"
- ",mtc.exchange_deposit_value"
- ",mtc.exchange_deposit_fee"
- " FROM merchant_transfers mtr"
- " JOIN merchant_transfer_to_coin mtc"
- " USING (credit_serial)"
- " JOIN merchant_deposits dep"
- " USING (deposit_serial)"
- " JOIN merchant_deposit_confirmations mcon"
- " USING (deposit_confirmation_serial)"
- " JOIN merchant_contract_terms mct"
- " USING (order_serial)"
- " WHERE mtr.wtid=$2"
- " AND mtr.exchange_url=$1"),
- /* for postgres_lookup_transfer_details() */
- GNUNET_PQ_make_prepare ("lookup_transfer_details",
- "SELECT"
- " mterm.h_contract_terms"
- ",mtcoin.offset_in_exchange_list"
- ",dep.coin_pub"
- ",mtcoin.exchange_deposit_value"
- ",mtcoin.exchange_deposit_fee"
- " FROM merchant_transfer_to_coin mtcoin"
- " JOIN merchant_deposits dep"
- " USING (deposit_serial)"
- " JOIN merchant_deposit_confirmations mcon"
- " USING (deposit_confirmation_serial)"
- " JOIN merchant_contract_terms mterm"
- " USING (order_serial)"
- " JOIN merchant_transfers mtr"
- " USING (credit_serial)"
- " WHERE mtr.wtid=$2"
- " AND mtr.exchange_url=$1"),
/* For postgres_insert_reserve() */
GNUNET_PQ_make_prepare ("insert_reserve_key",
"INSERT INTO merchant_reward_reserve_keys"
@@ -3838,27 +2444,40 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
= &TMH_PG_lookup_order_status_by_serial;
plugin->lookup_payment_status
= &TMH_PG_lookup_payment_status;
- plugin->lookup_deposits_by_order = &postgres_lookup_deposits_by_order;
- plugin->lookup_transfer_details_by_order =
- &postgres_lookup_transfer_details_by_order;
- plugin->mark_order_wired = &postgres_mark_order_wired;
+ plugin->lookup_deposits_by_order
+ = &TMH_PG_lookup_deposits_by_order;
+ plugin->lookup_transfer_details_by_order
+ = &TMH_PG_lookup_transfer_details_by_order;
+ plugin->mark_order_wired
+ = &TMH_PG_mark_order_wired;
plugin->increase_refund
= &TMH_PG_increase_refund;
- plugin->lookup_refunds_detailed = &postgres_lookup_refunds_detailed;
- plugin->insert_refund_proof = &postgres_insert_refund_proof;
- plugin->lookup_refund_proof = &postgres_lookup_refund_proof;
- plugin->lookup_order_by_fulfillment = &postgres_lookup_order_by_fulfillment;
- plugin->delete_transfer = &postgres_delete_transfer;
- plugin->check_transfer_exists = &postgres_check_transfer_exists;
- plugin->lookup_account = &postgres_lookup_account;
- plugin->lookup_wire_fee = &postgres_lookup_wire_fee;
- plugin->lookup_deposits_by_contract_and_coin =
- &postgres_lookup_deposits_by_contract_and_coin;
- plugin->lookup_transfer = &postgres_lookup_transfer;
- plugin->set_transfer_status_to_confirmed =
- &TMH_PG_set_transfer_status_to_confirmed;
- plugin->lookup_transfer_summary = &postgres_lookup_transfer_summary;
- plugin->lookup_transfer_details = &postgres_lookup_transfer_details;
+ plugin->lookup_refunds_detailed
+ = &TMH_PG_lookup_refunds_detailed;
+ plugin->insert_refund_proof
+ = &TMH_PG_insert_refund_proof;
+ plugin->lookup_refund_proof
+ = &TMH_PG_lookup_refund_proof;
+ plugin->lookup_order_by_fulfillment
+ = &TMH_PG_lookup_order_by_fulfillment;
+ plugin->delete_transfer
+ = &TMH_PG_delete_transfer;
+ plugin->check_transfer_exists
+ = &TMH_PG_check_transfer_exists;
+ plugin->lookup_account
+ = &TMH_PG_lookup_account;
+ plugin->lookup_wire_fee
+ = &TMH_PG_lookup_wire_fee;
+ plugin->lookup_deposits_by_contract_and_coin
+ = &TMH_PG_lookup_deposits_by_contract_and_coin;
+ plugin->lookup_transfer
+ = &TMH_PG_lookup_transfer;
+ plugin->set_transfer_status_to_confirmed
+ = &TMH_PG_set_transfer_status_to_confirmed;
+ plugin->lookup_transfer_summary
+ = &TMH_PG_lookup_transfer_summary;
+ plugin->lookup_transfer_details
+ = &TMH_PG_lookup_transfer_details;
plugin->lookup_instances
= &TMH_PG_lookup_instances;
plugin->lookup_instance