diff --git a/src/bench/particl_add_tx.cpp b/src/bench/particl_add_tx.cpp index c51397997e87b..8a77bf20a3bab 100644 --- a/src/bench/particl_add_tx.cpp +++ b/src/bench/particl_add_tx.cpp @@ -128,7 +128,7 @@ static std::shared_ptr CreateTestWallet(wallet::WalletContext& wallet std::vector warnings; options.create_flags = WALLET_FLAG_BLANK_WALLET; auto database = MakeWalletDatabase(wallet_name, options, status, error); - auto wallet = CWallet::Create(wallet_context, wallet_name, std::move(database), options.create_flags, error, warnings); + auto wallet = CWallet::Create(wallet_context, wallet_name, std::move(database), options.create_flags, error, warnings, /*warn_no_active_acc*/ false); return std::static_pointer_cast(wallet); } diff --git a/src/wallet/hdwallet.cpp b/src/wallet/hdwallet.cpp index 1f4c068130845..89cfc84a7d026 100644 --- a/src/wallet/hdwallet.cpp +++ b/src/wallet/hdwallet.cpp @@ -1633,7 +1633,7 @@ DBErrors CHDWallet::LoadWallet() */ } } - if (idDefaultAccount.IsNull() && m_chain) { // If !m_chain, probably running from particl-wallet + if (idDefaultAccount.IsNull() && m_chain && m_warn_no_active_acc) { // If !m_chain, probably running from particl-wallet std::string sWarning = "Warning: Wallet " + GetName() + " has no active account, please view the readme."; #ifndef ENABLE_QT tfm::format(std::cout, "%s\n", sWarning.c_str()); diff --git a/src/wallet/hdwallet.h b/src/wallet/hdwallet.h index 231c9ede717aa..0b4a8ad35bdb0 100644 --- a/src/wallet/hdwallet.h +++ b/src/wallet/hdwallet.h @@ -40,8 +40,9 @@ class TxValidationState; class CHDWallet : public wallet::CWallet { public: - CHDWallet(interfaces::Chain* chain, const std::string& name, std::unique_ptr database) : CWallet(chain, name, std::move(database)) + CHDWallet(interfaces::Chain* chain, const std::string& name, std::unique_ptr database, bool warn_no_active_acc=true) : CWallet(chain, name, std::move(database)) { + m_warn_no_active_acc = warn_no_active_acc; m_default_address_type = OutputType::LEGACY; // In Particl segwit is enabled for all types m_fallback_fee = CFeeRate(DEFAULT_FALLBACK_FEE_PART); } @@ -581,6 +582,8 @@ class CHDWallet : public wallet::CWallet std::map m_derived_keys; // Allows multiple provisional derivations from the same extkey + bool m_warn_no_active_acc{true}; + private: void ParseAddressForMetaData(const CTxDestination &addr, COutputRecord &rec); diff --git a/src/wallet/test/hdwallet_test_fixture.cpp b/src/wallet/test/hdwallet_test_fixture.cpp index c2d9eba182f1b..a7e4dcf0ae6f6 100644 --- a/src/wallet/test/hdwallet_test_fixture.cpp +++ b/src/wallet/test/hdwallet_test_fixture.cpp @@ -24,6 +24,7 @@ HDWalletTestingSetup::HDWalletTestingSetup(const ChainType chain_type): m_wallet_loader{interfaces::MakeWalletLoader(*m_node.chain, *Assert(m_node.args))} { pwalletMain = std::make_shared(m_node.chain.get(), "", CreateMockWalletDatabaseBDB()); + pwalletMain->m_warn_no_active_acc = false; WalletContext& wallet_context = *m_wallet_loader->context(); AddWallet(wallet_context, pwalletMain); pwalletMain->LoadWallet(); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 8d9f07eb10b3d..4cf09d5cf15ec 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3044,7 +3044,7 @@ std::unique_ptr MakeWalletDatabase(const std::string& name, cons return MakeDatabase(wallet_path, options, status, error_string); } -std::shared_ptr CWallet::Create(WalletContext& context, const std::string& name, std::unique_ptr database, uint64_t wallet_creation_flags, bilingual_str& error, std::vector& warnings) +std::shared_ptr CWallet::Create(WalletContext& context, const std::string& name, std::unique_ptr database, uint64_t wallet_creation_flags, bilingual_str& error, std::vector& warnings, bool warn_no_active_acc) { interfaces::Chain* chain = context.chain; ArgsManager& args = *Assert(context.args); @@ -3054,7 +3054,7 @@ std::shared_ptr CWallet::Create(WalletContext& context, const std::stri // TODO: Can't use std::make_shared because we need a custom deleter but // should be possible to use std::allocate_shared. std::shared_ptr walletInstance(fParticlMode - ? std::shared_ptr(new CHDWallet(chain, name, std::move(database)), ReleaseWallet) + ? std::shared_ptr(new CHDWallet(chain, name, std::move(database), warn_no_active_acc), ReleaseWallet) : std::shared_ptr(new CWallet(chain, name, std::move(database)), ReleaseWallet)); walletInstance->m_keypool_size = std::max(args.GetIntArg("-keypool", DEFAULT_KEYPOOL_SIZE), int64_t{1}); diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index ae91b11a62834..8ad90b922a645 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -962,7 +962,7 @@ friend class CWalletTx; bool MarkReplaced(const uint256& originalHash, const uint256& newHash); /* Initializes the wallet, returns a new CWallet instance or a null pointer in case of an error */ - static std::shared_ptr Create(WalletContext& context, const std::string& name, std::unique_ptr database, uint64_t wallet_creation_flags, bilingual_str& error, std::vector& warnings); + static std::shared_ptr Create(WalletContext& context, const std::string& name, std::unique_ptr database, uint64_t wallet_creation_flags, bilingual_str& error, std::vector& warnings, bool warn_no_active_acc=true); /** * Wallet post-init setup