Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BuzzCoin v3.0
BuzzCoin v3.0.1

Copyright (c) 2013 NovaCoin Developers Copyright (c) 2011-2012 PPCoin Developers
Copyright (c) 2017 BUZZ Developers Distributed under the MIT/X11 software
Expand Down
6 changes: 3 additions & 3 deletions share/setup.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SetCompressor /SOLID lzma

# General Symbol Definitions
!define REGKEY "SOFTWARE\$(^Name)"
!define VERSION 0.3.0
!define VERSION 0.3.0.1
!define COMPANY "NovaCoin project"
!define URL http://www.novacoin.ru/

Expand Down Expand Up @@ -45,13 +45,13 @@ Var StartMenuGroup
!insertmacro MUI_LANGUAGE English

# Installer attributes
OutFile novacoin-0.3.0-win32-setup.exe
OutFile novacoin-0.3.0.1-win32-setup.exe
InstallDir $PROGRAMFILES\NovaCoin
CRCCheck on
XPStyle on
BrandingText " "
ShowInstDetails show
VIProductVersion 0.3.0.0
VIProductVersion 0.3.0.1.0
VIAddVersionKey ProductName NovaCoin
VIAddVersionKey ProductVersion "${VERSION}"
VIAddVersionKey CompanyName "${COMPANY}"
Expand Down
2 changes: 1 addition & 1 deletion src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 3
#define CLIENT_VERSION_MINOR 0
#define CLIENT_VERSION_REVISION 0
#define CLIENT_VERSION_REVISION 1
#define CLIENT_VERSION_BUILD 0

// Set to true for release, false for prerelease or test build
Expand Down
36 changes: 29 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -787,13 +787,16 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CTransaction &tx, bool fLimitFree, boo
// At default rate it would take over a month to fill 1GB
if (dFreeCount > GetArg("-limitfreerelay", 15)*10*1000)
return error("AcceptToMemoryPool : free transaction rejected by rate limiter");

LogPrint("mempool", "Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount+nSize);
dFreeCount += nSize;
}

uint64_t nBurnCoins = 0;

// Check against previous transactions
// This is done last to help prevent CPU exhaustion denial-of-service attacks.
if (!tx.ConnectInputs(txdb, mapInputs, mapUnused, CDiskTxPos(1,1,1), pindexBest, false, false, STANDARD_SCRIPT_VERIFY_FLAGS))
if (!tx.ConnectInputs(txdb, mapInputs, mapUnused, CDiskTxPos(1,1,1), pindexBest, nBurnCoins, false, false, STANDARD_SCRIPT_VERIFY_FLAGS))
{
return error("AcceptToMemoryPool : ConnectInputs failed %s", hash.ToString());
}
Expand All @@ -807,7 +810,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CTransaction &tx, bool fLimitFree, boo
// There is a similar check in CreateNewBlock() to prevent creating
// invalid blocks, however allowing such transactions into the mempool
// can be exploited as a DoS attack.
if (!tx.ConnectInputs(txdb, mapInputs, mapUnused, CDiskTxPos(1,1,1), pindexBest, false, false, MANDATORY_SCRIPT_VERIFY_FLAGS))
if (!tx.ConnectInputs(txdb, mapInputs, mapUnused, CDiskTxPos(1,1,1), pindexBest, nBurnCoins, false, false, MANDATORY_SCRIPT_VERIFY_FLAGS))
{
return error("AcceptToMemoryPool: : BUG! PLEASE REPORT THIS! ConnectInputs failed against MANDATORY but not STANDARD flags %s", hash.ToString());
}
Expand Down Expand Up @@ -1383,7 +1386,7 @@ int64_t CTransaction::GetValueIn(const MapPrevTx& inputs) const
}

bool CTransaction::ConnectInputs(CTxDB& txdb, MapPrevTx inputs, map<uint256, CTxIndex>& mapTestPool, const CDiskTxPos& posThisTx,
const CBlockIndex* pindexBlock, bool fBlock, bool fMiner, unsigned int flags)
const CBlockIndex* pindexBlock, uint64_t &nBurnCoins, bool fBlock, bool fMiner, unsigned int flags)
{
// Take over previous transactions' spent pointers
// fBlock is true when this is called from AcceptBlock when a new best-block is added to the blockchain
Expand All @@ -1403,6 +1406,16 @@ bool CTransaction::ConnectInputs(CTxDB& txdb, MapPrevTx inputs, map<uint256, CTx
if (prevout.n >= txPrev.vout.size() || prevout.n >= txindex.vSpent.size())
return DoS(100, error("ConnectInputs() : %s prevout.n out of range %d %u %u prev tx %s\n%s", GetHash().ToString(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString(), txPrev.ToString()));

// Coins Burning
// if OP_BURN is set, destroy selected coins.
for (unsigned int i = 0; i < vout.size(); i++) {
if (vout[i].scriptPubKey[1] == OP_BURN) {
nBurnCoins += vout[i].nValue;
if (fDebug)
LogPrintf("ConnectInputs() : burning coins %ld\n", vout[i].nValue);
}
}

// If prev is coinbase or coinstake, check that it's matured
if (txPrev.IsCoinBase() || txPrev.IsCoinStake())
for (const CBlockIndex* pindex = pindexBlock; pindex && pindexBlock->nHeight - pindex->nHeight < nCoinbaseMaturity; pindex = pindex->pprev)
Expand Down Expand Up @@ -1543,6 +1556,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck)
int64_t nFees = 0;
int64_t nValueIn = 0;
int64_t nValueOut = 0;
int64_t nBurnCoins = 0;
int64_t nStakeReward = 0;
unsigned int nSigOps = 0;
BOOST_FOREACH(CTransaction& tx, vtx)
Expand Down Expand Up @@ -1601,13 +1615,18 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck)
if (tx.IsCoinStake())
nStakeReward = nTxValueOut - nTxValueIn;

if (!tx.ConnectInputs(txdb, mapInputs, mapQueuedChanges, posThisTx, pindex, true, false, flags))
if (!tx.ConnectInputs(txdb, mapInputs, mapQueuedChanges, posThisTx, pindex, nBurnCoins, true, false, flags))
return false;
}

