]>
Commit | Line | Data |
---|---|---|
26c16d9d JT |
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 | |
bc909a7a | 4 | // file COPYING or https://www.opensource.org/licenses/mit-license.php . |
26c16d9d JT |
5 | |
6 | #ifndef BITCOIN_VALIDATIONINTERFACE_H | |
7 | #define BITCOIN_VALIDATIONINTERFACE_H | |
8 | ||
9 | #include <boost/signals2/signal.hpp> | |
f4055fe1 | 10 | #include <boost/shared_ptr.hpp> |
26c16d9d | 11 | |
de42390f JG |
12 | #include "zcash/IncrementalMerkleTree.hpp" |
13 | ||
26c16d9d | 14 | class CBlock; |
769e031c | 15 | class CBlockIndex; |
63e4c9cd | 16 | struct CBlockLocator; |
f4055fe1 | 17 | class CReserveScript; |
26c16d9d JT |
18 | class CTransaction; |
19 | class CValidationInterface; | |
20 | class CValidationState; | |
21 | class uint256; | |
22 | ||
23 | // These functions dispatch to one or all registered wallets | |
24 | ||
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); | |
ce379cf7 MT |
33 | /** Erase a transaction from all registered wallets */ |
34 | void EraseFromWallets(const uint256 &hash); | |
47ab0926 | 35 | /** Rescan all registered wallets */ |
36 | void RescanWallets(); | |
26c16d9d JT |
37 | |
38 | class CValidationInterface { | |
39 | protected: | |
6a793d9c | 40 | virtual void UpdatedBlockTip(const CBlockIndex *pindex) {} |
0a7bcb7e PK |
41 | virtual void SyncTransaction(const CTransaction &tx, const CBlock *pblock) {} |
42 | virtual void EraseFromWallet(const uint256 &hash) {} | |
47ab0926 | 43 | virtual void RescanWallet() {} |
4fc309f0 | 44 | virtual void ChainTip(const CBlockIndex *pindex, const CBlock *pblock, SproutMerkleTree sproutTree, SaplingMerkleTree saplingTree, bool added) {} |
0a7bcb7e PK |
45 | virtual void SetBestChain(const CBlockLocator &locator) {} |
46 | virtual void UpdatedTransaction(const uint256 &hash) {} | |
47 | virtual void Inventory(const uint256 &hash) {} | |
48 | virtual void ResendWalletTransactions(int64_t nBestBlockTime) {} | |
49 | virtual void BlockChecked(const CBlock&, const CValidationState&) {} | |
f4055fe1 | 50 | virtual void GetScriptForMining(boost::shared_ptr<CReserveScript>&) {}; |
648d6bee | 51 | virtual void ResetRequestCount(const uint256 &hash) {}; |
26c16d9d JT |
52 | friend void ::RegisterValidationInterface(CValidationInterface*); |
53 | friend void ::UnregisterValidationInterface(CValidationInterface*); | |
54 | friend void ::UnregisterAllValidationInterfaces(); | |
55 | }; | |
56 | ||
57 | struct CMainSignals { | |
7e6ec078 | 58 | /** Notifies listeners of updated block chain tip */ |
6a793d9c | 59 | boost::signals2::signal<void (const CBlockIndex *)> UpdatedBlockTip; |
26c16d9d JT |
60 | /** Notifies listeners of updated transaction data (transaction, and optionally the block it is found in. */ |
61 | boost::signals2::signal<void (const CTransaction &, const CBlock *)> SyncTransaction; | |
47ab0926 | 62 | /** Notifies listeners of an erased transaction. */ |
26c16d9d | 63 | boost::signals2::signal<void (const uint256 &)> EraseTransaction; |
47ab0926 | 64 | /** Notifies listeners of the need to rescan the wallet. */ |
65 | boost::signals2::signal<void ()> RescanWallet; | |
26c16d9d JT |
66 | /** Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). */ |
67 | boost::signals2::signal<void (const uint256 &)> UpdatedTransaction; | |
769e031c | 68 | /** Notifies listeners of a change to the tip of the active block chain. */ |
4fc309f0 | 69 | boost::signals2::signal<void (const CBlockIndex *, const CBlock *, SproutMerkleTree, SaplingMerkleTree, bool)> ChainTip; |
26c16d9d JT |
70 | /** Notifies listeners of a new active block chain. */ |
71 | boost::signals2::signal<void (const CBlockLocator &)> SetBestChain; | |
72 | /** Notifies listeners about an inventory item being seen on the network. */ | |
73 | boost::signals2::signal<void (const uint256 &)> Inventory; | |
74 | /** Tells listeners to broadcast their data. */ | |
0f5954c4 | 75 | boost::signals2::signal<void (int64_t nBestBlockTime)> Broadcast; |
26c16d9d JT |
76 | /** Notifies listeners of a block validation result */ |
77 | boost::signals2::signal<void (const CBlock&, const CValidationState&)> BlockChecked; | |
b2993bc5 | 78 | /** Notifies listeners that a key for mining is required (coinbase) */ |
f4055fe1 | 79 | boost::signals2::signal<void (boost::shared_ptr<CReserveScript>&)> ScriptForMining; |
b2993bc5 | 80 | /** Notifies listeners that a block has been successfully mined */ |
648d6bee | 81 | boost::signals2::signal<void (const uint256 &)> BlockFound; |
26c16d9d JT |
82 | }; |
83 | ||
84 | CMainSignals& GetMainSignals(); | |
85 | ||
86 | #endif // BITCOIN_VALIDATIONINTERFACE_H |