From: alex Date: Fri, 10 May 2013 20:30:54 +0000 (+0400) Subject: update to 0.4.1 X-Git-Tag: v0.4.1-nvc^0 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=6145f2d5e9f380a11bce933fe343d48fd8936a33;hp=ada04fc66d18048cb1d94ab02290be2796d9395f update to 0.4.1 --- diff --git a/contrib/macdeploy/background.png b/contrib/macdeploy/background.png index fce12e3..51dc01a 100644 Binary files a/contrib/macdeploy/background.png and b/contrib/macdeploy/background.png differ diff --git a/contrib/macdeploy/background.psd b/contrib/macdeploy/background.psd index 5889676..e0a8c9a 100644 Binary files a/contrib/macdeploy/background.psd and b/contrib/macdeploy/background.psd differ diff --git a/novacoin-qt.pro b/novacoin-qt.pro index a059167..7146671 100644 --- a/novacoin-qt.pro +++ b/novacoin-qt.pro @@ -305,7 +305,7 @@ OTHER_FILES += \ # platform specific defaults, if not overridden on command line isEmpty(BOOST_LIB_SUFFIX) { macx:BOOST_LIB_SUFFIX = -mt - windows:BOOST_LIB_SUFFIX = -mgw44-mt-s-1_50 + windows:BOOST_LIB_SUFFIX = -mgw44-mt-1_53 } isEmpty(BOOST_THREAD_LIB_SUFFIX) { diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index c9b4ce8..33961bd 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -732,7 +732,7 @@ void ThreadRPCServer2(void* parg) { unsigned char rand_pwd[32]; RAND_bytes(rand_pwd, 32); - string strWhatAmI = "To use bitcoind"; + string strWhatAmI = "To use novacoind"; if (mapArgs.count("-server")) strWhatAmI = strprintf(_("To use the %s option"), "\"-server\""); else if (mapArgs.count("-daemon")) diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 6256fb4..04799cf 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -24,16 +24,17 @@ namespace Checkpoints // static MapCheckpoints mapCheckpoints = boost::assign::map_list_of - ( 0, hashGenesisBlockOfficial ) + ( 0, hashGenesisBlock ) ( 6000, uint256("0x000000000945e3c9d8e15df834e802521eb79f9ceb4191a27bdfadad4b777f4a")) - ( 8700, uint256("0x00000000014270724837789c9a69859290f6bdee38556bc4561c21f17935a178")) + ( 9690, uint256("0x00000000026561450859c46868099e0df6068a538f038cb18988fd8d47dcdaf5")) ( 13560, uint256("0xa1591a0fcbf11f282d671581edb9f0aadcd06fee69761081e0a3245914c13729")) ( 14189, uint256("0x00000000020f76474d2522b19c7bfafc43ba6ecbabae54293bcd9546159c8c1d")) + ( 19600, uint256("0x252ae08d6df4bc7220c1dcdaed7b8a6e78bab05a60173511e8f565a3a38ce3c3")) ; static MapCheckpoints mapCheckpointsTestnet = boost::assign::map_list_of - ( 0, hashGenesisBlockOfficial ) + ( 0, hashGenesisBlockTestNet ) ; bool CheckHardened(int nHeight, const uint256& hash) @@ -297,7 +298,7 @@ namespace Checkpoints { // Test signing a sync-checkpoint with genesis block CSyncCheckpoint checkpoint; - checkpoint.hashCheckpoint = hashGenesisBlock; + checkpoint.hashCheckpoint = !fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet; CDataStream sMsg(SER_NETWORK, PROTOCOL_VERSION); sMsg << (CUnsignedSyncCheckpoint)checkpoint; checkpoint.vchMsg = std::vector(sMsg.begin(), sMsg.end()); diff --git a/src/db.cpp b/src/db.cpp index 74c265d..5d3eb3d 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -847,7 +847,7 @@ bool CTxDB::LoadBlockIndexGuts() pindexNew->nNonce = diskindex.nNonce; // Watch for genesis block - if (pindexGenesisBlock == NULL && diskindex.GetBlockHash() == hashGenesisBlock) + if (pindexGenesisBlock == NULL && diskindex.GetBlockHash() == (!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet)) pindexGenesisBlock = pindexNew; if (!pindexNew->CheckIndex()) diff --git a/src/init.cpp b/src/init.cpp index 42f80a2..f22dbc2 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -243,6 +243,7 @@ std::string HelpMessage() " -listen " + _("Accept connections from outside (default: 1 if no -proxy or -connect)") + "\n" + " -bind= " + _("Bind to given address. Use [host]:port notation for IPv6") + "\n" + " -dnsseed " + _("Find peers using DNS lookup (default: 0)") + "\n" + + " -nosynccheckpoints " + _("Disable sync checkpoints (default: 0)") + "\n" + " -banscore= " + _("Threshold for disconnecting misbehaving peers (default: 100)") + "\n" + " -bantime= " + _("Number of seconds to keep misbehaving peers from reconnecting (default: 86400)") + "\n" + " -maxreceivebuffer= " + _("Maximum per-connection receive buffer, *1000 bytes (default: 5000)") + "\n" + diff --git a/src/irc.cpp b/src/irc.cpp index 2057419..0499c8f 100644 --- a/src/irc.cpp +++ b/src/irc.cpp @@ -302,8 +302,8 @@ void ThreadIRCSeed2(void* parg) } if (fTestNet) { - Send(hSocket, "JOIN #novacoinTEST\r"); - Send(hSocket, "WHO #novacoinTEST\r"); + Send(hSocket, "JOIN #novacoinTEST2\r"); + Send(hSocket, "WHO #novacoinTEST2\r"); } else { // randomly join #novacoin00-#novacoin05 // int channel_number = GetRandInt(5); diff --git a/src/kernel.cpp b/src/kernel.cpp index 663e811..1d9aa62 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -12,16 +12,14 @@ using namespace std; extern int nStakeMaxAge; extern int nStakeTargetSpacing; -// Modifier interval: time to elapse before new modifier is computed -// Set to 6-hour for production network and 20-minute for test network -unsigned int nModifierInterval = MODIFIER_INTERVAL; - // Hard checkpoints of stake modifiers to ensure they are deterministic static std::map mapStakeModifierCheckpoints = boost::assign::map_list_of - ( 0, 0x0e00670bu ) - ( 6000, 0xb7cbc5d3u ) - ( 12661, 0x5d84115du ) + ( 0, 0x0e00670bu ) + ( 6000, 0xb7cbc5d3u ) + ( 9690, 0x97dcdafau ) + ( 12661, 0x5d84115du ) + ( 19600, 0xdded1b8du ) ; // Get the last stake modifier and its generation time from a given block @@ -367,7 +365,7 @@ bool CheckCoinStakeTimestamp(int64 nTimeBlock, int64 nTimeTx) // Get stake modifier checksum unsigned int GetStakeModifierChecksum(const CBlockIndex* pindex) { - assert (pindex->pprev || pindex->GetBlockHash() == hashGenesisBlock); + assert (pindex->pprev || pindex->GetBlockHash() == (!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet)); // Hash previous checksum with flags, hashProofOfStake and nStakeModifier CDataStream ss(SER_GETHASH, 0); if (pindex->pprev) diff --git a/src/kernel.h b/src/kernel.h index 9241173..95671c9 100644 --- a/src/kernel.h +++ b/src/kernel.h @@ -7,7 +7,6 @@ #include "main.h" // MODIFIER_INTERVAL: time to elapse before new modifier is computed -static const unsigned int MODIFIER_INTERVAL = 6 * 60 * 60; extern unsigned int nModifierInterval; // MODIFIER_INTERVAL_RATIO: diff --git a/src/main.cpp b/src/main.cpp index 3b7652e..ace9f56 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,14 +32,19 @@ unsigned int nTransactionsUpdated = 0; map mapBlockIndex; set > setStakeSeen; -uint256 hashGenesisBlock = hashGenesisBlockOfficial; + static CBigNum bnProofOfWorkLimit(~uint256(0) >> 20); static CBigNum bnProofOfStakeLimit(~uint256(0) >> 24); -static CBigNum bnProofOfStakeHardLimit(~uint256(0) >> 30); -static CBigNum bnInitialHashTarget(~uint256(0) >> 20); +static CBigNum bnProofOfStakeHardLimit(~uint256(0) >> 30); // disabled temporarily, will be used in the future to fix minimum PoS difficulty at 0.25 + +static CBigNum bnProofOfWorkLimitTestNet(~uint256(0) >> 16); +static CBigNum bnProofOfStakeLimitTestNet(~uint256(0) >> 20); + unsigned int nStakeMinAge = 60 * 60 * 24 * 30; // minimum age for coin age unsigned int nStakeMaxAge = 60 * 60 * 24 * 90; // stake age of full weight unsigned int nStakeTargetSpacing = 10 * 60; // 10-minute block spacing +unsigned int nModifierInterval = 6 * 60 * 60; // time to elapse before new modifier is computed + int nCoinbaseMaturity = 500; CBlockIndex* pindexGenesisBlock = NULL; int nBestHeight = -1; @@ -470,9 +475,11 @@ 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")); + // ppcoin: enforce minimum output amount if ((!txout.IsEmpty()) && txout.nValue < MIN_TXOUT_AMOUNT) return DoS(100, error("CTransaction::CheckTransaction() : txout.nValue below minimum")); + if (txout.nValue > MAX_MONEY) return DoS(100, error("CTransaction::CheckTransaction() : txout.nValue too high")); nValueOut += txout.nValue; @@ -514,23 +521,6 @@ int64 CTransaction::GetMinFee(unsigned int nBlockSize, bool fAllowFree, unsigned int nNewBlockSize = nBlockSize + nBytes; int64 nMinFee = (1 + (int64)nBytes / 1000) * nBaseFee; - if (fAllowFree) - { - if (nBlockSize == 1) - { - // Transactions under 10K are free - // (about 4500 BTC if made of 50 BTC inputs) - if (nBytes < 10000) - nMinFee = 0; - } - else - { - // Free transaction area - if (nNewBlockSize < 27000) - nMinFee = 0; - } - } - // To limit dust spam, require MIN_TX_FEE/MIN_RELAY_TX_FEE if any output is less than 0.01 if (nMinFee < nBaseFee) { @@ -946,6 +936,7 @@ uint256 WantedByOrphan(const CBlock* pblockOrphan) return pblockOrphan->hashPrevBlock; } +// miner's coin base reward based on nBits int64 GetProofOfWorkReward(unsigned int nBits) { CBigNum bnSubsidyLimit = MAX_MINT_PROOF_OF_WORK; @@ -954,7 +945,7 @@ int64 GetProofOfWorkReward(unsigned int nBits) CBigNum bnTargetLimit = bnProofOfWorkLimit; bnTargetLimit.SetCompact(bnTargetLimit.GetCompact()); - // ppcoin: subsidy is cut in half every 64x multiply of difficulty + // NovaCoin: subsidy is cut in half every 64x multiply of PoW difficulty // A reasonably continuous curve is used to avoid shock to market // (nSubsidyLimit / nSubsidy) ** 6 == bnProofOfWorkLimit / bnTarget // @@ -982,13 +973,54 @@ int64 GetProofOfWorkReward(unsigned int nBits) return min(nSubsidy, MAX_MINT_PROOF_OF_WORK); } -// ppcoin: miner's coin stake is rewarded based on coin age spent (coin-days) -int64 GetProofOfStakeReward(int64 nCoinAge) +// miner's coin stake reward based on nBits and coin age spent (coin-days) +int64 GetProofOfStakeReward(int64 nCoinAge, unsigned int nBits, unsigned int nTime) { - static int64 nRewardCoinYear = 5 * CENT; // creation amount per coin-year + int64 nRewardCoinYear; + + if(fTestNet || nTime > PROTOCOL_SWITCH_TIME) + { + // Stage 2 of emission process is PoS-based. It will be active on mainNet since 20 Jun 2013. + + CBigNum bnRewardCoinYearLimit = MAX_MINT_PROOF_OF_STAKE; // Base stake mint rate, 100% year interest + CBigNum bnTarget; + bnTarget.SetCompact(nBits); + CBigNum bnTargetLimit = bnProofOfStakeLimit; + bnTargetLimit.SetCompact(bnTargetLimit.GetCompact()); + + // NovaCoin: reward for coin-year is cut in half every 64x multiply of PoS difficulty + // A reasonably continuous curve is used to avoid shock to market + // (nRewardCoinYearLimit / nRewardCoinYear) ** 6 == bnProofOfStakeLimit / bnTarget + // + // Human readable form: + // + // nRewardCoinYear = 1 / (posdiff ^ 1/6) + + CBigNum bnLowerBound = 1 * CENT; // Lower interest bound is 1% per year + CBigNum bnUpperBound = bnRewardCoinYearLimit; + while (bnLowerBound + CENT <= bnUpperBound) + { + CBigNum bnMidValue = (bnLowerBound + bnUpperBound) / 2; + if (fDebug && GetBoolArg("-printcreation")) + printf("GetProofOfStakeReward() : lower=%"PRI64d" upper=%"PRI64d" mid=%"PRI64d"\n", bnLowerBound.getuint64(), bnUpperBound.getuint64(), bnMidValue.getuint64()); + if (bnMidValue * bnMidValue * bnMidValue * bnMidValue * bnMidValue * bnMidValue * bnTargetLimit > bnRewardCoinYearLimit * bnRewardCoinYearLimit * bnRewardCoinYearLimit * bnRewardCoinYearLimit * bnRewardCoinYearLimit * bnRewardCoinYearLimit * bnTarget) + bnUpperBound = bnMidValue; + else + bnLowerBound = bnMidValue; + } + + nRewardCoinYear = bnUpperBound.getuint64(); + nRewardCoinYear = min((nRewardCoinYear / CENT) * CENT, MAX_MINT_PROOF_OF_STAKE); + } + else + { + // Old creation amount per coin-year, 5% fixed stake mint rate + nRewardCoinYear = 5 * CENT; + } + int64 nSubsidy = nCoinAge * 33 / (365 * 33 + 8) * nRewardCoinYear; if (fDebug && GetBoolArg("-printcreation")) - printf("GetProofOfStakeReward(): create=%s nCoinAge=%"PRI64d"\n", FormatMoney(nSubsidy).c_str(), nCoinAge); + printf("GetProofOfStakeReward(): create=%s nCoinAge=%"PRI64d" nBits=%d\n", FormatMoney(nSubsidy).c_str(), nCoinAge, nBits); return nSubsidy; } @@ -1033,10 +1065,10 @@ unsigned int static GetNextTargetRequired(const CBlockIndex* pindexLast, bool fP { // Proof-of-Stake blocks has own target limit since nVersion=3 supermajority on mainNet and always on testNet if(fTestNet) - bnTargetLimit = bnProofOfStakeHardLimit; + bnTargetLimit = bnProofOfStakeLimit; else { - if(fTestNet || (pindexLast->nHeight + 1 > 15000)) + if(pindexLast->nHeight + 1 > 15000) bnTargetLimit = bnProofOfStakeLimit; else if(pindexLast->nHeight + 1 > 14060) bnTargetLimit = bnProofOfStakeHardLimit; @@ -1048,10 +1080,10 @@ unsigned int static GetNextTargetRequired(const CBlockIndex* pindexLast, bool fP const CBlockIndex* pindexPrev = GetLastBlockIndex(pindexLast, fProofOfStake); if (pindexPrev->pprev == NULL) - return bnInitialHashTarget.GetCompact(); // first block + return bnTargetLimit.GetCompact(); // first block const CBlockIndex* pindexPrevPrev = GetLastBlockIndex(pindexPrev->pprev, fProofOfStake); if (pindexPrevPrev->pprev == NULL) - return bnInitialHashTarget.GetCompact(); // second block + return bnTargetLimit.GetCompact(); // second block int64 nActualSpacing = pindexPrev->GetBlockTime() - pindexPrevPrev->GetBlockTime(); @@ -1381,7 +1413,7 @@ 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) - GetMinFee() + MIN_TX_FEE) + if (nStakeReward > GetProofOfStakeReward(nCoinAge, pindexBlock->nBits, nTime) - GetMinFee() + MIN_TX_FEE) return DoS(100, error("ConnectInputs() : %s stake reward exceeded", GetHash().ToString().substr(0,10).c_str())); } else @@ -1736,7 +1768,7 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew) if (!txdb.TxnBegin()) return error("SetBestChain() : TxnBegin failed"); - if (pindexGenesisBlock == NULL && hash == hashGenesisBlock) + if (pindexGenesisBlock == NULL && hash == (!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet)) { txdb.WriteHashBestChain(hash); if (!txdb.TxnCommit()) @@ -2111,7 +2143,16 @@ bool CBlock::AcceptBlock() // ppcoin: check that the block satisfies synchronized checkpoint if (!Checkpoints::CheckSync(hash, pindexPrev)) - return error("AcceptBlock() : rejected by synchronized checkpoint"); + { + if(!GetBoolArg("-nosynccheckpoints", false)) + { + return error("AcceptBlock() : rejected by synchronized checkpoint"); + } + else + { + strMiscWarning = _("WARNING: syncronized checkpoint violation detected, but skipped!"); + } + } // Reject block.nVersion < 3 blocks since 95% threshold on mainNet and always on testNet: if (nVersion < 3 && ((!fTestNet && nHeight > 14060) || (fTestNet && nHeight > 0))) @@ -2337,7 +2378,7 @@ bool CBlock::SignBlock(const CKeyStore& keystore) // ppcoin: check block signature bool CBlock::CheckBlockSignature() const { - if (GetHash() == hashGenesisBlock) + if (GetHash() == (!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet)) return vchBlockSig.empty(); vector vSolutions; @@ -2462,10 +2503,12 @@ bool LoadBlockIndex(bool fAllowNew) pchMessageStart[2] = 0xc0; pchMessageStart[3] = 0xef; - - hashGenesisBlock = hashGenesisBlockTestNet; - nStakeMinAge = 60 * 60 * 24; // test net min age is 1 day - nCoinbaseMaturity = 60; + bnProofOfStakeLimit = bnProofOfStakeLimitTestNet; // 0x00000fff PoS base target is fixed in testnet + bnProofOfWorkLimit = bnProofOfWorkLimitTestNet; // 0x0000ffff PoW base target is fixed in testnet + nStakeMinAge = 2 * 60 * 60; // test net min age is 2 hours + nModifierInterval = 20 * 60; // test modifier interval is 20 minutes + nCoinbaseMaturity = 10; // test maturity is 10 blocks + nStakeTargetSpacing = 3 * 60; // test block spacing is 3 minutes } // @@ -2506,12 +2549,12 @@ bool LoadBlockIndex(bool fAllowNew) block.nVersion = 1; block.nTime = 1360105017; block.nBits = bnProofOfWorkLimit.GetCompact(); - block.nNonce = 1575379; + block.nNonce = !fTestNet ? 1575379 : 46534; //// debug print assert(block.hashMerkleRoot == uint256("0x4cb33b3b6a861dcbc685d3e614a9cafb945738d6833f182855679f2fad02057b")); block.print(); - assert(block.GetHash() == hashGenesisBlock); + assert(block.GetHash() == (!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet)); assert(block.CheckBlock()); // Start new block file @@ -2523,7 +2566,7 @@ bool LoadBlockIndex(bool fAllowNew) return error("LoadBlockIndex() : genesis block not accepted"); // ppcoin: initialize synchronized checkpoint - if (!Checkpoints::WriteSyncCheckpoint(hashGenesisBlock)) + if (!Checkpoints::WriteSyncCheckpoint((!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet))) return error("LoadBlockIndex() : failed to init sync checkpoint"); } @@ -2711,14 +2754,13 @@ string GetWarnings(string strFor) if (GetBoolArg("-testsafemode")) strRPC = "test"; -/* + // ppcoin: wallet lock warning for minting if (strMintWarning != "") { nPriority = 0; strStatusBar = strMintWarning; } -*/ // Misc warnings like out of disk space and clock is wrong if (strMiscWarning != "") @@ -3879,8 +3921,6 @@ CBlock* CreateNewBlock(CWallet* pwallet, bool fProofOfStake) // Add our coinbase tx as first transaction pblock->vtx.push_back(txNew); - - // Largest block you're willing to create: unsigned int nBlockMaxSize = GetArg("-blockmaxsize", MAX_BLOCK_SIZE_GEN/2); // Limit to betweeen 1K and MAX_BLOCK_SIZE-1K for sanity: @@ -3909,7 +3949,7 @@ CBlock* CreateNewBlock(CWallet* pwallet, bool fProofOfStake) static int64 nLastCoinStakeSearchTime = GetAdjustedTime(); // only initialized at startup CBlockIndex* pindexPrev = pindexBest; - if (fProofOfStake) // attemp to find a coinstake + if (fProofOfStake) // attempt to find a coinstake { pblock->nBits = GetNextTargetRequired(pindexPrev, true); CTransaction txCoinStake; diff --git a/src/main.h b/src/main.h index 736ff5a..817a297 100644 --- a/src/main.h +++ b/src/main.h @@ -34,7 +34,10 @@ static const int64 MIN_TX_FEE = CENT; static const int64 MIN_RELAY_TX_FEE = CENT; static const int64 MAX_MONEY = 2000000000 * COIN; static const int64 MAX_MINT_PROOF_OF_WORK = 100 * COIN; +static const int64 MAX_MINT_PROOF_OF_STAKE = 1 * COIN; static const int64 MIN_TXOUT_AMOUNT = MIN_TX_FEE; +static const unsigned int PROTOCOL_SWITCH_TIME = 1371686400; // 20 Jun 2013 00:00:00 + inline bool MoneyRange(int64 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 @@ -45,22 +48,17 @@ static const int fHaveUPnP = true; static const int fHaveUPnP = false; #endif -static const uint256 hashGenesisBlockOfficial("0x00000a060336cbb72fe969666d337b87198b1add2abaa59cca226820b32933a4"); -static const uint256 hashGenesisBlockTestNet("0x00000a060336cbb72fe969666d337b87198b1add2abaa59cca226820b32933a4"); +static const uint256 hashGenesisBlock("0x00000a060336cbb72fe969666d337b87198b1add2abaa59cca226820b32933a4"); +static const uint256 hashGenesisBlockTestNet("0x000c763e402f2436da9ed36c7286f62c3f6e5dbafce9ff289bd43d7459327eb"); static const int64 nMaxClockDrift = 2 * 60 * 60; // two hours extern CScript COINBASE_FLAGS; - - - - extern CCriticalSection cs_main; extern std::map mapBlockIndex; extern std::set > setStakeSeen; -extern uint256 hashGenesisBlock; extern CBlockIndex* pindexGenesisBlock; extern unsigned int nStakeMinAge; extern int nCoinbaseMaturity; @@ -113,7 +111,7 @@ void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey); bool CheckProofOfWork(uint256 hash, unsigned int nBits); int64 GetProofOfWorkReward(unsigned int nBits); -int64 GetProofOfStakeReward(int64 nCoinAge); +int64 GetProofOfStakeReward(int64 nCoinAge, unsigned int nBits, unsigned int nTime); unsigned int ComputeMinWork(unsigned int nBase, int64 nTime); int GetNumBlocksOfPeers(); bool IsInitialBlockDownload(); @@ -834,7 +832,7 @@ class CBlock { public: // header - static const int CURRENT_VERSION=3; + static const int CURRENT_VERSION=4; int nVersion; uint256 hashPrevBlock; uint256 hashMerkleRoot; @@ -925,7 +923,7 @@ public: unsigned int GetStakeEntropyBit(unsigned int nHeight) const { // Protocol switch to support p2pool at novacoin block #9689 - if (nHeight >= 9689) + if (nHeight >= 9689 || fTestNet) { // Take last bit of block hash as entropy bit unsigned int nEntropyBit = ((GetHash().Get64()) & 1llu); @@ -1076,10 +1074,10 @@ public: void print() const { printf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%"PRIszu", vchBlockSig=%s)\n", - GetHash().ToString().substr(0,20).c_str(), + GetHash().ToString().c_str(), nVersion, - hashPrevBlock.ToString().substr(0,20).c_str(), - hashMerkleRoot.ToString().substr(0,10).c_str(), + hashPrevBlock.ToString().c_str(), + hashMerkleRoot.ToString().c_str(), nTime, nBits, nNonce, vtx.size(), HexStr(vchBlockSig.begin(), vchBlockSig.end()).c_str()); @@ -1345,8 +1343,8 @@ public: nStakeModifier, nStakeModifierChecksum, hashProofOfStake.ToString().c_str(), prevoutStake.ToString().c_str(), nStakeTime, - hashMerkleRoot.ToString().substr(0,10).c_str(), - GetBlockHash().ToString().substr(0,20).c_str()); + hashMerkleRoot.ToString().c_str(), + GetBlockHash().ToString().c_str()); } void print() const @@ -1430,8 +1428,8 @@ public: str += CBlockIndex::ToString(); str += strprintf("\n hashBlock=%s, hashPrev=%s, hashNext=%s)", GetBlockHash().ToString().c_str(), - hashPrev.ToString().substr(0,20).c_str(), - hashNext.ToString().substr(0,20).c_str()); + hashPrev.ToString().c_str(), + hashNext.ToString().c_str()); return str; } @@ -1510,7 +1508,7 @@ public: if (vHave.size() > 10) nStep *= 2; } - vHave.push_back(hashGenesisBlock); + vHave.push_back((!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet)); } int GetDistanceBack() @@ -1563,7 +1561,7 @@ public: return hash; } } - return hashGenesisBlock; + return (!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet); } int GetHeight() diff --git a/src/makefile.mingw b/src/makefile.mingw index b28088d..8b3311a 100644 --- a/src/makefile.mingw +++ b/src/makefile.mingw @@ -16,11 +16,11 @@ LIBPATHS= \ -L"C:\openssl-1.0.1c-mgw" LIBS= \ - -l boost_system-mgw45-mt-s-1_50 \ - -l boost_filesystem-mgw45-mt-s-1_50 \ - -l boost_program_options-mgw45-mt-s-1_50 \ - -l boost_thread-mgw45-mt-s-1_50 \ - -l boost_chrono-mgw45-mt-s-1_50 \ + -l boost_system-mgw44-mt-1_53 \ + -l boost_filesystem-mgw44-mt-1_53 \ + -l boost_program_options-mgw44-mt-1_53 \ + -l boost_thread-mgw44-mt-1_53 \ + -l boost_chrono-mgw44-mt-1_53 \ -l db_cxx \ -l ssl \ -l crypto diff --git a/src/net.cpp b/src/net.cpp index 007f49d..1363378 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -25,7 +25,7 @@ using namespace std; using namespace boost; -static const int MAX_OUTBOUND_CONNECTIONS = 8; +static const int MAX_OUTBOUND_CONNECTIONS = 16; void ThreadMessageHandler2(void* parg); void ThreadSocketHandler2(void* parg); diff --git a/src/qt/forms/sendcoinsentry.ui b/src/qt/forms/sendcoinsentry.ui index 22a3f8f..fe0f176 100644 --- a/src/qt/forms/sendcoinsentry.ui +++ b/src/qt/forms/sendcoinsentry.ui @@ -1,169 +1,169 @@ - - - SendCoinsEntry - - - - 0 - 0 - 729 - 136 - - - - Form - - - QFrame::StyledPanel - - - QFrame::Sunken - - - - 12 - - - - - A&mount: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - payAmount - - - - - - - Pay &To: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - payTo - - - - - - - - - - 0 - - - - - true - - - Enter a label for this address to add it to your address book - - - - - - - - - &Label: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - addAsLabel - - - - - - - 0 - - - - - The address to send the payment to (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L) - - - 34 - - - - - - - Choose address from address book - - - - - - - :/icons/address-book:/icons/address-book - - - Alt+A - - - - - - - Paste address from clipboard - - - - - - - :/icons/editpaste:/icons/editpaste - - - Alt+P - - - - - - - Remove this recipient - - - - - - - :/icons/remove:/icons/remove - - - - - - - - - - BitcoinAmountField - QLineEdit -
bitcoinamountfield.h
- 1 -
- - QValidatedLineEdit - QLineEdit -
qvalidatedlineedit.h
-
-
- - - - -
+ + + SendCoinsEntry + + + + 0 + 0 + 729 + 136 + + + + Form + + + QFrame::StyledPanel + + + QFrame::Sunken + + + + 12 + + + + + A&mount: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + payAmount + + + + + + + Pay &To: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + payTo + + + + + + + + + + 0 + + + + + true + + + Enter a label for this address to add it to your address book + + + + + + + + + &Label: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + addAsLabel + + + + + + + 0 + + + + + The address to send the payment to (e.g. 4Zo1ga6xuKuQ7JV7M9rGDoxdbYwV5zgQJ5) + + + 34 + + + + + + + Choose address from address book + + + + + + + :/icons/address-book:/icons/address-book + + + Alt+A + + + + + + + Paste address from clipboard + + + + + + + :/icons/editpaste:/icons/editpaste + + + Alt+P + + + + + + + Remove this recipient + + + + + + + :/icons/remove:/icons/remove + + + + + + + + + + QValidatedLineEdit + QLineEdit +
qvalidatedlineedit.h
+
+ + BitcoinAmountField + QLineEdit +
bitcoinamountfield.h
+ 1 +
+
+ + + + +
diff --git a/src/qt/forms/signverifymessagedialog.ui b/src/qt/forms/signverifymessagedialog.ui index 7d13c83..648e200 100644 --- a/src/qt/forms/signverifymessagedialog.ui +++ b/src/qt/forms/signverifymessagedialog.ui @@ -1,386 +1,386 @@ - - - SignVerifyMessageDialog - - - - 0 - 0 - 700 - 380 - - - - Signatures - Sign / Verify a Message - - - true - - - - - - 0 - - - - &Sign Message - - - - - - You can sign messages with your addresses to prove you own them. Be careful not to sign anything vague, as phishing attacks may try to trick you into signing your identity over to them. Only sign fully-detailed statements you agree to. - - - Qt::PlainText - - - true - - - - - - - 0 - - - - - The address to sign the message with (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L) - - - 34 - - - - - - - Choose an address from the address book - - - - - - - :/icons/address-book:/icons/address-book - - - Alt+A - - - false - - - - - - - Paste address from clipboard - - - - - - - :/icons/editpaste:/icons/editpaste - - - Alt+P - - - false - - - - - - - - - Enter the message you want to sign here - - - - - - - 0 - - - - - - true - - - - true - - - - - - - Copy the current signature to the system clipboard - - - - - - - :/icons/editcopy:/icons/editcopy - - - false - - - - - - - - - - - Sign the message to prove you own this NovaCoin address - - - &Sign Message - - - - :/icons/edit:/icons/edit - - - false - - - - - - - Reset all sign message fields - - - Clear &All - - - - :/icons/remove:/icons/remove - - - false - - - - - - - Qt::Horizontal - - - - 40 - 48 - - - - - - - - - 75 - true - - - - - - - true - - - - - - - Qt::Horizontal - - - - 40 - 48 - - - - - - - - - - - &Verify Message - - - - - - Enter the signing address, message (ensure you copy line breaks, spaces, tabs, etc. exactly) and signature below to verify the message. Be careful not to read more into the signature than what is in the signed message itself, to avoid being tricked by a man-in-the-middle attack. - - - Qt::PlainText - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - 0 - - - - - The address the message was signed with (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L) - - - 34 - - - - - - - Choose an address from the address book - - - - - - - :/icons/address-book:/icons/address-book - - - Alt+A - - - false - - - - - - - - - - - - - - - - - Verify the message to ensure it was signed with the specified NovaCoin address - - - &Verify Message - - - - :/icons/transaction_0:/icons/transaction_0 - - - false - - - - - - - Reset all verify message fields - - - Clear &All - - - - :/icons/remove:/icons/remove - - - false - - - - - - - Qt::Horizontal - - - - 40 - 48 - - - - - - - - - 75 - true - - - - - - - true - - - - - - - Qt::Horizontal - - - - 40 - 48 - - - - - - - - - - - - - - - QValidatedLineEdit - QLineEdit -
qvalidatedlineedit.h
-
-
- - - - -
+ + + SignVerifyMessageDialog + + + + 0 + 0 + 700 + 380 + + + + Signatures - Sign / Verify a Message + + + true + + + + + + 1 + + + + &Sign Message + + + + + + You can sign messages with your addresses to prove you own them. Be careful not to sign anything vague, as phishing attacks may try to trick you into signing your identity over to them. Only sign fully-detailed statements you agree to. + + + Qt::PlainText + + + true + + + + + + + 0 + + + + + The address to sign the message with (e.g. 4Zo1ga6xuKuQ7JV7M9rGDoxdbYwV5zgQJ5) + + + 34 + + + + + + + Choose an address from the address book + + + + + + + :/icons/address-book:/icons/address-book + + + Alt+A + + + false + + + + + + + Paste address from clipboard + + + + + + + :/icons/editpaste:/icons/editpaste + + + Alt+P + + + false + + + + + + + + + Enter the message you want to sign here + + + + + + + 0 + + + + + + true + + + + true + + + + + + + Copy the current signature to the system clipboard + + + + + + + :/icons/editcopy:/icons/editcopy + + + false + + + + + + + + + + + Sign the message to prove you own this NovaCoin address + + + &Sign Message + + + + :/icons/edit:/icons/edit + + + false + + + + + + + Reset all sign message fields + + + Clear &All + + + + :/icons/remove:/icons/remove + + + false + + + + + + + Qt::Horizontal + + + + 40 + 48 + + + + + + + + + 75 + true + + + + + + + true + + + + + + + Qt::Horizontal + + + + 40 + 48 + + + + + + + + + + + &Verify Message + + + + + + Enter the signing address, message (ensure you copy line breaks, spaces, tabs, etc. exactly) and signature below to verify the message. Be careful not to read more into the signature than what is in the signed message itself, to avoid being tricked by a man-in-the-middle attack. + + + Qt::PlainText + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + 0 + + + + + The address the message was signed with (e.g. 4Zo1ga6xuKuQ7JV7M9rGDoxdbYwV5zgQJ5) + + + 34 + + + + + + + Choose an address from the address book + + + + + + + :/icons/address-book:/icons/address-book + + + Alt+A + + + false + + + + + + + + + + + + + + + + + Verify the message to ensure it was signed with the specified NovaCoin address + + + &Verify Message + + + + :/icons/transaction_0:/icons/transaction_0 + + + false + + + + + + + Reset all verify message fields + + + Clear &All + + + + :/icons/remove:/icons/remove + + + false + + + + + + + Qt::Horizontal + + + + 40 + 48 + + + + + + + + + 75 + true + + + + + + + true + + + + + + + Qt::Horizontal + + + + 40 + 48 + + + + + + + + + + + + + + + QValidatedLineEdit + QLineEdit +
qvalidatedlineedit.h
+
+
+ + + + +
diff --git a/src/qt/res/icons/bitcoin.icns b/src/qt/res/icons/bitcoin.icns index 3c75708..65d6122 100644 Binary files a/src/qt/res/icons/bitcoin.icns and b/src/qt/res/icons/bitcoin.icns differ diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index 3706cb5..6549bbf 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -215,10 +215,8 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) strHTML += "" + tr("Transaction ID") + ": " + wtx.GetHash().ToString().c_str() + "
"; - if (wtx.IsCoinBase()) + if (wtx.IsCoinBase() || wtx.IsCoinStake()) strHTML += "
" + tr("Generated coins must mature 520 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, its state will change to \"not accepted\" and it won't be spendable. This may occasionally happen if another node generates a block within a few seconds of yours.") + "
"; - if (wtx.IsCoinStake()) - strHTML += QString("
") + tr("Staked coins must wait 520 blocks before they can return to balance and be spent. When you generated this proof-of-stake block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, it will change to \"not accepted\" and not be a valid stake. This may occasionally happen if another node generates a proof-of-stake block within a few seconds of yours.") + "
"; // // Debug view diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index 4c30719..18858e2 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -31,7 +31,12 @@ QList TransactionRecord::decomposeTransaction(const CWallet * uint256 hash = wtx.GetHash(); std::map mapValue = wtx.mapValue; - if (nNet > 0 || wtx.IsCoinBase()) + if (wtx.IsCoinStake()) + { + // Stake generation + parts.append(TransactionRecord(hash, nTime, TransactionRecord::StakeMint, "", -nDebit, wtx.GetValueOut())); + } + else if (nNet > 0 || wtx.IsCoinBase()) { // // Credit @@ -192,7 +197,7 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx) } // For generated transactions, determine maturity - if(type == TransactionRecord::Generated) + if(type == TransactionRecord::Generated || type == TransactionRecord::StakeMint) { int64 nCredit = wtx.GetCredit(true); if (nCredit == 0) diff --git a/src/qt/transactionrecord.h b/src/qt/transactionrecord.h index db06374..8d4ab03 100644 --- a/src/qt/transactionrecord.h +++ b/src/qt/transactionrecord.h @@ -68,7 +68,8 @@ public: SendToOther, RecvWithAddress, RecvFromOther, - SendToSelf + SendToSelf, + StakeMint }; /** Number of confirmation needed for transaction */ diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index 847c9e9..48c03d3 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -295,7 +295,7 @@ QString TransactionTableModel::formatTxStatus(const TransactionRecord *wtx) cons status = tr("Confirmed (%1 confirmations)").arg(wtx->status.depth); break; } - if(wtx->type == TransactionRecord::Generated) + if(wtx->type == TransactionRecord::Generated || wtx->type == TransactionRecord::StakeMint) { switch(wtx->status.maturity) { @@ -359,6 +359,7 @@ QString TransactionTableModel::formatTxType(const TransactionRecord *wtx) const return tr("Sent to"); case TransactionRecord::SendToSelf: return tr("Payment to yourself"); + case TransactionRecord::StakeMint: case TransactionRecord::Generated: return tr("Mined"); default: @@ -371,6 +372,7 @@ QVariant TransactionTableModel::txAddressDecoration(const TransactionRecord *wtx switch(wtx->type) { case TransactionRecord::Generated: + case TransactionRecord::StakeMint: return QIcon(":/icons/tx_mined"); case TransactionRecord::RecvWithAddress: case TransactionRecord::RecvFromOther: @@ -438,7 +440,7 @@ QString TransactionTableModel::formatTxAmount(const TransactionRecord *wtx, bool QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx) const { - if(wtx->type == TransactionRecord::Generated) + if(wtx->type == TransactionRecord::Generated || wtx->type == TransactionRecord::StakeMint) { switch(wtx->status.maturity) { @@ -573,7 +575,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const return QString::fromStdString(rec->getTxID()); case ConfirmedRole: // Return True if transaction counts for balance - return rec->status.confirmed && !(rec->type == TransactionRecord::Generated && + return rec->status.confirmed && !((rec->type == TransactionRecord::Generated || rec->type == TransactionRecord::StakeMint) && rec->status.maturity != TransactionStatus::Mature); case FormattedAmountRole: return formatTxAmount(rec, false); diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index 7acf5de..acd73e6 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -74,6 +74,7 @@ TransactionView::TransactionView(QWidget *parent) : typeWidget->addItem(tr("Sent to"), TransactionFilterProxy::TYPE(TransactionRecord::SendToAddress) | TransactionFilterProxy::TYPE(TransactionRecord::SendToOther)); typeWidget->addItem(tr("To yourself"), TransactionFilterProxy::TYPE(TransactionRecord::SendToSelf)); + typeWidget->addItem(tr("Mined"), TransactionFilterProxy::TYPE(TransactionRecord::StakeMint)); typeWidget->addItem(tr("Mined"), TransactionFilterProxy::TYPE(TransactionRecord::Generated)); typeWidget->addItem(tr("Other"), TransactionFilterProxy::TYPE(TransactionRecord::Other)); diff --git a/src/util.cpp b/src/util.cpp index 95bc3a9..027ee10 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1062,7 +1062,7 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific) path = GetDefaultDataDir(); } if (fNetSpecific && GetBoolArg("-testnet", false)) - path /= "testnet"; + path /= "testnet2"; fs::create_directory(path); diff --git a/src/version.h b/src/version.h index 0db6dc9..1f7d788 100644 --- a/src/version.h +++ b/src/version.h @@ -25,7 +25,7 @@ extern const std::string CLIENT_DATE; // network protocol versioning // -static const int PROTOCOL_VERSION = 60005; +static const int PROTOCOL_VERSION = 60006; // earlier versions not supported as of Feb 2012, and are disconnected static const int MIN_PROTO_VERSION = 209; @@ -46,7 +46,7 @@ static const int MEMPOOL_GD_VERSION = 60002; #define DISPLAY_VERSION_MAJOR 0 #define DISPLAY_VERSION_MINOR 4 -#define DISPLAY_VERSION_REVISION 0 +#define DISPLAY_VERSION_REVISION 1 #define DISPLAY_VERSION_BUILD 0 #endif diff --git a/src/wallet.cpp b/src/wallet.cpp index 7715419..e84920f 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1479,7 +1479,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int CTxDB txdb("r"); if (!txNew.GetCoinAge(txdb, nCoinAge)) return error("CreateCoinStake : failed to calculate coin age"); - nCredit += GetProofOfStakeReward(nCoinAge); + nCredit += GetProofOfStakeReward(nCoinAge, nBits, txNew.nTime); } int64 nMinFee = 0; @@ -1838,7 +1838,8 @@ void CWallet::KeepKey(int64 nIndex) CWalletDB walletdb(strWalletFile); walletdb.ErasePool(nIndex); } - printf("keypool keep %"PRI64d"\n", nIndex); + if(fDebug) + printf("keypool keep %"PRI64d"\n", nIndex); } void CWallet::ReturnKey(int64 nIndex) @@ -1848,7 +1849,8 @@ void CWallet::ReturnKey(int64 nIndex) LOCK(cs_wallet); setKeyPool.insert(nIndex); } - printf("keypool return %"PRI64d"\n", nIndex); + if(fDebug) + printf("keypool return %"PRI64d"\n", nIndex); } bool CWallet::GetKeyFromPool(CPubKey& result, bool fAllowReuse)