Skip to content

Commit ab9ba84

Browse files
committed
refactor: complete migration of code to wallet:: namespace
Continuation of prior commit, should compile successfully.
1 parent 1c2d529 commit ab9ba84

35 files changed

+211
-80
lines changed

src/bench/coin_selection.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@
1212
#include <set>
1313

1414
using node::NodeContext;
15+
using wallet::CHANGE_LOWER;
16+
using wallet::CoinEligibilityFilter;
17+
using wallet::CoinSelectionParams;
18+
using wallet::COutput;
19+
using wallet::CreateDummyWalletDatabase;
20+
using wallet::CWallet;
21+
using wallet::CWalletTx;
22+
using wallet::OutputGroup;
23+
using wallet::TxStateInactive;
1524

1625
static void addCoin(const CAmount& nValue, const CWallet& wallet, std::vector<std::unique_ptr<CWalletTx>>& wtxs)
1726
{

src/bench/wallet_balance.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414

1515
#include <optional>
1616

17+
using wallet::CreateMockWalletDatabase;
18+
using wallet::CWallet;
19+
using wallet::DBErrors;
20+
using wallet::WALLET_FLAG_DESCRIPTORS;
21+
1722
static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const bool add_mine, const uint32_t epoch_iters)
1823
{
1924
const auto test_setup = MakeNoLogFileContext<const TestingSetup>();

src/bitcoin-wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ MAIN_FUNCTION
112112
}
113113

