Skip to content

Commit

Permalink
replace int64_t with CAmount where it stores coins in CreateCoinStake
Browse files Browse the repository at this point in the history
  • Loading branch information
EvgenijM86 committed Mar 14, 2019
1 parent d7fe966 commit ae1cda2
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/wallet/wallet.cpp
Expand Up @@ -4256,7 +4256,6 @@ CTxDestination CWallet::AddAndGetDestinationForScript(const CScript& script, Out


// peercoin: create coin stake transaction
//ppcTODO: replace int64_t with CAmount where it deals with peercoin amounts.
typedef std::vector<unsigned char> valtype;
bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64_t nSearchInterval, CMutableTransaction& txNew)
{
Expand All @@ -4281,22 +4280,22 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
scriptEmpty.clear();
txNew.vout.push_back(CTxOut(0, scriptEmpty));
// Choose coins to use
int64_t nBalance = GetBalance();
int64_t nReserveBalance = 0;
CAmount nBalance = GetBalance();
CAmount nReserveBalance = 0;
if (gArgs.IsArgSet("-reservebalance") && !ParseMoney(gArgs.GetArg("-reservebalance", ""), nReserveBalance))
return error("CreateCoinStake : invalid reserve balance amount");
if (nBalance <= nReserveBalance)
return false;
std::set<CInputCoin> setCoins;
std::vector<CTransactionRef> vwtxPrev;
int64_t nValueIn = 0;
CAmount nValueIn = 0;
std::vector<COutput> vAvailableCoins;
AvailableCoins(vAvailableCoins, true, nullptr, 1, MAX_MONEY, MAX_MONEY, 0, 0, 9999999, txNew.nTime);
if (!SelectCoins(vAvailableCoins, nBalance - nReserveBalance, setCoins, nValueIn, nullptr))
return false;
if (setCoins.empty())
return false;
int64_t nCredit = 0;
CAmount nCredit = 0;
CScript scriptPubKeyKernel;
for (const auto& pcoin : setCoins)
{
Expand Down Expand Up @@ -4434,16 +4433,16 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
if (!GetCoinAge(txNew, view, nCoinAge))
return error("CreateCoinStake : failed to calculate coin age");

int64_t nReward = GetProofOfStakeReward(nCoinAge);
CAmount nReward = GetProofOfStakeReward(nCoinAge);
// Refuse to create mint that has zero or negative reward
if(nReward <= 0) {
return false;
}
nCredit += nReward;
}

int64_t nMinFee = 0;
int64_t nMinFeeBase = (IsProtocolV07(txNew.nTime) ? MIN_TX_FEE : MIN_TX_FEE_PREV7);
CAmount nMinFee = 0;
CAmount nMinFeeBase = (IsProtocolV07(txNew.nTime) ? MIN_TX_FEE : MIN_TX_FEE_PREV7);
while(true)
{
// Set output amount
Expand Down

0 comments on commit ae1cda2

Please sign in to comment.