Skip to content

Commit

Permalink
wallet: Disable missing account warning in benchmarks.
Browse files Browse the repository at this point in the history
  • Loading branch information
tecnovert committed Jun 13, 2024
1 parent 63c3b78 commit d11471a
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/bench/particl_add_tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static std::shared_ptr<CHDWallet> CreateTestWallet(wallet::WalletContext& wallet
std::vector<bilingual_str> 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<CHDWallet>(wallet);
}
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/hdwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,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());
Expand Down
5 changes: 4 additions & 1 deletion src/wallet/hdwallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ class TxValidationState;
class CHDWallet : public wallet::CWallet
{
public:
CHDWallet(interfaces::Chain* chain, const std::string& name, std::unique_ptr<WalletDatabase> database) : CWallet(chain, name, std::move(database))
CHDWallet(interfaces::Chain* chain, const std::string& name, std::unique_ptr<WalletDatabase> 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);
}
Expand Down Expand Up @@ -580,6 +581,8 @@ class CHDWallet : public wallet::CWallet

std::map<CKeyID, uint32_t> 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);

Expand Down
1 change: 1 addition & 0 deletions src/wallet/test/hdwallet_test_fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CHDWallet>(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();
Expand Down
4 changes: 2 additions & 2 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3092,7 +3092,7 @@ std::unique_ptr<WalletDatabase> MakeWalletDatabase(const std::string& name, cons
return MakeDatabase(wallet_path, options, status, error_string);
}

std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::string& name, std::unique_ptr<WalletDatabase> database, uint64_t wallet_creation_flags, bilingual_str& error, std::vector<bilingual_str>& warnings)
std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::string& name, std::unique_ptr<WalletDatabase> database, uint64_t wallet_creation_flags, bilingual_str& error, std::vector<bilingual_str>& warnings, bool warn_no_active_acc)
{
interfaces::Chain* chain = context.chain;
ArgsManager& args = *Assert(context.args);
Expand All @@ -3102,7 +3102,7 @@ std::shared_ptr<CWallet> 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<CWallet> walletInstance(fParticlMode
? std::shared_ptr<CWallet>(new CHDWallet(chain, name, std::move(database)), ReleaseWallet)
? std::shared_ptr<CWallet>(new CHDWallet(chain, name, std::move(database), warn_no_active_acc), ReleaseWallet)
: std::shared_ptr<CWallet>(new CWallet(chain, name, std::move(database)), ReleaseWallet));

walletInstance->m_keypool_size = std::max(args.GetIntArg("-keypool", DEFAULT_KEYPOOL_SIZE), int64_t{1});
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,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<CWallet> Create(WalletContext& context, const std::string& name, std::unique_ptr<WalletDatabase> database, uint64_t wallet_creation_flags, bilingual_str& error, std::vector<bilingual_str>& warnings);
static std::shared_ptr<CWallet> Create(WalletContext& context, const std::string& name, std::unique_ptr<WalletDatabase> database, uint64_t wallet_creation_flags, bilingual_str& error, std::vector<bilingual_str>& warnings, bool warn_no_active_acc=true);

/**
* Wallet post-init setup
Expand Down

0 comments on commit d11471a

Please sign in to comment.