1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2014 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 #ifndef BITCOIN_VALIDATIONINTERFACE_H
7 #define BITCOIN_VALIDATIONINTERFACE_H
9 #include <boost/signals2/signal.hpp>
10 #include <boost/shared_ptr.hpp>
12 #include "zcash/IncrementalMerkleTree.hpp"
19 class CValidationInterface;
20 class CValidationState;
23 // These functions dispatch to one or all registered wallets
25 /** Register a wallet to receive updates from core */
26 void RegisterValidationInterface(CValidationInterface* pwalletIn);
27 /** Unregister a wallet from core */
28 void UnregisterValidationInterface(CValidationInterface* pwalletIn);
29 /** Unregister all wallets from core */
30 void UnregisterAllValidationInterfaces();
31 /** Push an updated transaction to all registered wallets */
32 void SyncWithWallets(const CTransaction& tx, const CBlock* pblock = NULL);
34 class CValidationInterface {
36 virtual void UpdatedBlockTip(const CBlockIndex *pindex) {}
37 virtual void SyncTransaction(const CTransaction &tx, const CBlock *pblock) {}
38 virtual void EraseFromWallet(const uint256 &hash) {}
39 virtual void ChainTip(const CBlockIndex *pindex, const CBlock *pblock, SproutMerkleTree sproutTree, SaplingMerkleTree saplingTree, bool added) {}
40 virtual void SetBestChain(const CBlockLocator &locator) {}
41 virtual void UpdatedTransaction(const uint256 &hash) {}
42 virtual void Inventory(const uint256 &hash) {}
43 virtual void ResendWalletTransactions(int64_t nBestBlockTime) {}
44 virtual void BlockChecked(const CBlock&, const CValidationState&) {}
45 virtual void GetScriptForMining(boost::shared_ptr<CReserveScript>&) {};
46 virtual void ResetRequestCount(const uint256 &hash) {};
47 friend void ::RegisterValidationInterface(CValidationInterface*);
48 friend void ::UnregisterValidationInterface(CValidationInterface*);
49 friend void ::UnregisterAllValidationInterfaces();
53 /** Notifies listeners of updated block chain tip */
54 boost::signals2::signal<void (const CBlockIndex *)> UpdatedBlockTip;
55 /** Notifies listeners of updated transaction data (transaction, and optionally the block it is found in. */
56 boost::signals2::signal<void (const CTransaction &, const CBlock *)> SyncTransaction;
57 /** Notifies listeners of an erased transaction (currently disabled, requires transaction replacement). */
58 boost::signals2::signal<void (const uint256 &)> EraseTransaction;
59 /** Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). */
60 boost::signals2::signal<void (const uint256 &)> UpdatedTransaction;
61 /** Notifies listeners of a change to the tip of the active block chain. */
62 boost::signals2::signal<void (const CBlockIndex *, const CBlock *, SproutMerkleTree, SaplingMerkleTree, bool)> ChainTip;
63 /** Notifies listeners of a new active block chain. */
64 boost::signals2::signal<void (const CBlockLocator &)> SetBestChain;
65 /** Notifies listeners about an inventory item being seen on the network. */
66 boost::signals2::signal<void (const uint256 &)> Inventory;
67 /** Tells listeners to broadcast their data. */
68 boost::signals2::signal<void (int64_t nBestBlockTime)> Broadcast;
69 /** Notifies listeners of a block validation result */
70 boost::signals2::signal<void (const CBlock&, const CValidationState&)> BlockChecked;
71 /** Notifies listeners that a key for mining is required (coinbase) */
72 boost::signals2::signal<void (boost::shared_ptr<CReserveScript>&)> ScriptForMining;
73 /** Notifies listeners that a block has been successfully mined */
74 boost::signals2::signal<void (const uint256 &)> BlockFound;
77 CMainSignals& GetMainSignals();
79 #endif // BITCOIN_VALIDATIONINTERFACE_H