Skip to content

Commit

Permalink
Remove gArgs from wallet.h and wallet.cpp
Browse files Browse the repository at this point in the history
Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
  • Loading branch information
kiminuo and ryanofsky committed Nov 9, 2021
1 parent 94db963 commit 2ec38bd
Show file tree
Hide file tree
Showing 17 changed files with 62 additions and 57 deletions.
2 changes: 1 addition & 1 deletion src/bench/coin_selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static void CoinSelection(benchmark::Bench& bench)
{
NodeContext node;
auto chain = interfaces::MakeChain(node);
CWallet wallet(chain.get(), "", CreateDummyWalletDatabase());
CWallet wallet(chain.get(), "", gArgs, CreateDummyWalletDatabase());
std::vector<std::unique_ptr<CWalletTx>> wtxs;
LOCK(wallet.cs_wallet);

Expand Down
2 changes: 1 addition & 1 deletion src/bench/wallet_balance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const b

const auto& ADDRESS_WATCHONLY = ADDRESS_BCRT1_UNSPENDABLE;

CWallet wallet{test_setup->m_node.chain.get(), "", CreateMockWalletDatabase()};
CWallet wallet{test_setup->m_node.chain.get(), "", gArgs, CreateMockWalletDatabase()};
{
LOCK(wallet.cs_wallet);
wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/test/addressbooktests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void TestAddAddressesToSendBook(interfaces::Node& node)
auto wallet_client = interfaces::MakeWalletClient(*test.m_node.chain, *Assert(test.m_node.args));
test.m_node.wallet_client = wallet_client.get();
node.setContext(&test.m_node);
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", CreateMockWalletDatabase());
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", gArgs, CreateMockWalletDatabase());
wallet->LoadWallet();
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
{
Expand Down
2 changes: 1 addition & 1 deletion src/qt/test/wallettests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void TestGUI(interfaces::Node& node)
auto wallet_client = interfaces::MakeWalletClient(*test.m_node.chain, *Assert(test.m_node.args));
test.m_node.wallet_client = wallet_client.get();
node.setContext(&test.m_node);
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", CreateMockWalletDatabase());
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", gArgs, CreateMockWalletDatabase());
wallet->LoadWallet();
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
{
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ bool CreateFromDump(const std::string& name, const fs::path& wallet_path, biling

// dummy chain interface
bool ret = true;
std::shared_ptr<CWallet> wallet(new CWallet(nullptr /* chain */, name, std::move(database)), WalletToolReleaseWallet);
std::shared_ptr<CWallet> wallet(new CWallet(nullptr /* chain */, name, gArgs, std::move(database)), WalletToolReleaseWallet);
{
LOCK(wallet->cs_wallet);
DBErrors load_wallet_ret = wallet->LoadWallet();
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/salvage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ bool RecoverDatabaseFile(const fs::path& file_path, bilingual_str& error, std::v
}

DbTxn* ptxn = env->TxnBegin();
CWallet dummyWallet(nullptr, "", CreateDummyWalletDatabase());
CWallet dummyWallet(nullptr, "", gArgs, CreateDummyWalletDatabase());
for (KeyValPair& row : salvagedData)
{
/* Filter for only private key type KV pairs to be added to the salvaged wallet */
Expand Down
10 changes: 5 additions & 5 deletions src/wallet/test/coinselector_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
/* long_term_feerate= */ CFeeRate(1000), /* discard_feerate= */ CFeeRate(1000),
/* tx_noinputs_size= */ 0, /* avoid_partial= */ false);
{
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", m_args, CreateMockWalletDatabase());
wallet->LoadWallet();
LOCK(wallet->cs_wallet);
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
Expand All @@ -297,7 +297,7 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
}

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

BOOST_AUTO_TEST_CASE(knapsack_solver_test)
{
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", m_args, CreateMockWalletDatabase());
wallet->LoadWallet();
LOCK(wallet->cs_wallet);
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
Expand Down Expand Up @@ -601,7 +601,7 @@ BOOST_AUTO_TEST_CASE(knapsack_solver_test)

BOOST_AUTO_TEST_CASE(ApproximateBestSubset)
{
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", m_args, CreateMockWalletDatabase());
wallet->LoadWallet();
LOCK(wallet->cs_wallet);
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
Expand All @@ -624,7 +624,7 @@ BOOST_AUTO_TEST_CASE(ApproximateBestSubset)
// Tests that with the ideal conditions, the coin selector will always be able to find a solution that can pay the target value
BOOST_AUTO_TEST_CASE(SelectCoins_test)
{
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", m_args, CreateMockWalletDatabase());
wallet->LoadWallet();
LOCK(wallet->cs_wallet);
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
Expand Down
40 changes: 20 additions & 20 deletions src/wallet/test/ismine_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)

// P2PK compressed
{
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
keystore.SetupLegacyScriptPubKeyMan();
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
scriptPubKey = GetScriptForRawPubKey(pubkeys[0]);
Expand All @@ -51,7 +51,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)

// P2PK uncompressed
{
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
keystore.SetupLegacyScriptPubKeyMan();
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
scriptPubKey = GetScriptForRawPubKey(uncompressedPubkey);
Expand All @@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)

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

// P2PKH uncompressed
{
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
keystore.SetupLegacyScriptPubKeyMan();
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
scriptPubKey = GetScriptForDestination(PKHash(uncompressedPubkey));
Expand All @@ -102,7 +102,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)

// P2SH
{
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
keystore.SetupLegacyScriptPubKeyMan();
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);

Expand All @@ -126,7 +126,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)

// (P2PKH inside) P2SH inside P2SH (invalid)
{
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
keystore.SetupLegacyScriptPubKeyMan();
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);

Expand All @@ -144,7 +144,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)

// (P2PKH inside) P2SH inside P2WSH (invalid)
{
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
keystore.SetupLegacyScriptPubKeyMan();
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);

Expand All @@ -162,7 +162,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)

// P2WPKH inside P2WSH (invalid)
{
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
keystore.SetupLegacyScriptPubKeyMan();
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);

Expand All @@ -178,7 +178,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)

// (P2PKH inside) P2WSH inside P2WSH (invalid)
{
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
keystore.SetupLegacyScriptPubKeyMan();
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);

Expand All @@ -196,7 +196,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)

// P2WPKH compressed
{
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
keystore.SetupLegacyScriptPubKeyMan();
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
Expand All @@ -211,7 +211,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)

// P2WPKH uncompressed
{
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
keystore.SetupLegacyScriptPubKeyMan();
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(uncompressedKey));
Expand All @@ -230,7 +230,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)

// scriptPubKey multisig
{
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
keystore.SetupLegacyScriptPubKeyMan();
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);

Expand Down Expand Up @@ -261,7 +261,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)

// P2SH multisig
{
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
keystore.SetupLegacyScriptPubKeyMan();
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(uncompressedKey));
Expand All @@ -282,7 +282,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)

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

