Skip to content

Conversation

ryanofsky
Copy link
Contributor

@ryanofsky ryanofsky commented May 28, 2020

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.

@DrahtBot
Copy link
Contributor

DrahtBot commented May 29, 2020

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, 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.

@ryanofsky
Copy link
Contributor Author

ryanofsky commented May 29, 2020

Rebased 771b0e3 -> 05875a8 (pr/wclient.1 -> pr/wclient.2, compare) due to conflict with #17993, and including splashscreen init fix
Rebased 05875a8 -> 7f6b16c (pr/wclient.2 -> pr/wclient.3, compare) on updated base #19098 with no changes. Fixes UndefinedBehaviorSanitizer error https://travis-ci.org/github/bitcoin/bitcoin/jobs/692541509#L4295 from base pr
Rebased 7f6b16c -> 7e2da82 (pr/wclient.3 -> pr/wclient.4, compare) on rebased base pr #19098 pr/qtx.4
Rebased 7e2da82 -> f1afe0a (pr/wclient.4 -> pr/wclient.5, compare) on rebased base pr #19098 pr/qtx.5

Copy link
Contributor

@kallewoof kallewoof left a 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);
Copy link
Contributor

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)?

Suggested change
AppInitInterfaces(node);
if (!AppInitInterfaces(node)) return false;

Copy link
Member

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 {

Copy link
Contributor

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.

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);
Copy link
Contributor

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 (.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems to be addressed

ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Aug 26, 2020
ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Aug 26, 2020
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.
ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Aug 28, 2020
Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK 24bf176.

(actually reviewed in #19101)

Copy link
Member

@maflcko maflcko left a 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();
Copy link
Member

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! 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.

@maflcko maflcko merged commit 269a7cc into bitcoin:master Aug 31, 2020

//! 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.
Copy link
Member

@maflcko maflcko Aug 31, 2020

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?

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Aug 31, 2020
… 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
@hebasto
Copy link
Member

hebasto commented Oct 9, 2020

A regression introduced in this PR fixed in bitcoin-core/gui#102.

maflcko pushed a commit to bitcoin-core/gui that referenced this pull request Oct 13, 2020
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
janus pushed a commit to janus/bitgesell that referenced this pull request Dec 7, 2020
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Sep 19, 2021
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
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Sep 19, 2021
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
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Sep 19, 2021
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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants