Skip to content

Commit 21693ff

Browse files
committed
wallet: Add WalletLocation utility class
Github-Pull: bitcoin#14350 Rebased-From: 01a4c09
1 parent 1c98a75 commit 21693ff

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/wallet/walletutil.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,14 @@ fs::path GetWalletDir()
2525

2626
return path;
2727
}
28+
29+
WalletLocation::WalletLocation(const std::string& name)
30+
: m_name(name)
31+
, m_path(fs::absolute(name, GetWalletDir()))
32+
{
33+
}
34+
35+
bool WalletLocation::Exists() const
36+
{
37+
return fs::symlink_status(m_path).type() != fs::file_not_found;
38+
}

src/wallet/walletutil.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,24 @@
1111
//! Get the path of the wallet directory.
1212
fs::path GetWalletDir();
1313

14+
//! The WalletLocation class provides wallet information.
15+
class WalletLocation final
16+
{
17+
std::string m_name;
18+
fs::path m_path;
19+
20+
public:
21+
explicit WalletLocation() {}
22+
explicit WalletLocation(const std::string& name);
23+
24+
//! Get wallet name.
25+
const std::string& GetName() const { return m_name; }
26+
27+
//! Get wallet absolute path.
28+
const fs::path& GetPath() const { return m_path; }
29+
30+
//! Return whether the wallet exists.
31+
bool Exists() const;
32+
};
33+
1434
#endif // BITCOIN_WALLET_WALLETUTIL_H

0 commit comments

Comments
 (0)