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>
14 class CValidationInterface
;
15 class CValidationState
;
18 // These functions dispatch to one or all registered wallets
20 /** Register a wallet to receive updates from core */
21 void RegisterValidationInterface(CValidationInterface
* pwalletIn
);
22 /** Unregister a wallet from core */
23 void UnregisterValidationInterface(CValidationInterface
* pwalletIn
);
24 /** Unregister all wallets from core */
25 void UnregisterAllValidationInterfaces();
26 /** Push an updated transaction to all registered wallets */
27 void SyncWithWallets(const CTransaction
& tx
, const CBlock
* pblock
= NULL
);
29 class CValidationInterface
{
31 virtual void SyncTransaction(const CTransaction
&tx
, const CBlock
*pblock
) {};
32 virtual void EraseFromWallet(const uint256
&hash
) {};
33 virtual void SetBestChain(const CBlockLocator
&locator
) {};
34 virtual void UpdatedTransaction(const uint256
&hash
) {};
35 virtual void Inventory(const uint256
&hash
) {};
36 virtual void ResendWalletTransactions() {};
37 virtual void BlockChecked(const CBlock
&, const CValidationState
&) {};
38 friend void ::RegisterValidationInterface(CValidationInterface
*);
39 friend void ::UnregisterValidationInterface(CValidationInterface
*);
40 friend void ::UnregisterAllValidationInterfaces();
44 /** Notifies listeners of updated transaction data (transaction, and optionally the block it is found in. */
45 boost::signals2::signal
<void (const CTransaction
&, const CBlock
*)> SyncTransaction
;
46 /** Notifies listeners of an erased transaction (currently disabled, requires transaction replacement). */
47 boost::signals2::signal
<void (const uint256
&)> EraseTransaction
;
48 /** Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). */
49 boost::signals2::signal
<void (const uint256
&)> UpdatedTransaction
;
50 /** Notifies listeners of a new active block chain. */
51 boost::signals2::signal
<void (const CBlockLocator
&)> SetBestChain
;
52 /** Notifies listeners about an inventory item being seen on the network. */
53 boost::signals2::signal
<void (const uint256
&)> Inventory
;
54 /** Tells listeners to broadcast their data. */
55 boost::signals2::signal
<void ()> Broadcast
;
56 /** Notifies listeners of a block validation result */
57 boost::signals2::signal
<void (const CBlock
&, const CValidationState
&)> BlockChecked
;
60 CMainSignals
& GetMainSignals();
62 #endif // BITCOIN_VALIDATIONINTERFACE_H