Skip to content

Commit 3c52b1d

Browse files
Merge #7856: backport: bitcoin#26889: refactor: wallet, remove global 'ArgsManager' dependency
6f39d88 Merge bitcoin#26889: refactor: wallet, remove global 'ArgsManager' dependency (Konstantin Akimov) f7c864d refactor: drop coinjoin_loader from WalletContext and loader factories (Konstantin Akimov) f899d9a refactor: drop coinjoin_loader from CWallet constructor (Konstantin Akimov) 66d6b7f refactor: expose CoinJoin loader through interfaces::Chain (Konstantin Akimov) c25b960 refactor: register wallets with CoinJoin only in AddWallet (Konstantin Akimov) Pull request description: ## Issue being fixed or feature implemented CWallet has extra argument coinjoin_loader in its ctor and it makes pain when doing backports due to more than 100 usages spread all over code bases and it causes conflicts when doing backport. ## What was done? - fixed double call of registration in CWallet::Create in the freshly loaded wallet: with the CoinJoin client manager and AddWallet registered it again - expose CoinJoin loader through interfaces::Chain - drop coinjoin_loader from CWallet constructor - drop coinjoin_loader from WalletContext and loader factories - backport bitcoin#26889 - king of conflicts. Backport bitcoin#26889 is touching _every_ line what had caused conflicts due to extra argument in CWallet constructor, this PR has all important prerequisites to make its merge easier. NOTE: some chunks of 26889 is omitted because this code is not backported yet [including taproot's related], some other quite opposite added. Though, 26889 is not partial and done in full because compiler enforces missing changes to update: remove gArgs / m_args if they will be added later by other commits. ## How Has This Been Tested? Run unit & regressions tests. ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ Top commit has no ACKs. Tree-SHA512: 833aaf5c700e19345b172c7aa326d37d37ed12b1646fe274dba47eb9928ea481fd94afe8282e5a8d0e02e14d56a00bc07f0fcd0326990ea1135fe77244450264
2 parents 41cf1a7 + 6f39d88 commit 3c52b1d

50 files changed

Lines changed: 202 additions & 232 deletions

Some content is hidden

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

‎src/bench/coin_selection.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static void CoinSelection(benchmark::Bench& bench)
4444
{
4545
NodeContext node;
4646
auto chain = interfaces::MakeChain(node);
47-
CWallet wallet(chain.get(), /*coinjoin_loader=*/nullptr, "", gArgs, CreateDummyWalletDatabase());
47+
CWallet wallet(chain.get(), "", CreateDummyWalletDatabase());
4848
std::vector<std::unique_ptr<CWalletTx>> wtxs;
4949
LOCK(wallet.cs_wallet);
5050

‎src/bench/wallet_balance.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const b
3131
// Set clock to genesis block, so the descriptors/keys creation time don't interfere with the blocks scanning process.
3232
// The reason is 'generatetoaddress', which creates a chain with deterministic timestamps in the past.
3333
SetMockTime(test_setup->m_node.chainman->GetParams().GenesisBlock().nTime);
34-
CWallet wallet{test_setup->m_node.chain.get(), test_setup->m_node.coinjoin_loader.get(), "", gArgs, CreateMockWalletDatabase()};
34+
CWallet wallet{test_setup->m_node.chain.get(), "", CreateMockWalletDatabase()};
3535
{
3636
LOCK(wallet.cs_wallet);
3737
wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS);

‎src/bench/wallet_create_tx.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static void WalletCreateTx(benchmark::Bench& bench, const OutputType output_type
8484
{
8585
const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
8686

87-
CWallet wallet{test_setup->m_node.chain.get(), test_setup->m_node.coinjoin_loader.get(), "", gArgs, CreateMockWalletDatabase()};
87+
CWallet wallet{test_setup->m_node.chain.get(), "", CreateMockWalletDatabase()};
8888
{
8989
LOCK(wallet.cs_wallet);
9090
wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
@@ -137,7 +137,7 @@ static void WalletCreateTx(benchmark::Bench& bench, const OutputType output_type
137137
static void AvailableCoins(benchmark::Bench& bench, const std::vector<OutputType>& output_type)
138138
{
139139
const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
140-
CWallet wallet{test_setup->m_node.chain.get(), test_setup->m_node.coinjoin_loader.get(), "", gArgs, CreateMockWalletDatabase()};
140+
CWallet wallet{test_setup->m_node.chain.get(), "", CreateMockWalletDatabase()};
141141
{
142142
LOCK(wallet.cs_wallet);
143143
wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS);

‎src/dummywallet.cpp‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<wallet::CWallet>& walle
9696
throw std::logic_error("Wallet function called in non-wallet build.");
9797
}
9898

99-
std::unique_ptr<WalletClient> MakeWalletLoader(Chain& chain, ArgsManager& args, node::NodeContext& node_context,
100-
interfaces::CoinJoin::Loader& coinjoin_loader)
99+
std::unique_ptr<WalletClient> MakeWalletLoader(Chain& chain, ArgsManager& args, node::NodeContext& node_context)
101100
{
102101
throw std::logic_error("Wallet function called in non-wallet build.");
103102
}

‎src/init/bitcoin-gui.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ class BitcoinGuiInit : public interfaces::Init
3232
{
3333
return interfaces::MakeCoinJoinLoader(m_node);
3434
}
35-
std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain& chain, interfaces::CoinJoin::Loader& coinjoin_loader) override
35+
std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain& chain) override
3636
{
37-
return MakeWalletLoader(chain, *Assert(m_node.args), m_node, coinjoin_loader);
37+
return MakeWalletLoader(chain, *Assert(m_node.args), m_node);
3838
}
3939
std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
4040
interfaces::Ipc* ipc() override { return m_ipc.get(); }

‎src/init/bitcoin-node.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ class BitcoinNodeInit : public interfaces::Init
3535
{
3636
return interfaces::MakeCoinJoinLoader(m_node);
3737
}
38-
std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain& chain, interfaces::CoinJoin::Loader& coinjoin_loader) override
38+
std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain& chain) override
3939
{
40-
return MakeWalletLoader(chain, *Assert(m_node.args), m_node, coinjoin_loader);
40+
return MakeWalletLoader(chain, *Assert(m_node.args), m_node);
4141
}
4242
std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
4343
interfaces::Ipc* ipc() override { return m_ipc.get(); }

‎src/init/bitcoin-qt.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ class BitcoinQtInit : public interfaces::Init
2929
{
3030
return interfaces::MakeCoinJoinLoader(m_node);
3131
}
32-
std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain& chain, interfaces::CoinJoin::Loader& coinjoin_loader) override
32+
std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain& chain) override
3333
{
34-
return MakeWalletLoader(chain, *Assert(m_node.args), m_node, coinjoin_loader);
34+
return MakeWalletLoader(chain, *Assert(m_node.args), m_node);
3535
}
3636
std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
3737
node::NodeContext m_node;

