mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
wallet: Add AddWallet, RemoveWallet, GetWallet and GetWallets
With these new functions all vpwallets usage are removed and vpwallets is now a static variable (no external linkage).
This commit is contained in:
@@ -28,12 +28,45 @@
|
||||
#include <utilmoneystr.h>
|
||||
#include <wallet/fees.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
#include <future>
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
|
||||
std::vector<CWallet*> vpwallets;
|
||||
static std::vector<CWallet*> vpwallets;
|
||||
|
||||
bool AddWallet(CWallet* wallet)
|
||||
{
|
||||
assert(wallet);
|
||||
std::vector<CWallet*>::const_iterator i = std::find(vpwallets.begin(), vpwallets.end(), wallet);
|
||||
if (i != vpwallets.end()) return false;
|
||||
vpwallets.push_back(wallet);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RemoveWallet(CWallet* wallet)
|
||||
{
|
||||
assert(wallet);
|
||||
std::vector<CWallet*>::iterator i = std::find(vpwallets.begin(), vpwallets.end(), wallet);
|
||||
if (i == vpwallets.end()) return false;
|
||||
vpwallets.erase(i);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<CWallet*> GetWallets()
|
||||
{
|
||||
return vpwallets;
|
||||
}
|
||||
|
||||
CWallet* GetWallet(const std::string& name)
|
||||
{
|
||||
for (CWallet* wallet : vpwallets) {
|
||||
if (wallet->GetName() == name) return wallet;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** Transaction fee set by the user */
|
||||
CFeeRate payTxFee(DEFAULT_TRANSACTION_FEE);
|
||||
unsigned int nTxConfirmTarget = DEFAULT_TX_CONFIRM_TARGET;
|
||||
|
||||
Reference in New Issue
Block a user