/*
   This file is part of TALER
   Copyright (C) 2026 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 src/include/exchange-database/iterate_wallet_merges.h
 * @brief implementation of the select_wallet_merges function
 * @author Christian Grothoff
 */
#ifndef EXCHANGE_DATABASE_ITERATE_WALLET_MERGES_H
#define EXCHANGE_DATABASE_ITERATE_WALLET_MERGES_H

#include "taler/taler_util.h"
#include "taler/taler_json_lib.h"
#include "exchangedb_lib.h"


/**
 * Callback that is given AML-relevant transfer data.
 *
 * @param cls closure
 * @param row_id current row in AML status table
 * @param payto_uri account involved with the wire transfer
 * @param execution_time when was the transfer made
 * @param amount wire amount of the transfer
 */
#ifndef TALER_EXCHANGEDB_AML_TRANSFER_RESULT_CLOSURE
/**
 * Type of the closure for #TALER_EXCHANGEDB_AmlTransferCallback.
 */
#define TALER_EXCHANGEDB_AML_TRANSFER_RESULT_CLOSURE void
#endif
typedef void
(*TALER_EXCHANGEDB_AmlTransferCallback)(
  TALER_EXCHANGEDB_AML_TRANSFER_RESULT_CLOSURE *cls,
  uint64_t row_id,
  const char *payto_uri,
  struct GNUNET_TIME_Absolute execution_time,
  const struct TALER_Amount *amount);


/**
 * Return AML-relevant merges (credits) into a wallet.
 *
 * @param pg the database context
 * @param threshold minimum wire amount to return data for
 * @param offset offset in table to filter by
 * @param limit maximum number of entries to return, negative for descending
 * @param h_payto account to filter transfer data by
 * @param cb function to call on each result
 * @param cb_cls closure to pass to @a cb
 * @return transaction status
 */
enum GNUNET_DB_QueryStatus
TALER_EXCHANGEDB_iterate_wallet_merges (
  struct TALER_EXCHANGEDB_PostgresContext *pg,
  const struct TALER_Amount *threshold,
  uint64_t offset,
  int64_t limit,
  const struct TALER_NormalizedPaytoHashP *h_payto,
  TALER_EXCHANGEDB_AmlTransferCallback cb,
  TALER_EXCHANGEDB_AML_TRANSFER_RESULT_CLOSURE *cb_cls);


#endif
