Permalink
Browse files

Changes to nReserveBalance

Move this to wallet struct.
Start up switch will set all wallets loaded to same
-reservebalance=<amount>.
RPC command will allow individual wallets to be set using the usewallet
<walletname> reservebalance command.
  • Loading branch information...
Tranz5 committed Jul 19, 2014
1 parent c075abb commit 82ae703091a951e165191e6a55b6634c6f3e9420
Showing with 36 additions and 27 deletions.
  1. +27 −9 src/init.cpp
  2. +4 −7 src/rpcwallet.cpp
  3. +1 −11 src/wallet.cpp
  4. +4 −0 src/wallet.h
View
@@ -756,15 +756,7 @@ bool AppInit2()
}
}
if (mapArgs.count("-reservebalance")) // ppcoin: reserve balance amount
{
int64 nReserveBalance = 0;
if (!ParseMoney(mapArgs["-reservebalance"], nReserveBalance))
{
InitError(_("Invalid amount for -reservebalance=<amount>"));
return false;
}
}
if (mapArgs.count("-checkpointkey")) // ppcoin: checkpoint master priv key
{
@@ -849,6 +841,32 @@ bool AppInit2()
TimerThread::StartTimer(); // for walletpassphrase unlock
if (!LoadWallets(strErrors)) return false;
if (mapArgs.count("-reservebalance"))
{
int64 nReserveBalance = 0;
if (!ParseMoney(mapArgs["-reservebalance"], nReserveBalance))
InitError(_("Invalid amount for -reservebalance=<amount>"));
else
{
// Set the reservebalance the same for each wallet that was loaded.
// Individual Wallets can be set using the rpc command after loading is complete
vector<string> vstrNames;
vector<boost::shared_ptr<CWallet> > vpWallets;
BOOST_FOREACH(const wallet_map::value_type& item, pWalletManager->GetWalletMap())
{
vstrNames.push_back(item.first);
vpWallets.push_back(item.second);
}
for (unsigned int i = 0; i < vstrNames.size(); i++)
{
vpWallets[i]->nReserveBalance = nReserveBalance;
}
}
}
// ********************************************************* Step 9: import blocks
if (mapArgs.count("-loadblock"))
View
@@ -1755,22 +1755,19 @@ Value reservebalance(CWallet* pWallet, const Array& params, bool fHelp)
nAmount = (nAmount / CENT) * CENT; // round to cent
if (nAmount < 0)
throw runtime_error("amount cannot be negative.\n");
mapArgs["-reservebalance"] = FormatMoney(nAmount).c_str();
pWallet->nReserveBalance = nAmount;
}
else
{
if (params.size() > 1)
throw runtime_error("cannot specify amount to turn off reserve.\n");
mapArgs["-reservebalance"] = "0";
pWallet->nReserveBalance = 0 ;
}
}
Object result;
int64 nReserveBalance = 0;
if (mapArgs.count("-reservebalance") && !ParseMoney(mapArgs["-reservebalance"], nReserveBalance))
throw runtime_error("invalid reserve balance amount\n");
result.push_back(Pair("reserve", (nReserveBalance > 0)));
result.push_back(Pair("amount", ValueFromAmount(nReserveBalance)));
result.push_back(Pair("reserve", (pWallet->nReserveBalance > 0)));
result.push_back(Pair("amount", ValueFromAmount(pWallet->nReserveBalance)));
return result;
}
View
@@ -1562,15 +1562,9 @@ bool CWallet::GetStakeWeight(const CKeyStore& keystore, uint64& nMinWeight, uint
{
// Choose coins to use
int64 nBalance = GetBalance();
int64 nReserveBalance = 0;
nMinWeight = nMaxWeight = nWeight = 0;
if (mapArgs.count("-reservebalance") && !ParseMoney(mapArgs["-reservebalance"], nReserveBalance))
{
error("GetStakeWeight : invalid reserve balance amount");
return false;
}
nMinWeight = nMaxWeight = nWeight = 0;
if (nBalance <= nReserveBalance)
return false;
@@ -1651,10 +1645,6 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
// Choose coins to use
int64 nBalance = GetBalance();
int64 nReserveBalance = 0;
if (mapArgs.count("-reservebalance") && !ParseMoney(mapArgs["-reservebalance"], nReserveBalance))
return error("CreateCoinStake : invalid reserve balance amount");
if (nBalance <= nReserveBalance)
return false;
View
@@ -115,6 +115,8 @@ class CWallet : public CCryptoKeyStore
int nStakeForCharityPercent;
CBitcoinAddress StakeForCharityAddress;
std::string strWalletFile;
int64 nReserveBalance;
std::set<int64> setKeyPool;
@@ -140,6 +142,7 @@ class CWallet : public CCryptoKeyStore
fStakeForCharity = false;
nStakeForCharityPercent = 0;
StakeForCharityAddress = "";
nReserveBalance = 0;
}
CWallet(std::string strWalletFileIn)
{
@@ -157,6 +160,7 @@ class CWallet : public CCryptoKeyStore
fStakeForCharity = false;
nStakeForCharityPercent = 0;
StakeForCharityAddress = "";
nReserveBalance = 0;
}

0 comments on commit 82ae703

Please sign in to comment.