0diff --git a/src/bench/wallet_balance.cpp b/src/bench/wallet_balance.cpp
1index 98eac80055..aa436ee3ea 100644
2--- a/src/bench/wallet_balance.cpp
3+++ b/src/bench/wallet_balance.cpp
4@@ -24,7 +24,6 @@ static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const b
5
6 const auto& ADDRESS_WATCHONLY = ADDRESS_BCRT1_UNSPENDABLE;
7
8- test_setup.m_node.chain = interfaces::MakeChain(test_setup.m_node);
9 CWallet wallet{test_setup.m_node.chain.get(), "", CreateMockWalletDatabase()};
10 {
11 wallet.SetupLegacyScriptPubKeyMan();
12diff --git a/src/test/interfaces_tests.cpp b/src/test/interfaces_tests.cpp
13index b8c4bc8605..73463b071e 100644
14--- a/src/test/interfaces_tests.cpp
15+++ b/src/test/interfaces_tests.cpp
16@@ -17,7 +17,7 @@ BOOST_FIXTURE_TEST_SUITE(interfaces_tests, TestChain100Setup)
17
18 BOOST_AUTO_TEST_CASE(findBlock)
19 {
20- auto chain = interfaces::MakeChain(m_node);
21+ auto& chain = m_node.chain;
22 const CChain& active = Assert(m_node.chainman)->ActiveChain();
23
24 uint256 hash;
25@@ -61,7 +61,7 @@ BOOST_AUTO_TEST_CASE(findBlock)
26
27 BOOST_AUTO_TEST_CASE(findFirstBlockWithTimeAndHeight)
28 {
29- auto chain = interfaces::MakeChain(m_node);
30+ auto& chain = m_node.chain;
31 const CChain& active = Assert(m_node.chainman)->ActiveChain();
32 uint256 hash;
33 int height;
34@@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE(findFirstBlockWithTimeAndHeight)
35
36 BOOST_AUTO_TEST_CASE(findAncestorByHeight)
37 {
38- auto chain = interfaces::MakeChain(m_node);
39+ auto& chain = m_node.chain;
40 const CChain& active = Assert(m_node.chainman)->ActiveChain();
41 uint256 hash;
42 BOOST_CHECK(chain->findAncestorByHeight(active[20]->GetBlockHash(), 10, FoundBlock().hash(hash)));
43@@ -83,7 +83,7 @@ BOOST_AUTO_TEST_CASE(findAncestorByHeight)
44
45 BOOST_AUTO_TEST_CASE(findAncestorByHash)
46 {
47- auto chain = interfaces::MakeChain(m_node);
48+ auto& chain = m_node.chain;
49 const CChain& active = Assert(m_node.chainman)->ActiveChain();
50 int height = -1;
51 BOOST_CHECK(chain->findAncestorByHash(active[20]->GetBlockHash(), active[10]->GetBlockHash(), FoundBlock().height(height)));
52@@ -93,7 +93,7 @@ BOOST_AUTO_TEST_CASE(findAncestorByHash)
53
54 BOOST_AUTO_TEST_CASE(findCommonAncestor)
55 {
56- auto chain = interfaces::MakeChain(m_node);
57+ auto& chain = m_node.chain;
58 const CChain& active = Assert(m_node.chainman)->ActiveChain();
59 auto* orig_tip = active.Tip();
60 for (int i = 0; i < 10; ++i) {
61@@ -123,7 +123,7 @@ BOOST_AUTO_TEST_CASE(findCommonAncestor)
62
63 BOOST_AUTO_TEST_CASE(hasBlocks)
64 {
65- auto chain = interfaces::MakeChain(m_node);
66+ auto& chain = m_node.chain;
67 const CChain& active = Assert(m_node.chainman)->ActiveChain();
68
69 // Test ranges
70diff --git a/src/wallet/test/coinselector_tests.cpp b/src/wallet/test/coinselector_tests.cpp
71index f38ccba384..4127cd45f8 100644
72--- a/src/wallet/test/coinselector_tests.cpp
73+++ b/src/wallet/test/coinselector_tests.cpp
74@@ -283,7 +283,7 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
75 // Make sure that can use BnB when there are preset inputs
76 empty_wallet();
77 {
78- std::unique_ptr<CWallet> wallet = MakeUnique<CWallet>(m_chain.get(), "", CreateMockWalletDatabase());
79+ std::unique_ptr<CWallet> wallet = MakeUnique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
80 bool firstRun;
81 wallet->LoadWallet(firstRun);
82 wallet->SetupLegacyScriptPubKeyMan();
83diff --git a/src/wallet/test/init_test_fixture.cpp b/src/wallet/test/init_test_fixture.cpp
84index c80310045a..334e4ae0d8 100644
85--- a/src/wallet/test/init_test_fixture.cpp
86+++ b/src/wallet/test/init_test_fixture.cpp
87@@ -10,7 +10,7 @@
88
89 InitWalletDirTestingSetup::InitWalletDirTestingSetup(const std::string& chainName) : BasicTestingSetup(chainName)
90 {
91- m_wallet_client = MakeWalletClient(*m_chain, *Assert(m_node.args));
92+ m_wallet_client = MakeWalletClient(*m_node.chain, *Assert(m_node.args));
93
94 std::string sep;
95 sep += fs::path::preferred_separator;
96diff --git a/src/wallet/test/init_test_fixture.h b/src/wallet/test/init_test_fixture.h
97index f5bade77df..f666c45a34 100644
98--- a/src/wallet/test/init_test_fixture.h
99+++ b/src/wallet/test/init_test_fixture.h
100@@ -19,7 +19,6 @@ struct InitWalletDirTestingSetup: public BasicTestingSetup {
101 fs::path m_datadir;
102 fs::path m_cwd;
103 std::map<std::string, fs::path> m_walletdir_path_cases;
104- std::unique_ptr<interfaces::Chain> m_chain = interfaces::MakeChain(m_node);
105 std::unique_ptr<interfaces::WalletClient> m_wallet_client;
106 };
107
108diff --git a/src/wallet/test/ismine_tests.cpp b/src/wallet/test/ismine_tests.cpp
109index d5aed99d99..0ef8b9c4bf 100644
110--- a/src/wallet/test/ismine_tests.cpp
111+++ b/src/wallet/test/ismine_tests.cpp
112@@ -27,8 +27,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
113 CKey uncompressedKey;
114 uncompressedKey.MakeNewKey(false);
115 CPubKey uncompressedPubkey = uncompressedKey.GetPubKey();
116- NodeContext node;
117- std::unique_ptr<interfaces::Chain> chain = interfaces::MakeChain(node);
118+ std::unique_ptr<interfaces::Chain>& chain = m_node.chain;
119
120 CScript scriptPubKey;
121 isminetype result;
122diff --git a/src/wallet/test/scriptpubkeyman_tests.cpp b/src/wallet/test/scriptpubkeyman_tests.cpp
123index f7c1337b0d..347a436429 100644
124--- a/src/wallet/test/scriptpubkeyman_tests.cpp
125+++ b/src/wallet/test/scriptpubkeyman_tests.cpp
126@@ -17,9 +17,7 @@ BOOST_FIXTURE_TEST_SUITE(scriptpubkeyman_tests, BasicTestingSetup)
127 BOOST_AUTO_TEST_CASE(CanProvide)
128 {
129 // Set up wallet and keyman variables.
130- NodeContext node;
131- std::unique_ptr<interfaces::Chain> chain = interfaces::MakeChain(node);
132- CWallet wallet(chain.get(), "", CreateDummyWalletDatabase());
133+ CWallet wallet(m_node.chain.get(), "", CreateDummyWalletDatabase());
134 LegacyScriptPubKeyMan& keyman = *wallet.GetOrCreateLegacyScriptPubKeyMan();
135
136 // Make a 1 of 2 multisig script
137diff --git a/src/wallet/test/wallet_test_fixture.cpp b/src/wallet/test/wallet_test_fixture.cpp
138index 4d6f427618..badf2eb459 100644
139--- a/src/wallet/test/wallet_test_fixture.cpp
140+++ b/src/wallet/test/wallet_test_fixture.cpp
141@@ -6,10 +6,10 @@
142
143 WalletTestingSetup::WalletTestingSetup(const std::string& chainName)
144 : TestingSetup(chainName),
145- m_wallet(m_chain.get(), "", CreateMockWalletDatabase())
146+ m_wallet(m_node.chain.get(), "", CreateMockWalletDatabase())
147 {
148 bool fFirstRun;
149 m_wallet.LoadWallet(fFirstRun);
150- m_chain_notifications_handler = m_chain->handleNotifications({ &m_wallet, [](CWallet*) {} });
151+ m_chain_notifications_handler = m_node.chain->handleNotifications({ &m_wallet, [](CWallet*) {} });
152 m_wallet_client->registerRpcs();
153 }
154diff --git a/src/wallet/test/wallet_test_fixture.h b/src/wallet/test/wallet_test_fixture.h
155index ba8a5ff1f3..ab7fb8c42b 100644
156--- a/src/wallet/test/wallet_test_fixture.h
157+++ b/src/wallet/test/wallet_test_fixture.h
158@@ -20,8 +20,7 @@
159 struct WalletTestingSetup : public TestingSetup {
160 explicit WalletTestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
161
162- std::unique_ptr<interfaces::Chain> m_chain = interfaces::MakeChain(m_node);
163- std::unique_ptr<interfaces::WalletClient> m_wallet_client = interfaces::MakeWalletClient(*m_chain, *Assert(m_node.args));
164+ std::unique_ptr<interfaces::WalletClient> m_wallet_client = interfaces::MakeWalletClient(*m_node.chain, *Assert(m_node.args));
165 CWallet m_wallet;
166 std::unique_ptr<interfaces::Handler> m_chain_notifications_handler;
167 };
168diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp
169index 156be053d0..eb0bbb6ccc 100644
170--- a/src/wallet/test/wallet_tests.cpp
171+++ b/src/wallet/test/wallet_tests.cpp
172@@ -83,8 +83,6 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
173 CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
174 CBlockIndex* newTip = ::ChainActive().Tip();
175
176- m_node.chain = interfaces::MakeChain(m_node);
177-
178 // Verify ScanForWalletTransactions fails to read an unknown start block.
179 {
180 CWallet wallet(m_node.chain.get(), "", CreateDummyWalletDatabase());
181@@ -182,8 +180,6 @@ BOOST_FIXTURE_TEST_CASE(importmulti_rescan, TestChain100Setup)
182 CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
183 CBlockIndex* newTip = ::ChainActive().Tip();
184
185- m_node.chain = interfaces::MakeChain(m_node);
186-
187 // Prune the older block file.
188 {
189 LOCK(cs_main);
190@@ -253,8 +249,6 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
191 SetMockTime(KEY_TIME);
192 m_coinbase_txns.emplace_back(CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())).vtx[0]);
193
194- m_node.chain = interfaces::MakeChain(m_node);
195-
196 std::string backup_file = (GetDataDir() / "wallet.backup").string();
197
198 // Import key into wallet and call dumpwallet to create backup file.
199@@ -489,7 +483,6 @@ public:
200 ListCoinsTestingSetup()
201 {
202 CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
203- m_node.chain = interfaces::MakeChain(m_node);
204 wallet = MakeUnique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
205 {
206 LOCK2(wallet->cs_wallet, ::cs_main);
207@@ -701,7 +694,6 @@ BOOST_FIXTURE_TEST_CASE(wallet_descriptor_test, BasicTestingSetup)
208 BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup)
209 {
210 // Create new wallet with known key and unload it.
211- m_node.chain = interfaces::MakeChain(m_node);
212 auto wallet = TestLoadWallet(*m_node.chain);
213 CKey key;
214 key.MakeNewKey(true);
215@@ -794,8 +786,7 @@ BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup)
216
217 BOOST_FIXTURE_TEST_CASE(ZapSelectTx, TestChain100Setup)
218 {
219- auto chain = interfaces::MakeChain(m_node);
220- auto wallet = TestLoadWallet(*chain);
221+ auto wallet = TestLoadWallet(*m_node.chain);
222 CKey key;
223 key.MakeNewKey(true);
224 AddKey(*wallet, key);