diff options
author | Ryan Ofsky <ryan@ofsky.org> | 2023-03-13 11:53:33 -0400 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2023-04-11 15:52:25 -0400 |
commit | 8741522e6c75a0ad0c96f44e5668befc1624fb0b (patch) | |
tree | 7a48af86e753e88f2222883c1e38c6ab06c02883 | |
parent | 27dcc07c08a77eba53ccc91e5521ff674f1bd198 (diff) |
wallet: Add wallet/types.h for simple public enum and struct types
Move isminetype and isminefilter there this commit, add WalletPurpose type next
commit.
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/qt/transactiondesc.cpp | 2 | ||||
-rw-r--r-- | src/qt/transactionrecord.cpp | 2 | ||||
-rw-r--r-- | src/wallet/interfaces.cpp | 2 | ||||
-rw-r--r-- | src/wallet/receive.h | 2 | ||||
-rw-r--r-- | src/wallet/scriptpubkeyman.h | 2 | ||||
-rw-r--r-- | src/wallet/test/ismine_tests.cpp | 2 | ||||
-rw-r--r-- | src/wallet/transaction.h | 25 | ||||
-rw-r--r-- | src/wallet/types.h (renamed from src/wallet/ismine.h) | 38 |
9 files changed, 40 insertions, 37 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 444480f824..1d7004ac86 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -329,7 +329,6 @@ BITCOIN_CORE_H = \ wallet/external_signer_scriptpubkeyman.h \ wallet/feebumper.h \ wallet/fees.h \ - wallet/ismine.h \ wallet/load.h \ wallet/receive.h \ wallet/rpc/util.h \ @@ -339,6 +338,7 @@ BITCOIN_CORE_H = \ wallet/spend.h \ wallet/sqlite.h \ wallet/transaction.h \ + wallet/types.h \ wallet/wallet.h \ wallet/walletdb.h \ wallet/wallettool.h \ diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index 057e4a7f55..2461a06930 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -20,7 +20,7 @@ #include <policy/policy.h> #include <util/system.h> #include <validation.h> -#include <wallet/ismine.h> +#include <wallet/types.h> #include <stdint.h> #include <string> diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index 5f981ea250..1d2f6484fb 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -7,7 +7,7 @@ #include <chain.h> #include <interfaces/wallet.h> #include <key_io.h> -#include <wallet/ismine.h> +#include <wallet/types.h> #include <stdint.h> diff --git a/src/wallet/interfaces.cpp b/src/wallet/interfaces.cpp index df1eb19a33..eeac147d8b 100644 --- a/src/wallet/interfaces.cpp +++ b/src/wallet/interfaces.cpp @@ -22,7 +22,7 @@ #include <wallet/context.h> #include <wallet/feebumper.h> #include <wallet/fees.h> -#include <wallet/ismine.h> +#include <wallet/types.h> #include <wallet/load.h> #include <wallet/receive.h> #include <wallet/rpc/wallet.h> diff --git a/src/wallet/receive.h b/src/wallet/receive.h index 87be0fc2ae..d50644b4cf 100644 --- a/src/wallet/receive.h +++ b/src/wallet/receive.h @@ -6,8 +6,8 @@ #define BITCOIN_WALLET_RECEIVE_H #include <consensus/amount.h> -#include <wallet/ismine.h> #include <wallet/transaction.h> +#include <wallet/types.h> #include <wallet/wallet.h> namespace wallet { diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index 42407173c3..22b67c88e9 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -14,7 +14,7 @@ #include <util/result.h> #include <util/time.h> #include <wallet/crypter.h> -#include <wallet/ismine.h> +#include <wallet/types.h> #include <wallet/walletdb.h> #include <wallet/walletutil.h> diff --git a/src/wallet/test/ismine_tests.cpp b/src/wallet/test/ismine_tests.cpp index 90f369b22a..f6f2d423e4 100644 --- a/src/wallet/test/ismine_tests.cpp +++ b/src/wallet/test/ismine_tests.cpp @@ -8,7 +8,7 @@ #include <script/script.h> #include <script/standard.h> #include <test/util/setup_common.h> -#include <wallet/ismine.h> +#include <wallet/types.h> #include <wallet/wallet.h> #include <boost/test/unit_test.hpp> diff --git a/src/wallet/transaction.h b/src/wallet/transaction.h index 290ef4eaa9..1a79d7db4e 100644 --- a/src/wallet/transaction.h +++ b/src/wallet/transaction.h @@ -5,10 +5,12 @@ #ifndef BITCOIN_WALLET_TRANSACTION_H #define BITCOIN_WALLET_TRANSACTION_H +#include <bitset> +#include <cstdint> #include <consensus/amount.h> #include <primitives/transaction.h> #include <serialize.h> -#include <wallet/ismine.h> +#include <wallet/types.h> #include <threadsafety.h> #include <tinyformat.h> #include <util/overloaded.h> @@ -108,8 +110,29 @@ static inline int TxStateSerializedIndex(const TxState& state) } +/** + * Cachable amount subdivided into watchonly and spendable parts. + */ +struct CachableAmount +{ + // NO and ALL are never (supposed to be) cached + std::bitset<ISMINE_ENUM_ELEMENTS> m_cached; + CAmount m_value[ISMINE_ENUM_ELEMENTS]; + inline void Reset() + { + m_cached.reset(); + } + void Set(isminefilter filter, CAmount value) + { + m_cached.set(filter); + m_value[filter] = value; + } +}; + + typedef std::map<std::string, std::string> mapValue_t; + /** Legacy class used for deserializing vtxPrev for backwards compatibility. * vtxPrev was removed in commit 93a18a3650292afbb441a47d1fa1b94aeb0164e3, * but old wallet.dat files may still contain vtxPrev vectors of CMerkleTxs. diff --git a/src/wallet/ismine.h b/src/wallet/types.h index 4ef4ef98ac..8c1f72f131 100644 --- a/src/wallet/ismine.h +++ b/src/wallet/types.h @@ -3,20 +3,19 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef BITCOIN_WALLET_ISMINE_H -#define BITCOIN_WALLET_ISMINE_H +//! @file Public type definitions that are used inside and outside of the wallet +//! (e.g. by src/wallet and src/interfaces and src/qt code). +//! +//! File is home for simple enum and struct definitions that don't deserve +//! separate header files. More complicated wallet public types like +//! CCoinControl that are used externally can have separate headers. -#include <script/standard.h> +#ifndef BITCOIN_WALLET_TYPES_H +#define BITCOIN_WALLET_TYPES_H -#include <bitset> -#include <cstdint> #include <type_traits> -class CScript; - namespace wallet { -class CWallet; - /** * IsMine() return codes, which depend on ScriptPubKeyMan implementation. * Not every ScriptPubKeyMan covers all types, please refer to @@ -49,25 +48,6 @@ enum isminetype : unsigned int { }; /** used for bitflags of isminetype */ using isminefilter = std::underlying_type<isminetype>::type; - -/** - * Cachable amount subdivided into watchonly and spendable parts. - */ -struct CachableAmount -{ - // NO and ALL are never (supposed to be) cached - std::bitset<ISMINE_ENUM_ELEMENTS> m_cached; - CAmount m_value[ISMINE_ENUM_ELEMENTS]; - inline void Reset() - { - m_cached.reset(); - } - void Set(isminefilter filter, CAmount value) - { - m_cached.set(filter); - m_value[filter] = value; - } -}; } // namespace wallet -#endif // BITCOIN_WALLET_ISMINE_H +#endif // BITCOIN_WALLET_TYPES_H |