24
24
25
25
#ifdef ENABLE_WALLET
26
26
#include < qt/paymentserver.h>
27
- #include < qt/walletmodel .h>
27
+ #include < qt/walletcontroller .h>
28
28
#endif
29
29
30
30
#include < interfaces/handler.h>
@@ -184,10 +184,6 @@ BitcoinApplication::BitcoinApplication(interfaces::Node& node, int &argc, char *
184
184
clientModel(nullptr ),
185
185
window(nullptr ),
186
186
pollShutdownTimer(nullptr ),
187
- #ifdef ENABLE_WALLET
188
- paymentServer (nullptr ),
189
- m_wallet_models(),
190
- #endif
191
187
returnValue(0 ),
192
188
platformStyle(nullptr )
193
189
{
@@ -316,11 +312,8 @@ void BitcoinApplication::requestShutdown()
316
312
pollShutdownTimer->stop ();
317
313
318
314
#ifdef ENABLE_WALLET
319
- window->removeAllWallets ();
320
- for (const WalletModel* walletModel : m_wallet_models) {
321
- delete walletModel;
322
- }
323
- m_wallet_models.clear ();
315
+ delete m_wallet_controller;
316
+ m_wallet_controller = nullptr ;
324
317
#endif
325
318
delete clientModel;
326
319
clientModel = nullptr ;
@@ -331,35 +324,6 @@ void BitcoinApplication::requestShutdown()
331
324
Q_EMIT requestedShutdown ();
332
325
}
333
326
334
- void BitcoinApplication::addWallet (WalletModel* walletModel)
335
- {
336
- #ifdef ENABLE_WALLET
337
- window->addWallet (walletModel);
338
-
339
- if (m_wallet_models.empty ()) {
340
- window->setCurrentWallet (walletModel);
341
- }
342
-
343
- #ifdef ENABLE_BIP70
344
- connect (walletModel, &WalletModel::coinsSent,
345
- paymentServer, &PaymentServer::fetchPaymentACK);
346
- #endif
347
- connect (walletModel, &WalletModel::unload, this , &BitcoinApplication::removeWallet);
348
-
349
- m_wallet_models.push_back (walletModel);
350
- #endif
351
- }
352
-
353
- void BitcoinApplication::removeWallet ()
354
- {
355
- #ifdef ENABLE_WALLET
356
- WalletModel* walletModel = static_cast <WalletModel*>(sender ());
357
- m_wallet_models.erase (std::find (m_wallet_models.begin (), m_wallet_models.end (), walletModel));
358
- window->removeWallet (walletModel);
359
- walletModel->deleteLater ();
360
- #endif
361
- }
362
-
363
327
void BitcoinApplication::initializeResult (bool success)
364
328
{
365
329
qDebug () << __func__ << " : Initialization result: " << success;
@@ -370,26 +334,22 @@ void BitcoinApplication::initializeResult(bool success)
370
334
// Log this only after AppInitMain finishes, as then logging setup is guaranteed complete
371
335
qWarning () << " Platform customization:" << platformStyle->getName ();
372
336
#ifdef ENABLE_WALLET
337
+ m_wallet_controller = new WalletController (m_node, platformStyle, optionsModel, this );
373
338
#ifdef ENABLE_BIP70
374
339
PaymentServer::LoadRootCAs ();
375
340
#endif
376
- if (paymentServer) paymentServer->setOptionsModel (optionsModel);
341
+ if (paymentServer) {
342
+ paymentServer->setOptionsModel (optionsModel);
343
+ #ifdef ENABLE_BIP70
344
+ connect (m_wallet_controller, &WalletController::coinsSent, paymentServer, &PaymentServer::fetchPaymentACK);
345
+ #endif
346
+ }
377
347
#endif
378
348
379
349
clientModel = new ClientModel (m_node, optionsModel);
380
350
window->setClientModel (clientModel);
381
-
382
351
#ifdef ENABLE_WALLET
383
- m_handler_load_wallet = m_node.handleLoadWallet ([this ](std::unique_ptr<interfaces::Wallet> wallet) {
384
- WalletModel* wallet_model = new WalletModel (std::move (wallet), m_node, platformStyle, optionsModel, nullptr );
385
- // Fix wallet model thread affinity.
386
- wallet_model->moveToThread (thread ());
387
- QMetaObject::invokeMethod (this , " addWallet" , Qt::QueuedConnection, Q_ARG (WalletModel*, wallet_model));
388
- });
389
-
390
- for (auto & wallet : m_node.getWallets ()) {
391
- addWallet (new WalletModel (std::move (wallet), m_node, platformStyle, optionsModel));
392
- }
352
+ window->setWalletController (m_wallet_controller);
393
353
#endif
394
354
395
355
// If -min option passed, start window minimized (iconified) or minimized to tray
@@ -493,9 +453,6 @@ int GuiMain(int argc, char* argv[])
493
453
// IMPORTANT if it is no longer a typedef use the normal variant above
494
454
qRegisterMetaType< CAmount >(" CAmount" );
495
455
qRegisterMetaType< std::function<void ()> >(" std::function<void()>" );
496
- #ifdef ENABLE_WALLET
497
- qRegisterMetaType<WalletModel*>(" WalletModel*" );
498
- #endif
499
456
500
457
// / 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these
501
458
// Command-line options take precedence:
0 commit comments