Skip to content

Commit d1b03b8

Browse files
committed
interfaces: Add getWalletDir and listWalletDir to Node
1 parent fc4db35 commit d1b03b8

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

src/dummywallet.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ void DummyWalletInit::AddWalletOptions() const
3434

3535
const WalletInitInterface& g_wallet_init_interface = DummyWalletInit();
3636

37+
fs::path GetWalletDir()
38+
{
39+
throw std::logic_error("Wallet function called in non-wallet build.");
40+
}
41+
42+
std::vector<fs::path> ListWalletDir()
43+
{
44+
throw std::logic_error("Wallet function called in non-wallet build.");
45+
}
46+
3747
std::vector<std::shared_ptr<CWallet>> GetWallets()
3848
{
3949
throw std::logic_error("Wallet function called in non-wallet build.");

src/interfaces/node.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
#include <univalue.h>
3939

4040
class CWallet;
41+
fs::path GetWalletDir();
42+
std::vector<fs::path> ListWalletDir();
4143
std::vector<std::shared_ptr<CWallet>> GetWallets();
4244

4345
namespace interfaces {
@@ -218,6 +220,18 @@ class NodeImpl : public Node
218220
LOCK(::cs_main);
219221
return ::pcoinsTip->GetCoin(output, coin);
220222
}
223+
std::string getWalletDir() override
224+
{
225+
return GetWalletDir().string();
226+
}
227+
std::vector<std::string> listWalletDir() override
228+
{
229+
std::vector<std::string> paths;
230+
for (auto& path : ListWalletDir()) {
231+
paths.push_back(path.string());
232+
}
233+
return paths;
234+
}
221235
std::vector<std::unique_ptr<Wallet>> getWallets() override
222236
{
223237
std::vector<std::unique_ptr<Wallet>> wallets;

src/interfaces/node.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ class Node
173173
//! Get unspent outputs associated with a transaction.
174174
virtual bool getUnspentOutput(const COutPoint& output, Coin& coin) = 0;
175175

176+
//! Return default wallet directory.
177+
virtual std::string getWalletDir() = 0;
178+
179+
//! Return available wallets in wallet directory.
180+
virtual std::vector<std::string> listWalletDir() = 0;
181+
176182
//! Return interfaces for accessing wallets (if any).
177183
virtual std::vector<std::unique_ptr<Wallet>> getWallets() = 0;
178184

0 commit comments

Comments
 (0)