/*
   This file is part of TALER
   Copyright (C) 2024 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/merchant-database/insert_issued_token.h
 * @brief implementation of the insert_issued_token function for Postgres
 * @author Christian Blättler
 */
#ifndef MERCHANT_DATABASE_INSERT_ISSUED_TOKEN_H
#define MERCHANT_DATABASE_INSERT_ISSUED_TOKEN_H

#include <taler/taler_util.h>
#include <taler/taler_json_lib.h>
#include "merchantdb_lib.h"


struct TALER_MERCHANTDB_PostgresContext;
/**
 * @param pg database context
 * @param h_contract_terms hash of the contract the token was issued for
 * @param h_issue_pub hash of the token issue public key used to sign the issued token
 * @param blind_sig resulting blind token issue signature
 * @param[out] no_family set to true if the token family key is unknown,
 *        in which case #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS is returned
 * @return database result code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if
 *        the token was already issued or @a no_family is set
 */
enum GNUNET_DB_QueryStatus
TALER_MERCHANTDB_insert_issued_token (struct TALER_MERCHANTDB_PostgresContext *pg,
                                      const struct TALER_PrivateContractHashP *
                                      h_contract_terms,
                                      const struct TALER_TokenIssuePublicKeyHashP *
                                      h_issue_pub,
                                      const struct TALER_BlindedTokenIssueSignature *
                                      blind_sig,
                                      bool *no_family);

#endif
