Permalink
Browse files

Stake For Charity saved to wallet

  • Loading branch information...
Tranz5 committed Aug 31, 2014
1 parent 2ef0266 commit 60434e9ce62b9cc3c786058d8721a6b066e4e959
Showing with 40 additions and 0 deletions.
  1. +14 −0 src/qt/walletmodel.cpp
  2. +1 −0 src/wallet.h
  3. +11 −0 src/walletdb.cpp
  4. +14 −0 src/walletdb.h
View
@@ -386,6 +386,20 @@ void WalletModel::setStakeForCharity(bool fStakeForCharity, int& nStakeForCharit
int64& nStakeForCharityMaxAmount)
{
// This function assumes the values were checked before being called
if (wallet->fFileBacked) // Tranz add option to not save.
{
CWalletDB walletdb(wallet->strWalletFile);
if (wallet->fStakeForCharity) {
walletdb.EraseStakeForCharity(wallet->strStakeForCharityAddress.ToString());
walletdb.WriteStakeForCharity(strStakeForCharityAddress.ToString(), nStakeForCharityPercent );
}
else
walletdb.EraseStakeForCharity(strStakeForCharityAddress.ToString());
if(fDebug)
printf("setStakeForCharity: %s %d\n", strStakeForCharityAddress.ToString().c_str(), nStakeForCharityPercent);
}
{
LOCK(wallet->cs_wallet);
wallet->fStakeForCharity = fStakeForCharity;
View
@@ -222,6 +222,7 @@ class CWallet : public CCryptoKeyStore
typedef std::pair<CWalletTx*, CAccountingEntry*> TxPair;
typedef std::multimap<int64, TxPair > TxItems;
// Tranz: typedef boost::tuple<int64, int64, int64> MyTest;
/** Get the wallet's activity log
@return multimap of ordered transactions and accounting entries
View
@@ -421,6 +421,17 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
{
ssValue >> pwallet->nOrderPosNext;
}
else if (strType == "s4c")
{
string strS4CAccount;
ssKey >> strS4CAccount;
if (CBitcoinAddress(strS4CAccount).IsValid())
{
pwallet->fStakeForCharity = true;
pwallet->strStakeForCharityAddress = CBitcoinAddress(strS4CAccount).Get();
}
ssValue >> pwallet->nStakeForCharityPercent;
}
} catch (...)
{
return false;
View
@@ -165,6 +165,20 @@ class CWalletDB : public CDB
return Write(std::string("minversion"), nVersion);
}
bool WriteStakeForCharity(std::string strStakeForCharityAddress, int nStakeForCharityPercent)
{
nWalletDBUpdated++;
return Write(std::make_pair(std::string("s4c"), strStakeForCharityAddress),nStakeForCharityPercent);
}
bool EraseStakeForCharity(std::string strStakeForCharityAddress)
{
nWalletDBUpdated++;
return Erase(std::make_pair(std::string("s4c"), strStakeForCharityAddress));
}
bool ReadAccount(const std::string& strAccount, CAccount& account);
bool WriteAccount(const std::string& strAccount, const CAccount& account);
private:

0 comments on commit 60434e9

Please sign in to comment.