mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-12 15:03:18 +02:00
wallettool: Use GetWalletPath to determine the wallet path
Instead of computing the path separately, use GetWalletPath to use the behavior and error checking of the typical wallet path computation.
This commit is contained in:
@@ -2940,7 +2940,7 @@ bool CWallet::EraseAddressReceiveRequest(WalletBatch& batch, const CTxDestinatio
|
||||
return true;
|
||||
}
|
||||
|
||||
static util::Result<fs::path> GetWalletPath(const std::string& name)
|
||||
util::Result<fs::path> GetWalletPath(const std::string& name)
|
||||
{
|
||||
const fs::path name_path = fs::PathFromString(name);
|
||||
|
||||
|
||||
@@ -1150,6 +1150,9 @@ struct MigrationResult {
|
||||
[[nodiscard]] util::Result<MigrationResult> MigrateLegacyToDescriptor(const std::string& wallet_name, const SecureString& passphrase, WalletContext& context);
|
||||
//! Requirement: The wallet provided to this function must be isolated, with no attachment to the node's context.
|
||||
[[nodiscard]] util::Result<MigrationResult> MigrateLegacyToDescriptor(std::shared_ptr<CWallet> local_wallet, const SecureString& passphrase, WalletContext& context);
|
||||
|
||||
//! Determine the path that the wallet is stored in
|
||||
util::Result<fs::path> GetWalletPath(const std::string& name);
|
||||
} // namespace wallet
|
||||
|
||||
#endif // BITCOIN_WALLET_WALLET_H
|
||||
|
||||
@@ -102,7 +102,12 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command)
|
||||
return false;
|
||||
}
|
||||
const std::string name = args.GetArg("-wallet", "");
|
||||
const fs::path path = fsbridge::AbsPathJoin(GetWalletDir(), fs::PathFromString(name));
|
||||
util::Result<fs::path> path_res = GetWalletPath(name);
|
||||
if (!path_res) {
|
||||
tfm::format(std::cerr, "%s\n", util::ErrorString(path_res).original);
|
||||
return false;
|
||||
}
|
||||
const fs::path& path = *path_res;
|
||||
|
||||
if (command == "create") {
|
||||
if (name.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user