114114
ECC_Start();
115-
if (!WalletTool::ExecuteWalletToolFunc(args, command->command)) {
115+
if (!wallet::WalletTool::ExecuteWalletToolFunc(args, command->command)) {
116116
return EXIT_FAILURE;
117117
}
118118
ECC_Stop();

src/coinjoin/client.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@
3333
#include <memory>
3434
#include <univalue.h>
3535

36+
using wallet::CCoinControl;
37+
using wallet::CompactTallyItem;
38+
using wallet::COutput;
39+
using wallet::CoinType;
40+
using wallet::CWallet;
41+
using wallet::ReserveDestination;
42+
3643
PeerMsgRet CCoinJoinClientQueueManager::ProcessMessage(const CNode& peer, CConnman& connman, PeerManager& peerman,
3744
std::string_view msg_type, CDataStream& vRecv)
3845
{

src/coinjoin/client.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class CoinJoinWalletManager {
9696
}
9797
}
9898

99-
void Add(const std::shared_ptr<CWallet>& wallet);
99+
void Add(const std::shared_ptr<wallet::CWallet>& wallet);
100100
void DoMaintenance(CConnman& connman);
101101

102102
void Remove(const std::string& name);
@@ -138,7 +138,7 @@ class CoinJoinWalletManager {
138138
class CCoinJoinClientSession : public CCoinJoinBaseSession
139139
{
140140
private:
141-
const std::shared_ptr<CWallet> m_wallet;
141+
const std::shared_ptr<wallet::CWallet> m_wallet;
142142
CCoinJoinClientManager& m_clientman;
143143
CDeterministicMNManager& m_dmnman;
144144
CMasternodeMetaMan& m_mn_metaman;
@@ -162,12 +162,12 @@ class CCoinJoinClientSession : public CCoinJoinBaseSession
162162

163163
/// Create denominations
164164
bool CreateDenominated(CAmount nBalanceToDenominate);
165-
bool CreateDenominated(CAmount nBalanceToDenominate, const CompactTallyItem& tallyItem, bool fCreateMixingCollaterals)
165+
bool CreateDenominated(CAmount nBalanceToDenominate, const wallet::CompactTallyItem& tallyItem, bool fCreateMixingCollaterals)
166166
EXCLUSIVE_LOCKS_REQUIRED(m_wallet->cs_wallet);
167167

168168
/// Split up large inputs or make fee sized inputs
169169
bool MakeCollateralAmounts();
170-
bool MakeCollateralAmounts(const CompactTallyItem& tallyItem, bool fTryDenominated)
170+
bool MakeCollateralAmounts(const wallet::CompactTallyItem& tallyItem, bool fTryDenominated)
171171
EXCLUSIVE_LOCKS_REQUIRED(m_wallet->cs_wallet);
172172

173173
bool CreateCollateralTransaction(CMutableTransaction& txCollateral, std::string& strReason)
@@ -200,7 +200,7 @@ class CCoinJoinClientSession : public CCoinJoinBaseSession
200200
void SetNull() override EXCLUSIVE_LOCKS_REQUIRED(cs_coinjoin);
201201

202202
public:
203-
explicit CCoinJoinClientSession(const std::shared_ptr<CWallet>& wallet, CCoinJoinClientManager& clientman,
203+
explicit CCoinJoinClientSession(const std::shared_ptr<wallet::CWallet>& wallet, CCoinJoinClientManager& clientman,
204204
CDeterministicMNManager& dmnman, CMasternodeMetaMan& mn_metaman,
205205
const CMasternodeSync& mn_sync, const llmq::CInstantSendManager& isman,
206206
const std::unique_ptr<CCoinJoinClientQueueManager>& queueman, bool is_masternode);
@@ -263,7 +263,7 @@ class CCoinJoinClientQueueManager : public CCoinJoinBaseManager
263263
class CCoinJoinClientManager
264264
{
265265
private:
266-
const std::shared_ptr<CWallet> m_wallet;
266+
const std::shared_ptr<wallet::CWallet> m_wallet;
267267
CDeterministicMNManager& m_dmnman;
268268
CMasternodeMetaMan& m_mn_metaman;
269269
const CMasternodeSync& m_mn_sync;
@@ -302,7 +302,7 @@ class CCoinJoinClientManager
302302
CCoinJoinClientManager(CCoinJoinClientManager const&) = delete;
303303
CCoinJoinClientManager& operator=(CCoinJoinClientManager const&) = delete;
304304

305-
explicit CCoinJoinClientManager(const std::shared_ptr<CWallet>& wallet, CDeterministicMNManager& dmnman,
305+
explicit CCoinJoinClientManager(const std::shared_ptr<wallet::CWallet>& wallet, CDeterministicMNManager& dmnman,
306306
CMasternodeMetaMan& mn_metaman, const CMasternodeSync& mn_sync,
307307
const llmq::CInstantSendManager& isman,
308308
const std::unique_ptr<CCoinJoinClientQueueManager>& queueman, bool is_masternode) :

src/coinjoin/interfaces.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <string>
1919

2020
using node::NodeContext;
21+
using wallet::CWallet;
2122

2223
namespace coinjoin {
2324
namespace {

src/coinjoin/util.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414

1515
#include <numeric>
1616

17+
using wallet::CompactTallyItem;
18+
using wallet::CRecipient;
19+
using wallet::CWallet;
20+
using wallet::FEATURE_COMPRPUBKEY;
21+
using wallet::GetDiscardRate;
22+
using wallet::WalletBatch;
23+
1724
inline unsigned int GetSizeOfCompactSizeDiff(uint64_t nSizePrev, uint64_t nSizeNew)
1825
{
1926
assert(nSizePrev <= nSizeNew);

src/coinjoin/util.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ struct bilingual_str;
1313
class CKeyHolder
1414
{
1515
private:
16-
ReserveDestination reserveDestination;
16+
wallet::ReserveDestination reserveDestination;
1717
CTxDestination dest;
1818

1919
public:
20-
explicit CKeyHolder(CWallet* pwalletIn);
20+
explicit CKeyHolder(wallet::CWallet* pwalletIn);
2121
CKeyHolder(CKeyHolder&&) = delete;
2222
CKeyHolder& operator=(CKeyHolder&&) = delete;
2323
void KeepKey();
@@ -33,7 +33,7 @@ class CKeyHolderStorage
3333
std::vector<std::unique_ptr<CKeyHolder> > storage GUARDED_BY(cs_storage);
3434

3535
public:
36-
CScript AddKey(CWallet* pwalletIn) EXCLUSIVE_LOCKS_REQUIRED(!cs_storage);
36+
CScript AddKey(wallet::CWallet* pwalletIn) EXCLUSIVE_LOCKS_REQUIRED(!cs_storage);
3737
void KeepAll() EXCLUSIVE_LOCKS_REQUIRED(!cs_storage);
3838
void ReturnAll() EXCLUSIVE_LOCKS_REQUIRED(!cs_storage);
3939
};
@@ -47,14 +47,14 @@ class CTransactionBuilderOutput
4747
/// Used for amount updates
4848
CTransactionBuilder* pTxBuilder{nullptr};
4949
/// Reserve key where the amount of this output will end up
50-
ReserveDestination dest;
50+
wallet::ReserveDestination dest;
5151
/// Amount this output will receive
5252
CAmount nAmount{0};
5353
/// ScriptPubKey of this output
5454
CScript script;
5555

5656
public:
57-
CTransactionBuilderOutput(CTransactionBuilder* pTxBuilderIn, CWallet& wallet, CAmount nAmountIn);
57+
CTransactionBuilderOutput(CTransactionBuilder* pTxBuilderIn, wallet::CWallet& wallet, CAmount nAmountIn);
5858
CTransactionBuilderOutput(CTransactionBuilderOutput&&) = delete;
5959
CTransactionBuilderOutput& operator=(CTransactionBuilderOutput&&) = delete;
6060
/// Get the scriptPubKey of this output
@@ -77,15 +77,15 @@ class CTransactionBuilderOutput
7777
class CTransactionBuilder
7878
{
7979
/// Wallet the transaction will be build for
80-
CWallet& m_wallet;
80+
wallet::CWallet& m_wallet;
8181
/// See CTransactionBuilder() for initialization
82-
CCoinControl coinControl;
82+
wallet::CCoinControl coinControl;
8383
/// Dummy since we anyway use tallyItem's destination as change destination in coincontrol.
8484
/// Its a member just to make sure ReturnKey can be called in destructor just in case it gets generated/kept
8585
/// somewhere in CWallet code.
86-
ReserveDestination dummyReserveDestination;
86+
wallet::ReserveDestination dummyReserveDestination;
8787
/// Contains all utxos available to generate this transactions. They are all from the same address.
88-
CompactTallyItem tallyItem;
88+
wallet::CompactTallyItem tallyItem;
8989
/// Contains the number of bytes required for a transaction with only the inputs of tallyItems, no outputs
9090
int nBytesBase{0};
9191
/// Contains the number of bytes required to add one output
@@ -100,7 +100,7 @@ class CTransactionBuilder
100100
friend class CTransactionBuilderOutput;
101101

102102
public:
103-
CTransactionBuilder(CWallet& wallet, const CompactTallyItem& tallyItemIn);
103+
CTransactionBuilder(wallet::CWallet& wallet, const wallet::CompactTallyItem& tallyItemIn);
104104
~CTransactionBuilder();
105105
/// Check it would be possible to add a single output with the amount nAmount. Returns true if its possible and false if not.
106106
bool CouldAddOutput(CAmount nAmountOutput) const EXCLUSIVE_LOCKS_REQUIRED(!cs_outputs);

src/context.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ class ChainstateManager;
1313
class CTxMemPool;
1414
class CBlockPolicyEstimator;
1515
struct LLMQContext;
16-
struct WalletContext;
1716
namespace node {
1817
struct NodeContext;
1918
} // namespace node
19+
namespace wallet {
20+
struct WalletContext;
21+
} // namespace wallet
2022

2123
using CoreContext = std::variant<std::monostate,
2224
std::reference_wrapper<ArgsManager>,
2325
std::reference_wrapper<node::NodeContext>,
24-
std::reference_wrapper<WalletContext>,
26+
std::reference_wrapper<wallet::WalletContext>,
2527
std::reference_wrapper<CTxMemPool>,
2628
std::reference_wrapper<ChainstateManager>,
2729
std::reference_wrapper<CBlockPolicyEstimator>,

src/dummywallet.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
#include <walletinitinterface.h>
88

99
class ArgsManager;
10-
class CWallet;
11-
1210
namespace interfaces {
1311
class Chain;
1412
class Handler;
@@ -22,6 +20,9 @@ class Loader;
2220
namespace node {
2321
class NodeContext;
2422
} // namespace node
23+
namespace wallet {
24+
class CWallet;
25+
} // namespace wallet
2526

2627
class DummyWalletInit : public WalletInitInterface {
2728
public:
@@ -90,7 +91,7 @@ std::unique_ptr<CoinJoin::Loader> MakeCoinJoinLoader(node::NodeContext& node)
9091
throw std::logic_error("Wallet function called in non-wallet build.");
9192
}
9293

93-
std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet)
94+
std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<wallet::CWallet>& wallet)
9495
{
9596
throw std::logic_error("Wallet function called in non-wallet build.");
9697
}

0 commit comments

Comments
 (0)