‎src/init/bitcoind.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ class BitcoindInit : public interfaces::Init
3232
{
3333
return interfaces::MakeCoinJoinLoader(m_node);
3434
}
35-
std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain& chain, interfaces::CoinJoin::Loader& coinjoin_loader) override
35+
std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain& chain) override
3636
{
37-
return MakeWalletLoader(chain, *Assert(m_node.args), m_node, coinjoin_loader);
37+
return MakeWalletLoader(chain, *Assert(m_node.args), m_node);
3838
}
3939
std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
4040
NodeContext& m_node;

‎src/interfaces/chain.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ namespace interfaces {
4848

4949
class Wallet;
5050
class Handler;
51+
namespace CoinJoin {
52+
class Loader;
53+
} // namespace CoinJoin
5154

5255
//! Hash/height pair to help track and identify blocks.
5356
struct BlockKey {
@@ -181,6 +184,10 @@ class Chain
181184
//! Return list of MN Collateral from outputs
182185
virtual std::vector<COutPoint> listMNCollaterials(const std::vector<std::pair<const CTransactionRef&, uint32_t>>& outputs) = 0;
183186

187+
//! Return the loader that registers wallets with the node's CoinJoin
188+
//! client manager, or nullptr when the node runs without one.
189+
virtual CoinJoin::Loader* coinJoinLoader() = 0;
190+
184191
//! Return whether node has the block and optionally return block metadata
185192
//! or contents.
186193
virtual bool findBlock(const uint256& hash, const FoundBlock& block={}) = 0;

‎src/interfaces/init.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Init
3434
virtual std::unique_ptr<Node> makeNode() { return nullptr; }
3535
virtual std::unique_ptr<Chain> makeChain() { return nullptr; }
3636
virtual std::unique_ptr<CoinJoin::Loader> makeCoinJoinLoader() { return nullptr; }
37-
virtual std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain&, CoinJoin::Loader&) { return nullptr; }
37+
virtual std::unique_ptr<interfaces::WalletLoader> makeWalletLoader(interfaces::Chain&) { return nullptr; }
3838
virtual std::unique_ptr<Echo> makeEcho() { return nullptr; }
3939
virtual Ipc* ipc() { return nullptr; }
4040
};

0 commit comments

Comments
 (0)