Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Version 2.0.0.0 #9

Closed
wants to merge 10 commits into from
Closed
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
8 changes: 1 addition & 7 deletions Silkcoin-qt.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TEMPLATE = app
TARGET = silkcoin-qt
VERSION = 1.1.0.22
VERSION = 2.0.0.0

INCLUDEPATH += src src/json src/qt
DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE
Expand Down Expand Up @@ -227,7 +227,6 @@ HEADERS += \
src/qt/optionsmodel.h \
src/qt/overviewpage.h \
src/qt/poll.h \
src/qt/poolbrowser.h \
src/qt/qcustomplot.h \
src/qt/qtipcserver.h \
src/qt/qvalidatedlineedit.h \
Expand All @@ -241,7 +240,6 @@ HEADERS += \
src/qt/sendmessagesdialog.h \
src/qt/sendmessagesentry.h \
src/qt/signverifymessagedialog.h \
src/qt/statisticspage.h \
src/qt/transactiondesc.h \
src/qt/transactiondescdialog.h \
src/qt/transactionfilterproxy.h \
Expand Down Expand Up @@ -324,7 +322,6 @@ SOURCES += \
src/qt/optionsmodel.cpp \
src/qt/overviewpage.cpp \
src/qt/poll.cpp \
src/qt/poolbrowser.cpp \
src/qt/qcustomplot.cpp \
src/qt/qtipcserver.cpp \
src/qt/qvalidatedlineedit.cpp \
Expand All @@ -335,7 +332,6 @@ SOURCES += \
src/qt/sendcoinsdialog.cpp \
src/qt/sendcoinsentry.cpp \
src/qt/signverifymessagedialog.cpp \
src/qt/statisticspage.cpp \
src/qt/transactiondesc.cpp \
src/qt/transactiondescdialog.cpp \
src/qt/transactionfilterproxy.cpp \
Expand Down Expand Up @@ -389,15 +385,13 @@ FORMS += \
src/qt/forms/optionsdialog.ui \
src/qt/forms/overviewpage.ui \
src/qt/forms/poll.ui \
src/qt/forms/poolbrowser.ui \
src/qt/forms/richlist.ui \
src/qt/forms/rpcconsole.ui \
src/qt/forms/sendcoinsdialog.ui \
src/qt/forms/sendcoinsentry.ui \
src/qt/forms/sendmessagesdialog.ui \
src/qt/forms/sendmessagesentry.ui \
src/qt/forms/signverifymessagedialog.ui \
src/qt/forms/statisticspage.ui \
src/qt/forms/transactiondescdialog.ui \
src/qt/forms/tutoStackDialog.ui \
src/qt/forms/tutoWriteDialog.ui
Expand Down
5 changes: 5 additions & 0 deletions src/checkpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ static MapCheckpoints mapCheckpoints =
(60001 , uint256("0x9040b2b79f4cce50b3d804f17d48359b62ebce467564defbf51af54c8dd9da83"))
(87000 , uint256("0x6311aa124dda9ecfc854f98b5b981962f3fe46c6f55143f27769796a878a7ff9"))
(113900, uint256("0x028a7f9bcd7532952106c29cb690f9af7938659fa4ae735fb2c80ca70bea0ee5"))
(165000, uint256("0x4eb6d22357961113dc1d44aab36e6f2943e016402f9053947c26affc6b407c06"))
(220000, uint256("0x67d729b3e1a6be9f662ba04dd7f748fcf1b7bab3a651a1a0b993bbc5ad02ee47"))
(280000, uint256("0x836e4e24ccd9aab052bb7f6ceea8d765a42a76713147ef1c3726865cef023943"))
(320000, uint256("0x7c0fa78de33510845146766769b855fa6fccd8c209a5bbb53035a64c761c34d9"))
(386000, uint256("0x606355657246ffb87907a50f567e4d46e05e612df228053a4b2a906057c1b25c"))
;

// TestNet has no checkpoints
Expand Down
6 changes: 3 additions & 3 deletions src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
//

// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 1
#define CLIENT_VERSION_MINOR 1
#define CLIENT_VERSION_MAJOR 2
#define CLIENT_VERSION_MINOR 0
#define CLIENT_VERSION_REVISION 0
#define CLIENT_VERSION_BUILD 22
#define CLIENT_VERSION_BUILD 0

// Converts the parameter X to a string after macro replacement on X has been performed.
// Don't merge these into one macro!
Expand Down
120 changes: 103 additions & 17 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ using namespace boost;
//
// Global state
//
static const bool bCoinYearOnly = false;

CCriticalSection cs_setpwalletRegistered;
set<CWallet*> setpwalletRegistered;
Expand All @@ -33,6 +34,7 @@ CCriticalSection cs_main;
CTxMemPool mempool;
unsigned int nTransactionsUpdated = 0;


map<uint256, CBlockIndex*> mapBlockIndex;
set<pair<COutPoint, unsigned int> > setStakeSeen;
libzerocoin::Params* ZCParams;
Expand All @@ -41,10 +43,13 @@ CBigNum bnProofOfWorkLimit(~uint256(0) >> 20); // "standard" scrypt target limit
CBigNum bnProofOfStakeLimit(~uint256(0) >> 20);
CBigNum bnProofOfWorkLimitTestNet(~uint256(0) >> 16);

unsigned int nTargetSpacing = 1 * 60; // 1 minute
unsigned int nStakeMinAge = 12 * 60 * 60; // 12 hours
unsigned int nTargetSpacing = 1 * 60; // 1 minute block spacing (Old Block Spacing)
unsigned int nStakeTargetSpacing = 3 * 60; // 3-minute block spacing (New Block Spacing)
unsigned int nStakeMinAge = 12 * 60 * 60; // 12 hours (Original Minimum Stake Age)
unsigned int nStakeMaxAge = -1; // Unlimited Max Stake Age (Original Maximum Stake Age)
unsigned int nStakeMinAgeV2 = 8 * 60 * 60; // 8 Hour Minimum Stake Age (New Minimum Stake Age)
unsigned int nStakeMaxAgeV2 = -1; //Unlimited Max Stake Age (New Maximum Stake Age)

unsigned int nStakeMaxAge = -1; // unlimited
unsigned int nModifierInterval = 10 * 60; // time to elapse before new modifier is computed

int nCoinbaseMaturity = 350;
Expand Down Expand Up @@ -482,6 +487,8 @@ bool CTransaction::CheckTransaction() const
const CTxOut& txout = vout[i];
if (txout.IsEmpty() && !IsCoinBase() && !IsCoinStake())
return DoS(100, error("CTransaction::CheckTransaction() : txout empty for user transaction"));
if ((!txout.IsEmpty()) && txout.nValue < MIN_TXOUT_AMOUNT)
return DoS(100, error("CTransaction::CheckTransaction() : txout.nValue below minimum"));
if (txout.nValue < 0)
return DoS(100, error("CTransaction::CheckTransaction() : txout.nValue negative"));
if (txout.nValue > MAX_MONEY)
Expand Down Expand Up @@ -973,18 +980,21 @@ int64_t GetProofOfWorkReward(int64_t nFees, unsigned int nHeight)
{
int64_t nSubsidy = 0;

if (nHeight == 1)
{
nSubsidy = 2000000 * COIN;
}
else if (nHeight < 50000)
{
nSubsidy = 5000 * COIN;
}
else
{
nSubsidy = 2500 * COIN;
}
if (nHeight == 1)

{
nSubsidy = 2000000 * COIN;
}
else if (nHeight < 50000)

{
nSubsidy = 5000 * COIN;
}
else

{
nSubsidy = 2500 * COIN;
}


if (fDebug && GetBoolArg("-printcreation"))
Expand All @@ -994,7 +1004,19 @@ else
}

