Skip to content

Commit f63bf05

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#22928: refactor: Remove gArgs from wallet.h and wallet.cpp (2)
2ec38bd Remove `gArgs` from `wallet.h` and `wallet.cpp` (Kiminuo) Pull request description: This is a follow-up PR to #22183 and is related to #21005 issue. ACKs for top commit: ryanofsky: Code review ACK 2ec38bd. No changes since last review, just rebase Tree-SHA512: ae7fa1927b0a268f25697928ccaf1b3cf10ee1ccef3f9d2344001fbd7e11fe8ce768745c65e76bd7d1632c6c7650612b5b54eaf2be61093854f75a4c4dcb1784
2 parents e7feb73 + 2ec38bd commit f63bf05

17 files changed

+62
-57
lines changed

src/bench/coin_selection.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static void CoinSelection(benchmark::Bench& bench)
3232
{
3333
NodeContext node;
3434
auto chain = interfaces::MakeChain(node);
35-
CWallet wallet(chain.get(), "", CreateDummyWalletDatabase());
35+
CWallet wallet(chain.get(), "", gArgs, CreateDummyWalletDatabase());
3636
std::vector<std::unique_ptr<CWalletTx>> wtxs;
3737
LOCK(wallet.cs_wallet);
3838

src/bench/wallet_balance.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const b
2020

2121
const auto& ADDRESS_WATCHONLY = ADDRESS_BCRT1_UNSPENDABLE;
2222

23-
CWallet wallet{test_setup->m_node.chain.get(), "", CreateMockWalletDatabase()};
23+
CWallet wallet{test_setup->m_node.chain.get(), "", gArgs, CreateMockWalletDatabase()};
2424
{
2525
LOCK(wallet.cs_wallet);
2626
wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS);

src/qt/test/addressbooktests.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void TestAddAddressesToSendBook(interfaces::Node& node)
6363
auto wallet_client = interfaces::MakeWalletClient(*test.m_node.chain, *Assert(test.m_node.args));
6464
test.m_node.wallet_client = wallet_client.get();
6565
node.setContext(&test.m_node);
66-
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", CreateMockWalletDatabase());
66+
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", gArgs, CreateMockWalletDatabase());
6767
wallet->LoadWallet();
6868
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
6969
{

src/qt/test/wallettests.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void TestGUI(interfaces::Node& node)
141141
auto wallet_client = interfaces::MakeWalletClient(*test.m_node.chain, *Assert(test.m_node.args));
142142
test.m_node.wallet_client = wallet_client.get();
143143
node.setContext(&test.m_node);
144-
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", CreateMockWalletDatabase());
144+
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", gArgs, CreateMockWalletDatabase());
145145
wallet->LoadWallet();
146146
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
147147
{

src/wallet/dump.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ bool CreateFromDump(const std::string& name, const fs::path& wallet_path, biling
191191

192192
// dummy chain interface
193193
bool ret = true;
194-
std::shared_ptr<CWallet> wallet(new CWallet(nullptr /* chain */, name, std::move(database)), WalletToolReleaseWallet);
194+
std::shared_ptr<CWallet> wallet(new CWallet(nullptr /* chain */, name, gArgs, std::move(database)), WalletToolReleaseWallet);
195195
{
196196
LOCK(wallet->cs_wallet);
197197
DBErrors load_wallet_ret = wallet->LoadWallet();

src/wallet/salvage.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ bool RecoverDatabaseFile(const fs::path& file_path, bilingual_str& error, std::v
133133
}
134134

135135
DbTxn* ptxn = env->TxnBegin();
136-
CWallet dummyWallet(nullptr, "", CreateDummyWalletDatabase());
136+
CWallet dummyWallet(nullptr, "", gArgs, CreateDummyWalletDatabase());
137137
for (KeyValPair& row : salvagedData)
138138
{
139139
/* Filter for only private key type KV pairs to be added to the salvaged wallet */

src/wallet/test/coinselector_tests.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
273273
/* long_term_feerate= */ CFeeRate(1000), /* discard_feerate= */ CFeeRate(1000),
274274
/* tx_noinputs_size= */ 0, /* avoid_partial= */ false);
275275
{
276-
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
276+
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", m_args, CreateMockWalletDatabase());
277277
wallet->LoadWallet();
278278
LOCK(wallet->cs_wallet);
279279
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
@@ -297,7 +297,7 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
297297
}
298298

299299
{
300-
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
300+
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", m_args, CreateMockWalletDatabase());
301301
wallet->LoadWallet();
302302
LOCK(wallet->cs_wallet);
303303
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
@@ -320,7 +320,7 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
320320

321321
BOOST_AUTO_TEST_CASE(knapsack_solver_test)
322322
{
323-
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
323+
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", m_args, CreateMockWalletDatabase());
324324
wallet->LoadWallet();
325325
LOCK(wallet->cs_wallet);
326326
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
@@ -601,7 +601,7 @@ BOOST_AUTO_TEST_CASE(knapsack_solver_test)
601601

602602
BOOST_AUTO_TEST_CASE(ApproximateBestSubset)
603603
{
604-
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
604+
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", m_args, CreateMockWalletDatabase());
605605
wallet->LoadWallet();
606606
LOCK(wallet->cs_wallet);
607607
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
@@ -624,7 +624,7 @@ BOOST_AUTO_TEST_CASE(ApproximateBestSubset)
624624
// Tests that with the ideal conditions, the coin selector will always be able to find a solution that can pay the target value
625625
BOOST_AUTO_TEST_CASE(SelectCoins_test)
626626
{
627-
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
627+
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", m_args, CreateMockWalletDatabase());
628628
wallet->LoadWallet();
629629
LOCK(wallet->cs_wallet);
630630
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);

src/wallet/test/ismine_tests.cpp

+20-20
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
3434

3535
// P2PK compressed
3636
{
37-
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
37+
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
3838
keystore.SetupLegacyScriptPubKeyMan();
3939
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
4040
scriptPubKey = GetScriptForRawPubKey(pubkeys[0]);
@@ -51,7 +51,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
5151

5252
// P2PK uncompressed
5353
{
54-
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
54+
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
5555
keystore.SetupLegacyScriptPubKeyMan();
5656
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
5757
scriptPubKey = GetScriptForRawPubKey(uncompressedPubkey);
@@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
6868

6969
// P2PKH compressed
7070
{
71-
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
71+
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
7272
keystore.SetupLegacyScriptPubKeyMan();
7373
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
7474
scriptPubKey = GetScriptForDestination(PKHash(pubkeys[0]));
@@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
8585

8686
// P2PKH uncompressed
8787
{
88-
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
88+
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
8989
keystore.SetupLegacyScriptPubKeyMan();
9090
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
9191
scriptPubKey = GetScriptForDestination(PKHash(uncompressedPubkey));
@@ -102,7 +102,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
102102

103103
// P2SH
104104
{
105-
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
105+
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
106106
keystore.SetupLegacyScriptPubKeyMan();
107107
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
108108

@@ -126,7 +126,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
126126

127127
// (P2PKH inside) P2SH inside P2SH (invalid)
128128
{
129-
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
129+
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
130130
keystore.SetupLegacyScriptPubKeyMan();
131131
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
132132

@@ -144,7 +144,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
144144

145145
// (P2PKH inside) P2SH inside P2WSH (invalid)
146146
{
147-
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
147+
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
148148
keystore.SetupLegacyScriptPubKeyMan();
149149
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
150150

@@ -162,7 +162,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
162162

163163
// P2WPKH inside P2WSH (invalid)
164164
{
165-
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
165+
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
166166
keystore.SetupLegacyScriptPubKeyMan();
167167
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
168168

@@ -178,7 +178,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
178178

179179
// (P2PKH inside) P2WSH inside P2WSH (invalid)
180180
{
181-
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
181+
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
182182
keystore.SetupLegacyScriptPubKeyMan();
183183
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
184184

@@ -196,7 +196,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
196196

197197
// P2WPKH compressed
198198
{
199-
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
199+
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
200200
keystore.SetupLegacyScriptPubKeyMan();
201201
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
202202
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
@@ -211,7 +211,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
211211

212212
// P2WPKH uncompressed
213213
{
214-
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
214+
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
215215
keystore.SetupLegacyScriptPubKeyMan();
216216
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
217217
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(uncompressedKey));
@@ -230,7 +230,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
230230

231231
// scriptPubKey multisig
232232
{
233-
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
233+
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
234234
keystore.SetupLegacyScriptPubKeyMan();
235235
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
236236

@@ -261,7 +261,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
261261

262262
// P2SH multisig
263263
{
264-
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
264+
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
265265
keystore.SetupLegacyScriptPubKeyMan();
266266
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
267267
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(uncompressedKey));
@@ -282,7 +282,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
282282

283283
// P2WSH multisig with compressed keys
284284
{
285-
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
285+
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
286286
keystore.SetupLegacyScriptPubKeyMan();
287287
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
288288
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
@@ -308,7 +308,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
308308

309309
// P2WSH multisig with uncompressed key
310310
{
311-
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
311+
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
312312
keystore.SetupLegacyScriptPubKeyMan();
313313
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
314314
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(uncompressedKey));
@@ -334,7 +334,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
334334

335335
// P2WSH multisig wrapped in P2SH
336336
{
337-
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
337+
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
338338
keystore.SetupLegacyScriptPubKeyMan();
339339
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
340340

@@ -361,7 +361,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
361361

362362
// OP_RETURN
363363
{
364-
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
364+
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
365365
keystore.SetupLegacyScriptPubKeyMan();
366366
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
367367
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
@@ -375,7 +375,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
375375

376376
// witness unspendable
377377
{
378-
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
378+
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
379379
keystore.SetupLegacyScriptPubKeyMan();
380380
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
381381
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
@@ -389,7 +389,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
389389

390390
// witness unknown
391391
{
392-
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
392+
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
393393
keystore.SetupLegacyScriptPubKeyMan();
394394
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
395395
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
@@ -403,7 +403,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
403403

404404
// Nonstandard
405405
{
406-
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
406+
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
407407
keystore.SetupLegacyScriptPubKeyMan();
408408
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
409409
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));

src/wallet/test/scriptpubkeyman_tests.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ BOOST_FIXTURE_TEST_SUITE(scriptpubkeyman_tests, BasicTestingSetup)
1717
BOOST_AUTO_TEST_CASE(CanProvide)
1818
{
1919
// Set up wallet and keyman variables.
20-
CWallet wallet(m_node.chain.get(), "", CreateDummyWalletDatabase());
20+
CWallet wallet(m_node.chain.get(), "", m_args, CreateDummyWalletDatabase());
2121
LegacyScriptPubKeyMan& keyman = *wallet.GetOrCreateLegacyScriptPubKeyMan();
2222

2323
// Make a 1 of 2 multisig script

src/wallet/test/spend_tests.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ BOOST_FIXTURE_TEST_SUITE(spend_tests, WalletTestingSetup)
1717
BOOST_FIXTURE_TEST_CASE(SubtractFee, TestChain100Setup)
1818
{
1919
CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
20-
auto wallet = CreateSyncedWallet(*m_node.chain, m_node.chainman->ActiveChain(), coinbaseKey);
20+
auto wallet = CreateSyncedWallet(*m_node.chain, m_node.chainman->ActiveChain(), m_args, coinbaseKey);
2121

2222
// Check that a subtract-from-recipient transaction slightly less than the
2323
// coinbase input amount does not create a change output (because it would

src/wallet/test/util.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
#include <memory>
1717

18-
std::unique_ptr<CWallet> CreateSyncedWallet(interfaces::Chain& chain, CChain& cchain, const CKey& key)
18+
std::unique_ptr<CWallet> CreateSyncedWallet(interfaces::Chain& chain, CChain& cchain, ArgsManager& args, const CKey& key)
1919
{
20-
auto wallet = std::make_unique<CWallet>(&chain, "", CreateMockWalletDatabase());
20+
auto wallet = std::make_unique<CWallet>(&chain, "", args, CreateMockWalletDatabase());
2121
{
2222
LOCK2(wallet->cs_wallet, ::cs_main);
2323
wallet->SetLastBlockProcessed(cchain.Height(), cchain.Tip()->GetBlockHash());

src/wallet/test/util.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77

88
#include <memory>
99

10+
class ArgsManager;
1011
class CChain;
1112
class CKey;
1213
class CWallet;
1314
namespace interfaces {
1415
class Chain;
1516
} // namespace interfaces
1617

17-
std::unique_ptr<CWallet> CreateSyncedWallet(interfaces::Chain& chain, CChain& cchain, const CKey& key);
18+
std::unique_ptr<CWallet> CreateSyncedWallet(interfaces::Chain& chain, CChain& cchain, ArgsManager& args, const CKey& key);
1819

1920
#endif // BITCOIN_WALLET_TEST_UTIL_H

src/wallet/test/wallet_test_fixture.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
WalletTestingSetup::WalletTestingSetup(const std::string& chainName)
1010
: TestingSetup(chainName),
11-
m_wallet(m_node.chain.get(), "", CreateMockWalletDatabase())
11+
m_wallet(m_node.chain.get(), "", m_args, CreateMockWalletDatabase())
1212
{
1313
m_wallet.LoadWallet();
1414
m_chain_notifications_handler = m_node.chain->handleNotifications({ &m_wallet, [](CWallet*) {} });

0 commit comments

Comments
 (0)