Skip to content

Commit

Permalink
Per kilobyte fee will be reduced 20 times on Sep 18 10:49:29 UTC 2018
Browse files Browse the repository at this point in the history
  • Loading branch information
sparklecoin committed Jul 23, 2018
1 parent d5865c2 commit 3272fd4
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 18 deletions.
2 changes: 1 addition & 1 deletion doc/README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Sparklecoin 1.1.2
Sparklecoin 1.2.0
Copyright (c) 2014-2018 Sparklecoin developers

Distributed under the MIT/X11 software license, see the accompanying
Expand Down
2 changes: 1 addition & 1 deletion doc/README_windows.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Sparklecoin 1.1.2
Sparklecoin 1.2.0
Copyright (c) 2014-2018 Sparklecoin developers

Distributed under the MIT/X11 software license, see the accompanying
Expand Down
2 changes: 1 addition & 1 deletion 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 1.1.2.0
!define VERSION 1.2.0.0
!define COMPANY "Sparklecoin project"
!define URL http://github.com/sparklecoin/sparklecoin/

Expand Down
2 changes: 1 addition & 1 deletion sparklecoin.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TEMPLATE = app
TARGET = sparklecoin
VERSION = 1.1.2.0
VERSION = 1.2.0.0
INCLUDEPATH += src src/json src/qt
DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE USE_IPV6
CONFIG += no_include_pwd
Expand Down
10 changes: 9 additions & 1 deletion src/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ unsigned int nProtocolV05TestSwitchTime = 1505222712;
// Protocol switch time of v0.6 kernel protocol
unsigned int nProtocolV06SwitchTime = 1515693600;
unsigned int nProtocolV06TestSwitchTime = 1515092057;

// Protocol switch time of v0.7 kernel protocol
unsigned int nProtocolV07SwitchTime = 1537267769;
unsigned int nProtocolV07TestSwitchTime = 1532847324;

// TxDB upgrade time for v0.4 protocol
// Note: v0.4 upgrade does not require block chain re-download. However,
Expand Down Expand Up @@ -71,6 +73,12 @@ bool IsProtocolV06(unsigned int nTimeBlock)
return (nTimeBlock >= (fTestNet? nProtocolV06TestSwitchTime : nProtocolV06SwitchTime));
}

// Whether the given transaction is subject to new v0.7 protocol
bool IsProtocolV07(unsigned int nTimeTx)
{
return (nTimeTx >= (fTestNet? nProtocolV07TestSwitchTime : nProtocolV07SwitchTime));
}

