Line data Source code
1 : // Copyright (c) 2009-2010 Satoshi Nakamoto 2 : // Copyright (c) 2009-2014 The Bitcoin developers 3 : // Copyright (c) 2017-2020 The PIVX Core developers 4 : // Distributed under the MIT software license, see the accompanying 5 : // file COPYING or http://www.opensource.org/licenses/mit-license.php. 6 : 7 : #ifndef PIVX_SCRIPT_ISMINE_H 8 : #define PIVX_SCRIPT_ISMINE_H 9 : 10 : #include "destination_io.h" 11 : #include "key.h" 12 : #include "script/standard.h" 13 : #include <bitset> 14 : 15 : class CKeyStore; 16 : class CScript; 17 : 18 : /** IsMine() return codes */ 19 : enum isminetype { 20 : ISMINE_NO = 0, 21 : ISMINE_WATCH_ONLY = 1 << 0, 22 : ISMINE_SPENDABLE = 1 << 1, 23 : //! Indicates that we have the staking key of a P2CS 24 : ISMINE_COLD = 1 << 2, 25 : //! Indicates that we have the spending key of a P2CS 26 : ISMINE_SPENDABLE_DELEGATED = 1 << 3, 27 : //! Indicates that we don't have the spending key of a shielded spend/output 28 : ISMINE_WATCH_ONLY_SHIELDED = 1 << 4, 29 : //! Indicates that we have the spending key of a shielded spend/output. 30 : ISMINE_SPENDABLE_SHIELDED = 1 << 5, 31 : ISMINE_SPENDABLE_TRANSPARENT = ISMINE_SPENDABLE_DELEGATED | ISMINE_SPENDABLE, 32 : ISMINE_SPENDABLE_NO_DELEGATED = ISMINE_SPENDABLE | ISMINE_SPENDABLE_SHIELDED, 33 : ISMINE_SPENDABLE_ALL = ISMINE_SPENDABLE_DELEGATED | ISMINE_SPENDABLE | ISMINE_SPENDABLE_SHIELDED, 34 : ISMINE_WATCH_ONLY_ALL = ISMINE_WATCH_ONLY | ISMINE_WATCH_ONLY_SHIELDED, 35 : ISMINE_ALL = ISMINE_WATCH_ONLY | ISMINE_SPENDABLE | ISMINE_COLD | ISMINE_SPENDABLE_DELEGATED | ISMINE_SPENDABLE_SHIELDED | ISMINE_WATCH_ONLY_SHIELDED, 36 : ISMINE_ENUM_ELEMENTS 37 : }; 38 : /** used for bitflags of isminetype */ 39 : typedef uint8_t isminefilter; 40 : 41 : isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey); 42 : isminetype IsMine(const CKeyStore& keystore, const CTxDestination& dest); 43 : isminetype IsMine(const CKeyStore& keystore, const libzcash::SaplingPaymentAddress& pa); 44 : isminetype IsMine(const CKeyStore& keystore, const CWDestination& dest); 45 : /** 46 : * Cacheable amount subdivided into watchonly and spendable parts. 47 : */ 48 3029800 : struct CachableAmount 49 : { 50 : // NO and ALL are never (supposed to be) cached 51 : std::bitset<ISMINE_ENUM_ELEMENTS> m_cached; 52 : CAmount m_value[ISMINE_ENUM_ELEMENTS]; 53 1544786 : inline void Reset() 54 : { 55 1544786 : m_cached.reset(); 56 : } 57 32312 : void Set(isminefilter filter, CAmount value) 58 : { 59 32312 : m_cached.set(filter); 60 32312 : m_value[filter] = value; 61 32312 : } 62 : }; 63 : 64 : #endif // PIVX_SCRIPT_ISMINE_H