Skip to content
Permalink
Browse files

[Supply] Calc burnt/unspendable coins and subtract from nmoneysupply

  • Loading branch information...
akshaynexus committed Jul 7, 2019
1 parent 7946315 commit ca1c899610d90f433d12535fdacc845d8f54963a
Showing with 22 additions and 14 deletions.
  1. +9 −13 src/main.cpp
  2. +11 −0 src/primitives/transaction.cpp
  3. +2 −1 src/primitives/transaction.h
@@ -2901,18 +2901,6 @@ bool RecalculateDOGECSupply(int nHeightStart)
pindex->nMoneySupply -= nLocked;
LogPrintf("%s : Removing locked from supply - %s : supply=%s\n", __func__, FormatMoney(nLocked), FormatMoney(pindex->nMoneySupply));
}
//Rewrite moneysupply for burns
if(pindex->nHeight == 2195){
//500k DOGEC Burnt in tx f9c851fddc613db8ce3469b88faa28c373ed7881a752d4aac28a0463cd42db8e
pindex->nMoneySupply -= 500000 * COIN;

}
if(pindex->nHeight == 2216){
//717,064.07 DOGEC Burnt in tx 243e04d31933a998462b4f13f013cfa97e994a8d82141c7a9ce1d6ff45d58588
pindex->nMoneySupply -= 717064.07 * COIN;

}

assert(pblocktree->WriteBlockIndex(CDiskBlockIndex(pindex)));

if (pindex->nHeight < chainActive.Height())
@@ -3125,6 +3113,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
CBlockUndo blockundo;
blockundo.vtxundo.reserve(block.vtx.size() - 1);
CAmount nValueOut = 0;
CAmount nValueOutUnspendable = 0;

CAmount nValueIn = 0;
unsigned int nMaxBlockSigOps = MAX_BLOCK_SIGOPS_CURRENT + 4000;
vector<uint256> vSpendsInBlock;
@@ -3235,6 +3225,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
control.Add(vChecks);
}
nValueOut += tx.GetValueOut();
// Unspendable UTXOs (like coins burned) will be subtracted from nMoneySupply
nValueOutUnspendable += tx.GetValueOutUnspendable();

CTxUndo undoDummy;
if (i > 0) {
@@ -3261,8 +3253,12 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
// track money supply and mint amount info
CAmount nMoneySupplyPrev = pindex->pprev ? pindex->pprev->nMoneySupply : 0;
pindex->nMoneySupply = nMoneySupplyPrev + nValueOut - nValueIn;
// Subtract from the money supply the unspendable UTXO
pindex->nMoneySupply -= nValueOutUnspendable;
pindex->nMint = pindex->nMoneySupply - nMoneySupplyPrev + nFees;

// Unspendable Value (coins burn) can cause a negative nMint value
if (pindex->nMint < 0)
pindex->nMint = 0;
// LogPrintf("XX69----------> ConnectBlock(): nValueOut: %s, nValueIn: %s, nFees: %s, nMint: %s zdogecSpent: %s\n",
// FormatMoney(nValueOut), FormatMoney(nValueIn),
// FormatMoney(nFees), FormatMoney(pindex->nMint), FormatMoney(nAmountZerocoinSpent));
@@ -176,6 +176,17 @@ CAmount CTransaction::GetValueOut() const
return nValueOut;
}

CAmount CTransaction::GetValueOutUnspendable() const
{
CAmount nValueOut = 0;
for (std::vector<CTxOut>::const_iterator it(vout.begin()); it != vout.end(); ++it)
{
if( !it->IsNull() && !it->IsEmpty() && it->scriptPubKey.IsUnspendable() )
nValueOut += it->nValue;
}
return nValueOut;
}

CAmount CTransaction::GetZerocoinMinted() const
{
for (const CTxOut& txOut : vout) {
@@ -252,7 +252,8 @@ class CTransaction
CAmount GetValueOut() const;
// GetValueIn() is a method on CCoinsViewCache, because
// inputs must be known to compute value in.

// Return sum of unspendable txouts .
CAmount GetValueOutUnspendable() const;
// Compute priority, given priority of inputs and (optionally) tx size
double ComputePriority(double dPriorityInputs, unsigned int nTxSize=0) const;

0 comments on commit ca1c899

Please sign in to comment.
You can’t perform that action at this time.