Skip to content

Commit 6d3af3a

Browse files
committed
wallettool: pass in DatabaseOptions into MakeWallet
1 parent fa8dd34 commit 6d3af3a

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/wallet/wallettool.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,9 @@ static void WalletCreate(CWallet* wallet_instance)
3636
wallet_instance->TopUpKeyPool();
3737
}
3838

39-
static std::shared_ptr<CWallet> MakeWallet(const std::string& name, const fs::path& path, bool create)
39+
static std::shared_ptr<CWallet> MakeWallet(const std::string& name, const fs::path& path, DatabaseOptions options)
4040
{
41-
DatabaseOptions options;
4241
DatabaseStatus status;
43-
if (create) {
44-
options.require_create = true;
45-
} else {
46-
options.require_existing = true;
47-
}
4842
bilingual_str error;
4943
std::unique_ptr<WalletDatabase> database = MakeDatabase(path, options, status, error);
5044
if (!database) {
@@ -85,7 +79,7 @@ static std::shared_ptr<CWallet> MakeWallet(const std::string& name, const fs::pa
8579
}
8680
}
8781

88-
if (create) WalletCreate(wallet_instance.get());
82+
if (options.require_create) WalletCreate(wallet_instance.get());
8983

9084
return wallet_instance;
9185
}
@@ -110,14 +104,18 @@ bool ExecuteWalletToolFunc(const std::string& command, const std::string& name)
110104
fs::path path = fs::absolute(name, GetWalletDir());
111105

112106
if (command == "create") {
113-
std::shared_ptr<CWallet> wallet_instance = MakeWallet(name, path, /* create= */ true);
107+
DatabaseOptions options;
108+
options.require_create = true;
109+
std::shared_ptr<CWallet> wallet_instance = MakeWallet(name, path, options);
114110
if (wallet_instance) {
115111
WalletShowInfo(wallet_instance.get());
116112
wallet_instance->Close();
117113
}
118114
} else if (command == "info" || command == "salvage") {
119115
if (command == "info") {
120-
std::shared_ptr<CWallet> wallet_instance = MakeWallet(name, path, /* create= */ false);
116+
DatabaseOptions options;
117+
options.require_existing = true;
118+
std::shared_ptr<CWallet> wallet_instance = MakeWallet(name, path, options);
121119
if (!wallet_instance) return false;
122120
WalletShowInfo(wallet_instance.get());
123121
wallet_instance->Close();

0 commit comments

Comments
 (0)