text: // Copyright (c) 2009-2010 Satoshi Nakamoto
  // Copyright (c) 2009-2015 The Bitcoin Core developers
  // Copyright (c) 2017-2019 The PIVX developers
  // Distributed under the MIT software license, see the accompanying
  // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  
  #ifndef BITCOIN_VALIDATIONINTERFACE_H
  #define BITCOIN_VALIDATIONINTERFACE_H
  
  #include "optional.h"
  #include "sapling/incrementalmerkletree.h"
  
  class CBlock;
  struct CBlockLocator;
  class CBlockIndex;
  class CConnman;
  class CReserveScript;
  class CTransaction;
  class CValidationInterface;
  class CValidationState;
  class uint256;
  
  // These functions dispatch to one or all registered wallets
  
  /** Register a wallet to receive updates from core */
  void RegisterValidationInterface(CValidationInterface* pwalletIn);
  /** Unregister a wallet from core */
  void UnregisterValidationInterface(CValidationInterface* pwalletIn);
  /** Unregister all wallets from core */
  void UnregisterAllValidationInterfaces();
  
  class CValidationInterface {
  protected:
      /** Notifies listeners of updated block chain tip */
      virtual void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) {}
      virtual void SyncTransaction(const CTransaction &tx, const CBlockIndex *pindex, int posInBlock) {}
      virtual void ChainTip(const CBlockIndex *pindex, const CBlock *pblock, Optional<SaplingMerkleTree> added) {}
      virtual void NotifyTransactionLock(const CTransaction &tx) {}
      /** Notifies listeners of the new active block chain on-disk. */
      virtual void SetBestChain(const CBlockLocator &locator) {}
      virtual bool UpdatedTransaction(const uint256 &hash) { return false;}
      /** Tells listeners to broadcast their data. */
      virtual void ResendWalletTransactions(CConnman* connman) {}
      virtual void BlockChecked(const CBlock&, const CValidationState&) {}
      virtual void ResetRequestCount(const uint256 &hash) {};
      friend void ::RegisterValidationInterface(CValidationInterface*);
      friend void ::UnregisterValidationInterface(CValidationInterface*);
      friend void ::UnregisterAllValidationInterfaces();
  };
  
  struct MainSignalsInstance;
  class CMainSignals {
  private:
      std::unique_ptr<MainSignalsInstance> m_internals;
  
      friend void ::RegisterValidationInterface(CValidationInterface*);
      friend void ::UnregisterValidationInterface(CValidationInterface*);
      friend void ::UnregisterAllValidationInterfaces();
  public:
      CMainSignals();
  
      /** A posInBlock value for SyncTransaction which indicates the transaction was conflicted, disconnected, or not in a block */
      static const int SYNC_TRANSACTION_NOT_IN_BLOCK = -1;
  
      void UpdatedBlockTip(const CBlockIndex *, const CBlockIndex *, bool fInitialDownload);
      void SyncTransaction(const CTransaction &, const CBlockIndex *pindex, int posInBlock);
      void NotifyTransactionLock(const CTransaction&);
      void UpdatedTransaction(const uint256 &);
      void SetBestChain(const CBlockLocator &);
      void Broadcast(CConnman* connman);
      void BlockChecked(const CBlock&, const CValidationState&);
      void BlockFound(const uint256&);
      void ChainTip(const CBlockIndex *, const CBlock *, Optional<SaplingMerkleTree>);
  };
  
  CMainSignals& GetMainSignals();
  
  #endif // BITCOIN_VALIDATIONINTERFACE_H
  