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>
16 class CValidationInterface
;
17 class CValidationState
;
20 // These functions dispatch to one or all registered wallets
22 /** Register a wallet to receive updates from core */
23 void RegisterValidationInterface(CValidationInterface
* pwalletIn
);
24 /** Unregister a wallet from core */
25 void UnregisterValidationInterface(CValidationInterface
* pwalletIn
);
26 /** Unregister all wallets from core */
27 void UnregisterAllValidationInterfaces();
28 /** Push an updated transaction to all registered wallets */
29 void SyncWithWallets(const CTransaction
& tx
, const CBlock
* pblock
= NULL
);
31 class CValidationInterface
{
33 virtual void UpdatedBlockTip(const uint256
&newHashTip
) {}
34 virtual void SyncTransaction(const CTransaction
&tx
, const CBlock
*pblock
) {}
35 virtual void SetBestChain(const CBlockLocator
&locator
) {}
36 virtual void UpdatedTransaction(const uint256
&hash
) {}
37 virtual void Inventory(const uint256
&hash
) {}
38 virtual void ResendWalletTransactions(int64_t nBestBlockTime
) {}
39 virtual void BlockChecked(const CBlock
&, const CValidationState
&) {}
40 virtual void GetScriptForMining(boost::shared_ptr
<CReserveScript
>&) {};
41 virtual void ResetRequestCount(const uint256
&hash
) {};
42 friend void ::RegisterValidationInterface(CValidationInterface
*);
43 friend void ::UnregisterValidationInterface(CValidationInterface
*);
44 friend void ::UnregisterAllValidationInterfaces();
48 /** Notifies listeners of updated block chain tip */
49 boost::signals2::signal
<void (const uint256
&)> UpdatedBlockTip
;
50 /** Notifies listeners of updated transaction data (transaction, and optionally the block it is found in. */
51 boost::signals2::signal
<void (const CTransaction
&, const CBlock
*)> SyncTransaction
;
52 /** Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). */
53 boost::signals2::signal
<void (const uint256
&)> UpdatedTransaction
;
54 /** Notifies listeners of a new active block chain. */
55 boost::signals2::signal
<void (const CBlockLocator
&)> SetBestChain
;
56 /** Notifies listeners about an inventory item being seen on the network. */
57 boost::signals2::signal
<void (const uint256
&)> Inventory
;
58 /** Tells listeners to broadcast their data. */
59 boost::signals2::signal
<void (int64_t nBestBlockTime
)> Broadcast
;
60 /** Notifies listeners of a block validation result */
61 boost::signals2::signal
<void (const CBlock
&, const CValidationState
&)> BlockChecked
;
62 /** Notifies listeners that a key for mining is required (coinbase) */
63 boost::signals2::signal
<void (boost::shared_ptr
<CReserveScript
>&)> ScriptForMining
;
64 /** Notifies listeners that a block has been successfully mined */
65 boost::signals2::signal
<void (const uint256
&)> BlockFound
;
68 CMainSignals
& GetMainSignals();
70 #endif // BITCOIN_VALIDATIONINTERFACE_H