@@ -221,8 +221,9 @@ void PrepareShutdown()
221221 StopRPC ();
222222 StopHTTPServer ();
223223#ifdef ENABLE_WALLET
224- if (pwalletMain)
225- pwalletMain->Flush (false );
224+ for (CWalletRef pwallet : vpwallets) {
225+ pwallet->Flush (false );
226+ }
226227 GenerateBitcoins (false , NULL , 0 );
227228#endif
228229 StopMapPort ();
@@ -301,8 +302,9 @@ void PrepareShutdown()
301302 evoDb.reset ();
302303 }
303304#ifdef ENABLE_WALLET
304- if (pwalletMain)
305- pwalletMain->Flush (true );
305+ for (CWalletRef pwallet : vpwallets) {
306+ pwallet->Flush (true );
307+ }
306308#endif
307309
308310 if (pEvoNotificationInterface) {
@@ -354,8 +356,10 @@ void Shutdown()
354356 PrepareShutdown ();
355357 }
356358#ifdef ENABLE_WALLET
357- delete pwalletMain;
358- pwalletMain = NULL ;
359+ for (CWalletRef pwallet : vpwallets) {
360+ delete pwallet;
361+ }
362+ vpwallets.clear ();
359363#endif
360364 globalVerifyHandle.reset ();
361365 ECC_Stop ();
@@ -1877,14 +1881,15 @@ bool AppInitMain()
18771881 strBudgetMode = gArgs .GetArg (" -budgetvotemode" , " auto" );
18781882
18791883#ifdef ENABLE_WALLET
1880- if (gArgs .GetBoolArg (" -mnconflock" , DEFAULT_MNCONFLOCK) && pwalletMain) {
1881- LOCK (pwalletMain->cs_wallet );
1884+ // use only the first wallet here. This section can be removed after transition to DMN
1885+ if (gArgs .GetBoolArg (" -mnconflock" , DEFAULT_MNCONFLOCK) && !vpwallets.empty () && vpwallets[0 ]) {
1886+ LOCK (vpwallets[0 ]->cs_wallet );
18821887 LogPrintf (" Locking Masternodes collateral utxo:\n " );
18831888 uint256 mnTxHash;
18841889 for (const auto & mne : masternodeConfig.getEntries ()) {
18851890 mnTxHash.SetHex (mne.getTxHash ());
18861891 COutPoint outpoint = COutPoint (mnTxHash, (unsigned int ) std::stoul (mne.getOutputIndex ()));
1887- pwalletMain ->LockCoin (outpoint);
1892+ vpwallets[ 0 ] ->LockCoin (outpoint);
18881893 LogPrintf (" Locked collateral, MN: %s, tx hash: %s, output index: %s\n " ,
18891894 mne.getAlias (), mne.getTxHash (), mne.getOutputIndex ());
18901895 }
@@ -1918,11 +1923,13 @@ bool AppInitMain()
19181923
19191924#ifdef ENABLE_WALLET
19201925 {
1921- if (pwalletMain) {
1922- LOCK (pwalletMain->cs_wallet );
1923- LogPrintf (" setKeyPool.size() = %u\n " , pwalletMain ? pwalletMain->GetKeyPoolSize () : 0 );
1924- LogPrintf (" mapWallet.size() = %u\n " , pwalletMain ? pwalletMain->mapWallet .size () : 0 );
1925- LogPrintf (" mapAddressBook.size() = %u\n " , pwalletMain ? pwalletMain->GetAddressBookSize () : 0 );
1926+ int idx = 0 ;
1927+ for (CWalletRef pwallet : vpwallets) {
1928+ LogPrintf (" Wallet %d\n " , idx++);
1929+ LOCK (pwallet->cs_wallet );
1930+ LogPrintf (" setKeyPool.size() = %u\n " , pwallet->GetKeyPoolSize ());
1931+ LogPrintf (" mapWallet.size() = %u\n " , pwallet->mapWallet .size ());
1932+ LogPrintf (" mapAddressBook.size() = %u\n " , pwallet->GetAddressBookSize ());
19261933 }
19271934 }
19281935#endif
@@ -1953,22 +1960,21 @@ bool AppInitMain()
19531960 return UIError (strNodeError);
19541961
19551962#ifdef ENABLE_WALLET
1956- // Generate coins in the background
1957- if (pwalletMain )
1958- GenerateBitcoins (gArgs .GetBoolArg (" -gen" , DEFAULT_GENERATE), pwalletMain , gArgs .GetArg (" -genproclimit" , DEFAULT_GENERATE_PROCLIMIT));
1963+ // Generate coins in the background (disabled on mainnet. use only wallet 0)
1964+ if (!vpwallets. empty () )
1965+ GenerateBitcoins (gArgs .GetBoolArg (" -gen" , DEFAULT_GENERATE), vpwallets[ 0 ] , gArgs .GetArg (" -genproclimit" , DEFAULT_GENERATE_PROCLIMIT));
19591966#endif
19601967
19611968 // ********************************************************* Step 12: finished
19621969
19631970#ifdef ENABLE_WALLET
1964- if (pwalletMain) {
1965- uiInterface.InitMessage (_ (" Reaccepting wallet transactions..." ));
1966- pwalletMain->postInitProcess (scheduler);
1967-
1968- // StakeMiner thread disabled by default on regtest
1969- if (gArgs .GetBoolArg (" -staking" , !Params ().IsRegTestNet () && DEFAULT_STAKING)) {
1970- threadGroup.create_thread (std::bind (&ThreadStakeMinter));
1971- }
1971+ uiInterface.InitMessage (_ (" Reaccepting wallet transactions..." ));
1972+ for (CWalletRef pwallet : vpwallets) {
1973+ pwallet->postInitProcess (scheduler);
1974+ }
1975+ // StakeMiner thread disabled by default on regtest
1976+ if (!vpwallets.empty () && gArgs .GetBoolArg (" -staking" , !Params ().IsRegTestNet () && DEFAULT_STAKING)) {
1977+ threadGroup.create_thread (std::bind (&ThreadStakeMinter));
19721978 }
19731979#endif
19741980
0 commit comments