// P2WSH multisig with uncompressed key
{
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
keystore.SetupLegacyScriptPubKeyMan();
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(uncompressedKey));
Expand All @@ -334,7 +334,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)

// P2WSH multisig wrapped in P2SH
{
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
keystore.SetupLegacyScriptPubKeyMan();
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);

Expand All @@ -361,7 +361,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)

// OP_RETURN
{
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
keystore.SetupLegacyScriptPubKeyMan();
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
Expand All @@ -375,7 +375,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)

// witness unspendable
{
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
keystore.SetupLegacyScriptPubKeyMan();
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
Expand All @@ -389,7 +389,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)

// witness unknown
{
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
keystore.SetupLegacyScriptPubKeyMan();
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
Expand All @@ -403,7 +403,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)

// Nonstandard
{
CWallet keystore(chain.get(), "", CreateDummyWalletDatabase());
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
keystore.SetupLegacyScriptPubKeyMan();
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0]));
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/test/scriptpubkeyman_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ BOOST_FIXTURE_TEST_SUITE(scriptpubkeyman_tests, BasicTestingSetup)
BOOST_AUTO_TEST_CASE(CanProvide)
{
// Set up wallet and keyman variables.
CWallet wallet(m_node.chain.get(), "", CreateDummyWalletDatabase());
CWallet wallet(m_node.chain.get(), "", m_args, CreateDummyWalletDatabase());
LegacyScriptPubKeyMan& keyman = *wallet.GetOrCreateLegacyScriptPubKeyMan();

// Make a 1 of 2 multisig script
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/test/spend_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ BOOST_FIXTURE_TEST_SUITE(spend_tests, WalletTestingSetup)
BOOST_FIXTURE_TEST_CASE(SubtractFee, TestChain100Setup)
{
CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
auto wallet = CreateSyncedWallet(*m_node.chain, m_node.chainman->ActiveChain(), coinbaseKey);
auto wallet = CreateSyncedWallet(*m_node.chain, m_node.chainman->ActiveChain(), m_args, coinbaseKey);

// Check that a subtract-from-recipient transaction slightly less than the
// coinbase input amount does not create a change output (because it would
Expand Down
4 changes: 2 additions & 2 deletions src/wallet/test/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

#include <memory>

std::unique_ptr<CWallet> CreateSyncedWallet(interfaces::Chain& chain, CChain& cchain, const CKey& key)
std::unique_ptr<CWallet> CreateSyncedWallet(interfaces::Chain& chain, CChain& cchain, ArgsManager& args, const CKey& key)
{
auto wallet = std::make_unique<CWallet>(&chain, "", CreateMockWalletDatabase());
auto wallet = std::make_unique<CWallet>(&chain, "", args, CreateMockWalletDatabase());
{
LOCK2(wallet->cs_wallet, ::cs_main);
wallet->SetLastBlockProcessed(cchain.Height(), cchain.Tip()->GetBlockHash());
Expand Down
3 changes: 2 additions & 1 deletion src/wallet/test/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@

#include <memory>

class ArgsManager;
class CChain;
class CKey;
class CWallet;
namespace interfaces {
class Chain;
} // namespace interfaces

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

#endif // BITCOIN_WALLET_TEST_UTIL_H
2 changes: 1 addition & 1 deletion src/wallet/test/wallet_test_fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

WalletTestingSetup::WalletTestingSetup(const std::string& chainName)
: TestingSetup(chainName),
m_wallet(m_node.chain.get(), "", CreateMockWalletDatabase())
m_wallet(m_node.chain.get(), "", m_args, CreateMockWalletDatabase())
{
m_wallet.LoadWallet();
m_chain_notifications_handler = m_node.chain->handleNotifications({ &m_wallet, [](CWallet*) {} });
Expand Down
Loading

0 comments on commit 2ec38bd

Please sign in to comment.