Skip to content

Commit

Permalink
Prevent sending the same S4C twice.
Browse files Browse the repository at this point in the history
happens during a rollback.
  • Loading branch information
Tranz5 committed Sep 29, 2014
1 parent 97e7d2e commit 8c418a4
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,8 @@ int64 CWallet::GetNewMint() const


bool fGlobalStakeForCharity = false;
int64 nPrevS4CNet = 0;
int nPrevS4CHeight = 0;

bool CWallet::StakeForCharity()
{
Expand All @@ -1243,9 +1245,19 @@ bool CWallet::StakeForCharity()
printf("StakeForCharity: Amount: %s is not in range of Min: %s and Max:%s\n",FormatMoney(nNet).c_str(),FormatMoney(nStakeForCharityMin).c_str(),FormatMoney(nStakeForCharityMax).c_str());
return false;
}

printf("StakeForCharity Sending: %s to Address: %s\n", FormatMoney(nNet).c_str(), strStakeForCharityAddress.ToString().c_str());
SendMoneyToDestination(strStakeForCharityAddress.Get(), nNet, wtx, false, true);
if (nPrevS4CNet == nNet && nBestHeight <= nPrevS4CHeight ) {
printf("StakeForCharity Warning. nNet: %s equals nPrevS4CNet: %s. and nBestHeight %d less or equal to nPreveS4CHeight %d.\n",
FormatMoney(nNet).c_str(),
FormatMoney(nPrevS4CNet).c_str(),
nBestHeight,
nPrevS4CHeight);
return false;
} else {
printf("StakeForCharity Sending: %s to Address: %s\n", FormatMoney(nNet).c_str(), strStakeForCharityAddress.ToString().c_str());
SendMoneyToDestination(strStakeForCharityAddress.Get(), nNet, wtx, false, true);
nPrevS4CNet = nNet;
nPrevS4CHeight = nBestHeight;
}
}

}
Expand Down

0 comments on commit 8c418a4

Please sign in to comment.