Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallettool.cpp
Show All 25 Lines | |||||
static std::shared_ptr<CWallet> CreateWallet(const std::string &name, | static std::shared_ptr<CWallet> CreateWallet(const std::string &name, | ||||
const fs::path &path) { | const fs::path &path) { | ||||
if (fs::exists(path)) { | if (fs::exists(path)) { | ||||
tfm::format(std::cerr, "Error: File exists already\n"); | tfm::format(std::cerr, "Error: File exists already\n"); | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
// dummy chain interface | // dummy chain interface | ||||
std::shared_ptr<CWallet> wallet_instance( | std::shared_ptr<CWallet> wallet_instance( | ||||
new CWallet(Params(), nullptr /* chain */, WalletLocation(name), | new CWallet(nullptr /* chain */, WalletLocation(name), | ||||
WalletDatabase::Create(path)), | WalletDatabase::Create(path)), | ||||
WalletToolReleaseWallet); | WalletToolReleaseWallet); | ||||
LOCK(wallet_instance->cs_wallet); | LOCK(wallet_instance->cs_wallet); | ||||
bool first_run = true; | bool first_run = true; | ||||
DBErrors load_wallet_ret = wallet_instance->LoadWallet(first_run); | DBErrors load_wallet_ret = wallet_instance->LoadWallet(first_run); | ||||
if (load_wallet_ret != DBErrors::LOAD_OK) { | if (load_wallet_ret != DBErrors::LOAD_OK) { | ||||
tfm::format(std::cerr, "Error creating %s", name); | tfm::format(std::cerr, "Error creating %s", name); | ||||
return nullptr; | return nullptr; | ||||
Show All 15 Lines | static std::shared_ptr<CWallet> LoadWallet(const std::string &name, | ||||
const fs::path &path) { | const fs::path &path) { | ||||
if (!fs::exists(path)) { | if (!fs::exists(path)) { | ||||
tfm::format(std::cerr, "Error: Wallet files does not exist\n"); | tfm::format(std::cerr, "Error: Wallet files does not exist\n"); | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
// dummy chain interface | // dummy chain interface | ||||
std::shared_ptr<CWallet> wallet_instance( | std::shared_ptr<CWallet> wallet_instance( | ||||
new CWallet(Params(), nullptr /* chain */, WalletLocation(name), | new CWallet(nullptr /* chain */, WalletLocation(name), | ||||
WalletDatabase::Create(path)), | WalletDatabase::Create(path)), | ||||
WalletToolReleaseWallet); | WalletToolReleaseWallet); | ||||
DBErrors load_wallet_ret; | DBErrors load_wallet_ret; | ||||
try { | try { | ||||
bool first_run; | bool first_run; | ||||
load_wallet_ret = wallet_instance->LoadWallet(first_run); | load_wallet_ret = wallet_instance->LoadWallet(first_run); | ||||
} catch (const std::runtime_error &) { | } catch (const std::runtime_error &) { | ||||
tfm::format( | tfm::format( | ||||
▲ Show 20 Lines • Show All 110 Lines • Show Last 20 Lines |