/*
   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/auditor-database/iterate_aml_holds.h
 * @brief implementation of the iterate_aml_holds function
 * @author Christian Grothoff
 */
#ifndef AUDITOR_DATABASE_ITERATE_AML_HOLDS_H
#define AUDITOR_DATABASE_ITERATE_AML_HOLDS_H

#include "taler/taler_util.h"
#include "auditordb_lib.h"


#ifndef TALER_AUDITORDB_AML_HOLD_RESULT_CLOSURE
/**
 * Type of the closure for #TALER_AUDITORDB_AmlHoldCallback.
 */
#define TALER_AUDITORDB_AML_HOLD_RESULT_CLOSURE void
#endif

/**
 * Function called on each hold currently on file.
 *
 * @param cls closure
 * @param ah the hold
 * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop iterating
 */
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_AmlHoldCallback)(
  TALER_AUDITORDB_AML_HOLD_RESULT_CLOSURE *cls,
  const struct TALER_AUDITORDB_AmlHold *ah);


/**
 * Iterate over every wire transfer the exchange is currently holding.
 *
 * Unlike #TALER_AUDITORDB_iterate_auditor_aml_holds() this returns suppressed
 * rows as well and takes no limit: it is meant for the audit helper, which has
 * to re-examine each hold on every run, and for which a suppressed row is
 * still money that is being held.
 *
 * @param pg the database context
 * @param cb function to call with results
 * @param cb_cls closure for @a cb
 * @return query result status
 */
enum GNUNET_DB_QueryStatus
TALER_AUDITORDB_iterate_aml_holds (
  struct TALER_AUDITORDB_PostgresContext *pg,
  TALER_AUDITORDB_AmlHoldCallback cb,
  TALER_AUDITORDB_AML_HOLD_RESULT_CLOSURE *cb_cls);

#endif