// Get the last stake modifier and its generation time from a given block
static bool GetLastStakeModifier(const CBlockIndex* pindex, uint64& nStakeModifier, int64& nModifierTime)
{
Expand Down
2 changes: 2 additions & 0 deletions src/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ bool IsProtocolV04(unsigned int nTimeBlock);
bool IsProtocolV05(unsigned int nTimeTx);
// Whether a given transaction is subject to new v0.5 protocol
bool IsProtocolV06(unsigned int nTimeBlock);
// Whether a given transaction is subject to new v0.7 protocol
bool IsProtocolV07(unsigned int nTimeTx);

// Compute the hash modifier for proof-of-stake
bool ComputeNextStakeModifier(const CBlockIndex* pindexCurrent, uint64& nStakeModifier, bool& fGeneratedStakeModifier);
Expand Down
13 changes: 10 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,10 @@ int64 CTransaction::GetMinFee(unsigned int nBlockSize, bool fAllowFree, enum Get
// Base fee is either MIN_TX_FEE or MIN_RELAY_TX_FEE
int64 nBaseFee = (mode == GMF_RELAY) ? MIN_RELAY_TX_FEE : MIN_TX_FEE;

// if old protocol multiply by 20 to get old base fee of 0.01
if (!IsProtocolV07(nTime))
nBaseFee *= 20;

unsigned int nBytes = ::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION);
unsigned int nNewBlockSize = nBlockSize + nBytes;
int64 nMinFee = (1 + (int64)nBytes / 1000) * nBaseFee;
Expand Down Expand Up @@ -1397,9 +1401,10 @@ bool CTransaction::ConnectInputs(CTxDB& txdb, MapPrevTx inputs,
if (!GetCoinAge(txdb, nCoinAge))
return error("ConnectInputs() : %s unable to get coin age for coinstake", GetHash().ToString().substr(0,10).c_str());
int64 nStakeReward = GetValueOut() - nValueIn;
if (nStakeReward > GetProofOfStakeReward(nCoinAge, nTime) - GetMinFee() + MIN_TX_FEE)
int64 nMinFeeBase = IsProtocolV07(nTime) ? MIN_TX_FEE : MIN_TX_FEE*20;
if (nStakeReward > GetProofOfStakeReward(nCoinAge, nTime) - GetMinFee() + nMinFeeBase)
return DoS(100, error("ConnectInputs() : %s stake reward exceeded (%d > %d - %d + %d)", GetHash().ToString().substr(0,10).c_str(),
nStakeReward, GetProofOfStakeReward(nCoinAge, nTime), GetMinFee(), MIN_TX_FEE));
nStakeReward, GetProofOfStakeReward(nCoinAge, nTime), GetMinFee(), nMinFeeBase));
}
else
{
Expand Down Expand Up @@ -2029,7 +2034,9 @@ bool CBlock::CheckBlock(int64 nBlockHeight) const
return DoS(50, error("CheckBlock() : coinstake timestamp violation nTimeBlock=%u nTimeTx=%u", GetBlockTime(), vtx[1].nTime));

// Check coinbase reward
if (vtx[0].GetValueOut() > (IsProofOfWork()? (GetProofOfWorkReward(nBits, nBlockHeight, GetBlockTime()) - vtx[0].GetMinFee() + MIN_TX_FEE) : 0))
int64 nBaseFee = IsProtocolV07(vtx[0].nTime) ? MIN_TX_FEE : MIN_TX_FEE*20;

if (vtx[0].GetValueOut() > (IsProofOfWork()? (GetProofOfWorkReward(nBits, nBlockHeight, GetBlockTime()) - vtx[0].GetMinFee() + nBaseFee) : 0))
return DoS(50, error("CheckBlock() : coinbase reward exceeded %s > %s",
FormatMoney(vtx[0].GetValueOut()).c_str(),
FormatMoney(IsProofOfWork()? GetProofOfWorkReward(nBits, nBlockHeight, nTime) : 0).c_str()));
Expand Down
4 changes: 2 additions & 2 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ static const unsigned int MAX_BLOCK_SIZE = 2000000;
static const unsigned int MAX_BLOCK_SIZE_GEN = MAX_BLOCK_SIZE/2;
static const unsigned int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;
static const unsigned int MAX_ORPHAN_TRANSACTIONS = MAX_BLOCK_SIZE/100;
static const int64 MIN_TX_FEE = CENT;
static const int64 MIN_RELAY_TX_FEE = CENT;
static const int64 MIN_TX_FEE = CENT / 20;
static const int64 MIN_RELAY_TX_FEE = CENT / 20;
static const int64 MAX_MONEY = 2000000000 * COIN;
static const int64 MAX_MINT_PROOF_OF_WORK = 9999 * COIN;
static const int64 MIN_TXOUT_AMOUNT = MIN_TX_FEE;
Expand Down
8 changes: 4 additions & 4 deletions src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

// sparklecoin version - intended for display purpose only
#define SPARKLEUNITY_VERSION_MAJOR 1
#define SPARKLEUNITY_VERSION_MINOR 1
#define SPARKLEUNITY_VERSION_REVISION 2
#define SPARKLEUNITY_VERSION_MINOR 2
#define SPARKLEUNITY_VERSION_REVISION 0
#define SPARKLEUNITY_VERSION_BUILD 0

static const int SPARKLEUNITY_VERSION =
Expand All @@ -28,7 +28,7 @@ static const int SPARKLEUNITY_VERSION =

// sparklecoin version - reference for code tracking
#define SPRKOIN_VERSION_MAJOR 0
#define SPRKOIN_VERSION_MINOR 6
#define SPRKOIN_VERSION_MINOR 7
#define SPRKOIN_VERSION_REVISION 0
#define SPRKOIN_VERSION_BUILD 0

Expand Down Expand Up @@ -61,7 +61,7 @@ extern const std::string CLIENT_DATE;
// network protocol versioning
//

static const int PROTOCOL_VERSION = 60007;
static const int PROTOCOL_VERSION = 60008;

// earlier versions not supported as of Feb 2012, and are disconnected
// NOTE: as of bitcoin v0.6 message serialization (vSend, vRecv) still
Expand Down
11 changes: 7 additions & 4 deletions src/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1179,9 +1179,10 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64> >& vecSend, CW
// if sub-cent change is required, the fee must be raised to at least MIN_TX_FEE
// or until nChange becomes zero
// NOTE: this depends on the exact behaviour of GetMinFee
if (nFeeRet < MIN_TX_FEE && nChange > 0 && nChange < CENT)
int64 nMinFeeBase = IsProtocolV07(wtxNew.nTime) ? MIN_TX_FEE : MIN_TX_FEE*20;
if (nFeeRet < nMinFeeBase && nChange > 0 && nChange < CENT)
{
int64 nMoveToFee = min(nChange, MIN_TX_FEE - nFeeRet);
int64 nMoveToFee = min(nChange, nMinFeeBase - nFeeRet);
nChange -= nMoveToFee;
nFeeRet += nMoveToFee;
}
Expand Down Expand Up @@ -1427,6 +1428,8 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
}

int64 nMinFee = 0;
int64 nMinFeeBase = IsProtocolV07(txNew.nTime)? MIN_TX_FEE : MIN_TX_FEE*20;

loop
{
// Set output amount
Expand All @@ -1452,9 +1455,9 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
return error("CreateCoinStake : exceeded coinstake size limit");

// Check enough fee is paid
if (nMinFee < txNew.GetMinFee() - MIN_TX_FEE)
if (nMinFee < txNew.GetMinFee() - nMinFeeBase)
{
nMinFee = txNew.GetMinFee() - MIN_TX_FEE;
nMinFee = txNew.GetMinFee() - nMinFeeBase;
continue; // try signing again
}
else
Expand Down

0 comments on commit 3272fd4

Please sign in to comment.