mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
Merge 0ae0aa251b into merged_master (Bitcoin PR bitcoin/bitcoin#24678)
This commit is contained in:
commit
ef90df8f7e
3 changed files with 12 additions and 5 deletions
|
|
@ -64,12 +64,11 @@ std::shared_ptr<CWallet> GetWalletForJSONRPCRequest(const JSONRPCRequest& reques
|
|||
return pwallet;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<CWallet>> wallets = GetWallets(context);
|
||||
if (wallets.size() == 1) {
|
||||
return wallets[0];
|
||||
}
|
||||
size_t count{0};
|
||||
auto wallet = GetDefaultWallet(context, count);
|
||||
if (wallet) return wallet;
|
||||
|
||||
if (wallets.empty()) {
|
||||
if (count == 0) {
|
||||
throw JSONRPCError(
|
||||
RPC_WALLET_NOT_FOUND, "No wallet is loaded. Load a wallet using loadwallet or create a new one with createwallet. (Note: A default wallet is no longer automatically created)");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,6 +159,13 @@ std::vector<std::shared_ptr<CWallet>> GetWallets(WalletContext& context)
|
|||
return context.wallets;
|
||||
}
|
||||
|
||||
std::shared_ptr<CWallet> GetDefaultWallet(WalletContext& context, size_t& count)
|
||||
{
|
||||
LOCK(context.wallets_mutex);
|
||||
count = context.wallets.size();
|
||||
return count == 1 ? context.wallets[0] : nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<CWallet> GetWallet(WalletContext& context, const std::string& name)
|
||||
{
|
||||
LOCK(context.wallets_mutex);
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ bool AddWallet(WalletContext& context, const std::shared_ptr<CWallet>& wallet);
|
|||
bool RemoveWallet(WalletContext& context, const std::shared_ptr<CWallet>& wallet, std::optional<bool> load_on_start, std::vector<bilingual_str>& warnings);
|
||||
bool RemoveWallet(WalletContext& context, const std::shared_ptr<CWallet>& wallet, std::optional<bool> load_on_start);
|
||||
std::vector<std::shared_ptr<CWallet>> GetWallets(WalletContext& context);
|
||||
std::shared_ptr<CWallet> GetDefaultWallet(WalletContext& context, size_t& count);
|
||||
std::shared_ptr<CWallet> GetWallet(WalletContext& context, const std::string& name);
|
||||
std::shared_ptr<CWallet> LoadWallet(WalletContext& context, const std::string& name, std::optional<bool> load_on_start, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error, std::vector<bilingual_str>& warnings);
|
||||
std::shared_ptr<CWallet> CreateWallet(WalletContext& context, const std::string& name, std::optional<bool> load_on_start, DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error, std::vector<bilingual_str>& warnings);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue