wallet: Add wallet/types.h for simple public enum and struct types

Move isminetype and isminefilter there this commit, add WalletPurpose type next
commit.
This commit is contained in:
Ryan Ofsky 2023-03-13 11:53:33 -04:00 committed by Andrew Chow
parent 27dcc07c08
commit 8741522e6c
9 changed files with 40 additions and 37 deletions

View File

@ -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 \

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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 {

View File

@ -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>

View File

@ -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>

View File

@ -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.

View File

@ -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