// miner's coin stake reward based on coin age spent (coin-days)
int64_t GetProofOfStakeReward(int64_t nCoinAge, int64_t nFees)
int64_t GetProofOfStakeReward(int64_t nCoinAge, unsigned int nBits, int64_t nFees, int64_t nTime, bool bCoinYearOnly)
{
int64_t nSubsidy = 0;

if ( nTime > VERSION2_SWITCH_TIME )
nSubsidy = GetProofOfStakeRewardV2(nCoinAge, nBits, nTime, bCoinYearOnly);
else
nSubsidy = GetProofOfStakeRewardV1(nCoinAge, nFees);

return nSubsidy;
}

int64_t GetProofOfStakeRewardV1(int64_t nCoinAge, int64_t nFees)
{
int64_t nSubsidy = nCoinAge * COIN_YEAR_REWARD * 33 / (365 * 33 + 8);

Expand All @@ -1006,6 +1028,70 @@ int64_t GetProofOfStakeReward(int64_t nCoinAge, int64_t nFees)

static const int64_t nTargetTimespan = 16 * 60; // 16 mins

int64_t GetProofOfStakeRewardV2(int64_t nCoinAge, unsigned int nBits, unsigned int nTime, bool bCoinYearOnly)
{
int64_t nRewardCoinYear, nSubsidyLimit = 1000 * COIN;

// bool fPrintCreation = GetBoolArg("-printcreation");

CBigNum bnRewardCoinYearLimit = COIN_YEAR_REWARDV2; // Base stake mint rate, 111% year interest
CBigNum bnTarget;
bnTarget.SetCompact(nBits);
CBigNum bnTargetLimit = bnProofOfStakeLimit;
bnTargetLimit.SetCompact(bnTargetLimit.GetCompact());
CBigNum bnLowerBound = 11 * CENT; // Lower interest bound is 11% per year
CBigNum bnUpperBound = bnRewardCoinYearLimit;
while (bnLowerBound + CENT <= bnUpperBound)
{
CBigNum bnMidValue = (bnLowerBound + bnUpperBound) / 2;
// if (fDebug && fPrintCreation )
// printf("GetProofOfStakeReward() : lower=%"PRI64d" upper=%"PRI64d" mid=%"PRI64d"\n", bnLowerBound.getuint64(), bnUpperBound.getuint64(), bnMidValue.getuint64());
if (bnMidValue * bnMidValue * bnMidValue * bnMidValue * bnTargetLimit > bnRewardCoinYearLimit * bnRewardCoinYearLimit * bnRewardCoinYearLimit * bnRewardCoinYearLimit * bnTarget)
bnUpperBound = bnMidValue;
else
bnLowerBound = bnMidValue;
}

nRewardCoinYear = bnUpperBound.getuint64();

nRewardCoinYear = min((nRewardCoinYear / CENT) * CENT, COIN_YEAR_REWARDV2);

if(bCoinYearOnly)
return nRewardCoinYear;

int64_t nSubsidy = (nCoinAge * 33 * nRewardCoinYear) / (365 * 33 + 8);

// if (fDebug && fPrintCreation && nSubsidyLimit < nSubsidy)
// printf("GetProofOfStakeReward(): %s is greater than %s, coinstake reward will be truncated\n", FormatMoney(nSubsidy).c_str(), FormatMoney(nSubsidyLimit).c_str());

nSubsidy = min(nSubsidy, nSubsidyLimit);

// if (fDebug && fPrintCreation)
// printf("GetProofOfStakeReward(): create=%s nCoinAge=%"PRI64d" nBits=%d\n", FormatMoney(nSubsidy).c_str(), nCoinAge, nBits);

return nSubsidy;
}

unsigned int GetStakeMinAge(unsigned int nTime)
{
if (nTime > VERSION2_SWITCH_TIME)
return nStakeMinAgeV2;
else
return nStakeMinAge;
}

unsigned int GetStakeMaxAge(unsigned int nTime)
{
if (nTime > VERSION2_SWITCH_TIME)
return nStakeMaxAgeV2;
else
return nStakeMaxAge;
}

static const int64_t nTargetSpacingWorkMax = 12 * nStakeTargetSpacing; // 2-hour



//
// maximum nBits value could possible be required nTime after
//
Expand Down Expand Up @@ -1617,7 +1703,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck)
if (!vtx[1].GetCoinAge(txdb, nCoinAge))
return error("ConnectBlock() : %s unable to get coin age for coinstake", vtx[1].GetHash().ToString().substr(0,10).c_str());

