Permalink
Browse files

Make sure wallet is filebacked before writing S4C

  • Loading branch information...
Tranz5 committed Sep 6, 2014
1 parent e5cdb6d commit a19920fdc82d0ef9865275922f0547b67f7395ea
Showing with 14 additions and 7 deletions.
  1. +8 −4 src/qt/walletmodel.cpp
  2. +6 −3 src/rpcwallet.cpp
View
@@ -390,12 +390,16 @@ void WalletModel::setStakeForCharity(bool fStakeForCharity, int& nStakeForCharit
{
CWalletDB walletdb(wallet->strWalletFile);
if (fStakeForCharity) {
walletdb.EraseStakeForCharity(wallet->strStakeForCharityAddress.ToString());
walletdb.WriteStakeForCharity(strStakeForCharityAddress.ToString(), nStakeForCharityPercent );
if(wallet->fFileBacked) {
walletdb.EraseStakeForCharity(wallet->strStakeForCharityAddress.ToString());
walletdb.WriteStakeForCharity(strStakeForCharityAddress.ToString(), nStakeForCharityPercent );
}
}
else {
walletdb.EraseStakeForCharity(wallet->strStakeForCharityAddress.ToString());
walletdb.EraseStakeForCharity(strStakeForCharityAddress.ToString());
if(wallet->fFileBacked) {
walletdb.EraseStakeForCharity(wallet->strStakeForCharityAddress.ToString());
walletdb.EraseStakeForCharity(strStakeForCharityAddress.ToString());
}
}
if(fDebug)
View
@@ -278,7 +278,8 @@ Value stakeforcharity(CWallet *pWallet, const Array &params, bool fHelp)
pWallet->nStakeForCharityMin = nMinAmount;
pWallet->nStakeForCharityMax = nMaxAmount;
walletdb.EraseStakeForCharity(pWallet->strStakeForCharityAddress.ToString());
if(pWallet->fFileBacked)
walletdb.EraseStakeForCharity(pWallet->strStakeForCharityAddress.ToString());
pWallet->strStakeForCharityAddress = "";
@@ -290,7 +291,8 @@ Value stakeforcharity(CWallet *pWallet, const Array &params, bool fHelp)
nPer = 50;
// Future: These will be an array of addr/per/wallet
walletdb.EraseStakeForCharity(pWallet->strStakeForCharityAddress.ToString());
if(pWallet->fFileBacked)
walletdb.EraseStakeForCharity(pWallet->strStakeForCharityAddress.ToString());
pWallet->strStakeForCharityAddress = address;
pWallet->nStakeForCharityPercent = nPer;
@@ -299,7 +301,8 @@ Value stakeforcharity(CWallet *pWallet, const Array &params, bool fHelp)
pWallet->fStakeForCharity = true;
fGlobalStakeForCharity = true;
walletdb.WriteStakeForCharity(address.ToString(), nPer);
if(pWallet->fFileBacked)
walletdb.WriteStakeForCharity(address.ToString(), nPer);
}
return Value::null;

0 comments on commit a19920f

Please sign in to comment.