-
Notifications
You must be signed in to change notification settings - Fork 37.7k
refactor: Move wallet methods out of chain.h and node.h #19099
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Rebased 771b0e3 -> 05875a8 ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conceptually looks like a good change, and codewise looks like a clean-up, but the PR description could use a bit more motivation as for why this is needed. It could simply be that I'm not aware of the bigger project, though.
Code review ACK
src/bitcoind.cpp
Outdated
@@ -152,6 +151,7 @@ static bool AppInit(int argc, char* argv[]) | |||
// If locking the data directory failed, exit immediately | |||
return false; | |||
} | |||
AppInitInterfaces(node); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why ignore returned value (even if only true
at this point)?
AppInitInterfaces(node); | |
if (!AppInitInterfaces(node)) return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems to be addressed
namespace interfaces { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μNit: This empty line looks nice, IMO.
src/interfaces/node.cpp
Outdated
std::shared_ptr<CWallet> wallet; | ||
status = CreateWallet(*m_context->chain, passphrase, wallet_creation_flags, name, error, warnings, wallet); | ||
return MakeWallet(wallet); | ||
assert (m_context->wallet_client); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style-nit: Usually no space before (
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems to be addressed
Add AppInitInterfaces function so wallet chain and chain client interfaces are created earlier during initialization. This is needed in the next commit to allow the gui splash screen to be able to register for wallet events through a dedicated WalletClient interface instead managing wallets indirectly through the Node interface. This only works if the wallet client interface is created before the splash screen needs to use it.
Add WalletClient interface so node interface is cleaner and don't need wallet-specific methods. The new NodeContext::wallet_client pointer will also be needed to eliminate global wallet variables like ::vpwallets, because createWallet(), loadWallet(), getWallets(), etc methods called by the GUI need a way to get a reference to the list of open wallets if it is no longer a global variable. Also tweaks splash screen registration for load wallet events to be delayed until after wallet client is created.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 24bf176 🐚
Show signature and timestamp
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
ACK 24bf17602c620445f76c3b407937751c8a894d37 🐚
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUjmewv/dJqaPdgxC1U3bn+w8eyykTimZGhO7qQeEkDFIM/KtzP62aCYhPeIUw4P
5bvnVqwB7+xU6ulQ8bKQBfWIZQiyCehQ5xCrB6kdTO8U2jUnUqO4G3c3ypgqbUXd
oNhRKT2P+V3XtkpU2DbAz+7n+B5GeoJA7OxXksEN8U9q3EdymgmTVVfeBQB36gtt
GlfQYbCksyKl8cj6FN5l4D0pJKOqPgfS21jh7WEjHoKIPE8ttTLYelgXQeSijhci
Iuc4NTts7l0dwTescpwOpVqyk0Mz/k6TshEZSDGaf7fjY26s5wz7RZFUVtYtICf8
S2zYQDque8mwZTnaEs4dVo5wGG6dqpWK5fPEdQFDAskdsDiXLnumsYpZOH68V5ov
62cztTrLVECqErAPjT0P+P/mBTrp8oHoTagzvrSO71Y/pyoc3zoAdNimxmT1K8ya
GStgbd4W9ia6J8D1s/ov4rxmZBH2XPBBaTXpas4++8BYiPjmx+NkteVXjJsRNOX/
ZNWwcqg0
=TcZF
-----END PGP SIGNATURE-----
Timestamp of file with hash 77e30443c0b09185b05b8ce84203f4afece67e0a8bb120e17ec2f352a85547ac -
@@ -129,5 +130,7 @@ void WalletInit::Construct(NodeContext& node) const | |||
settings.rw_settings["wallet"] = wallets; | |||
}); | |||
} | |||
node.chain_clients.emplace_back(interfaces::MakeWalletClient(*node.chain, args, args.GetArgs("-wallet"))); | |||
auto wallet_client = interfaces::MakeWalletClient(*node.chain, args, args.GetArgs("-wallet")); | |||
node.wallet_client = wallet_client.get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit in e4f4350:
Would be good to assert !node.wallet_client
to avoid accidentally re-seating the reference
@@ -40,7 +41,11 @@ struct NodeContext { | |||
std::unique_ptr<BanMan> banman; | |||
ArgsManager* args{nullptr}; // Currently a raw pointer because the memory is not managed by this struct | |||
std::unique_ptr<interfaces::Chain> chain; | |||
//! List of all chain clients (wallet processes or other client) connected to node. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//! List of all chain clients (wallet processes or other client) connected to node. | |
//! List of all chain clients (wallet client or other client) connected to node. |
nit in e4f4350:
could simply say that there is at most a single wallet client in this list, not one for each wallet.
|
||
//! Create a wallet from file | ||
virtual std::unique_ptr<Wallet> createWallet(const SecureString& passphrase, uint64_t wallet_creation_flags, const std::string& name, bilingual_str& error, std::vector<bilingual_str>& warnings, WalletCreationStatus& status) = 0; | ||
//! Get wallet client. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc-nit: Should the docs say that this is not allowed to be called in a non-wallet build or when the wallet is disabled?
… node.h 24bf176 gui refactor: Inline SplashScreen::ConnectWallet (Russell Yanofsky) e4f4350 refactor: Move wallet methods out of chain.h and node.h (Russell Yanofsky) b266b3e refactor: Create interfaces earlier during initialization (Russell Yanofsky) Pull request description: Add WalletClient interface so node interface is cleaner and don't need wallet-specific methods. The new NodeContext::wallet_client pointer will also be needed to eliminate global wallet variables like ::vpwallets in bitcoin#19101, because createWallet(), loadWallet(), getWallets(), etc methods called by the GUI need a way to get a reference to the list of open wallets if it is no longer a global variable. ACKs for top commit: promag: Code review ACK 24bf176. MarcoFalke: ACK 24bf176 🐚 Tree-SHA512: a70d3776cd6723093db8912028c50075ec5fa0a48b961cb1a945f922658f5363754f8380dbb8378ed128c8c858913024f8264740905b8121a35c0d63bfaed7cf
A regression introduced in this PR fixed in bitcoin-core/gui#102. |
c056064 gui: Fix SplashScreen crash when run with -disablewallet (Hennadii Stepanov) Pull request description: This PR fixes the bug introduced in bitcoin/bitcoin#19099: ``` $ src/qt/bitcoin-qt -disablewallet bitcoin-qt: interfaces/node.cpp:236: auto interfaces::(anonymous namespace)::NodeImpl::walletClient()::(anonymous class)::operator()() const: Assertion `"m_context->wallet_client" && check' failed. Aborted (core dumped) ``` ACKs for top commit: Sjors: tACK c056064 promag: ACK c056064. Tree-SHA512: 263d9efd5899cc6e447dfc5142bf911ca627149fac0a1c5e5b58dd196aa5e0d12fe13e3f750fb5f3c4338222f7959935d2f77391263f967dbca2e0e79a416a29
Summary: Add AppInitInterfaces function so wallet chain and chain client interfaces are created earlier during initialization. This is needed in the next commit to allow the gui splash screen to be able to register for wallet events through a dedicated WalletClient interface instead managing wallets indirectly through the Node interface. This only works if the wallet client interface is created before the splash screen needs to use it. This is a backport of [[bitcoin/bitcoin#19099 | core#19099]] [1/3] bitcoin/bitcoin@b266b3e Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D10141
Summary: bitcoin/bitcoin@e4f4350 > Add WalletClient interface so node interface is cleaner and don't need > wallet-specific methods. > > The new NodeContext::wallet_client pointer will also be needed to eliminate > global wallet variables like ::vpwallets, because createWallet(), loadWallet(), > getWallets(), etc methods called by the GUI need a way to get a reference to > the list of open wallets if it is no longer a global variable. > > Also tweaks splash screen registration for load wallet events to be delayed > until after wallet client is created. bitcoin-core/gui@c056064 > gui: Fix SplashScreen crash when run with -disablewallet This is a backport of [[bitcoin/bitcoin#19099 | core#19099]] [2/3] and [[bitcoin-core/gui#102 | core-gui#102]] (small bugfix) Depends on D10141 Test Plan: `ninja all check-all` Test for bugfix core-gui#102: `src/qt/bitcoin-qt -disablewallet` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Klakurka, boardgamesaz, Fabien Differential Revision: https://reviews.bitcoinabc.org/D10142
Summary: Suggested bitcoin/bitcoin#19099 (comment) This concludes backport of [[bitcoin/bitcoin#19099 | core#19099]] [3/3] bitcoin/bitcoin@24bf176 Depends on D10142 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D10143
Add WalletClient interface so node interface is cleaner and don't need wallet-specific methods.
The new NodeContext::wallet_client pointer will also be needed to eliminate global wallet variables like ::vpwallets in #19101, because createWallet(), loadWallet(), getWallets(), etc methods called by the GUI need a way to get a reference to the list of open wallets if it is no longer a global variable.