32 CPubKey seed = spk_man->GenerateNewSeed();
33 spk_man->SetHDSeed(seed);
39 static std::shared_ptr<CWallet>
MakeWallet(
const std::string&
name,
const fs::path& path,
bool create)
49 std::unique_ptr<WalletDatabase> database =
MakeDatabase(path, options, status, error);
60 load_wallet_ret = wallet_instance->LoadWallet(first_run);
61 }
catch (
const std::runtime_error&) {
62 tfm::format(std::cerr,
"Error loading %s. Is wallet being used by another process?\n", name);
67 wallet_instance =
nullptr;
69 tfm::format(std::cerr,
"Error loading %s: Wallet corrupted", name);
72 tfm::format(std::cerr,
"Error reading %s! All keys read correctly, but transaction data"
73 " or address book entries might be missing or incorrect.",
76 tfm::format(std::cerr,
"Error loading %s: Wallet requires newer version of %s",
90 return wallet_instance;
97 tfm::format(std::cout,
"Wallet info\n===========\n");
104 tfm::format(std::cout,
"Transactions: %zu\n", wallet_instance->mapWallet.size());
105 tfm::format(std::cout,
"Address Book: %zu\n", wallet_instance->m_address_book.size());
112 if (command ==
"create") {
113 std::shared_ptr<CWallet> wallet_instance =
MakeWallet(name, path,
true);
114 if (wallet_instance) {
116 wallet_instance->Close();
118 }
else if (command ==
"info" || command ==
"salvage") {
119 if (command ==
"info") {
120 std::shared_ptr<CWallet> wallet_instance =
MakeWallet(name, path,
false);
121 if (!wallet_instance)
return false;
123 wallet_instance->Close();
124 }
else if (command ==
"salvage") {
126 std::vector<bilingual_str> warnings;
129 for (
const auto& warning : warnings) {
132 if (!error.
empty()) {
139 tfm::format(std::cerr,
"Invalid command: %s\n", command);
const std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
void Close()
Close wallet database.
bool IsWalletFlagSet(uint64_t flag) const override
check if a certain wallet flag is set
unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void WalletLogPrintf(std::string fmt, Params...parameters) const
Prepends the wallet name in logging output to ease debugging in multi-wallet use cases.
void SetMinVersion(enum WalletFeature, WalletBatch *batch_in=nullptr) override
signify that a particular wallet feature is now used.
DBErrors
Error statuses for the wallet database.
bool error(const char *fmt, const Args &...args)
fs::path GetWalletDir()
Get the path of the wallet directory.
virtual std::string Format()=0
An encapsulated public key.
LegacyScriptPubKeyMan * GetOrCreateLegacyScriptPubKeyMan()
WalletDatabase & GetDatabase() const override
bool TopUpKeyPool(unsigned int kpSize=0)
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
bool RecoverDatabaseFile(const fs::path &file_path, bilingual_str &error, std::vector< bilingual_str > &warnings)
Indicate that this wallet supports DescriptorScriptPubKeyMan.
std::unique_ptr< WalletDatabase > MakeDatabase(const fs::path &path, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error)