Branch data 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 : : /** # 18 : : * IsMine() return codes, which depend on ScriptPubKeyMan implementation. # 19 : : * Not every ScriptPubKeyMan covers all types, please refer to # 20 : : * https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-0.21.0.md#ismine-semantics # 21 : : * for better understanding. # 22 : : * # 23 : : * For LegacyScriptPubKeyMan, # 24 : : * ISMINE_NO: the scriptPubKey is not in the wallet; # 25 : : * ISMINE_WATCH_ONLY: the scriptPubKey has been imported into the wallet; # 26 : : * ISMINE_SPENDABLE: the scriptPubKey corresponds to an address owned by the wallet user (can spend with the private key); # 27 : : * ISMINE_USED: the scriptPubKey corresponds to a used address owned by the wallet user; # 28 : : * ISMINE_ALL: all ISMINE flags except for USED; # 29 : : * ISMINE_ALL_USED: all ISMINE flags including USED; # 30 : : * ISMINE_ENUM_ELEMENTS: the number of isminetype enum elements. # 31 : : * # 32 : : * For DescriptorScriptPubKeyMan and future ScriptPubKeyMan, # 33 : : * ISMINE_NO: the scriptPubKey is not in the wallet; # 34 : : * ISMINE_SPENDABLE: the scriptPubKey matches a scriptPubKey in the wallet. # 35 : : * ISMINE_USED: the scriptPubKey corresponds to a used address owned by the wallet user. # 36 : : * # 37 : : */ # 38 : : enum isminetype : unsigned int # 39 : : { # 40 : : ISMINE_NO = 0, # 41 : : ISMINE_WATCH_ONLY = 1 << 0, # 42 : : ISMINE_SPENDABLE = 1 << 1, # 43 : : ISMINE_USED = 1 << 2, # 44 : : ISMINE_ALL = ISMINE_WATCH_ONLY | ISMINE_SPENDABLE, # 45 : : ISMINE_ALL_USED = ISMINE_ALL | ISMINE_USED, # 46 : : ISMINE_ENUM_ELEMENTS, # 47 : : }; # 48 : : /** used for bitflags of isminetype */ # 49 : : typedef uint8_t isminefilter; # 50 : : # 51 : : /** # 52 : : * Cachable amount subdivided into watchonly and spendable parts. # 53 : : */ # 54 : : struct CachableAmount # 55 : : { # 56 : : // NO and ALL are never (supposed to be) cached # 57 : : std::bitset<ISMINE_ENUM_ELEMENTS> m_cached; # 58 : : CAmount m_value[ISMINE_ENUM_ELEMENTS]; # 59 : : inline void Reset() # 60 : 922376 : { # 61 : 922376 : m_cached.reset(); # 62 : 922376 : } # 63 : : void Set(isminefilter filter, CAmount value) # 64 : 89517 : { # 65 : 89517 : m_cached.set(filter); # 66 : 89517 : m_value[filter] = value; # 67 : 89517 : } # 68 : : }; # 69 : : # 70 : : #endif // BITCOIN_WALLET_ISMINE_H