Merge #19099: refactor: Move wallet methods out of chain.h and node.h
24bf17602cgui refactor: Inline SplashScreen::ConnectWallet (Russell Yanofsky)e4f4350471refactor: Move wallet methods out of chain.h and node.h (Russell Yanofsky)b266b3e0bfrefactor: 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 #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 ACK24bf17602c. MarcoFalke: ACK24bf17602c🐚 Tree-SHA512: a70d3776cd6723093db8912028c50075ec5fa0a48b961cb1a945f922658f5363754f8380dbb8378ed128c8c858913024f8264740905b8121a35c0d63bfaed7cf
This commit is contained in:
23 files changed
+131
-158
No files matched your search
@@ -267,6 +267,7 @@ void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle)
|
||||
// We don't hold a direct pointer to the splash screen after creation, but the splash
|
||||
// screen will take care of deleting itself when finish() happens.
|
||||
m_splash->show();
|
||||
connect(this, &BitcoinApplication::requestedInitialize, m_splash, &SplashScreen::handleLoadWallet);
|
||||
connect(this, &BitcoinApplication::splashFinished, m_splash, &SplashScreen::finish);
|
||||
connect(this, &BitcoinApplication::requestedShutdown, m_splash, &QWidget::close);
|
||||
}
|
||||
|
||||
@@ -1189,7 +1189,7 @@ void BitcoinGUI::incomingTransaction(const QString& date, int unit, const CAmoun
|
||||
// On new transaction, make an info balloon
|
||||
QString msg = tr("Date: %1\n").arg(date) +
|
||||
tr("Amount: %1\n").arg(BitcoinUnits::formatWithUnit(unit, amount, true));
|
||||
if (m_node.getWallets().size() > 1 && !walletName.isEmpty()) {
|
||||
if (m_node.walletClient().getWallets().size() > 1 && !walletName.isEmpty()) {
|
||||
msg += tr("Wallet: %1\n").arg(walletName);
|
||||
}
|
||||
msg += tr("Type: %1\n").arg(type);
|
||||
|
||||
@@ -185,21 +185,21 @@ static void ShowProgress(SplashScreen *splash, const std::string &title, int nPr
|
||||
: _("press q to shutdown").translated) +
|
||||
strprintf("\n%d", nProgress) + "%");
|
||||
}
|
||||
#ifdef ENABLE_WALLET
|
||||
void SplashScreen::ConnectWallet(std::unique_ptr<interfaces::Wallet> wallet)
|
||||
{
|
||||
m_connected_wallet_handlers.emplace_back(wallet->handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2, false)));
|
||||
m_connected_wallets.emplace_back(std::move(wallet));
|
||||
}
|
||||
#endif
|
||||
|
||||
void SplashScreen::subscribeToCoreSignals()
|
||||
{
|
||||
// Connect signals to client
|
||||
m_handler_init_message = m_node->handleInitMessage(std::bind(InitMessage, this, std::placeholders::_1));
|
||||
m_handler_show_progress = m_node->handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||
}
|
||||
|
||||
void SplashScreen::handleLoadWallet()
|
||||
{
|
||||
#ifdef ENABLE_WALLET
|
||||
m_handler_load_wallet = m_node->handleLoadWallet([this](std::unique_ptr<interfaces::Wallet> wallet) { ConnectWallet(std::move(wallet)); });
|
||||
m_handler_load_wallet = m_node->walletClient().handleLoadWallet([this](std::unique_ptr<interfaces::Wallet> wallet) {
|
||||
m_connected_wallet_handlers.emplace_back(wallet->handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2, false)));
|
||||
m_connected_wallets.emplace_back(std::move(wallet));
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,9 @@ public Q_SLOTS:
|
||||
/** Show message and progress */
|
||||
void showMessage(const QString &message, int alignment, const QColor &color);
|
||||
|
||||
/** Handle wallet load notifications. */
|
||||
void handleLoadWallet();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject * obj, QEvent * ev) override;
|
||||
|
||||
@@ -53,8 +56,6 @@ private:
|
||||
void unsubscribeFromCoreSignals();
|
||||
/** Initiate shutdown */
|
||||
void shutdown();
|
||||
/** Connect wallet signals to splash screen */
|
||||
void ConnectWallet(std::unique_ptr<interfaces::Wallet> wallet);
|
||||
|
||||
QPixmap pixmap;
|
||||
QString curMessage;
|
||||
|
||||
@@ -35,11 +35,11 @@ WalletController::WalletController(ClientModel& client_model, const PlatformStyl
|
||||
, m_platform_style(platform_style)
|
||||
, m_options_model(client_model.getOptionsModel())
|
||||
{
|
||||
m_handler_load_wallet = m_node.handleLoadWallet([this](std::unique_ptr<interfaces::Wallet> wallet) {
|
||||
m_handler_load_wallet = m_node.walletClient().handleLoadWallet([this](std::unique_ptr<interfaces::Wallet> wallet) {
|
||||
getOrCreateWallet(std::move(wallet));
|
||||
});
|
||||
|
||||
for (std::unique_ptr<interfaces::Wallet>& wallet : m_node.getWallets()) {
|
||||
for (std::unique_ptr<interfaces::Wallet>& wallet : m_node.walletClient().getWallets()) {
|
||||
getOrCreateWallet(std::move(wallet));
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ std::map<std::string, bool> WalletController::listWalletDir() const
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
std::map<std::string, bool> wallets;
|
||||
for (const std::string& name : m_node.listWalletDir()) {
|
||||
for (const std::string& name : m_node.walletClient().listWalletDir()) {
|
||||
wallets[name] = false;
|
||||
}
|
||||
for (WalletModel* wallet_model : m_wallets) {
|
||||
@@ -250,7 +250,7 @@ void CreateWalletActivity::createWallet()
|
||||
|
||||
QTimer::singleShot(500, worker(), [this, name, flags] {
|
||||
WalletCreationStatus status;
|
||||
std::unique_ptr<interfaces::Wallet> wallet = node().createWallet(m_passphrase, flags, name, m_error_message, m_warning_message, status);
|
||||
std::unique_ptr<interfaces::Wallet> wallet = node().walletClient().createWallet(name, m_passphrase, flags, status, m_error_message, m_warning_message);
|
||||
|
||||
if (status == WalletCreationStatus::SUCCESS) m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(wallet));
|
||||
|
||||
@@ -321,7 +321,7 @@ void OpenWalletActivity::open(const std::string& path)
|
||||
showProgressDialog(tr("Opening Wallet <b>%1</b>...").arg(name.toHtmlEscaped()));
|
||||
|
||||
QTimer::singleShot(0, worker(), [this, path] {
|
||||
std::unique_ptr<interfaces::Wallet> wallet = node().loadWallet(path, m_error_message, m_warning_message);
|
||||
std::unique_ptr<interfaces::Wallet> wallet = node().walletClient().loadWallet(path, m_error_message, m_warning_message);
|
||||
|
||||
if (wallet) m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(wallet));
|
||||
|
||||
|
||||
@@ -581,7 +581,7 @@ QString WalletModel::getDisplayName() const
|
||||
|
||||
bool WalletModel::isMultiwallet()
|
||||
{
|
||||
return m_node.getWallets().size() > 1;
|
||||
return m_node.walletClient().getWallets().size() > 1;
|
||||
}
|
||||
|
||||
void WalletModel::refresh(bool pk_hash_only)
|
||||
|
||||
Reference in new issue
Block a user