mapQueuedChanges[hashTx] = CTxIndex(posThisTx, tx.vout.size());
}

if (nBurnCoins > 0 && fDebug) {
LogPrintf("ConnectBlock() : burning coins %s\n", FormatMoney(nBurnCoins));
}


if (IsProofOfWork())
{
int64_t nReward = GetProofOfWorkReward(nFees, pindex);
Expand All @@ -1632,7 +1651,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck)

// ppcoin: track money supply and mint amount info
pindex->nMint = nValueOut - nValueIn + nFees;
pindex->nMoneySupply = (pindex->pprev ? pindex->pprev->nMoneySupply : 0) + nValueOut - nValueIn;
pindex->nMoneySupply = ((pindex->pprev ? pindex->pprev->nMoneySupply : 0) + nValueOut - nValueIn) - nBurnCoins;
if (!txdb.WriteBlockIndex(CDiskBlockIndex(pindex)))
return error("Connect() : WriteBlockIndex for pindex failed");

Expand Down Expand Up @@ -1935,10 +1954,13 @@ bool CTransaction::GetCoinAge(CTxDB& txdb, uint64_t& nCoinAge, CBlockIndex* pind

// Read block header
CBlock block;
if (!block.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, false))
if (!block.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, false)) {
return false; // unable to read block of previous transaction
if (block.GetBlockTime() + GetMinStakeAge(pindex) > nTime)
}

if (block.GetBlockTime() + GetMinStakeAge(pindex) > nTime){
continue; // only count coins meeting min age requirement
}

int64_t nValueIn = txPrev.vout[txin.prevout.n].nValue;
bnCentSecond += CBigNum(nValueIn) * (nTime-txPrev.nTime) / CENT;
Expand Down
4 changes: 3 additions & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,9 @@ class CTransaction
*/
bool ConnectInputs(CTxDB& txdb, MapPrevTx inputs,
std::map<uint256, CTxIndex>& mapTestPool, const CDiskTxPos& posThisTx,
const CBlockIndex* pindexBlock, bool fBlock, bool fMiner, unsigned int flags = STANDARD_SCRIPT_VERIFY_FLAGS);
const CBlockIndex* pindexBlock, uint64_t &nBurnCoins, bool fBlock, bool fMiner,
unsigned int flags = STANDARD_SCRIPT_VERIFY_FLAGS);

bool CheckTransaction() const;
bool GetCoinAge(CTxDB& txdb, uint64_t& nCoinAge, CBlockIndex* pindex) const; // ppcoin: get transaction coin age

Expand Down
3 changes: 2 additions & 1 deletion src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ CBlock* CreateNewBlock(CReserveKey& reservekey, bool fProofOfStake, int64_t* pFe
// Note that flags: we don't want to set mempool/IsStandard()
// policy here, but we still have to ensure that the block we
// create only contains transactions that are valid in new blocks.
if (!tx.ConnectInputs(txdb, mapInputs, mapTestPoolTmp, CDiskTxPos(1,1,1), pindexPrev, false, true, MANDATORY_SCRIPT_VERIFY_FLAGS))
uint64_t nBurnCoins = 0;
if (!tx.ConnectInputs(txdb, mapInputs, mapTestPoolTmp, CDiskTxPos(1,1,1), pindexPrev, nBurnCoins, false, true, MANDATORY_SCRIPT_VERIFY_FLAGS))
continue;
mapTestPoolTmp[tx.GetHash()] = CTxIndex(CDiskTxPos(1,1,1), tx.vout.size());
swap(mapTestPool, mapTestPoolTmp);
Expand Down
26 changes: 26 additions & 0 deletions src/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,32 @@ string AccountFromValue(const Value& value)
return strAccount;
}

Value burn(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 1)
throw runtime_error(
"burn <amount>\n"
"<amount> is a real and is rounded to the nearest 0.00000001"
+ HelpRequiringPassphrase());

CScript scriptPubKey;
scriptPubKey = CScript() << OP_RETURN << OP_BURN;

// Amount
int64_t nAmount = AmountFromValue(params[0]);

if (pwalletMain->IsLocked())
throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first.");

CWalletTx wtx;
string strError = pwalletMain->SendMoney(scriptPubKey, nAmount, wtx);
if (strError != "") {
throw JSONRPCError(RPC_WALLET_ERROR, strError);
}

return wtx.GetHash().GetHex();
}


Value getnewpubkey(const Array& params, bool fHelp)
{
Expand Down
1 change: 1 addition & 0 deletions src/script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ const char* GetOpName(opcodetype opcode)
case OP_ENDIF : return "OP_ENDIF";
case OP_VERIFY : return "OP_VERIFY";
case OP_RETURN : return "OP_RETURN";
case OP_BURN : return "OP_BURN";

// stack ops
case OP_TOALTSTACK : return "OP_TOALTSTACK";
Expand Down
3 changes: 2 additions & 1 deletion src/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ enum opcodetype
OP_NOP9 = 0xb8,
OP_NOP10 = 0xb9,


// extra control funcion
OP_BURN = 0xd0,

// template matching params
OP_SMALLDATA = 0xf9,
Expand Down