Line data Source code
1 : // Copyright (c) 2009-2010 Satoshi Nakamoto 2 : // Copyright (c) 2009-2019 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. 5 : 6 : #ifndef BITCOIN_WALLET_ISMINE_H 7 : #define BITCOIN_WALLET_ISMINE_H 8 : 9 : #include <script/standard.h> 10 : 11 : #include <stdint.h> 12 : #include <bitset> 13 : 14 : class CWallet; 15 : class CScript; 16 : 17 : /** IsMine() return codes */ 18 : enum isminetype : unsigned int 19 : { 20 : ISMINE_NO = 0, 21 : ISMINE_WATCH_ONLY = 1 << 0, 22 : ISMINE_SPENDABLE = 1 << 1, 23 : ISMINE_USED = 1 << 2, 24 : ISMINE_ALL = ISMINE_WATCH_ONLY | ISMINE_SPENDABLE, 25 : ISMINE_ALL_USED = ISMINE_ALL | ISMINE_USED, 26 : ISMINE_ENUM_ELEMENTS, 27 : }; 28 : /** used for bitflags of isminetype */ 29 : typedef uint8_t isminefilter; 30 : 31 : /** 32 : * Cachable amount subdivided into watchonly and spendable parts. 33 : */ 34 1376720 : struct CachableAmount 35 : { 36 : // NO and ALL are never (supposed to be) cached 37 : std::bitset<ISMINE_ENUM_ELEMENTS> m_cached; 38 : CAmount m_value[ISMINE_ENUM_ELEMENTS]; 39 867620 : inline void Reset() 40 : { 41 867620 : m_cached.reset(); 42 867620 : } 43 75136 : void Set(isminefilter filter, CAmount value) 44 : { 45 75136 : m_cached.set(filter); 46 75136 : m_value[filter] = value; 47 75136 : } 48 : }; 49 : 50 : #endif // BITCOIN_WALLET_ISMINE_H