Skip to content

Commit f7086fd

Browse files
committed
Add src/wallet/* code to wallet:: namespace
1 parent 90fc8b0 commit f7086fd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+293
-74
lines changed

src/bench/coin_selection.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@
1212
#include <set>
1313

1414
using node::NodeContext;
15+
using wallet::AttemptSelection;
16+
using wallet::CInputCoin;
17+
using wallet::COutput;
18+
using wallet::CWallet;
19+
using wallet::CWalletTx;
20+
using wallet::CoinEligibilityFilter;
21+
using wallet::CoinSelectionParams;
22+
using wallet::CreateDummyWalletDatabase;
23+
using wallet::OutputGroup;
24+
using wallet::SelectCoinsBnB;
25+
using wallet::TxStateInactive;
1526

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

src/bench/wallet_balance.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414

1515
#include <optional>
1616

17+
using wallet::CWallet;
18+
using wallet::CreateMockWalletDatabase;
19+
using wallet::DBErrors;
20+
using wallet::GetBalance;
21+
using wallet::WALLET_FLAG_DESCRIPTORS;
22+
1723
static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const bool add_mine)
1824
{
1925
const auto test_setup = MakeNoLogFileContext<const TestingSetup>();

src/bitcoin-wallet.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ int main(int argc, char* argv[])
123123

124124
ECCVerifyHandle globalVerifyHandle;
125125
ECC_Start();
126-
if (!WalletTool::ExecuteWalletToolFunc(args, command->command)) {
126+
if (!wallet::WalletTool::ExecuteWalletToolFunc(args, command->command)) {
127127
return EXIT_FAILURE;
128128
}
129129
ECC_Stop();

src/dummywallet.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <walletinitinterface.h>
77

88
class ArgsManager;
9-
class CWallet;
109

1110
namespace interfaces {
1211
class Chain;
@@ -59,11 +58,6 @@ const WalletInitInterface& g_wallet_init_interface = DummyWalletInit();
5958

6059
namespace interfaces {
6160

62-
std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet)
63-
{
64-
throw std::logic_error("Wallet function called in non-wallet build.");
65-
}
66-
6761
std::unique_ptr<WalletLoader> MakeWalletLoader(Chain& chain, ArgsManager& args)
6862
{
6963
throw std::logic_error("Wallet function called in non-wallet build.");

src/interfaces/node.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <vector>
2323

2424
class BanMan;
25-
class CCoinControl;
2625
class CFeeRate;
2726
class CNodeStats;
2827
class Coin;
@@ -36,6 +35,9 @@ struct bilingual_str;
3635
namespace node {
3736
struct NodeContext;
3837
} // namespace node
38+
namespace wallet {
39+
class CCoinControl;
40+
} // namespace wallet
3941

4042
namespace interfaces {
4143
class Handler;

src/interfaces/wallet.h

+24-22
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,21 @@
2323
#include <utility>
2424
#include <vector>
2525

26-
class CCoinControl;
2726
class CFeeRate;
2827
class CKey;
29-
class CWallet;
3028
enum class FeeReason;
3129
enum class OutputType;
3230
enum class TransactionError;
31+
struct PartiallySignedTransaction;
32+
struct bilingual_str;
33+
namespace wallet {
34+
class CCoinControl;
35+
class CWallet;
3336
enum isminetype : unsigned int;
3437
struct CRecipient;
35-
struct PartiallySignedTransaction;
3638
struct WalletContext;
37-
struct bilingual_str;
3839
using isminefilter = std::underlying_type<isminetype>::type;
40+
} // namespace wallet
3941

4042
namespace interfaces {
4143

@@ -107,7 +109,7 @@ class Wallet
107109
//! Look up address in wallet, return whether exists.
108110
virtual bool getAddress(const CTxDestination& dest,
109111
std::string* name,
110-
isminetype* is_mine,
112+
wallet::isminetype* is_mine,
111113
std::string* purpose) = 0;
112114

113115
//! Get wallet address list.
@@ -135,8 +137,8 @@ class Wallet
135137
virtual void listLockedCoins(std::vector<COutPoint>& outputs) = 0;
136138

137139
//! Create transaction.
138-
virtual CTransactionRef createTransaction(const std::vector<CRecipient>& recipients,
139-
const CCoinControl& coin_control,
140+
virtual CTransactionRef createTransaction(const std::vector<wallet::CRecipient>& recipients,
141+
const wallet::CCoinControl& coin_control,
140142
bool sign,
141143
int& change_pos,
142144
CAmount& fee,
@@ -158,7 +160,7 @@ class Wallet
158160

159161
//! Create bump transaction.
160162
virtual bool createBumpTransaction(const uint256& txid,
161-
const CCoinControl& coin_control,
163+
const wallet::CCoinControl& coin_control,
162164
std::vector<bilingual_str>& errors,
163165
CAmount& old_fee,
164166
CAmount& new_fee,
@@ -213,19 +215,19 @@ class Wallet
213215
virtual CAmount getBalance() = 0;
214216

215217
//! Get available balance.
216-
virtual CAmount getAvailableBalance(const CCoinControl& coin_control) = 0;
218+
virtual CAmount getAvailableBalance(const wallet::CCoinControl& coin_control) = 0;
217219

218220
//! Return whether transaction input belongs to wallet.
219-
virtual isminetype txinIsMine(const CTxIn& txin) = 0;
221+
virtual wallet::isminetype txinIsMine(const CTxIn& txin) = 0;
220222

221223
//! Return whether transaction output belongs to wallet.
222-
virtual isminetype txoutIsMine(const CTxOut& txout) = 0;
224+
virtual wallet::isminetype txoutIsMine(const CTxOut& txout) = 0;
223225

224226
//! Return debit amount if transaction input belongs to wallet.
225-
virtual CAmount getDebit(const CTxIn& txin, isminefilter filter) = 0;
227+
virtual CAmount getDebit(const CTxIn& txin, wallet::isminefilter filter) = 0;
226228

227229
//! Return credit amount if transaction input belongs to wallet.
228-
virtual CAmount getCredit(const CTxOut& txout, isminefilter filter) = 0;
230+
virtual CAmount getCredit(const CTxOut& txout, wallet::isminefilter filter) = 0;
229231

230232
//! Return AvailableCoins + LockedCoins grouped by wallet address.
231233
//! (put change in one group with wallet address)
@@ -240,7 +242,7 @@ class Wallet
240242

241243
//! Get minimum fee.
242244
virtual CAmount getMinimumFee(unsigned int tx_bytes,
243-
const CCoinControl& coin_control,
245+
const wallet::CCoinControl& coin_control,
244246
int* returned_target,
245247
FeeReason* reason) = 0;
246248

@@ -307,7 +309,7 @@ class Wallet
307309
virtual std::unique_ptr<Handler> handleCanGetAddressesChanged(CanGetAddressesChangedFn fn) = 0;
308310

309311
//! Return pointer to internal wallet class, useful for testing.
310-
virtual CWallet* wallet() { return nullptr; }
312+
virtual wallet::CWallet* wallet() { return nullptr; }
311313
};
312314

313315
//! Wallet chain client that in addition to having chain client methods for
@@ -341,18 +343,18 @@ class WalletLoader : public ChainClient
341343
virtual std::unique_ptr<Handler> handleLoadWallet(LoadWalletFn fn) = 0;
342344

343345
//! Return pointer to internal context, useful for testing.
344-
virtual WalletContext* context() { return nullptr; }
346+
virtual wallet::WalletContext* context() { return nullptr; }
345347
};
346348

347349
//! Information about one wallet address.
348350
struct WalletAddress
349351
{
350352
CTxDestination dest;
351-
isminetype is_mine;
353+
wallet::isminetype is_mine;
352354
std::string name;
353355
std::string purpose;
354356

355-
WalletAddress(CTxDestination dest, isminetype is_mine, std::string name, std::string purpose)
357+
WalletAddress(CTxDestination dest, wallet::isminetype is_mine, std::string name, std::string purpose)
356358
: dest(std::move(dest)), is_mine(is_mine), name(std::move(name)), purpose(std::move(purpose))
357359
{
358360
}
@@ -382,10 +384,10 @@ struct WalletBalances
382384
struct WalletTx
383385
{
384386
CTransactionRef tx;
385-
std::vector<isminetype> txin_is_mine;
386-
std::vector<isminetype> txout_is_mine;
387+
std::vector<wallet::isminetype> txin_is_mine;
388+
std::vector<wallet::isminetype> txout_is_mine;
387389
std::vector<CTxDestination> txout_address;
388-
std::vector<isminetype> txout_address_is_mine;
390+
std::vector<wallet::isminetype> txout_address_is_mine;
389391
CAmount credit;
390392
CAmount debit;
391393
CAmount change;
@@ -420,7 +422,7 @@ struct WalletTxOut
420422

421423
//! Return implementation of Wallet interface. This function is defined in
422424
//! dummywallet.cpp and throws if the wallet component is not compiled.
423-
std::unique_ptr<Wallet> MakeWallet(WalletContext& context, const std::shared_ptr<CWallet>& wallet);
425+
std::unique_ptr<Wallet> MakeWallet(wallet::WalletContext& context, const std::shared_ptr<wallet::CWallet>& wallet);
424426

425427
//! Return implementation of ChainClient interface for a wallet loader. This
426428
//! function will be undefined in builds where ENABLE_WALLET is false.

src/qt/coincontroldialog.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
#include <QSettings>
3232
#include <QTreeWidget>
3333

34+
using wallet::CCoinControl;
35+
using wallet::MIN_CHANGE;
36+
3437
QList<CAmount> CoinControlDialog::payAmounts;
3538
bool CoinControlDialog::fSubtractFeeFromAmount = false;
3639

src/qt/coincontroldialog.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
class PlatformStyle;
2020
class WalletModel;
2121

22+
namespace wallet {
2223
class CCoinControl;
24+
} // namespace wallet
2325

2426
namespace Ui {
2527
class CoinControlDialog;
@@ -42,11 +44,11 @@ class CoinControlDialog : public QDialog
4244
Q_OBJECT
4345

4446
public:
45-
explicit CoinControlDialog(CCoinControl& coin_control, WalletModel* model, const PlatformStyle *platformStyle, QWidget *parent = nullptr);
47+
explicit CoinControlDialog(wallet::CCoinControl& coin_control, WalletModel* model, const PlatformStyle *platformStyle, QWidget *parent = nullptr);
4648
~CoinControlDialog();
4749

4850
// static because also called from sendcoinsdialog
49-
static void updateLabels(CCoinControl& m_coin_control, WalletModel*, QDialog*);
51+
static void updateLabels(wallet::CCoinControl& m_coin_control, WalletModel*, QDialog*);
5052

5153
static QList<CAmount> payAmounts;
5254
static bool fSubtractFeeFromAmount;
@@ -56,7 +58,7 @@ class CoinControlDialog : public QDialog
5658

5759
private:
5860
Ui::CoinControlDialog *ui;
59-
CCoinControl& m_coin_control;
61+
wallet::CCoinControl& m_coin_control;
6062
WalletModel *model;
6163
int sortColumn;
6264
Qt::SortOrder sortOrder;

src/qt/sendcoinsdialog.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
#include <QSettings>
3636
#include <QTextDocument>
3737

38+
using wallet::CCoinControl;
39+
using wallet::DEFAULT_PAY_TX_FEE;
40+
3841
static constexpr std::array confTargets{2, 4, 6, 12, 24, 48, 144, 504, 1008};
3942
int getConfTargetForIndex(int index) {
4043
if (index+1 > static_cast<int>(confTargets.size())) {

src/qt/sendcoinsdialog.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
#include <QString>
1313
#include <QTimer>
1414

15-
class CCoinControl;
1615
class ClientModel;
1716
class PlatformStyle;
1817
class SendCoinsEntry;
1918
class SendCoinsRecipient;
2019
enum class SynchronizationState;
20+
namespace wallet {
21+
class CCoinControl;
22+
} // namespace wallet
2123

2224
namespace Ui {
2325
class SendCoinsDialog;
@@ -62,7 +64,7 @@ public Q_SLOTS:
6264
Ui::SendCoinsDialog *ui;
6365
ClientModel *clientModel;
6466
WalletModel *model;
65-
std::unique_ptr<CCoinControl> m_coin_control;
67+
std::unique_ptr<wallet::CCoinControl> m_coin_control;
6668
std::unique_ptr<WalletModelTransaction> m_current_transaction;
6769
bool fNewRecipientAllowed;
6870
bool fFeeMinimized;

src/qt/test/addressbooktests.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
#include <QTimer>
2525
#include <QMessageBox>
2626

27+
using wallet::AddWallet;
28+
using wallet::CWallet;
29+
using wallet::CreateMockWalletDatabase;
30+
using wallet::RemoveWallet;
31+
using wallet::WALLET_FLAG_DESCRIPTORS;
32+
using wallet::WalletContext;
33+
2734
namespace
2835
{
2936

src/qt/test/wallettests.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@
3939
#include <QListView>
4040
#include <QDialogButtonBox>
4141

42+
using wallet::AddWallet;
43+
using wallet::CWallet;
44+
using wallet::CreateMockWalletDatabase;
45+
using wallet::RemoveWallet;
46+
using wallet::WALLET_FLAG_DESCRIPTORS;
47+
using wallet::WalletContext;
48+
using wallet::WalletDescriptor;
49+
using wallet::WalletRescanReserver;
50+
4251
namespace
4352
{
4453
//! Press "Yes" or "Cancel" buttons in modal send confirmation dialog.

src/qt/transactiondesc.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828

2929
#include <QLatin1String>
3030

31+
using wallet::ISMINE_ALL;
32+
using wallet::ISMINE_SPENDABLE;
33+
using wallet::ISMINE_WATCH_ONLY;
34+
using wallet::isminetype;
35+
3136
QString TransactionDesc::FormatTxStatus(const interfaces::WalletTx& wtx, const interfaces::WalletTxStatus& status, bool inMempool, int numBlocks)
3237
{
3338
if (!status.is_final)

src/qt/transactionrecord.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313

1414
#include <QDateTime>
1515

16+
using wallet::ISMINE_SPENDABLE;
17+
using wallet::ISMINE_WATCH_ONLY;
18+
using wallet::isminetype;
19+
1620
/* Return positive answer if transaction should be shown in list.
1721
*/
1822
bool TransactionRecord::showTransaction()

src/qt/walletcontroller.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
#include <QTimer>
2929
#include <QWindow>
3030

31+
using wallet::WALLET_FLAG_BLANK_WALLET;
32+
using wallet::WALLET_FLAG_DESCRIPTORS;
33+
using wallet::WALLET_FLAG_DISABLE_PRIVATE_KEYS;
34+
using wallet::WALLET_FLAG_EXTERNAL_SIGNER;
35+
3136
WalletController::WalletController(ClientModel& client_model, const PlatformStyle* platform_style, QObject* parent)
3237
: QObject(parent)
3338
, m_activity_thread(new QThread(this))

src/qt/walletmodel.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
#include <QSet>
3737
#include <QTimer>
3838

39+
using wallet::CCoinControl;
40+
using wallet::CRecipient;
41+
using wallet::DEFAULT_DISABLE_WALLET;
3942

4043
WalletModel::WalletModel(std::unique_ptr<interfaces::Wallet> wallet, ClientModel& client_model, const PlatformStyle *platformStyle, QObject *parent) :
4144
QObject(parent),

0 commit comments

Comments
 (0)