Skip to content

Commit 8741522

Browse files
ryanofskyachow101
authored andcommitted
wallet: Add wallet/types.h for simple public enum and struct types
Move isminetype and isminefilter there this commit, add WalletPurpose type next commit.
1 parent 27dcc07 commit 8741522

File tree

9 files changed

+40
-37
lines changed

9 files changed

+40
-37
lines changed

src/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,6 @@ BITCOIN_CORE_H = \
329329
wallet/external_signer_scriptpubkeyman.h \
330330
wallet/feebumper.h \
331331
wallet/fees.h \
332-
wallet/ismine.h \
333332
wallet/load.h \
334333
wallet/receive.h \
335334
wallet/rpc/util.h \
@@ -339,6 +338,7 @@ BITCOIN_CORE_H = \
339338
wallet/spend.h \
340339
wallet/sqlite.h \
341340
wallet/transaction.h \
341+
wallet/types.h \
342342
wallet/wallet.h \
343343
wallet/walletdb.h \
344344
wallet/wallettool.h \

src/qt/transactiondesc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <policy/policy.h>
2121
#include <util/system.h>
2222
#include <validation.h>
23-
#include <wallet/ismine.h>
23+
#include <wallet/types.h>
2424

2525
#include <stdint.h>
2626
#include <string>

src/qt/transactionrecord.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <chain.h>
88
#include <interfaces/wallet.h>
99
#include <key_io.h>
10-
#include <wallet/ismine.h>
10+
#include <wallet/types.h>
1111

1212
#include <stdint.h>
1313

src/wallet/interfaces.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <wallet/context.h>
2323
#include <wallet/feebumper.h>
2424
#include <wallet/fees.h>
25-
#include <wallet/ismine.h>
25+
#include <wallet/types.h>
2626
#include <wallet/load.h>
2727
#include <wallet/receive.h>
2828
#include <wallet/rpc/wallet.h>

src/wallet/receive.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#define BITCOIN_WALLET_RECEIVE_H
77

88
#include <consensus/amount.h>
9-
#include <wallet/ismine.h>
109
#include <wallet/transaction.h>
10+
#include <wallet/types.h>
1111
#include <wallet/wallet.h>
1212

1313
namespace wallet {

src/wallet/scriptpubkeyman.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <util/result.h>
1515
#include <util/time.h>
1616
#include <wallet/crypter.h>
17-
#include <wallet/ismine.h>
17+
#include <wallet/types.h>
1818
#include <wallet/walletdb.h>
1919
#include <wallet/walletutil.h>
2020

src/wallet/test/ismine_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <script/script.h>
99
#include <script/standard.h>
1010
#include <test/util/setup_common.h>
11-
#include <wallet/ismine.h>
11+
#include <wallet/types.h>
1212
#include <wallet/wallet.h>
1313

1414
#include <boost/test/unit_test.hpp>

src/wallet/transaction.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
#ifndef BITCOIN_WALLET_TRANSACTION_H
66
#define BITCOIN_WALLET_TRANSACTION_H
77

8+
#include <bitset>
9+
#include <cstdint>
810
#include <consensus/amount.h>
911
#include <primitives/transaction.h>
1012
#include <serialize.h>
11-
#include <wallet/ismine.h>
13+
#include <wallet/types.h>
1214
#include <threadsafety.h>
1315
#include <tinyformat.h>
1416
#include <util/overloaded.h>
@@ -108,8 +110,29 @@ static inline int TxStateSerializedIndex(const TxState& state)
108110
}
109111

110112

113+
/**
114+
* Cachable amount subdivided into watchonly and spendable parts.
115+
*/
116+
struct CachableAmount
117+
{
118+
// NO and ALL are never (supposed to be) cached
119+
std::bitset<ISMINE_ENUM_ELEMENTS> m_cached;
120+
CAmount m_value[ISMINE_ENUM_ELEMENTS];
121+
inline void Reset()
122+
{
123+
m_cached.reset();
124+
}
125+
void Set(isminefilter filter, CAmount value)
126+
{
127+
m_cached.set(filter);
128+
m_value[filter] = value;
129+
}
130+
};
131+
132+
111133
typedef std::map<std::string, std::string> mapValue_t;
112134

135+
113136
/** Legacy class used for deserializing vtxPrev for backwards compatibility.
114137
* vtxPrev was removed in commit 93a18a3650292afbb441a47d1fa1b94aeb0164e3,
115138
* but old wallet.dat files may still contain vtxPrev vectors of CMerkleTxs.

src/wallet/ismine.h renamed to src/wallet/types.h

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@
33
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

6-
#ifndef BITCOIN_WALLET_ISMINE_H
7-
#define BITCOIN_WALLET_ISMINE_H
6+
//! @file Public type definitions that are used inside and outside of the wallet
7+
//! (e.g. by src/wallet and src/interfaces and src/qt code).
8+
//!
9+
//! File is home for simple enum and struct definitions that don't deserve
10+
//! separate header files. More complicated wallet public types like
11+
//! CCoinControl that are used externally can have separate headers.
812

9-
#include <script/standard.h>
13+
#ifndef BITCOIN_WALLET_TYPES_H
14+
#define BITCOIN_WALLET_TYPES_H
1015

11-
#include <bitset>
12-
#include <cstdint>
1316
#include <type_traits>
1417

15-
class CScript;
16-
1718
namespace wallet {
18-
class CWallet;
19-
2019
/**
2120
* IsMine() return codes, which depend on ScriptPubKeyMan implementation.
2221
* Not every ScriptPubKeyMan covers all types, please refer to
@@ -49,25 +48,6 @@ enum isminetype : unsigned int {
4948
};
5049
/** used for bitflags of isminetype */
5150
using isminefilter = std::underlying_type<isminetype>::type;
52-
53-
/**
54-
* Cachable amount subdivided into watchonly and spendable parts.
55-
*/
56-
struct CachableAmount
57-
{
58-
// NO and ALL are never (supposed to be) cached
59-
std::bitset<ISMINE_ENUM_ELEMENTS> m_cached;
60-
CAmount m_value[ISMINE_ENUM_ELEMENTS];
61-
inline void Reset()
62-
{
63-
m_cached.reset();
64-
}
65-
void Set(isminefilter filter, CAmount value)
66-
{
67-
m_cached.set(filter);
68-
m_value[filter] = value;
69-
}
70-
};
7151
} // namespace wallet
7252

73-
#endif // BITCOIN_WALLET_ISMINE_H
53+
#endif // BITCOIN_WALLET_TYPES_H

0 commit comments

Comments
 (0)