int64_t nCalculatedStakeReward = GetProofOfStakeReward(nCoinAge, nFees);
int64_t nCalculatedStakeReward = GetProofOfStakeReward(nCoinAge, nBits, nFees, nTime, bCoinYearOnly);

if (nStakeReward > nCalculatedStakeReward)
return DoS(100, error("ConnectBlock() : coinstake pays too much(actual=%"PRId64" vs calculated=%"PRId64")", nStakeReward, nCalculatedStakeReward));
Expand Down
15 changes: 12 additions & 3 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ static const unsigned int MAX_INV_SZ = 50000;
static const int64_t MIN_TX_FEE = 10000;
static const int64_t MIN_RELAY_TX_FEE = MIN_TX_FEE;
static const int64_t MAX_MONEY = 2000000000 * COIN;
static const int64_t COIN_YEAR_REWARD = 2 * CENT; // 1% per year

static const int64_t COIN_YEAR_REWARD = 2 * CENT; // 2% per year
static const int64_t COIN_YEAR_REWARDV2 = 111 * CENT; // 111% per year
static const unsigned int VERSION2_SWITCH_TIME = 1417392001; // December 1st 2014 @ 00:00:01
static const int64_t MIN_TXOUT_AMOUNT = MIN_TX_FEE;
inline bool MoneyRange(int64_t nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
// Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp.
static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC


#ifdef USE_UPNP
static const int fHaveUPnP = true;
#else
Expand Down Expand Up @@ -94,6 +97,8 @@ extern bool fEnforceCanonical;
// Minimum disk space required - used in CheckDiskSpace()
static const uint64_t nMinDiskSpace = 52428800;



class CReserveKey;
class CTxDB;
class CTxIndex;
Expand All @@ -115,7 +120,11 @@ bool LoadExternalBlockFile(FILE* fileIn);
bool CheckProofOfWork(uint256 hash, unsigned int nBits);
unsigned int GetNextTargetRequired(const CBlockIndex* pindexLast, bool fProofOfStake);
int64_t GetProofOfWorkReward(int64_t nFees, unsigned int nHeight);
int64_t GetProofOfStakeReward(int64_t nCoinAge, int64_t nFees);
int64_t GetProofOfWorkRewardV2(int64_t nFees, unsigned int nHeight);
int64_t GetProofOfStakeReward(int64_t nCoinAge, unsigned int nBits, int64_t nFees, int64_t nTime, bool bCoinYearOnly=false);
int64_t GetProofOfStakeRewardV1(int64_t nCoinAge, int64_t nFees);
int64_t GetProofOfStakeRewardV2(int64_t nCoinAge, unsigned int nBits, unsigned int nTime, bool bCoinYearOnly=false);

unsigned int ComputeMinWork(unsigned int nBase, int64_t nTime);
unsigned int ComputeMinStake(unsigned int nBase, int64_t nTime, unsigned int nBlockTime);
int GetNumBlocksOfPeers();
Expand Down
7 changes: 0 additions & 7 deletions src/qt/bitcoinamountfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "bitcoinunits.h"

#include "guiconstants.h"
#include "poolbrowser.h"

#include <QLabel>
#include <QLineEdit>
Expand Down Expand Up @@ -89,12 +88,6 @@ void BitcoinAmountField::setValid(bool valid) {
}

QString BitcoinAmountField::text() const {

//Avoid putting 'NaN' in BTC price due to divide by zero. Happens when price has not been received from Market Data API
QString qsBtcPrice = _dBtcPriceCurrent > 0 ? (QString::number(amount->value() * (_dScPriceLast / _dBtcPriceCurrent))) : "0";

label_btc->setText("Sending $" + (QString::number(amount->value() * _dScPriceLast)) + " or " + qsBtcPrice + " BTC at current market rate");

if (amount->text().isEmpty()) {
return QString();
} else {
Expand Down
Loading