23 wallet->WalletLogPrintf(
"Releasing wallet\n");
45 std::vector<bilingual_str> warnings;
46 std::unique_ptr<WalletDatabase> database =
MakeDatabase(path, options, status, error);
56 load_wallet_ret = wallet_instance->PopulateWalletFromDB(error, warnings);
57 }
catch (
const std::runtime_error&) {
58 tfm::format(std::cerr,
"Error loading %s. Is wallet being used by another process?\n",
name);
66 for (
const auto &warning : warnings) {
76 return wallet_instance;
83 tfm::format(std::cout,
"Wallet info\n===========\n");
90 tfm::format(std::cout,
"Transactions: %zu\n", wallet_instance->mapWallet.size());
91 tfm::format(std::cout,
"Address Book: %zu\n", wallet_instance->m_address_book.size());
97 std::vector<std::string> details;
104 tfm::format(std::cerr,
"Wallet name must be provided when creating a new wallet.\n");
113 const fs::path& path = *path_res;
117 tfm::format(std::cerr,
"Wallet name cannot be empty\n");
126 const std::shared_ptr<CWallet> wallet_instance =
MakeWallet(
name, path, options);
127 if (wallet_instance) {
129 wallet_instance->Close();
131 }
else if (
command ==
"info") {
135 const std::shared_ptr<CWallet> wallet_instance =
MakeWallet(
name, path, options);
136 if (!wallet_instance)
return false;
138 wallet_instance->Close();
139 }
else if (
command ==
"dump") {
150 std::unique_ptr<WalletDatabase> database =
MakeDatabase(path, options, status, error);
161 tfm::format(std::cout,
"The dumpfile may contain private keys. To ensure the safety of your Bitcoin, do not share the dumpfile.\n");
163 }
else if (
command ==
"createfromdump") {
165 std::vector<bilingual_str> warnings;
167 for (
const auto& warning : warnings) {
#define Assert(val)
Identity function.
bool CheckCommandOptions(const std::string &command, std::vector< std::string > *errors=nullptr) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Check that any command-specific options the user specified are valid for the given command.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Return string argument or default value.
bool IsArgSet(const std::string &strArg) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Return true if the given argument has been manually set.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
bool TopUpKeyPool(unsigned int kpSize=0)
unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
const std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
bool HasEncryptionKeys() const override
void SetupDescriptorScriptPubKeyMans(WalletBatch &batch, const CExtKey &master_key) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Create new DescriptorScriptPubKeyMans and add them to the wallet.
WalletDatabase & GetDatabase() const override
RecursiveMutex cs_wallet
Main wallet lock.
virtual std::string Format()=0
bool IsWalletFlagSet(uint64_t flag) const override
check if a certain wallet flag is set
void InitWalletFlags(uint64_t flags)
overwrite all flags by the given uint64_t flags must be uninitialised (or 0) only known flags may be ...
bilingual_str ErrorString(const Result< T > &result)
std::string MakeUnorderedList(const std::vector< std::string > &items)
Create an unordered multi-line list of items.
void ReadDatabaseArgs(const ArgsManager &args, DatabaseOptions &options)
std::unique_ptr< WalletDatabase > MakeDatabase(const fs::path &path, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error)
DBErrors
Overview of wallet database classes:
bool CreateFromDump(const ArgsManager &args, const std::string &name, const fs::path &wallet_path, bilingual_str &error, std::vector< bilingual_str > &warnings)
bool IsBDBFile(const fs::path &path)
fs::path BDBDataFile(const fs::path &wallet_path)
bool DumpWallet(const ArgsManager &args, WalletDatabase &db, bilingual_str &error)
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.
util::Result< fs::path > GetWalletPath(const std::string &name)
Determine the path that the wallet is stored in.
std::optional< DatabaseFormat > require_format