diff --git a/configure.ac b/configure.ac index 3de2279d6..51e81526f 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.69]) define(_CLIENT_VERSION_MAJOR, 0) define(_CLIENT_VERSION_MINOR, 13) define(_CLIENT_VERSION_REVISION, 2) -define(_CLIENT_VERSION_BUILD, 2) +define(_CLIENT_VERSION_BUILD, 3) define(_CLIENT_VERSION_IS_RELEASE, true) define(_COPYRIGHT_YEAR, 2019) AC_INIT([Kore Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[www.kore.org],[kore]) diff --git a/depends/.gitignore b/depends/.gitignore new file mode 100644 index 000000000..1f163897b --- /dev/null +++ b/depends/.gitignore @@ -0,0 +1,9 @@ +SDKs/ +work/ +built/ +sources/ +config.site +x86_64* +i686* +mips* +arm* diff --git a/doc/.gitignore b/doc/.gitignore new file mode 100644 index 000000000..cef6e7b6b --- /dev/null +++ b/doc/.gitignore @@ -0,0 +1 @@ +Doxyfile \ No newline at end of file diff --git a/qa/rpc-tests/.gitignore b/qa/rpc-tests/.gitignore new file mode 100644 index 000000000..cb41d9442 --- /dev/null +++ b/qa/rpc-tests/.gitignore @@ -0,0 +1,2 @@ +*.pyc +cache diff --git a/qa/rpc-tests/python-bitcoinrpc/bitcoinrpc/.gitignore b/qa/rpc-tests/python-bitcoinrpc/bitcoinrpc/.gitignore new file mode 100644 index 000000000..0d20b6487 --- /dev/null +++ b/qa/rpc-tests/python-bitcoinrpc/bitcoinrpc/.gitignore @@ -0,0 +1 @@ +*.pyc diff --git a/src/blocksignature.h b/src/blocksignature.h index b7e4dbb61..4a53bd3c4 100644 --- a/src/blocksignature.h +++ b/src/blocksignature.h @@ -12,7 +12,6 @@ bool SignBlockWithKey(CBlock& block, const CKey& key); bool SignBlock(CBlock& block, const CKeyStore& keystore); bool CheckBlockSignature(const CBlock& block); - bool CheckBlockSignature_Legacy(const CBlock& block, const uint256& hash); #endif //KORE_BLOCKSIGNATURE_H diff --git a/src/chainparams.cpp b/src/chainparams.cpp index fadb7bcd7..8394ed6f0 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -123,7 +123,7 @@ class CMainParams : public CChainParams nCoinMaturity = 25; nMaxMoneyOut = MAX_MONEY; nMaxReorganizationDepth = 25; - nMaxTipAge = 24 * 60 * 60; + nMaxTipAge = 2 * 60 * 60; nMinerConfirmationWindow = 50; // nPowTargetTimespan / nPowTargetSpacing nMinerThreads = 0; nPastBlocksMax = 128; @@ -248,6 +248,24 @@ class CTestNetParams : public CMainParams /* nTxCount */ 0, /* dTxRate */ 0 }; + + // + checkpointData = { + { + { 0, nHashGenesisBlock}, + { 25000, uint256S("0xdf692454f3b24470af3fe9d3e4591ae16a98f2d9709e33889001c2df3b27c747")} + } + }; + + // Getting info from + // getchaintxstats 24999 df692454f3b24470af3fe9d3e4591ae16a98f2d9709e33889001c2df3b27c747 + chainTxData = ChainTxData{ + // Data from rpc: getchaintxstats + /* nTime */ 1559712610, + /* nTxCount */ 50376, + /* dTxRate */ 0.02124285951644177 + }; + } }; static CTestNetParams testNetParams; diff --git a/src/chainparams.h b/src/chainparams.h index 015d05fdb..c055af213 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -98,7 +98,7 @@ class CChainParams int64_t GetBudgetFeeConfirmations() const { return nBudgetFeeConfirmations; } int64_t GetBudgetVoteUpdate() const { return nBudgetVoteUpdate; } int32_t GetCoinMaturity() const { return nCoinMaturity; } - /** Used if GenerateBitcoins is called with a negative number of threads */ + /** Used if GenerateKores is called with a negative number of threads */ int32_t GetDefaultMinerThreads() const { return nMinerThreads; } int32_t GetDefaultPort() const { return nDefaultPort; } std::string GetDevFundPubKey() const { return strDevFundPubKey; } diff --git a/src/coins.cpp b/src/coins.cpp index 7ee66cec9..f3035cf9e 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -155,7 +155,7 @@ CCoinsModifier CCoinsViewCache::ModifyCoins(const uint256& txid) size_t cachedCoinUsage = 0; if (fDebug) { LogPrintf("Coins in the cache : %d \n", cacheCoins.size()); - LogPrintf("ModifyCoins_Legacy txid: %s inserted ? %s \n", txid.ToString().c_str(), ret.second ? "true" : "false"); + LogPrintf("ModifyCoins txid: %s inserted ? %s \n", txid.ToString().c_str(), ret.second ? "true" : "false"); } if (ret.second) { if (!base->GetCoins(txid, ret.first->second.coins)) { diff --git a/src/init.cpp b/src/init.cpp index b908215fe..17b513b26 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -197,7 +197,7 @@ void PrepareShutdown() #ifdef ENABLE_WALLET if (pwalletMain) bitdb.Flush(false); - GenerateBitcoins(false, NULL, 0); + GenerateKores(false, 0); #endif StopNode(); StopTorControl(); @@ -1738,7 +1738,7 @@ bool AppInit2() #ifdef ENABLE_WALLET // Mine proof-of-stake blocks in the background if (pwalletMain) - GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain, GetArg("-genproclimit", 1)); + GenerateKores(GetBoolArg("-gen", false), GetArg("-genproclimit", 1)); // Mine proof-of-stake blocks in the background if (!GetBoolArg("-staking", false)) LogPrintf("Staking disabled\n"); diff --git a/src/leveldb/.gitignore b/src/leveldb/.gitignore new file mode 100644 index 000000000..71d87a4ee --- /dev/null +++ b/src/leveldb/.gitignore @@ -0,0 +1,13 @@ +build_config.mk +*.a +*.o +*.dylib* +*.so +*.so.* +*_test +db_bench +leveldbutil +Release +Debug +Benchmark +vs2010.* diff --git a/src/main.cpp b/src/main.cpp index 6f4b7ef85..dea64d802 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2089,7 +2089,7 @@ bool IsInitialBlockDownload() static bool lockIBDState = false; if (lockIBDState) return false; - bool state = (chainActive.Height() < pindexBestHeader->nHeight - 24 * 60 || // 60 => Blocks per hour + bool state = (chainActive.Height() < pindexBestHeader->nHeight - 2 * 60 || // 60 Blocks per hour pindexBestHeader->GetBlockTime() < GetTime() - chainParams.GetMaxTipAge()); // ~1440 blocks behind -> 2 x fork detection time if (!state) lockIBDState = true; @@ -2891,7 +2891,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin int64_t nTime1 = GetTimeMicros(); nTimeConnect += nTime1 - nTimeStart; - LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", + LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs - 1), nTimeConnect * 0.000001); @@ -2909,7 +2909,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin int64_t nTime2 = GetTimeMicros(); nTimeVerify += nTime2 - nTimeStart; - LogPrint("bench", " - Verify %u txins: %.2fms (%.3fms/txin) [%.2fs]\n", nInputs - 1, 0.001 * (nTime2 - nTimeStart), + LogPrint("bench", " - Verify %u txins: %.2fms (%.3fms/txin) [%.2fs]\n", nInputs - 1, 0.001 * (nTime2 - nTimeStart), nInputs <= 1 ? 0 : 0.001 * (nTime2 - nTimeStart) / (nInputs - 1), nTimeVerify * 0.000001); //IMPORTANT NOTE: Nothing before this point should actually store to disk (or even memory) @@ -2942,7 +2942,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin int64_t nTime3 = GetTimeMicros(); nTimeIndex += nTime3 - nTime2; - LogPrint("bench", " - Index writing: %.2fms [%.2fs]\n", 0.001 * (nTime3 - nTime2), nTimeIndex * 0.000001); + LogPrint("bench", " - Index writing: %.2fms [%.2fs]\n", 0.001 * (nTime3 - nTime2), nTimeIndex * 0.000001); // Watch for changes to the previous coinbase transaction. static uint256 hashPrevBestCoinBase; @@ -2951,7 +2951,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin int64_t nTime4 = GetTimeMicros(); nTimeCallbacks += nTime4 - nTime3; - LogPrint("bench", " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime3), nTimeCallbacks * 0.000001); + LogPrint("bench", " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime3), nTimeCallbacks * 0.000001); return true; } @@ -3532,11 +3532,14 @@ void static UpdateTip(CBlockIndex* pindexNew) mempool.AddTransactionsUpdated(1); if (fDebug) - LogPrintf("%s: new best=%s height=%d log2_work=%.8g tx=%lu date=%s progress=%f cache=%.1fMiB(%utx)\n", __func__, - chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(), log(chainActive.Tip()->nChainWork.getdouble()) / log(2.0), (unsigned long)chainActive.Tip()->nChainTx, - DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()), - Checkpoints::GuessVerificationProgress(Params().GetTxData(), chainActive.Tip()), pcoinsTip->DynamicMemoryUsage() * (1.0 / (1 << 20)), pcoinsTip->GetCacheSize()); - + LogPrintf("%s:\n", __func__); + LogPrintf("New Best Block: %s\n", chainActive.Tip()->GetBlockHash().ToString()); + LogPrintf("Height: %d\n", chainActive.Height()); + LogPrintf("log2_work: %.8g\n", log(chainActive.Tip()->nChainWork.getdouble()) / log(2.0)); + LogPrintf("tx: %lu\n", (unsigned long)chainActive.Tip()->nChainTx); + LogPrintf("date: %s\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime())); + LogPrintf("progress: %f\n", Checkpoints::GuessVerificationProgress(Params().GetTxData(), chainActive.Tip())); + LogPrintf("cache: %.1fMiB(%utx)\n", pcoinsTip->DynamicMemoryUsage() * (1.0 / (1 << 20)), pcoinsTip->GetCacheSize()); cvBlockChange.notify_all(); // Check the version of the last 100 blocks to see if we need to upgrade: @@ -3679,7 +3682,7 @@ bool static ConnectTip(CValidationState& state, CBlockIndex* pindexNew, const CB int64_t nTime6 = GetTimeMicros(); nTimePostConnect += nTime6 - nTime5; nTimeTotal += nTime6 - nTime1; - LogPrint("bench", " - Connect postprocess: %.2fms [%.2fs]\n", (nTime6 - nTime5) * 0.001, nTimePostConnect * 0.000001); + LogPrint("bench", "- Connect postprocess: %.2fms [%.2fs]\n", (nTime6 - nTime5) * 0.001, nTimePostConnect * 0.000001); LogPrint("bench", "- Connect block: %.2fms [%.2fs]\n", (nTime6 - nTime1) * 0.001, nTimeTotal * 0.000001); return true; @@ -4972,8 +4975,8 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex, CAmount stakedBalance; if (!CheckProofOfStake(block, hashProofOfStake, listStake, stakedBalance)){ - if (nHeight < 493000) - return state.DoS(1, error("%s: proof of stake check failed", __func__)); + if (IsInitialBlockDownload()) + return state.DoS(0, error("%s: proof of stake check failed", __func__)); return state.DoS(100, error("%s: proof of stake check failed", __func__)); } @@ -5034,7 +5037,7 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex, } if (fDebug) { - LogPrintf("AcceptBlock block: %d<-- \n",nHeight); + LogPrintf("AcceptBlock block: %d \n",nHeight); } return true; } @@ -6530,7 +6533,7 @@ bool static ProcessMessageGetHeaders(CNode* pfrom, string strCommand, CDataStrea // we must use CBlocks, as CBlockHeaders won't include the 0x00 nTx count at the end vector vHeaders; int nLimit = MAX_HEADERS_RESULTS; - if (pindex != NULL) + if (pindex != NULL) LogPrint("net", "getheaders for block %d with hash %s from peerId=%d\n", pindex->nHeight, (locator.IsNull() ? hashStop.ToString() : pindex->GetBlockHash().ToString()), pfrom->id); for (; pindex; pindex = chainActive.Next(pindex)) { vHeaders.push_back(pindex->GetBlockHeader()); diff --git a/src/miner.cpp b/src/miner.cpp index 359a36b50..48d86ec61 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -6,7 +6,6 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "miner.h" - #include "amount.h" #include "arith_uint256.h" #include "hash.h" @@ -29,10 +28,10 @@ #include "invalid.h" #include "validationinterface.h" - #include #include #include +#include #include // Legacy using namespace std; @@ -41,7 +40,6 @@ using namespace std; // // KOREMiner // - // // Unconfirmed transactions in the memory pool often depend on other // transactions in the memory pool. When we select transactions from the @@ -106,8 +104,8 @@ CAmount GetBlockReward(CBlockIndex* pindexPrev) if (pindexPrev->nMoneySupply == MAX_MONEY) return 0; - double moneySupplyFloat = (double)pindexPrev->nMoneySupply / COIN; - double rewardDouble = pow(1.44e14 - pow(moneySupplyFloat, 2), (double)1 / 2)/1.436e7; + double moneySupplyFloat = (double)pindexPrev->nMoneySupply / COIN; + double rewardDouble = pow(1.44e14 - pow(moneySupplyFloat, 2), (double)1 / 2) / 1.436e7; CAmount reward = ceil(rewardDouble * COIN); if (reward + pindexPrev->nMoneySupply < MAX_MONEY) @@ -135,12 +133,11 @@ inline CBlockIndex* GetParentIndex(CBlockIndex* index) return index->pprev; } -unsigned int static DarkGravityWave3(const CBlockIndex* pindexLast, const CBlockHeader *pblock, bool fProofOfStake) +unsigned int static DarkGravityWave3(const CBlockIndex* pindexLast, const CBlockHeader* pblock, bool fProofOfStake) { /* current difficulty formula, darkcoin - DarkGravity v3, written by Evan Duffield - evan@darkcoin.io */ - const CBlockIndex *BlockLastSolved = pindexLast; - const CBlockIndex *BlockReading = pindexLast; - const CBlockHeader *BlockCreating = pblock; + const CBlockIndex* BlockLastSolved = pindexLast; + const CBlockIndex* BlockReading = pindexLast; int64_t nActualTimespan = 0; int64_t LastBlockTime = 0; static int64_t PastBlocksMin = 24; @@ -151,49 +148,57 @@ unsigned int static DarkGravityWave3(const CBlockIndex* pindexLast, const CBlock static int64_t nTargetSpacing = Params().GetTargetSpacing(); if (BlockLastSolved == NULL || BlockLastSolved->nHeight == 0 || BlockLastSolved->nHeight < PastBlocksMin) { - return fProofOfStake ? Params().ProofOfStakeLimit().GetCompact() : Params().ProofOfWorkLimit().GetCompact(); + return fProofOfStake ? Params().ProofOfStakeLimit().GetCompact() : Params().ProofOfWorkLimit().GetCompact(); } - + uint256 bnTargetLimit = fProofOfStake ? Params().ProofOfStakeLimit() : Params().ProofOfWorkLimit(); // loop over the past n blocks, where n == PastBlocksMax for (unsigned int i = 1; BlockReading && BlockReading->nHeight > 0; i++) { - if (PastBlocksMax > 0 && i > PastBlocksMax) { break; } + if (PastBlocksMax > 0 && i > PastBlocksMax) { + break; + } CountBlocks++; // Calculate average difficulty based on the blocks we iterate over in this for loop - if(CountBlocks <= PastBlocksMin) { - if (CountBlocks == 1) { PastDifficultyAverage.SetCompact(BlockReading->nBits); } - else { PastDifficultyAverage = ((PastDifficultyAveragePrev * CountBlocks)+(uint256().SetCompact(BlockReading->nBits))) / (CountBlocks+1); } + if (CountBlocks <= PastBlocksMin) { + if (CountBlocks == 1) + PastDifficultyAverage.SetCompact(BlockReading->nBits); + else + PastDifficultyAverage = ((PastDifficultyAveragePrev * CountBlocks) + (uint256().SetCompact(BlockReading->nBits))) / (CountBlocks + 1); + PastDifficultyAveragePrev = PastDifficultyAverage; } // If this is the second iteration (LastBlockTime was set) - if(LastBlockTime > 0){ + if (LastBlockTime > 0) { // Calculate time difference between previous block and current block int64_t Diff = (LastBlockTime - BlockReading->GetBlockTime()); // Increment the actual timespan nActualTimespan += Diff; } // Set LasBlockTime to the block time for the block in current iteration - LastBlockTime = BlockReading->GetBlockTime(); + LastBlockTime = BlockReading->GetBlockTime(); - if (BlockReading->pprev == NULL) { assert(BlockReading); break; } + if (BlockReading->pprev == NULL) { + assert(BlockReading); + break; + } BlockReading = BlockReading->pprev; } - + // bnNew is the difficulty uint256 bnNew(PastDifficultyAverage); // nTargetTimespan is the time that the CountBlocks should have taken to be generated. - int64_t nTargetTimespan = CountBlocks*nTargetSpacing; + int64_t nTargetTimespan = CountBlocks * nTargetSpacing; // Limit the re-adjustment to 3x or 0.33x // We don't want to increase/decrease diff too much. - if (nActualTimespan < nTargetTimespan/3) - nActualTimespan = nTargetTimespan/3; - if (nActualTimespan > nTargetTimespan*3) - nActualTimespan = nTargetTimespan*3; + if (nActualTimespan < nTargetTimespan / 3) + nActualTimespan = nTargetTimespan / 3; + if (nActualTimespan > nTargetTimespan * 3) + nActualTimespan = nTargetTimespan * 3; int64_t nMyBlockSpacing = pblock->GetBlockTime() - pindexLast->GetBlockTime(); @@ -216,15 +221,13 @@ unsigned int static DarkGravityWave3(const CBlockIndex* pindexLast, const CBlock uint32_t GetNextTarget(const CBlockIndex* pindexLast, const CBlockHeader* pblock, bool fProofOfStake) { - // Lico - return UseLegacyCode(pindexLast->nHeight + 1) ? - GetNextWorkRequired_Legacy(pindexLast, pblock, fProofOfStake) : - DarkGravityWave3(pindexLast, pblock, fProofOfStake); - + // Lico + return UseLegacyCode(pindexLast->nHeight + 1) ? + GetNextWorkRequired_Legacy(pindexLast, pblock, fProofOfStake) : + DarkGravityWave3(pindexLast, pblock, fProofOfStake); } - inline CMutableTransaction CreateCoinbaseTransaction(const CScript& scriptPubKeyIn) { // Create coinbase tx @@ -237,11 +240,8 @@ inline CMutableTransaction CreateCoinbaseTransaction(const CScript& scriptPubKey return txNew; } -std::pair > pCheckpointCache; CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet, bool fProofOfStake) { - CReserveKey reservekey(pwallet); - // Create new block unique_ptr pblocktemplate(new CBlockTemplate(CBlockHeader::POS_FORK_VERSION)); if (!pblocktemplate.get()) @@ -263,25 +263,19 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet, pblocktemplate->vTxFees.push_back(-1); // updated at end pblocktemplate->vTxSigOps.push_back(-1); // updated at end - // ppcoin: if coinstake available add coinstake tx if (fProofOfStake) { boost::this_thread::interruption_point(); static int64_t nLastCoinStakeSearchTime = GetAdjustedTime(); // only initialized at startup - bool fStakeFound = false; unsigned int nTxNewTime = 0; - CKey key; CMutableTransaction txCoinbase; CMutableTransaction txCoinStake; - pblock->nTime = GetAdjustedTime(); - CBlockIndex* pindexPrev = chainActive.Tip(); - pblock->nBits = GetNextTarget(pindexPrev, pblock, fProofOfStake); + pblock->nBits = GetNextTarget(chainActive.Tip(), pblock, fProofOfStake); int64_t nSearchTime = pblock->nTime; // search to current time - if (nSearchTime >= nLastCoinStakeSearchTime) { - if (pwallet->CreateCoinStake(*pwallet, pblock->nBits, nSearchTime - nLastCoinStakeSearchTime, txCoinbase, txCoinStake, nTxNewTime, fProofOfStake, key)) { + if (pwallet->CreateCoinStake(*pwallet, pblock->nBits, nSearchTime - nLastCoinStakeSearchTime, txCoinbase, txCoinStake, nTxNewTime, fProofOfStake)) { pblock->nTime = nTxNewTime; pblock->vtx[0] = CTransaction(txCoinbase); pblock->vtx.push_back(CTransaction(txCoinStake)); @@ -291,13 +285,15 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet, } if (fDebug && fStakeFound) LogPrintf("%s(): stake found\n", __func__); - + if (!fStakeFound) return NULL; - } + } else + pblock->nTime = GetAdjustedTime(); // Largest block you're willing to create: unsigned int nBlockMaxSize = GetArg("-blockmaxsize", DEFAULT_BLOCK_MAX_SIZE); + // Limit to betweeen 1K and MAX_BLOCK_SIZE-1K for sanity: unsigned int nBlockMaxSizeNetwork = MAX_BLOCK_SIZE; nBlockMaxSize = std::max((unsigned int)1000, std::min((nBlockMaxSizeNetwork - 1000), nBlockMaxSize)); @@ -320,10 +316,6 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet, CBlockIndex* pindexPrev = chainActive.Tip(); const int nHeight = pindexPrev->nHeight + 1; - if (!fProofOfStake) - pblock->nTime = GetAdjustedTime(); - // we will be creating blocks from after fork here always - pblock->nVersion = CBlockHeader::POS_FORK_VERSION; CCoinsViewCache view(pcoinsTip); // Priority order to process transactions @@ -375,7 +367,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet, if (invalid_out::ContainsOutPoint(txin.prevout)) { if (fDebug) LogPrintf("%s : found invalid input %s in tx %s", __func__, txin.prevout.ToString(), tx.GetHash().ToString()); - + fMissingInputs = true; break; } @@ -481,9 +473,9 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet, nBlockSigOps += nTxSigOps; nFees += nTxFees; - if (fPrintPriority && fDebug) + if (fPrintPriority && fDebug) LogPrintf("priority %.1f fee %s txid %s\n", dPriority, feeRate.ToString(), tx.GetHash().ToString()); - + // Add transactions that depend on this one to the priority queue if (mapDependers.count(hash)) { BOOST_FOREACH (COrphan* porphan, mapDependers[hash]) { @@ -507,16 +499,12 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet, pblock->vtx[0] = txNew; pblock->vtx[0].vin[0].scriptSig = CScript() << nHeight << OP_0; pblock->vtx[0].vout[0].nValue += nFees; - } - else + UpdateTime(pblock, pindexPrev, fProofOfStake); + } else pblock->vtx[0].vout[1].nValue += nFees; // Fill in header pblock->hashPrevBlock = pindexPrev->GetBlockHash(); - if (!fProofOfStake) { - UpdateTime(pblock, pindexPrev, fProofOfStake); - pblock->nBits = GetNextTarget(pindexPrev, pblock, fProofOfStake); - } pblock->nNonce = 0; pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]); @@ -544,7 +532,7 @@ inline CMutableTransaction CreateCoinbaseTransaction_Legacy(const CScript& scrip txNew.vin[0].prevout.SetNull(); txNew.vin[0].scriptSig = CScript() << nHeight << OP_0; txNew.nTime = GetAdjustedTime(); - txNew.SetVersion(1); + txNew.SetVersion(1); if (fProofOfStake) { txNew.vout.resize(1); @@ -782,7 +770,7 @@ CBlockTemplate* CreateNewBlock_Legacy(const CChainParams& chainparams, const CSc } -void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce) +void IncrementExtraNonce(CBlock* pblock, const CBlockIndex* pindexPrev, unsigned int& nExtraNonce) { // Update nExtraNonce static uint256 hashPrevBlock; @@ -800,24 +788,6 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& pblock->hashMerkleRoot = pblock->BuildMerkleTree(); } -void IncrementExtraNonce_Legacy(CBlock* pblock, const CBlockIndex* pindexPrev, unsigned int& nExtraNonce) -{ - // Update nExtraNonce - static uint256 hashPrevBlock; - if (hashPrevBlock != pblock->hashPrevBlock) { - nExtraNonce = 0; - hashPrevBlock = pblock->hashPrevBlock; - } - ++nExtraNonce; - unsigned int nHeight = pindexPrev->nHeight + 1; // Height first in coinbase required for block.version=2 - CMutableTransaction txCoinbase(pblock->vtx[0]); - txCoinbase.vin[0].scriptSig = (CScript() << nHeight << CScriptNum(nExtraNonce)) + COINBASE_FLAGS; - assert(txCoinbase.vin[0].scriptSig.size() <= 100); - - pblock->vtx[0] = txCoinbase; - pblock->hashMerkleRoot = BlockMerkleRoot(*pblock); -} - #ifdef ENABLE_WALLET ////////////////////////////////////////////////////////////////////////////// // @@ -892,8 +862,6 @@ bool ProcessBlockFound_Legacy(const CBlock* pblock, const CChainParams& chainpar return true; } -#include - // attempt to generate suitable proof-of-stake bool SignBlock_Legacy(CWallet* pwallet, CBlock* pblock) { @@ -908,7 +876,7 @@ bool SignBlock_Legacy(CWallet* pwallet, CBlock* pblock) if (pblock->IsProofOfStake()) { if (fDebug) LogPrintf("trying to sign a complete proof-of-stake block\n"); - + return true; } @@ -925,7 +893,6 @@ bool SignBlock_Legacy(CWallet* pwallet, CBlock* pblock) if (nSearchTime >= nLastCoinStakeSearchTime) { int64_t nSearchInterval = 1; if (pwallet->CreateCoinStake_Legacy(*pwallet, pblock, nSearchInterval, nFees, txCoinStake, key)) { - // we have to make sure that we have no future timestamps in our transactions set for (vector::iterator it = pblock->vtx.begin(); it != pblock->vtx.end();) if (it->nTime > pblock->nTime) { @@ -945,108 +912,68 @@ bool SignBlock_Legacy(CWallet* pwallet, CBlock* pblock) return false; } -bool fGenerateBitcoins = false; -bool fMintableCoins = false; -int nMintableLastCheck = 0; - -// ***TODO*** that part changed in bitcoin, we are using a mix with old one here for now - -void BitcoinMiner(CWallet* pwallet, bool fProofOfStake) +void KoreMinter(CWallet* pwallet) { - LogPrintf("KOREMiner started, fProofOfStake:%s \n", fProofOfStake ? "true" : "false"); + LogPrintf("KOREMitner started"); SetThreadPriority(THREAD_PRIORITY_LOWEST); - RenameThread("kore-miner"); + RenameThread("kore-minter"); // Each thread has its own key and counter CReserveKey reservekey(pwallet); unsigned int nExtraNonce = 0; + bool fMintableCoins = false; + int nMintableLastCheck = 0; - while (!ShutdownRequested() && UseLegacyCode(GetnHeight(chainActive.Tip()) + 1)) { + while (!ShutdownRequested()) { boost::this_thread::interruption_point(); - // while nobody requested to shutdown and we should use the legacy code - // this thread should wait - if (fDebug) { - LogPrintf("This thread is waiting for the Fork to happen.\n"); - LogPrintf("Current nHeight: %d \n", GetnHeight(chainActive.Tip())); - LogPrintf("Height to Fork : %d \n", Params().HeightToFork()); + //control the amount of times the client will check for mintable coins + if ((GetTime() - nMintableLastCheck > Params().GetTargetSpacing())) { + nMintableLastCheck = GetTime(); + fMintableCoins = pwallet->MintableCoins(); } - // check every 5 seconds - MilliSleep(10000); - } - if (fDebug) - LogPrintf("We are Free to create Block: %s \n", GetnHeight(chainActive.Tip()) + 1); - - while (!ShutdownRequested() && (fGenerateBitcoins || fProofOfStake)) { - boost::this_thread::interruption_point(); - if (fProofOfStake) { - //control the amount of times the client will check for mintable coins - if ((GetTime() - nMintableLastCheck > Params().GetTargetSpacing())) { - nMintableLastCheck = GetTime(); - fMintableCoins = pwallet->MintableCoins(); - } - while (vNodes.empty() || pwallet->IsLocked() || !fMintableCoins || pwallet->GetBalance() == 0 || nReserveBalance > pwallet->GetBalance()) - { - if (fDebug) { - LogPrintf("%s(): still unable to stake.\n", __func__); - if (vNodes.empty()) - LogPrintf("\tThere are no nodes connected;\n"); - if (pwallet->IsLocked()) - LogPrintf("\tThe wallet is locked;\n"); - if (!fMintableCoins) - LogPrintf("\tThere are no mintable coins;\n"); - if (pwallet->GetBalance() == 0) - LogPrintf("\tZero balance;\n"); - if (nReserveBalance >= pwallet->GetBalance()) - LogPrintf("\tThe wallet balance is lower than the reserved balance;\n"); - } - - MilliSleep(5000); - boost::this_thread::interruption_point(); - if (!fGenerateBitcoins && !fProofOfStake) { - if (fDebug) - LogPrintf("BitcoinMiner Going out of Loop !!! \n"); + while (vNodes.empty() || pwallet->IsLocked() || !fMintableCoins || (pwallet->GetBalance() - nReserveBalance) < MINIMUM_STAKE_VALUE) { + if (fDebug) { + LogPrintf("%s(): still unable to stake.\n", __func__); + if (vNodes.empty()) + LogPrintf("\tThere are no nodes connected;\n"); + if (pwallet->IsLocked()) + LogPrintf("\tThe wallet is locked;\n"); + if (!fMintableCoins) + LogPrintf("\tThere are no mintable coins;\n"); + if (pwallet->GetBalance() - nReserveBalance < MINIMUM_STAKE_VALUE) + LogPrintf("\tAvailable balance to stake is less than minimun stake value;\n"); + } - continue; - } + MilliSleep(5000); + boost::this_thread::interruption_point(); - // Do a separate 1 minute check here to ensure fMintableCoins is updated - if (!fMintableCoins) { - if (GetTime() - nMintableLastCheck > Params().GetTargetSpacing()) // 1 minute check time - { - nMintableLastCheck = GetTime(); - fMintableCoins = pwallet->MintableCoins(); - } - } + // Do a separate 1 minute check here to ensure fMintableCoins is updated + if (!fMintableCoins && GetTime() - nMintableLastCheck > Params().GetTargetSpacing()) { + nMintableLastCheck = GetTime(); + fMintableCoins = pwallet->MintableCoins(); } + } - if (mapHashedBlocks.count(chainActive.Tip()->nHeight)) //search our map of hashed blocks, see if bestblock has been hashed yet + if (mapHashedBlocks.count(chainActive.Tip()->nHeight)) //search our map of hashed blocks, see if bestblock has been hashed yet + { + if (GetTime() - mapHashedBlocks[chainActive.Tip()->nHeight] < Params().GetTargetSpacingForStake() / 2) // wait half of the nHashDrift { - if (GetTime() - mapHashedBlocks[chainActive.Tip()->nHeight] < Params().GetTargetSpacingForStake() / 2) // wait half of the nHashDrift - { - MilliSleep(5000); - boost::this_thread::interruption_point(); - if (!fGenerateBitcoins && !fProofOfStake) { - if (fDebug) - LogPrintf("BitcoinMiner Going out of Loop !!! \n"); - - continue; - } - } + MilliSleep(500); + boost::this_thread::interruption_point(); } } - if (vNodes.size() < 3 || nChainHeight < GetBestPeerHeight()) { - MilliSleep(60000); + if (vNodes.size() < 3 || IsInitialBlockDownload()) { + MilliSleep(2 * 60 * 1000); continue; } - if (!fProofOfStake && (chainActive.Tip()->nHeight > Params().GetLastPoWBlock())) { - if (fDebug) - LogPrintf("Pow Period has ended, we need to exit this thread \n"); - - break; + if (nChainHeight < GetBestPeerHeight()) { + MilliSleep(5000); + continue; } + // // Create new block // @@ -1057,7 +984,7 @@ void BitcoinMiner(CWallet* pwallet, bool fProofOfStake) continue; } - unique_ptr pblocktemplate(CreateNewBlockWithKey(reservekey, pwallet, fProofOfStake)); + unique_ptr pblocktemplate(CreateNewBlockWithKey(reservekey, pwallet, true)); if (!pblocktemplate.get()) continue; @@ -1065,222 +992,36 @@ void BitcoinMiner(CWallet* pwallet, bool fProofOfStake) IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); //Stake miner main - if (fProofOfStake) { - LogPrintf("%s(): proof-of-stake block found %s \n", __func__, pblock->GetHash().ToString().c_str()); - - if (!SignBlock(*pblock, *pwallet)) { - LogPrintf("%s(): Signing new block with UTXO key failed \n", __func__); - MilliSleep(500); - continue; - } + LogPrintf("%s(): proof-of-stake block found %s \n", __func__, pblock->GetHash().ToString().c_str()); - if (fDebug) - LogPrintf("BitcoinMiner : proof-of-stake block was signed %s \n", pblock->GetHash().ToString().c_str()); - - SetThreadPriority(THREAD_PRIORITY_NORMAL); - ProcessBlockFound(pblock, *pwallet, reservekey); - SetThreadPriority(THREAD_PRIORITY_LOWEST); - MilliSleep(Params().GetTargetSpacingForStake() * 1000); + if (!SignBlock(*pblock, *pwallet)) { + LogPrintf("%s(): Signing new block with UTXO key failed \n", __func__); + MilliSleep(500); continue; } if (fDebug) - LogPrintf("Running KOREMiner with %u transactions in block (%u bytes)\n", pblock->vtx.size(), ::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION)); - - // - // Search - // - int64_t nStart = GetTime(); - uint256 hashTarget = uint256().SetCompact(pblock->nBits); - if (fDebug) - LogPrintf("target: %s\n", hashTarget.GetHex()); - - while (true) { - unsigned int nHashesDone = 0; - - uint256 hash; - - if (fDebug) - LogPrintf("nbits : %08x \n", pblock->nBits); - - while (true) { - hash = pblock->GetHash(); - if (fDebug) { - LogPrintf("hash %s\n", hash.ToString().c_str()); - LogPrintf("hashTarget %s\n", hashTarget.ToString().c_str()); - } - - if (hash <= hashTarget) { - // Found a solution - SetThreadPriority(THREAD_PRIORITY_NORMAL); - LogPrintf("%s(): proof-of-work found \n hash: %s \ntarget: %s\n", __func__, hash.GetHex(), hashTarget.GetHex()); - ProcessBlockFound(pblock, *pwallet, reservekey); - SetThreadPriority(THREAD_PRIORITY_LOWEST); - MilliSleep(Params().GetTargetSpacingForStake() * 1000); - - // In regression test mode, stop mining after a block is found. This - // allows developers to controllably generate a block on demand. - if (Params().ShouldMineBlocksOnDemand()) - throw boost::thread_interrupted(); - - break; - } - pblock->nNonce += 1; - nHashesDone += 1; - if (fDebug) - LogPrintf("Looking for a solution with nounce: %d hashesDone : %d \n", pblock->nNonce, nHashesDone); - - if ((pblock->nNonce & 0xFF) == 0) - break; - } + LogPrintf("KoreMinter : proof-of-stake block was signed %s \n", pblock->GetHash().ToString().c_str()); - // Meter hashes/sec - static int64_t nHashCounter; - if (nHPSTimerStart == 0) { - nHPSTimerStart = GetTimeMillis(); - nHashCounter = 0; - } else - nHashCounter += nHashesDone; - if (GetTimeMillis() - nHPSTimerStart > 4000) { - static CCriticalSection cs; - { - LOCK(cs); - if (GetTimeMillis() - nHPSTimerStart > 4000) { - dHashesPerMin = 1000.0 * nHashCounter / (GetTimeMillis() - nHPSTimerStart); - nHPSTimerStart = GetTimeMillis(); - nHashCounter = 0; - static int64_t nLogTime; - if (GetTime() - nLogTime > 30 * 60) { - nLogTime = GetTime(); - if (fDebug) - LogPrintf("hashmeter %6.0f khash/s\n", dHashesPerMin / 1000.0); - } - } - } - } - - // Check for stop or if block needs to be rebuilt - boost::this_thread::interruption_point(); - // Regtest mode doesn't require peers - if (vNodes.empty() && Params().DoesMiningRequiresPeers()) - break; - if (pblock->nNonce >= 0xffff0000) - break; - if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60) - break; - if (pindexPrev != chainActive.Tip()) - break; - - // Update nTime every few seconds - UpdateTime(pblock, pindexPrev, fProofOfStake); - // Changing pblock->nTime can change work required: - hashTarget.SetCompact(pblock->nBits); - } + SetThreadPriority(THREAD_PRIORITY_NORMAL); + ProcessBlockFound(pblock, *pwallet, reservekey); + SetThreadPriority(THREAD_PRIORITY_LOWEST); + MilliSleep(Params().GetTargetSpacingForStake() * 1000); + continue; } + if (fDebug) LogPrintf("Exiting kore-miner \n"); } -void static ThreadBitcoinMiner(void* parg) -{ - boost::this_thread::interruption_point(); - CWallet* pwallet = (CWallet*)parg; - try { - BitcoinMiner(pwallet, false); - boost::this_thread::interruption_point(); - } catch (std::exception& e) { - LogPrintf("ThreadBitcoinMiner( %c) exception", e.what()); - } catch (...) { - LogPrintf("ThreadBitcoinMiner() exception"); - } - - LogPrintf("ThreadBitcoinMiner exiting\n"); -} - -void ThreadStakeMinter_Legacy(CWallet* pwallet) +void KoreMiner() { if (fDebug) - LogPrintf("StakeMiner Legacy started\n"); - - SetThreadPriority(THREAD_PRIORITY_LOWEST); - RenameThread("kore-pos-legacy"); + LogPrintf("KoreMiner started\n"); - const CChainParams& chainparams = Params(); - boost::shared_ptr coinstakeScript; - GetMainSignals().ScriptForMining(coinstakeScript); - - if (!coinstakeScript || coinstakeScript->reserveScript.empty()) - throw std::runtime_error("No coinstake script available (staking requires a wallet)"); - - bool fTryToSync = true; - - // lets say the fork will happen at block 50, this thread can only be running until - // block 48, because if we are in block 48 it means we are trying to create the last - // legacy block which is the block 49. - while (!ShutdownRequested() && UseLegacyCode(GetnHeight(chainActive.Tip()) + 1)) { - boost::this_thread::interruption_point(); - - while (pwallet->IsLocked()) { - MilliSleep(2000); - boost::this_thread::interruption_point(); - } - - while (vNodes.empty() || IsInitialBlockDownload() ) { - fTryToSync = true; - MilliSleep(2000); - boost::this_thread::interruption_point(); - } - - if (fTryToSync) - { - fTryToSync = false; - if (vNodes.size() < 3 || nChainHeight < GetBestPeerHeight()) - { - MilliSleep(60000); - continue; - } - } - - if (nChainHeight < GetBestPeerHeight() - 1) - { - MilliSleep(2000); - continue; - } - - // Do we have balance? - if (pwallet->GetBalance() <= 0) { - MilliSleep(60000); - continue; - } - - // Create new block - unique_ptr pblocktemplate(CreateNewBlock_Legacy(chainparams, coinstakeScript->reserveScript, pwallet, true)); - if (!pblocktemplate.get()) - return; - - CBlock* pblock = &pblocktemplate->block; - if (SignBlock_Legacy(pwallet, pblock)) { - SetThreadPriority(THREAD_PRIORITY_NORMAL); - ProcessBlockFound_Legacy(pblock, chainparams); - SetThreadPriority(THREAD_PRIORITY_LOWEST); - MilliSleep(Params().GetTargetSpacing()/2 * 1000); - } - - MilliSleep(500); - } - - if (fDebug) - LogPrintf("Exiting stake-miner-legacy at block: %d", GetnHeight(chainActive.Tip())); -} - -void KoreMiner_Legacy() -{ - if (fDebug) - LogPrintf("KoreMiner_Legacy started\n"); - const CChainParams& chainparams = Params(); SetThreadPriority(THREAD_PRIORITY_LOWEST); - RenameThread("kore-pow-legacy"); + RenameThread("kore-pow"); unsigned int nExtraNonce = 0; @@ -1294,31 +1035,24 @@ void KoreMiner_Legacy() if (!coinbaseScript || coinbaseScript->reserveScript.empty()) { if (fDebug) LogPrintf("No coinbase script available (mining requires a wallet)\n"); - throw std::runtime_error("No coinbase script available (mining requires a wallet)"); } // This thread should exit, if it has reached last - while (!ShutdownRequested() && UseLegacyCode(GetnHeight(chainActive.Tip()) + 1)) { - if (chainActive.Tip()->nHeight > Params().GetLastPoWBlock() ) { - if (fDebug) - LogPrintf("Pow Period has ended, we need to exit this thread \n"); - - break; - } + while (!ShutdownRequested() && chainActive.Tip()->nHeight <= Params().GetLastPoWBlock()) { if (chainparams.DoesMiningRequiresPeers()) { // Busy-wait for the network to come online so we don't waste time mining // on an obsolete chain. In regtest mode we expect to fly solo. do { if (fDebug) - LogPrintf("KoreMiner_Legacy is waiting for a Peer!!! \n"); - + LogPrintf("KoreMiner is waiting for a Peer!!! \n"); + bool fvNodesEmpty; { LOCK(cs_vNodes); fvNodesEmpty = vNodes.empty(); } - if (!fvNodesEmpty && !IsInitialBlockDownload() ) + if (!fvNodesEmpty && !IsInitialBlockDownload()) break; MilliSleep(1000); } while (true); @@ -1332,14 +1066,14 @@ void KoreMiner_Legacy() if (!pblocktemplate.get()) { LogPrintf("Error in KoreMiner: Keypool ran out, please call keypoolrefill before restarting the mining thread\n"); - return; } + CBlock* pblock = &pblocktemplate->block; - IncrementExtraNonce_Legacy(pblock, pindexPrev, nExtraNonce); + IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); if (fDebug) - LogPrintf("KoreMiner_Legacy Running with %u transactions in block (%u bytes)\n", pblock->vtx.size(), ::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION)); + LogPrintf("KoreMiner Running with %u transactions in block (%u bytes)\n", pblock->vtx.size(), ::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION)); // Search int64_t nStart = GetTime(); @@ -1350,27 +1084,26 @@ void KoreMiner_Legacy() unsigned int nHashesDone = 0; unsigned int nNonceFound = (unsigned int)-1; if (fDebug) - LogPrintf("KoreMiner_Legacy Looking for a Hash Solution \n"); - + LogPrintf("KoreMiner Looking for a Hash Solution \n"); + for (int i = 0; i < 1; i++) { pblock->nNonce = pblock->nNonce + 1; testHash = pblock->CalculateBestBirthdayHash(); nHashesDone++; if (fDebug) { - LogPrintf("KoreMiner_Legacy testHash %s\n", testHash.ToString().c_str()); - LogPrintf("KoreMiner_Legacy Hash Target %s\n", hashTarget.ToString().c_str()); + LogPrintf("KoreMiner testHash %s\n", testHash.ToString().c_str()); + LogPrintf("KoreMiner Hash Target %s\n", hashTarget.ToString().c_str()); } if (UintToArith256(testHash) < hashTarget) { // Found a solution nNonceFound = pblock->nNonce; if (fDebug) { - LogPrintf("KoreMiner_Legacy Found Hash %s\n", testHash.ToString().c_str()); - LogPrintf("KoreMiner_Legacy hash2 %s\n", pblock->GetHash().ToString().c_str()); + LogPrintf("KoreMiner Found Hash %s\n", testHash.ToString().c_str()); + LogPrintf("KoreMiner hash2 %s\n", pblock->GetHash().ToString().c_str()); } // Found a solution assert(testHash == pblock->GetHash()); - SetThreadPriority(THREAD_PRIORITY_NORMAL); ProcessBlockFound_Legacy(pblock, chainparams); SetThreadPriority(THREAD_PRIORITY_LOWEST); @@ -1420,19 +1153,20 @@ void KoreMiner_Legacy() UpdateTime(pblock, pindexPrev); } } + if (fDebug) + LogPrintf("Pow Period has ended, we need to exit this thread \n"); } catch (const boost::thread_interrupted&) { - LogPrintf("KoreMiner_Legacy Exiting at block: %d", GetnHeight(chainActive.Tip())); - + LogPrintf("KoreMiner Exiting at block: %d", GetnHeight(chainActive.Tip())); throw; + } catch (const std::runtime_error& e) { LogPrintf("KoreMiner runtime error: %s\n", e.what()); - LogPrintf("KoreMiner_Legacy Runtime Error : %s Exiting at block: %d", e.what(), GetnHeight(chainActive.Tip())); - + LogPrintf("KoreMiner Runtime Error : %s Exiting at block: %d", e.what(), GetnHeight(chainActive.Tip())); return; } if (fDebug) - LogPrintf("Exiting stake-miner-legacy at block: %d", GetnHeight(chainActive.Tip())); + LogPrintf("Exiting kore-pow at block: %d", GetnHeight(chainActive.Tip())); } // ppcoin: stake minter thread @@ -1440,25 +1174,23 @@ void ThreadStakeMinter() { boost::this_thread::interruption_point(); if (fDebug) - LogPrintf("ThreadStakeMinter started\n"); - + LogPrintf("StakeMinter started\n"); + CWallet* pwallet = pwalletMain; try { - BitcoinMiner(pwallet, true); - + KoreMinter(pwallet); boost::this_thread::interruption_point(); } catch (std::exception& e) { - LogPrintf("ThreadStakeMinter() exception \n"); + LogPrintf("StakeMinter() exception \n"); } catch (...) { - LogPrintf("ThreadStakeMinter() error \n"); + LogPrintf("StakeMinter() error \n"); } - LogPrintf("ThreadStakeMinter exiting,\n"); + LogPrintf("StakeMinter exiting,\n"); } void StakingCoins(bool fStaking) { static boost::thread_group* stakingThreads = NULL; - CWallet* pwallet = pwalletMain; if (stakingThreads != NULL) { stakingThreads->interrupt_all(); @@ -1466,21 +1198,36 @@ void StakingCoins(bool fStaking) stakingThreads = NULL; } - if (!fStaking){ + if (!fStaking) { return; } stakingThreads = new boost::thread_group(); - stakingThreads->create_thread(boost::bind(&ThreadStakeMinter_Legacy, pwallet)); stakingThreads->create_thread(boost::bind(&TraceThread, "stakemint", &ThreadStakeMinter)); } -void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads) +void static ThreadKoreMiner() +{ + boost::this_thread::interruption_point(); + if (fDebug) + LogPrintf("ThreadKoreMiner started\n"); + try { + KoreMiner(); + boost::this_thread::interruption_point(); + } catch (std::exception& e) { + LogPrintf("ThreadKoreMiner( %c) exception", e.what()); + } catch (...) { + LogPrintf("ThreadKoreMiner() exception"); + } + + LogPrintf("ThreadKoreMiner exiting\n"); +} + +void GenerateKores(bool fGenerate, int nThreads) { - LogPrintf("GenerateBitcoins with %d threads\n", nThreads); - + LogPrintf("GenerateKores with %d threads\n", nThreads); + static boost::thread_group* minerThreads = NULL; - fGenerateBitcoins = fGenerate; if (nThreads < 0) { // In regtest threads defaults to 1 @@ -1501,8 +1248,7 @@ void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads) minerThreads = new boost::thread_group(); for (int i = 0; i < nThreads; i++) { - minerThreads->create_thread(boost::bind(&KoreMiner_Legacy)); - minerThreads->create_thread(boost::bind(&ThreadBitcoinMiner, pwallet)); + minerThreads->create_thread(boost::bind(&TraceThread, "miner", &ThreadKoreMiner)); } } @@ -1516,4 +1262,4 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, CWallet* pwallet, return CreateNewBlock(scriptPubKey, pwallet, fProofOfStake); } -#endif // ENABLE_WALLET +#endif // ENABLE_WALLET \ No newline at end of file diff --git a/src/miner.h b/src/miner.h index 812a8353b..03edbebc3 100644 --- a/src/miner.h +++ b/src/miner.h @@ -24,25 +24,18 @@ struct CBlockTemplate; CAmount GetBlockReward(CBlockIndex* pindexPrev); uint32_t GetNextTarget(const CBlockIndex* pindexLast, const CBlockHeader* pblock, bool fProofOfStake); - -/** Run the miner threads */ -void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads); -CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet, bool fProofOfStake); +void UpdateTime(CBlockHeader* block, const CBlockIndex* pindexPrev, bool fProofOfStake = false); CBlockTemplate* CreateNewBlock_Legacy(const CChainParams& chainparams, const CScript& scriptPubKeyIn, CWallet* pwallet, bool fProofOfStake); +CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet, bool fProofOfStake); CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, CWallet* pwallet, bool fProofOfStake); bool SignBlock_Legacy(CWallet* pwallet, CBlock* pblock); bool ProcessBlockFound_Legacy(const CBlock* pblock, const CChainParams& chainparams); bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey); /** Modify the extranonce in a block */ -void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce); -void IncrementExtraNonce_Legacy(CBlock* pblock, const CBlockIndex* pindexPrev, unsigned int& nExtraNonce); -/** Check mined block */ -void UpdateTime(CBlockHeader* block, const CBlockIndex* pindexPrev, bool fProofOfStake = false); - -void ThreadStakeMinter_Legacy(CWallet* pwallet); -void BitcoinMiner(CWallet* pwallet, bool fProofOfStake); -void KoreMiner_Legacy(); -void ThreadStakeMinter(); +void IncrementExtraNonce(CBlock* pblock, const CBlockIndex* pindexPrev, unsigned int& nExtraNonce); +/** Run the miner threads */ +void GenerateKores(bool fGenerate, int nThreads); +/** Run the staking thread */ void StakingCoins(bool fStaking); extern double dHashesPerMin; diff --git a/src/net.cpp b/src/net.cpp index 12fa97ad8..0767693fb 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1170,10 +1170,15 @@ void ThreadSocketHandler() // hidden service seeds static const char* strMainNetOnionSeed[][1] = { + {"mp2a5yjqtz4eh23s.onion"}, + {"qlnfmbykjv66j4qv.onion"}, {NULL} // last element => couldn't use size ? }; static const char* strTestNetOnionSeed[][1] = { + {"5c5fxjpfgceb6s4c.onion"}, + {"7pxgbkz26lymgqwi.onion"}, + {"w4ockyd7ruolzr5d.onion"}, {NULL} // last element => couldn't use size ? }; diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 91ae8791e..0ff045f9f 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -116,7 +116,7 @@ BitcoinGUI::BitcoinGUI(const NetworkStyle* networkStyle, QWidget* parent) : QMai this->setStyleSheet(GUIUtil::loadStyleSheet()); GUIUtil::restoreWindowGeometry("nWindow", QSize(750, 650), this); - + QString windowTitle = tr("Kore") + " - "; #ifdef ENABLE_WALLET /* if compiled with wallet support, -disablewallet can still disable the wallet */ @@ -185,22 +185,28 @@ BitcoinGUI::BitcoinGUI(const NetworkStyle* networkStyle, QWidget* parent) : QMai frameBlocks->setContentsMargins(0, 0, 0, 0); frameBlocks->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); QHBoxLayout* frameBlocksLayout = new QHBoxLayout(frameBlocks); - frameBlocksLayout->setContentsMargins(3, 0, 3, 0); - frameBlocksLayout->setSpacing(3); + frameBlocksLayout->setContentsMargins(0, 0, 0, 0); + frameBlocksLayout->setSpacing(8); unitDisplayControl = new UnitDisplayStatusBarControl(); + unitDisplayControl->setObjectName("unitDisplayControl"); labelStakingIcon = new QLabel(); + labelStakingIcon->setObjectName("labelStakingIcon"); labelEncryptionIcon = new QPushButton(); + labelEncryptionIcon->setFixedSize(STATUSBAR_ICONSIZE+STATUSBAR_ICON_SELECTION_SHADE,STATUSBAR_ICONSIZE+STATUSBAR_ICON_SELECTION_SHADE); + labelEncryptionIcon->setText(""); + labelEncryptionIcon->setIconSize(QSize(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); labelEncryptionIcon->setObjectName("labelEncryptionIcon"); labelEncryptionIcon->setFlat(true); // Make the button look like a label, but clickable - labelEncryptionIcon->setStyleSheet(".QPushButton { background-color: rgba(255, 255, 255, 0);}"); - labelEncryptionIcon->setMaximumSize(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE); + //labelEncryptionIcon->setMaximumSize(STATUSBAR_ICONSIZE+STATUSBAR_ICON_SELECTION_SHADE, STATUSBAR_ICONSIZE+STATUSBAR_ICON_SELECTION_SHADE); labelConnectionsIcon = new QPushButton(); + labelConnectionsIcon->setFixedSize(STATUSBAR_ICONSIZE+STATUSBAR_ICON_SELECTION_SHADE,STATUSBAR_ICONSIZE+STATUSBAR_ICON_SELECTION_SHADE); + labelConnectionsIcon->setText(""); + labelConnectionsIcon->setIconSize(QSize(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); labelConnectionsIcon->setObjectName("labelConnectionsIcon"); labelConnectionsIcon->setFlat(true); // Make the button look like a label, but clickable - labelConnectionsIcon->setStyleSheet(".QPushButton { background-color: rgba(255, 255, 255, 0);}"); - labelConnectionsIcon->setMaximumSize(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE); + //labelConnectionsIcon->setMaximumSize(STATUSBAR_ICONSIZE + STATUSBAR_ICON_SELECTION_SHADE, STATUSBAR_ICONSIZE + STATUSBAR_ICON_SELECTION_SHADE); labelBlocksIcon = new QLabel(); - + labelBlocksIcon->setObjectName("labelBlocksIcon"); if (enableWallet) { frameBlocksLayout->addStretch(); frameBlocksLayout->addWidget(unitDisplayControl); @@ -226,10 +232,12 @@ BitcoinGUI::BitcoinGUI(const NetworkStyle* networkStyle, QWidget* parent) : QMai // Override style sheet for progress bar for styles that have a segmented progress bar, // as they make the text unreadable (workaround for issue #1071) // See https://qt-project.org/doc/qt-4.8/gallery.html + /* QString curStyle = QApplication::style()->metaObject()->className(); if (curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle") { progressBar->setStyleSheet("QProgressBar { background-color: #F8F8F8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #00CCFF, stop: 1 #33CCFF); border-radius: 7px; margin: 0px; }"); } + */ statusBar()->addWidget(progressBarLabel); statusBar()->addWidget(progressBar); @@ -290,10 +298,11 @@ void BitcoinGUI::createActions(const NetworkStyle* networkStyle) { QActionGroup* tabGroup = new QActionGroup(this); - overviewAction = new QAction(QIcon(":/icons/overview"), tr("&MY WALLET"), this); + overviewAction = new QAction(QIcon(":/icons/overview"),tr("&MY WALLET"), this); overviewAction->setStatusTip(tr("Show general overview of wallet")); overviewAction->setToolTip(overviewAction->statusTip()); overviewAction->setCheckable(true); + overviewAction->setObjectName("overviewAction"); #ifdef Q_OS_MAC overviewAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_1)); #else @@ -521,10 +530,10 @@ void BitcoinGUI::createToolBars() if (walletFrame) { QLabel* header = new QLabel(); - header->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + //header->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); header->setPixmap(QPixmap(":/images/about")); header->setAlignment(Qt::AlignHCenter); - header->setMaximumSize(190,190); + header->setMaximumSize(148,96); header->setScaledContents(true); QToolBar* toolbar = new QToolBar(tr("Tabs toolbar")); toolbar->setObjectName("Main-Toolbar"); // Name for CSS addressing @@ -912,7 +921,7 @@ void BitcoinGUI::setNumBlocks(int count) progressBarLabel->setVisible(true); progressBar->setFormat(tr("%1 behind. Scanning block %2").arg(timeBehindText).arg(count)); progressBar->setMaximum(1000000000); - progressBar->setValue(clientModel->getVerificationProgress() * 1000000000.0 + 0.5); + progressBar->setValue(clientModel->getVerificationProgress()*1000000000); progressBar->setVisible(true); tooltip = tr("Catching up...") + QString("
") + tooltip; @@ -921,7 +930,17 @@ void BitcoinGUI::setNumBlocks(int count) ":/movies/spinner-%1") .arg(spinnerFrame, 3, 10, QChar('0'))) .pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); + spinnerFrame = (spinnerFrame + 1) % SPINNER_FRAMES; + + /* Code to spin a file + QPixmap pixmap(QIcon(QString(":/movies/spinner-001")).pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); + QTransform rm; + rm.rotate(spinnerFrame*10); + pixmap = pixmap.transformed(rm); + labelBlocksIcon->setPixmap(pixmap); spinnerFrame = (spinnerFrame + 1) % SPINNER_FRAMES; + */ + } prevBlocks = count; @@ -1254,6 +1273,18 @@ void UnitDisplayStatusBarControl::mousePressEvent(QMouseEvent* event) void UnitDisplayStatusBarControl::createContextMenu() { menu = new QMenu(); + QString menuStyle( + "QMenu::item:selected{" + "background-color: rgba(222, 222, 222);" + "color: #333;" + "}" + ); + + menu->setStyleSheet(menuStyle); + // doesn work reading from default.css ... + //menu->setStyleSheet(GUIUtil::loadStyleSheet()); + //menu->setObjectName("unitMenu"); + Q_FOREACH (BitcoinUnits::Unit u, BitcoinUnits::availableUnits()) { QAction* menuAction = new QAction(QString(BitcoinUnits::name(u)), this); menuAction->setData(QVariant(u)); @@ -1279,11 +1310,7 @@ void UnitDisplayStatusBarControl::setOptionsModel(OptionsModel* optionsModel) /** When Display Units are changed on OptionsModel it will refresh the display text of the control on the status bar */ void UnitDisplayStatusBarControl::updateDisplayUnit(int newUnits) { - if (Params().GetNetworkID() == CBaseChainParams::MAIN) { - setPixmap(QIcon(":/icons/unit_" + BitcoinUnits::id(newUnits)).pixmap(39, STATUSBAR_ICONSIZE)); - } else { - setPixmap(QIcon(":/icons/unit_t" + BitcoinUnits::id(newUnits)).pixmap(39, STATUSBAR_ICONSIZE)); - } + setPixmap(QIcon(":/icons/unit_" + BitcoinUnits::id(newUnits)).pixmap(39 + 20 , STATUSBAR_ICONSIZE)); } /** Shows context menu with Display Unit options by the mouse coordinates */ diff --git a/src/qt/bitcoinunits.cpp b/src/qt/bitcoinunits.cpp index 58b1a15f7..a83592467 100644 --- a/src/qt/bitcoinunits.cpp +++ b/src/qt/bitcoinunits.cpp @@ -53,28 +53,15 @@ QString BitcoinUnits::id(int unit) QString BitcoinUnits::name(int unit) { - if (Params().GetNetworkID() == CBaseChainParams::MAIN) { - switch (unit) { - case KORE: - return QString("KORE"); - case mKORE: - return QString("mKORE"); - case uKORE: - return QString::fromUtf8("μKORE"); - default: - return QString("???"); - } - } else { - switch (unit) { - case KORE: - return QString("tKORE"); - case mKORE: - return QString("mtKORE"); - case uKORE: - return QString::fromUtf8("μtKORE"); - default: - return QString("???"); - } + switch (unit) { + case KORE: + return QString("KORE"); + case mKORE: + return QString("mKORE"); + case uKORE: + return QString::fromUtf8("μKORE"); + default: + return QString("???"); } } @@ -210,7 +197,8 @@ QString BitcoinUnits::floorHtmlWithUnit(int unit, const CAmount& amount, bool pl { QString str(floorWithUnit(unit, amount, plussign, separators)); str.replace(QChar(THIN_SP_CP), QString(THIN_SP_HTML)); - return QString("%1").arg(str); + //return QString("%1").arg(str); + return str; } bool BitcoinUnits::parse(int unit, const QString& value, CAmount* val_out) diff --git a/src/qt/forms/overviewpage.ui b/src/qt/forms/overviewpage.ui index 1e9856dff..e71807820 100644 --- a/src/qt/forms/overviewpage.ui +++ b/src/qt/forms/overviewpage.ui @@ -6,13 +6,13 @@ 0 0 - 960 - 629 + 800 + 513 - 960 + 800 0 @@ -20,6 +20,12 @@ Form + + 0 + + + 9 + @@ -49,12 +55,29 @@ QFrame::Raised + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + Ubuntu + 16 75 true @@ -73,7 +96,7 @@ The displayed information may be out of date. Your wallet automatically synchronizes with the KORE network after a connection is established, but this process has not completed yet. - QLabel { color: red; } + QLabel { color: rgba(189,22,22,0.95); } (out of sync) @@ -103,51 +126,59 @@ QLayout::SetDefaultConstraint - + 15 - - - - Spendable: + + 0 + + + + + + 75 + true + - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + IBeamCursor + + + Unconfirmed transactions to watch-only addresses - - - - - Staked: + 0.000 000 00 BTC Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + - - + + - Watch-only: + Immature: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + - Available: + Total: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + 75 @@ -158,7 +189,7 @@ IBeamCursor - Your current spendable balance + Total of transactions that have yet to be confirmed, and do not yet count toward the spendable balance 0.000 000 00 BTC @@ -174,8 +205,8 @@ - - + + 75 @@ -186,7 +217,7 @@ IBeamCursor - Your current balance in watch-only addresses + Current total balance in watch-only addresses 0.000 000 00 BTC @@ -199,46 +230,38 @@ - - + + - Pending: + Spendable: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - 75 - true - - - - IBeamCursor - - - Total of transactions that have yet to be confirmed, and do not yet count toward the spendable balance - + + - 0.000 000 00 BTC + Watch-only: - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - 5 + + + + + + Staked: - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + 75 @@ -249,44 +272,24 @@ IBeamCursor - Unconfirmed transactions to watch-only addresses + Your current spendable balance 0.000 000 00 BTC - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 5 Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Immature: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - + + 75 @@ -313,8 +316,18 @@ - - + + + + Pending: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + 75 @@ -325,7 +338,7 @@ IBeamCursor - Staked rewards in watch-only addresses that has not yet matured + Your current balance in watch-only addresses 0.000 000 00 BTC @@ -338,49 +351,17 @@ - - - - - 0 - 0 - - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - - 140 - 0 - - - - Qt::Horizontal - - - - - + + - Total: + Available: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + @@ -408,8 +389,8 @@ - - + + 75 @@ -420,7 +401,7 @@ IBeamCursor - Current total balance in watch-only addresses + Staked rewards in watch-only addresses that has not yet matured 0.000 000 00 BTC @@ -433,8 +414,8 @@ - - + + 75 @@ -461,6 +442,19 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -495,12 +489,29 @@ QFrame::Raised + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + Ubuntu + 16 75 true @@ -519,13 +530,13 @@ The displayed information may be out of date. Your wallet automatically synchronizes with the KORE network after a connection is established, but this process has not completed yet. - QLabel { color: red; } + QLabel { color: rgba(189,22,22,0.95); } (out of sync) - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -558,6 +569,9 @@ Qt::ScrollBarAlwaysOff + + false + QAbstractItemView::NoSelection diff --git a/src/qt/forms/receivecoinsdialog.ui b/src/qt/forms/receivecoinsdialog.ui index 7d28d9d2e..0a8c7a5b1 100644 --- a/src/qt/forms/receivecoinsdialog.ui +++ b/src/qt/forms/receivecoinsdialog.ui @@ -6,10 +6,16 @@ 0 0 - 962 + 800 616 + + + 800 + 0 + + @@ -137,6 +143,12 @@ QFrame::Sunken + + 2 + + + 0 + diff --git a/src/qt/forms/sendcoinsdialog.ui b/src/qt/forms/sendcoinsdialog.ui index d1e0d19e5..4335cdc79 100644 --- a/src/qt/forms/sendcoinsdialog.ui +++ b/src/qt/forms/sendcoinsdialog.ui @@ -6,14 +6,23 @@ 0 0 - 850 + 700 610 + + + 700 + 0 + + Send Coins + + 20 + 8 @@ -189,9 +198,9 @@ 0 - + - 20 + 5 0 @@ -650,7 +659,7 @@ 0 0 - 830 + 669 113 @@ -1417,17 +1426,17 @@ - - QValidatedLineEdit - QLineEdit -
qvalidatedlineedit.h
-
BitcoinAmountField QLineEdit
bitcoinamountfield.h
1
+ + QValidatedLineEdit + QLineEdit +
qvalidatedlineedit.h
+
diff --git a/src/qt/forms/transactiondescdialog.ui b/src/qt/forms/transactiondescdialog.ui index 5ae1e1285..50d1d69f2 100644 --- a/src/qt/forms/transactiondescdialog.ui +++ b/src/qt/forms/transactiondescdialog.ui @@ -6,14 +6,29 @@ 0 0 - 620 - 250 + 800 + 324 + + + 800 + 0 + + Transaction details + + 0 + + + 0 + + + 10 + diff --git a/src/qt/guiconstants.h b/src/qt/guiconstants.h index e2bf14bb3..47cbe00f9 100644 --- a/src/qt/guiconstants.h +++ b/src/qt/guiconstants.h @@ -14,7 +14,8 @@ static const int MODEL_UPDATE_DELAY = 500; static const int MAX_PASSPHRASE_SIZE = 1024; /* Kore GUI -- Size of icons in status bar */ -static const int STATUSBAR_ICONSIZE = 16; +static const int STATUSBAR_ICONSIZE = 22; +static const int STATUSBAR_ICON_SELECTION_SHADE = 5; static const bool DEFAULT_SPLASHSCREEN = true; @@ -24,7 +25,9 @@ static const bool DEFAULT_SPLASHSCREEN = true; /* Transaction list -- unconfirmed transaction */ #define COLOR_UNCONFIRMED QColor(91, 76, 134) /* Transaction list -- negative amount */ -#define COLOR_NEGATIVE QColor(206, 0, 188) +#define COLOR_NEGATIVE QColor(189, 22, 22) +/* Transaction list -- positive amount */ +#define COLOR_POSITIVE QColor(25, 158, 60) /* Transaction list -- bare address (without label) */ #define COLOR_BAREADDRESS QColor(140, 140, 140) /* Transaction list -- TX status decoration - open until date */ @@ -37,7 +40,7 @@ static const bool DEFAULT_SPLASHSCREEN = true; #define COLOR_CONFLICTED QColor(255, 0, 0) /* Transaction list -- TX status decoration - orphan (Light Gray #D3D3D3) */ #define COLOR_ORPHAN QColor(211, 211, 211) -/* Transaction list -- TX status decoration - stake (BlueViolet #8A2BE2) */ +/* Transaction list -- TX status decoration - stake (yellow #ffbb11) */ #define COLOR_STAKE QColor(138,43,226) /* Tooltips longer than this (in characters) are converted into rich text, so that they can be word-wrapped. diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index ec8e1cc75..041b2a6bd 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -23,9 +23,9 @@ #include #include -#define DECORATION_SIZE 48 +#define DECORATION_SIZE 40 #define ICON_OFFSET 16 -#define NUM_ITEMS 5 +#define NUM_ITEMS 10 extern CWallet* pwalletMain; @@ -37,43 +37,69 @@ class TxViewDelegate : public QAbstractItemDelegate { } + inline QColor amountTextColor(const QModelIndex& index, const qint64& amount) const + { + // Check transaction status + int nStatus = index.data(TransactionTableModel::StatusRole).toInt(); + //cout << "Status: " << nStatus << endl; + if (nStatus == TransactionStatus::Conflicted || nStatus == TransactionStatus::NotAccepted) { + //cout << "COLOR_ORPHAN" << endl; + return COLOR_ORPHAN; + } + + if (nStatus == TransactionRecord::Generated || nStatus == TransactionRecord::StakeMint || + nStatus == TransactionRecord::MNReward) { + //cout << "COLOR_STAKE" << endl; + return COLOR_STAKE; + } + + // Conflicted tx + if (nStatus == TransactionStatus::Conflicted || nStatus == TransactionStatus::NotAccepted) { + //cout << "COLOR_CONFLICTED" << endl; + return COLOR_CONFLICTED; + } + // Unconfimed or immature + if ((nStatus == TransactionStatus::Unconfirmed) || (nStatus == TransactionStatus::Immature)) { + //cout << "COLOR_UNCONFIRMED" << endl; + return COLOR_UNCONFIRMED; + } + if (amount < 0) { + //cout << "COLOR_NEGATIVE" << endl; + return COLOR_NEGATIVE; + } + if (amount > 0) { + //cout << "COLOR_POSITIVE" << endl; + return COLOR_POSITIVE; + } + + // To avoid overriding above conditional formats a default text color for this QTableView is not defined in stylesheet, + // so we must always return a color here + return COLOR_BLACK; + } + inline void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { painter->save(); QIcon icon = qvariant_cast(index.data(Qt::DecorationRole)); QRect mainRect = option.rect; - mainRect.moveLeft(ICON_OFFSET); - QRect decorationRect(mainRect.topLeft(), QSize(DECORATION_SIZE, DECORATION_SIZE)); - int xspace = DECORATION_SIZE + 8; + //mainRect.moveLeft(ICON_OFFSET); + QPoint iconPos(mainRect.left(), mainRect.top()+8); + + QRect decorationRect(iconPos, QSize(24, 24)); + //int xspace = DECORATION_SIZE + 8; + int xspace = 24 + 8; int ypad = 6; int halfheight = (mainRect.height() - 2 * ypad) / 2; - QRect amountRect(mainRect.left() + xspace, mainRect.top() + ypad, mainRect.width() - xspace - ICON_OFFSET, halfheight); + QRect amountRect(mainRect.left() + xspace, mainRect.top() + ypad, mainRect.width() - xspace /*- ICON_OFFSET*/, halfheight); QRect addressRect(mainRect.left() + xspace, mainRect.top() + ypad + halfheight, mainRect.width() - xspace, halfheight); icon.paint(painter, decorationRect); QDateTime date = index.data(TransactionTableModel::DateRole).toDateTime(); QString address = index.data(Qt::DisplayRole).toString(); qint64 amount = index.data(TransactionTableModel::AmountRole).toLongLong(); - bool confirmed = index.data(TransactionTableModel::ConfirmedRole).toBool(); - - // Check transaction status - int nStatus = index.data(TransactionTableModel::StatusRole).toInt(); - bool fConflicted = false; - if (nStatus == TransactionStatus::Conflicted || nStatus == TransactionStatus::NotAccepted) { - fConflicted = true; // Most probably orphaned, but could have other reasons as well - } - bool fImmature = false; - if (nStatus == TransactionStatus::Immature) { - fImmature = true; - } - - QVariant value = index.data(Qt::ForegroundRole); + bool confirmed = index.data(TransactionTableModel::ConfirmedRole).toBool(); QColor foreground = COLOR_BLACK; - if (value.canConvert()) { - QBrush brush = qvariant_cast(value); - foreground = brush.color(); - } painter->setPen(foreground); QRect boundingRect; @@ -85,23 +111,12 @@ class TxViewDelegate : public QAbstractItemDelegate iconWatchonly.paint(painter, watchonlyRect); } - if (fConflicted) { // No need to check anything else for conflicted transactions - foreground = COLOR_CONFLICTED; - } else if (!confirmed || fImmature) { - foreground = COLOR_UNCONFIRMED; - } else if (amount < 0) { - foreground = COLOR_NEGATIVE; - } else { - foreground = COLOR_BLACK; - } + foreground = amountTextColor(index, amount); painter->setPen(foreground); - QString amountText = BitcoinUnits::formatWithUnit(unit, amount, true, BitcoinUnits::separatorAlways); - if (!confirmed) { - amountText = QString("[") + amountText + QString("]"); - } + QString amountText = BitcoinUnits::format(unit, amount, true, BitcoinUnits::separatorAlways); painter->drawText(amountRect, Qt::AlignRight | Qt::AlignVCenter, amountText); - painter->setPen(COLOR_BLACK); + painter->setPen(QColor(9, 9, 9)); painter->drawText(amountRect, Qt::AlignLeft | Qt::AlignVCenter, GUIUtil::dateTimeStr(date)); painter->restore(); @@ -138,6 +153,7 @@ OverviewPage::OverviewPage(QWidget* parent) : QWidget(parent), ui->listTransactions->setIconSize(QSize(DECORATION_SIZE, DECORATION_SIZE)); ui->listTransactions->setMinimumHeight(NUM_ITEMS * (DECORATION_SIZE + 2)); ui->listTransactions->setAttribute(Qt::WA_MacShowFocusRect, false); + ui->listTransactions->setSpacing(0); connect(ui->listTransactions, SIGNAL(clicked(QModelIndex)), this, SLOT(handleTransactionClicked(QModelIndex))); @@ -170,13 +186,11 @@ void OverviewPage::setBalance(const CAmount& balance, const CAmount& unconfirmed currentWatchUnconfBalance = watchUnconfBalance; currentWatchImmatureBalance = watchImmatureBalance; - ui->labelBalance->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, balance, false, BitcoinUnits::separatorAlways)); ui->labelUnconfirmed->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, unconfirmedBalance, false, BitcoinUnits::separatorAlways)); ui->labelImmature->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, immatureBalance, false, BitcoinUnits::separatorAlways)); ui->labelStaked->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, stakedBalance, false, BitcoinUnits::separatorAlways)); - ui->labelTotal->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, balance + unconfirmedBalance + stakedBalance, false, BitcoinUnits::separatorAlways)); - + ui->labelTotal->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, balance + unconfirmedBalance + immatureBalance + stakedBalance, false, BitcoinUnits::separatorAlways)); ui->labelWatchAvailable->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, watchOnlyBalance, false, BitcoinUnits::separatorAlways)); ui->labelWatchPending->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, watchUnconfBalance, false, BitcoinUnits::separatorAlways)); @@ -185,7 +199,7 @@ void OverviewPage::setBalance(const CAmount& balance, const CAmount& unconfirmed // only show immature (newly mined) balance if it's non-zero, so as not to complicate things // for the non-mining users - bool showImmature = immatureBalance != 0; + bool showImmature = true;//immatureBalance != 0; bool showWatchOnlyImmature = watchImmatureBalance != 0; // for symmetry reasons also show immature label when the watch-only one is shown @@ -195,7 +209,7 @@ void OverviewPage::setBalance(const CAmount& balance, const CAmount& unconfirmed // only show staked (locked) balance if it's non-zero, so as not to complicate things // for the non-staking users - bool showStaked = stakedBalance != 0; + bool showStaked = true;//stakedBalance != 0; ui->labelStaked->setVisible(showStaked); ui->labelStakedText->setVisible(showStaked); @@ -206,7 +220,6 @@ void OverviewPage::updateWatchOnlyLabels(bool showWatchOnly) { ui->labelSpendable->setVisible(showWatchOnly); // show spendable label (only when watch-only is active) ui->labelWatchonly->setVisible(showWatchOnly); // show watch-only label - ui->lineWatchBalance->setVisible(showWatchOnly); // show watch-only balance separator line ui->labelWatchAvailable->setVisible(showWatchOnly); // show watch-only available balance ui->labelWatchPending->setVisible(showWatchOnly); // show watch-only pending balance ui->labelWatchTotal->setVisible(showWatchOnly); // show watch-only total balance diff --git a/src/qt/receivecoinsdialog.cpp b/src/qt/receivecoinsdialog.cpp index 0ac884c8c..cc64a7999 100644 --- a/src/qt/receivecoinsdialog.cpp +++ b/src/qt/receivecoinsdialog.cpp @@ -74,6 +74,8 @@ void ReceiveCoinsDialog::setModel(WalletModel* model) tableView->setSelectionMode(QAbstractItemView::ContiguousSelection); tableView->setColumnWidth(RecentRequestsTableModel::Date, DATE_COLUMN_WIDTH); tableView->setColumnWidth(RecentRequestsTableModel::Label, LABEL_COLUMN_WIDTH); + tableView->setColumnWidth(RecentRequestsTableModel::Message, MINIMUM_COLUMN_WIDTH); + tableView->setColumnWidth(RecentRequestsTableModel::Amount, MINIMUM_COLUMN_WIDTH); connect(tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, diff --git a/src/qt/res/css/default.css b/src/qt/res/css/default.css index 9600a5b2b..44ff6251f 100755 --- a/src/qt/res/css/default.css +++ b/src/qt/res/css/default.css @@ -6,8 +6,57 @@ padding:0; } QStatusBar { -background-color:#ffffff; +background-color:rgba(86, 86, 86, 0.8); +padding: 0px; +color: #fafafa; +} + +QProgressBar { + color: #444; + border:0px solid grey; + /* border-radius:5px; */ + background-color: #999; + padding: 2px; + } + +QProgressBar::chunk { + background-color: #fafafa; + width: 20px; +} + +QLabel#progressBarLabel { + color: #fafafa; +} + +QPushButton#labelEncryptionIcon { + background-color:transparent; +} + +QPushButton#labelEncryptionIcon:hover { + background-color: rgba(255,255,255,0.2); +} + +QPushButton#labelConnectionsIcon { + background-color: transparent; +} + +QPushButton#labelConnectionsIcon:hover { + background-color: rgba(255,255,255,0.2); +} + +QPushButton#labelBlocksIcon:hover { + background-color: rgba(255,255,255,0.2); +} + + +QPushButton#labelConnectionsIcon:active { + border:0px +} + +QPushButton#labelEncryptionIcon:active { + border:0px } + .QFrame { background-color:transparent; @@ -17,7 +66,6 @@ border:0px solid #ffffff; QMenuBar { background-color:#ffffff; } - QMenuBar::item { background-color:#ffffff; color:#333; @@ -31,6 +79,14 @@ QMenu { background-color:#ffffff; } +#unitDisplayControl:hover { + background-color: rgba(255,255,255,0.2); + padding-bottom: 6px; + padding-top: 6px; + padding-right: 10px; + padding-left: 2px; +} + QMenu::item { color:#333; } @@ -41,35 +97,45 @@ color:#333; } QToolBar { -background-color:#ffffff; +background-color:qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #b8b8b8, stop: 1 white); border:0px solid #000; -padding:5; +padding-left: 10px; +padding-right: 0px; +padding-top: 0px; +padding-bottom: 5px; margin:0; spacing:6px; } +QToolBar > .QLabel { + padding-bottom:3px; +} + QToolBar > QToolButton { -border:2px solid grey; +border:2px solid #f8f8f8; +background-color:white; border-radius:5px; +border-style: outset; font-weight:bold; -color:#E62E00; +color:rgba(189,22,22,0.90); font-weight:600; font-size:12px; -padding-left:10px; +padding-left:2px; +padding-right: 0px; padding-top:16px; padding-bottom:16px; width:100%; -min-width:170px; +min-width:140px; text-align: left; text-transform:uppercase; - } + QToolBar > QToolButton:checked { background-color:#DEDEDE; border:2px solid grey; border-radius:5px; -color:#E62E00; +color:rgba(189,22,22); font-weight:bold; } @@ -77,21 +143,16 @@ QToolBar > QToolButton:pressed { background-color: #DEDEDE; } - -QMessageBox { -background-color:#ffffff; +QToolBar#Main-Toolbar QToolButton#overviewAction{ + background-image: url(':/icons/overview'); } -QProgressBar { -color:#000000; -border:2px solid grey; -border-radius:5px; -background-color:transparent; +QToolBar#Main-Toolbar QToolButton#overviewAction:hover{ + background-image: url(':/icons/overview_red'); } -QProgressBar::chunk { -background-color:#CF715A; -width: 20px; +QMessageBox { +background-color:#ffffff; } QTabWidget { @@ -113,7 +174,7 @@ background-color:#dedbe5; } QWidget { -selection-background-color:#e62d00; /* Object highlight color e62d00 */ +selection-background-color:rgba(189,22,22,0.95); /* Object highlight color bd1616 */ selection-color:#ffffff; outline:0; /* Remove Annoying Focus Rectangle */ } @@ -172,7 +233,7 @@ background-color:#f2f2f2; /****************************************************************************************/ QPushButton { /* Global Button Style */ -background-color: #e62d00; +background-color: #666; border-width: 1px; border-style: outset; border-color: #382f44; @@ -187,7 +248,7 @@ padding-bottom:5px; } QPushButton:hover { -background-color: #e68067; +background-color: rgba(86, 86, 86, 0.8); border-radius:3px; } @@ -317,7 +378,7 @@ outline:0; QHeaderView::section { /* Table Header Sections */ qproperty-alignment:center; -background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 0.25, stop: 0 #6C6262, stop: 1 #e62d00); +background-color: #999; color:#ffffff; min-height:25px; font-weight:bold; @@ -341,7 +402,7 @@ border:0; .QTableView { /* Table - has to be selected as a class otherwise it throws off QCalendarWidget */ background:transparent; -border:1px solid #333; +border:1px solid #666; } QTableView::item { /* Table Item */ @@ -350,12 +411,12 @@ font-size:12px; } QTableView::item:selected { /* Table Item Selected */ -background-color:#e62d00; -color:#ffffff; +background-color:rgb(231, 229, 229); +color:#333; } QTableWidget { /* Table Background */ -background-color:red; /*#ffffff;*/ +background-color:red; border:1px solid #333; } @@ -462,7 +523,7 @@ border-radius:10px; } QSlider::sub-page:horizontal { -background-color:#e62d00; +background-color:rgba(189,22,22,0.95); border-color:#c2c2c2; border-radius:3px; } @@ -565,7 +626,7 @@ padding-right:10px; } QDialog#SignVerifyMessageDialog QPlainTextEdit { /* Message Signing Text */ -border:1px solid #e62d00; +border:1px solid rgba(189,22,22,0.95); background-color:#ffffff; } @@ -778,7 +839,7 @@ padding-right:10px; } QDialog#RPCConsole .QGroupBox #line { /* Network In Line */ -background-color:#e62d00; +background-color:rgba(189,22,22,0.95); } QDialog#RPCConsole .QGroupBox #line_2 { /* Network Out Line */ @@ -816,7 +877,7 @@ padding-right:5px; /**************************** OVERVIEW SCREEN *******************************************/ QWidget .QFrame#frame { /* Wallet Balance */ -min-width:490px; +/* min-width:490px; */ } QWidget .QFrame#frame > .QLabel { @@ -829,14 +890,19 @@ QWidget .QFrame#frame .QLabel#label_5 { /* Wallet Label */ qproperty-alignment: 'AlignVCenter | AlignRight'; min-width:160px; background-color:transparent; -color:#ffffff; +color:#6C6262; +margin-top:109px; margin-right:5px; padding-right:5px; +font-weight:bold; +font-size:16px; +min-height:24px; } QWidget .QFrame#frame .QLabel#labelWalletStatus { /* Wallet Sync Status */ qproperty-alignment: 'AlignVCenter | AlignLeft'; margin-left:3px; +margin-top:90px; } QWidget .QFrame#frame .QLabel#labelSpendable { /* Spendable Header */ @@ -854,21 +920,19 @@ margin-left:16px; QWidget .QFrame#frame .QLabel#labelBalanceText { /* Available Balance Label */ qproperty-alignment: 'AlignVCenter | AlignRight'; min-width:160px; -background-color:#e62d00; -border-radius:5px; -color:#ffffff; +font-size:12px; +/* font-weight:bold; */ +background-color:transparent; +color:#6C6262; margin-right:5px; padding-right:5px; -font-weight:bold; -font-size:14px; -min-height:35px; } QWidget .QFrame#frame .QLabel#labelBalance { /* Available Balance */ -qproperty-alignment: 'AlignVCenter | AlignLeft'; +qproperty-alignment: 'AlignVCenter | AlignRight'; font-size:12px; font-weight:bold; -color:#e62d00; +color: #6C6262; margin-left:0px; } @@ -883,7 +947,7 @@ padding-right:5px; } QWidget .QFrame#frame .QLabel#labelStaked { /* Staked Amount */ -qproperty-alignment: 'AlignVCenter | AlignLeft'; +qproperty-alignment: 'AlignVCenter | AlignRight'; font-size:12px; margin-left:0px; } @@ -906,7 +970,7 @@ padding-right:5px; } QWidget .QFrame#frame .QLabel#labelUnconfirmed { /* Pending Balance */ -qproperty-alignment: 'AlignVCenter | AlignLeft'; +qproperty-alignment: 'AlignVCenter | AlignRight'; font-size:12px; margin-left:0px; } @@ -928,7 +992,7 @@ padding-right:5px; } QWidget .QFrame#frame .QLabel#labelImmature { /* Immature Balance */ -qproperty-alignment: 'AlignVCenter | AlignLeft'; +qproperty-alignment: 'AlignVCenter | AlignRight'; font-size:12px; margin-left:0px; } @@ -950,17 +1014,24 @@ padding-right:5px; } QWidget .QFrame#frame .QLabel#labelTotal { /* Total Balance */ -qproperty-alignment: 'AlignVCenter | AlignLeft'; +qproperty-alignment: 'AlignVCenter | AlignRight'; font-size:12px; +font-weight:bold; +color: #6C6262; margin-left:0px; +margin-top: 10px; +border-top: 1px solid #6C6262; } QWidget .QFrame#frame .QLabel#labelWatchTotal { /* Watch-only Total Balance */ qproperty-alignment: 'AlignVCenter | AlignLeft'; font-size:12px; margin-left:16px; +border-top: 1px solid #6C6262; } + + /**************************** OBFUSCATION WIDGET ****************************************/ @@ -976,7 +1047,7 @@ qproperty-geometry: rect(10 0 431 35); QWidget .QFrame#frameObfuscation .QLabel#label_2 { /* Obfuscation Header */ qproperty-alignment: 'AlignVCenter | AlignRight'; min-width:160px; -background-color:#e62d00; +background-color:rgba(189,22,22,0.95); border-radius:5px; color:#ffffff; margin-right:5px; @@ -1110,7 +1181,7 @@ border-radius:5px; font-size:15px; font-weight:bold; -color:#E62E00; +color:rgba(189,22,22,0.95); padding-left:10px; padding-right:10px; padding-top:5px; @@ -1166,11 +1237,11 @@ border:1px solid #9e9e9e; /**************************** RECENT TRANSACTIONS ***************************************/ QWidget .QFrame#frame_2 { /* Transactions Widget */ -min-width:410px; -margin-right:20px; +/* min-width:410px; */ +margin-right:10px; margin-left:0; margin-top:0; -background-image: url(':/images/cteam_logo_horizontal'); +/* background: black; */ background-repeat:none; } @@ -1178,18 +1249,18 @@ QWidget .QFrame#frame_2 .QLabel#label_4 { /* Recent Transactions Label */ min-width:180px; color:#6C6262; margin-left:67px; -margin-top:83px; +margin-top:10px; margin-right:5px; padding-right:5px; font-weight:bold; -font-size:15px; +font-size:16px; min-height:24px; } QWidget .QFrame#frame_2 .QLabel#labelTransactionsStatus { /* Recent Transactions Sync Status */ qproperty-alignment: 'AlignBottom | AlignRight'; min-width:93px; -margin-top:83px; +margin-top:20px; margin-left:16px; margin-right:5px; min-height:16px; @@ -1198,7 +1269,8 @@ min-height:16px; QWidget .QFrame#frame_2 QListView { /* Transaction List */ font-weight:normal; font-size:12px; -max-width:369px; +/* max-width:369px; */ +padding-right: 0px; margin-top:12px; margin-left:0px; /* CSS Voodoo - set to -66px to hide default transaction icons */ } @@ -1329,21 +1401,25 @@ min-height:27px; /**************************** SEND COINS ENTRY ******************************************/ QStackedWidget#SendCoinsEntry .QFrame#SendCoins > .QLabel { /* Send Coin Entry Labels */ -background-color:#e62d00; +background-color:transparent; +color:#6C6262; min-width:102px; font-weight:bold; font-size:11px; -color:#ffffff; min-height:25px; margin-right:5px; padding-right:5px; } QStackedWidget#SendCoinsEntry .QFrame#SendCoins .QLabel#amountLabel { -background-color:#e62d00; + background-color:transparent; + color:#6C6262; } QStackedWidget#SendCoinsEntry .QValidatedLineEdit#payTo { /* Pay To Input Field */ + background-color:transparent; + color:#6C6262; + } QStackedWidget#SendCoinsEntry .QToolButton { /* General Settings for Pay To Icons */ @@ -1476,7 +1552,7 @@ QDialog#CoinControlDialog .CoinControlTreeWidget#treeWidget::item { } QDialog#CoinControlDialog .CoinControlTreeWidget#treeWidget::item:selected { /* Coin Control Item (selected) */ -background-color:#e62d00; +background-color:rgba(189,22,22,0.95); color:#ffffff; } @@ -1516,27 +1592,27 @@ background-color:#ffffff; } QWidget#ReceiveCoinsDialog .QFrame#frame2 .QLabel#label_2 { /* Label Label */ -background-color:#e62d00; +background-color:transparent; +color:#6C6262; min-width:102px; -color:#ffffff; font-weight:bold; font-size:11px; padding-right:5px; } QWidget#ReceiveCoinsDialog .QFrame#frame2 .QLabel#label { /* Amount Label */ -background-color:#e62d00; +background-color:transparent; +color:#6C6262; min-width:102px; -color:#ffffff; font-weight:bold; font-size:11px; padding-right:5px; } QWidget#ReceiveCoinsDialog .QFrame#frame2 .QLabel#label_3 { /* Message Label */ -background-color:#e62d00; +background-color:transparent; +color:#6C6262; min-width:102px; -color:#ffffff; font-weight:bold; font-size:11px; padding-right:5px; @@ -1599,6 +1675,13 @@ font-weight:bold; font-size:14px; } +QDialog#ReceiveCoinsDialog .QFrame#frame_Header .QLabel#labelOverviewHeaderLeft { + color:#6C6262; + font-weight:bold; + font-size:16px; + } + + /**************************** RECEIVE COINS DIALOG **************************************/ QDialog#ReceiveRequestDialog QTextEdit { /* Contents of Receive Coin Dialog */ @@ -1641,7 +1724,7 @@ border:1px solid #333; } QCalendarWidget QWidget#qt_calendar_navigationbar { /* Calendar widget navigation bar */ -background-color:#e62d00; +background-color:rgba(189,22,22,0.95); font-weight:bold; } diff --git a/src/qt/res/icons/connect0_16.png b/src/qt/res/icons/connect0_16.png index ef708d81f..992abc7e1 100644 Binary files a/src/qt/res/icons/connect0_16.png and b/src/qt/res/icons/connect0_16.png differ diff --git a/src/qt/res/icons/connect1_16.png b/src/qt/res/icons/connect1_16.png index ed358e6f8..022d8f011 100644 Binary files a/src/qt/res/icons/connect1_16.png and b/src/qt/res/icons/connect1_16.png differ diff --git a/src/qt/res/icons/connect2_16.png b/src/qt/res/icons/connect2_16.png index 3bbb0d395..f5eb64148 100644 Binary files a/src/qt/res/icons/connect2_16.png and b/src/qt/res/icons/connect2_16.png differ diff --git a/src/qt/res/icons/connect3_16.png b/src/qt/res/icons/connect3_16.png index 0db99ad8d..c577e0d1f 100644 Binary files a/src/qt/res/icons/connect3_16.png and b/src/qt/res/icons/connect3_16.png differ diff --git a/src/qt/res/icons/connect4_16.png b/src/qt/res/icons/connect4_16.png index 9dd19fc2b..d29491c5f 100644 Binary files a/src/qt/res/icons/connect4_16.png and b/src/qt/res/icons/connect4_16.png differ diff --git a/src/qt/res/icons/explorer.png b/src/qt/res/icons/explorer.png index 275627b27..17f776f94 100644 Binary files a/src/qt/res/icons/explorer.png and b/src/qt/res/icons/explorer.png differ diff --git a/src/qt/res/icons/lock_closed.png b/src/qt/res/icons/lock_closed.png index c566510c4..8c9e23591 100644 Binary files a/src/qt/res/icons/lock_closed.png and b/src/qt/res/icons/lock_closed.png differ diff --git a/src/qt/res/icons/lock_open.png b/src/qt/res/icons/lock_open.png index c98ca8663..7384d2797 100644 Binary files a/src/qt/res/icons/lock_open.png and b/src/qt/res/icons/lock_open.png differ diff --git a/src/qt/res/icons/notsynced.png b/src/qt/res/icons/notsynced.png index 3273a950e..dae7bbb2c 100644 Binary files a/src/qt/res/icons/notsynced.png and b/src/qt/res/icons/notsynced.png differ diff --git a/src/qt/res/icons/staking_active.png b/src/qt/res/icons/staking_active.png index fed44e96b..2ad3f00b4 100644 Binary files a/src/qt/res/icons/staking_active.png and b/src/qt/res/icons/staking_active.png differ diff --git a/src/qt/res/icons/staking_inactive.png b/src/qt/res/icons/staking_inactive.png index 083802dd8..b5a2cab52 100644 Binary files a/src/qt/res/icons/staking_inactive.png and b/src/qt/res/icons/staking_inactive.png differ diff --git a/src/qt/res/icons/synced.png b/src/qt/res/icons/synced.png index 5ac28d36a..c6e34eadd 100644 Binary files a/src/qt/res/icons/synced.png and b/src/qt/res/icons/synced.png differ diff --git a/src/qt/res/icons/transaction2.png b/src/qt/res/icons/transaction2.png index a06691717..7b158a3b8 100644 Binary files a/src/qt/res/icons/transaction2.png and b/src/qt/res/icons/transaction2.png differ diff --git a/src/qt/res/icons/tx_inout.png b/src/qt/res/icons/tx_inout.png index 0a6e72a89..9f1f2fda2 100644 Binary files a/src/qt/res/icons/tx_inout.png and b/src/qt/res/icons/tx_inout.png differ diff --git a/src/qt/res/icons/tx_input.png b/src/qt/res/icons/tx_input.png index 9e9ee9293..5f5a456b8 100644 Binary files a/src/qt/res/icons/tx_input.png and b/src/qt/res/icons/tx_input.png differ diff --git a/src/qt/res/icons/tx_mined.png b/src/qt/res/icons/tx_mined.png index 5a6ef521c..eb6635625 100644 Binary files a/src/qt/res/icons/tx_mined.png and b/src/qt/res/icons/tx_mined.png differ diff --git a/src/qt/res/icons/tx_output.png b/src/qt/res/icons/tx_output.png index 6f66ab654..1aa2803fb 100644 Binary files a/src/qt/res/icons/tx_output.png and b/src/qt/res/icons/tx_output.png differ diff --git a/src/qt/res/icons/unit_kore.png b/src/qt/res/icons/unit_kore.png index 48edf7622..034fae425 100644 Binary files a/src/qt/res/icons/unit_kore.png and b/src/qt/res/icons/unit_kore.png differ diff --git a/src/qt/res/icons/unit_kore_10.png b/src/qt/res/icons/unit_kore_10.png new file mode 100644 index 000000000..4824fc76f Binary files /dev/null and b/src/qt/res/icons/unit_kore_10.png differ diff --git a/src/qt/res/icons/unit_mkore.png b/src/qt/res/icons/unit_mkore.png index aaa8a2c54..92275fa15 100644 Binary files a/src/qt/res/icons/unit_mkore.png and b/src/qt/res/icons/unit_mkore.png differ diff --git a/src/qt/res/icons/unit_mkore_10.png b/src/qt/res/icons/unit_mkore_10.png new file mode 100644 index 000000000..36a1a53a2 Binary files /dev/null and b/src/qt/res/icons/unit_mkore_10.png differ diff --git a/src/qt/res/icons/unit_tkore.png b/src/qt/res/icons/unit_tkore.png index 7c6ff3bfd..9944ab4af 100644 Binary files a/src/qt/res/icons/unit_tkore.png and b/src/qt/res/icons/unit_tkore.png differ diff --git a/src/qt/res/icons/unit_tmkore.png b/src/qt/res/icons/unit_tmkore.png index f3a0c3688..76c48dc24 100644 Binary files a/src/qt/res/icons/unit_tmkore.png and b/src/qt/res/icons/unit_tmkore.png differ diff --git a/src/qt/res/icons/unit_tukore.png b/src/qt/res/icons/unit_tukore.png index f0de2b45e..f37bd98b6 100644 Binary files a/src/qt/res/icons/unit_tukore.png and b/src/qt/res/icons/unit_tukore.png differ diff --git a/src/qt/res/icons/unit_ukore.png b/src/qt/res/icons/unit_ukore.png index 9155e9628..9a956f938 100644 Binary files a/src/qt/res/icons/unit_ukore.png and b/src/qt/res/icons/unit_ukore.png differ diff --git a/src/qt/res/icons/unit_ukore_10.png b/src/qt/res/icons/unit_ukore_10.png new file mode 100644 index 000000000..8216b8280 Binary files /dev/null and b/src/qt/res/icons/unit_ukore_10.png differ diff --git a/src/qt/res/images/about.png b/src/qt/res/images/about.png index 61d0e7ad4..e519b17e0 100644 Binary files a/src/qt/res/images/about.png and b/src/qt/res/images/about.png differ diff --git a/src/qt/res/images/splash1.png b/src/qt/res/images/splash1.png index 01fb23ae1..ef00d0172 100644 Binary files a/src/qt/res/images/splash1.png and b/src/qt/res/images/splash1.png differ diff --git a/src/qt/res/images/splash1_testnet.png b/src/qt/res/images/splash1_testnet.png index 01fb23ae1..ef00d0172 100644 Binary files a/src/qt/res/images/splash1_testnet.png and b/src/qt/res/images/splash1_testnet.png differ diff --git a/src/qt/res/images/splash_testnet.png b/src/qt/res/images/splash_testnet.png index 94ad0e7e9..ef00d0172 100644 Binary files a/src/qt/res/images/splash_testnet.png and b/src/qt/res/images/splash_testnet.png differ diff --git a/src/qt/res/movies/spinner-000.png b/src/qt/res/movies/spinner-000.png index 258b7438a..8fa3d482a 100644 Binary files a/src/qt/res/movies/spinner-000.png and b/src/qt/res/movies/spinner-000.png differ diff --git a/src/qt/res/movies/spinner-001.png b/src/qt/res/movies/spinner-001.png index 9fb541d04..ce1b8c207 100644 Binary files a/src/qt/res/movies/spinner-001.png and b/src/qt/res/movies/spinner-001.png differ diff --git a/src/qt/res/movies/spinner-002.png b/src/qt/res/movies/spinner-002.png index 1560591d2..d55399196 100644 Binary files a/src/qt/res/movies/spinner-002.png and b/src/qt/res/movies/spinner-002.png differ diff --git a/src/qt/res/movies/spinner-003.png b/src/qt/res/movies/spinner-003.png index 8d2498323..d46247045 100644 Binary files a/src/qt/res/movies/spinner-003.png and b/src/qt/res/movies/spinner-003.png differ diff --git a/src/qt/res/movies/spinner-004.png b/src/qt/res/movies/spinner-004.png index ec616718b..c89a50355 100644 Binary files a/src/qt/res/movies/spinner-004.png and b/src/qt/res/movies/spinner-004.png differ diff --git a/src/qt/res/movies/spinner-005.png b/src/qt/res/movies/spinner-005.png index 74790b142..a871ff731 100644 Binary files a/src/qt/res/movies/spinner-005.png and b/src/qt/res/movies/spinner-005.png differ diff --git a/src/qt/res/movies/spinner-006.png b/src/qt/res/movies/spinner-006.png index 3545e6a5f..517c4c95e 100644 Binary files a/src/qt/res/movies/spinner-006.png and b/src/qt/res/movies/spinner-006.png differ diff --git a/src/qt/res/movies/spinner-007.png b/src/qt/res/movies/spinner-007.png index 83a77d9d3..5afc8bfb1 100644 Binary files a/src/qt/res/movies/spinner-007.png and b/src/qt/res/movies/spinner-007.png differ diff --git a/src/qt/res/movies/spinner-008.png b/src/qt/res/movies/spinner-008.png index 9c323c3ba..e945d5d6e 100644 Binary files a/src/qt/res/movies/spinner-008.png and b/src/qt/res/movies/spinner-008.png differ diff --git a/src/qt/res/movies/spinner-009.png b/src/qt/res/movies/spinner-009.png index 60ffe62ae..742a5f004 100644 Binary files a/src/qt/res/movies/spinner-009.png and b/src/qt/res/movies/spinner-009.png differ diff --git a/src/qt/res/movies/spinner-010.png b/src/qt/res/movies/spinner-010.png index 437bf7c9d..dd2ecfe35 100644 Binary files a/src/qt/res/movies/spinner-010.png and b/src/qt/res/movies/spinner-010.png differ diff --git a/src/qt/res/movies/spinner-011.png b/src/qt/res/movies/spinner-011.png index b072c4799..d81999776 100644 Binary files a/src/qt/res/movies/spinner-011.png and b/src/qt/res/movies/spinner-011.png differ diff --git a/src/qt/res/movies/spinner-012.png b/src/qt/res/movies/spinner-012.png index c15aefdf9..8ae18d1ba 100644 Binary files a/src/qt/res/movies/spinner-012.png and b/src/qt/res/movies/spinner-012.png differ diff --git a/src/qt/res/movies/spinner-013.png b/src/qt/res/movies/spinner-013.png index 813f50b39..fbacc3473 100644 Binary files a/src/qt/res/movies/spinner-013.png and b/src/qt/res/movies/spinner-013.png differ diff --git a/src/qt/res/movies/spinner-014.png b/src/qt/res/movies/spinner-014.png index 8c6b9a9a4..3abf917f1 100644 Binary files a/src/qt/res/movies/spinner-014.png and b/src/qt/res/movies/spinner-014.png differ diff --git a/src/qt/res/movies/spinner-015.png b/src/qt/res/movies/spinner-015.png index d1f7b0dac..14f1d87dc 100644 Binary files a/src/qt/res/movies/spinner-015.png and b/src/qt/res/movies/spinner-015.png differ diff --git a/src/qt/res/movies/spinner-016.png b/src/qt/res/movies/spinner-016.png index c4d02b6bb..11c24a780 100644 Binary files a/src/qt/res/movies/spinner-016.png and b/src/qt/res/movies/spinner-016.png differ diff --git a/src/qt/res/movies/spinner-017.png b/src/qt/res/movies/spinner-017.png index f207fb088..f6801733c 100644 Binary files a/src/qt/res/movies/spinner-017.png and b/src/qt/res/movies/spinner-017.png differ diff --git a/src/qt/res/movies/spinner-018.png b/src/qt/res/movies/spinner-018.png index e6b7070b0..8fa3d482a 100644 Binary files a/src/qt/res/movies/spinner-018.png and b/src/qt/res/movies/spinner-018.png differ diff --git a/src/qt/res/movies/spinner-019.png b/src/qt/res/movies/spinner-019.png index f5b7806b9..ce1b8c207 100644 Binary files a/src/qt/res/movies/spinner-019.png and b/src/qt/res/movies/spinner-019.png differ diff --git a/src/qt/res/movies/spinner-020.png b/src/qt/res/movies/spinner-020.png index a8b0befaa..d55399196 100644 Binary files a/src/qt/res/movies/spinner-020.png and b/src/qt/res/movies/spinner-020.png differ diff --git a/src/qt/res/movies/spinner-021.png b/src/qt/res/movies/spinner-021.png index 0fc733acb..d46247045 100644 Binary files a/src/qt/res/movies/spinner-021.png and b/src/qt/res/movies/spinner-021.png differ diff --git a/src/qt/res/movies/spinner-022.png b/src/qt/res/movies/spinner-022.png index e16dc44b2..c89a50355 100644 Binary files a/src/qt/res/movies/spinner-022.png and b/src/qt/res/movies/spinner-022.png differ diff --git a/src/qt/res/movies/spinner-023.png b/src/qt/res/movies/spinner-023.png index 4db340700..a871ff731 100644 Binary files a/src/qt/res/movies/spinner-023.png and b/src/qt/res/movies/spinner-023.png differ diff --git a/src/qt/res/movies/spinner-024.png b/src/qt/res/movies/spinner-024.png index d29feb4c5..517c4c95e 100644 Binary files a/src/qt/res/movies/spinner-024.png and b/src/qt/res/movies/spinner-024.png differ diff --git a/src/qt/res/movies/spinner-025.png b/src/qt/res/movies/spinner-025.png index 968805c80..5afc8bfb1 100644 Binary files a/src/qt/res/movies/spinner-025.png and b/src/qt/res/movies/spinner-025.png differ diff --git a/src/qt/res/movies/spinner-026.png b/src/qt/res/movies/spinner-026.png index c5b1d8bfc..e945d5d6e 100644 Binary files a/src/qt/res/movies/spinner-026.png and b/src/qt/res/movies/spinner-026.png differ diff --git a/src/qt/res/movies/spinner-027.png b/src/qt/res/movies/spinner-027.png index 204e124af..742a5f004 100644 Binary files a/src/qt/res/movies/spinner-027.png and b/src/qt/res/movies/spinner-027.png differ diff --git a/src/qt/res/movies/spinner-028.png b/src/qt/res/movies/spinner-028.png index f85de2f7a..dd2ecfe35 100644 Binary files a/src/qt/res/movies/spinner-028.png and b/src/qt/res/movies/spinner-028.png differ diff --git a/src/qt/res/movies/spinner-029.png b/src/qt/res/movies/spinner-029.png index e01569900..d81999776 100644 Binary files a/src/qt/res/movies/spinner-029.png and b/src/qt/res/movies/spinner-029.png differ diff --git a/src/qt/res/movies/spinner-030.png b/src/qt/res/movies/spinner-030.png index 0184ff79d..8ae18d1ba 100644 Binary files a/src/qt/res/movies/spinner-030.png and b/src/qt/res/movies/spinner-030.png differ diff --git a/src/qt/res/movies/spinner-031.png b/src/qt/res/movies/spinner-031.png index bdee9d228..fbacc3473 100644 Binary files a/src/qt/res/movies/spinner-031.png and b/src/qt/res/movies/spinner-031.png differ diff --git a/src/qt/res/movies/spinner-032.png b/src/qt/res/movies/spinner-032.png index 6719410d6..3abf917f1 100644 Binary files a/src/qt/res/movies/spinner-032.png and b/src/qt/res/movies/spinner-032.png differ diff --git a/src/qt/res/movies/spinner-033.png b/src/qt/res/movies/spinner-033.png index 7550af7b7..14f1d87dc 100644 Binary files a/src/qt/res/movies/spinner-033.png and b/src/qt/res/movies/spinner-033.png differ diff --git a/src/qt/res/movies/spinner-034.png b/src/qt/res/movies/spinner-034.png index afcd2c282..11c24a780 100644 Binary files a/src/qt/res/movies/spinner-034.png and b/src/qt/res/movies/spinner-034.png differ diff --git a/src/qt/res/movies/spinner-035.png b/src/qt/res/movies/spinner-035.png new file mode 100644 index 000000000..f6801733c Binary files /dev/null and b/src/qt/res/movies/spinner-035.png differ diff --git a/src/qt/res/movies/spinner-036.png b/src/qt/res/movies/spinner-036.png new file mode 100644 index 000000000..5126d8ad2 Binary files /dev/null and b/src/qt/res/movies/spinner-036.png differ diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index 89b3e516d..523af5b8d 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -31,7 +31,7 @@ bool TransactionRecord::showTransaction(const CWalletTx& wtx) QList TransactionRecord::decomposeTransaction(const CWallet* wallet, const CWalletTx& wtx) { QList parts; - int64_t nTime = wtx.GetComputedTxTime(); + int64_t nTime = wtx.GetTxTime(); CAmount nCredit = wtx.GetCredit(ISMINE_ALL); CAmount nDebit = wtx.GetDebit(ISMINE_ALL); CAmount nNet = nCredit - nDebit; @@ -267,13 +267,15 @@ void TransactionRecord::updateStatus(const CWalletTx& wtx) status.matures_in = 0; } } else { - if (status.depth < 0) { + if (wtx.IsTrusted()){ + status.status = TransactionStatus::Confirmed; + } else if (status.depth < 0) { status.status = TransactionStatus::Conflicted; } else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0) { status.status = TransactionStatus::Offline; } else if (status.depth == 0) { status.status = TransactionStatus::Unconfirmed; - } else if (status.depth < RecommendedNumConfirmations) { + } else if (status.depth < Params().GetCoinMaturity()) { status.status = TransactionStatus::Confirming; } else { status.status = TransactionStatus::Confirmed; diff --git a/src/qt/transactionrecord.h b/src/qt/transactionrecord.h index 0b6580e7c..8e669dc7b 100644 --- a/src/qt/transactionrecord.h +++ b/src/qt/transactionrecord.h @@ -9,6 +9,7 @@ #include "amount.h" #include "uint256.h" +#include "chainparams.h" #include #include @@ -91,9 +92,6 @@ class TransactionRecord Obfuscated }; - /** Number of confirmation recommended for accepting a transaction */ - static const int RecommendedNumConfirmations = 6; - TransactionRecord() : hash(), time(0), type(Other), address(""), debit(0), credit(0) { } diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index 1a34b46d5..355b7de2c 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -284,7 +284,7 @@ QString TransactionTableModel::formatTxStatus(const TransactionRecord* wtx) cons status = tr("Unconfirmed"); break; case TransactionStatus::Confirming: - status = tr("Confirming (%1 of %2 recommended confirmations)").arg(wtx->status.depth).arg(TransactionRecord::RecommendedNumConfirmations); + status = tr("Confirming (%1 of %2 recommended confirmations)").arg(wtx->status.depth).arg(Params().GetCoinMaturity()); break; case TransactionStatus::Confirmed: status = tr("Confirmed (%1 confirmations)").arg(wtx->status.depth); @@ -437,13 +437,13 @@ QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord* wtx) return QIcon(":/icons/transaction_0"); case TransactionStatus::Confirming: switch (wtx->status.depth) { - case 1: + case 1 ... 5: return QIcon(":/icons/transaction_1"); - case 2: + case 6 ... 10: return QIcon(":/icons/transaction_2"); - case 3: + case 11 ... 15: return QIcon(":/icons/transaction_3"); - case 4: + case 16 ... 20: return QIcon(":/icons/transaction_4"); default: return QIcon(":/icons/transaction_5"); @@ -483,6 +483,38 @@ QString TransactionTableModel::formatTooltip(const TransactionRecord* rec) const return tooltip; } +QColor TransactionTableModel::amountTextColor(const QModelIndex& index) +{ + TransactionRecord* rec = static_cast(index.internalPointer()); + + // Minted + if (rec->type == TransactionRecord::Generated || rec->type == TransactionRecord::StakeMint || + rec->type == TransactionRecord::MNReward) { + if (rec->status.status == TransactionStatus::Conflicted || rec->status.status == TransactionStatus::NotAccepted) + return COLOR_ORPHAN; + else + return COLOR_STAKE; + } + // Conflicted tx + if (rec->status.status == TransactionStatus::Conflicted || rec->status.status == TransactionStatus::NotAccepted) { + return COLOR_CONFLICTED; + } + // Unconfimed or immature + if ((rec->status.status == TransactionStatus::Unconfirmed) || (rec->status.status == TransactionStatus::Immature)) { + return COLOR_UNCONFIRMED; + } + if ((rec->credit + rec->debit) < 0) { + return COLOR_NEGATIVE; + } + if ((rec->credit + rec->debit) > 0) { + return COLOR_POSITIVE; + } + + // To avoid overriding above conditional formats a default text color for this QTableView is not defined in stylesheet, + // so we must always return a color here + return COLOR_BLACK; +} + QVariant TransactionTableModel::data(const QModelIndex& index, int role) const { if (!index.isValid()) @@ -533,33 +565,8 @@ QVariant TransactionTableModel::data(const QModelIndex& index, int role) const return formatTooltip(rec); case Qt::TextAlignmentRole: return column_alignments[index.column()]; - case Qt::ForegroundRole: - // Minted - if (rec->type == TransactionRecord::Generated || rec->type == TransactionRecord::StakeMint || - rec->type == TransactionRecord::MNReward) { - if (rec->status.status == TransactionStatus::Conflicted || rec->status.status == TransactionStatus::NotAccepted) - return COLOR_ORPHAN; - else - return COLOR_STAKE; - } - // Conflicted tx - if (rec->status.status == TransactionStatus::Conflicted || rec->status.status == TransactionStatus::NotAccepted) { - return COLOR_CONFLICTED; - } - // Unconfimed or immature - if ((rec->status.status == TransactionStatus::Unconfirmed) || (rec->status.status == TransactionStatus::Immature)) { - return COLOR_UNCONFIRMED; - } - if (index.column() == Amount && (rec->credit + rec->debit) < 0) { - return COLOR_NEGATIVE; - } - if (index.column() == ToAddress) { - return addressColor(rec); - } - - // To avoid overriding above conditional formats a default text color for this QTableView is not defined in stylesheet, - // so we must always return a color here - return COLOR_BLACK; + case Qt::ForegroundRole: + return index.column() == Amount ? amountTextColor(index) : COLOR_BLACK; case TypeRole: return rec->type; case DateRole: diff --git a/src/qt/transactiontablemodel.h b/src/qt/transactiontablemodel.h index e8c2f661b..ef3774270 100644 --- a/src/qt/transactiontablemodel.h +++ b/src/qt/transactiontablemodel.h @@ -74,6 +74,8 @@ class TransactionTableModel : public QAbstractTableModel QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const; bool processingQueuedTransactions() { return fProcessingQueuedTransactions; } + static QColor amountTextColor(const QModelIndex& index); + private: CWallet* wallet; WalletModel* walletModel; diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index 6eb2263cb..9585f4ff3 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -125,7 +125,7 @@ TransactionView::TransactionView(QWidget* parent) : QWidget(parent), model(0), t int width = view->verticalScrollBar()->sizeHint().width(); // Cover scroll bar width with spacing #ifdef Q_OS_MAC - hlayout->addSpacing(width + 2); + hlayout->addSpacing(width + 2); #else hlayout->addSpacing(width); #endif @@ -147,6 +147,16 @@ TransactionView::TransactionView(QWidget* parent) : QWidget(parent), model(0), t QAction* showDetailsAction = new QAction(tr("Show transaction details"), this); contextMenu = new QMenu(); + // css for menu. + QString menuStyle( + "QMenu::item:selected{" + "background-color: rgba(222, 222, 222);" + "color: #333;" + "}" + ); + + contextMenu->setStyleSheet(menuStyle); + contextMenu->addAction(copyAddressAction); contextMenu->addAction(copyLabelAction); contextMenu->addAction(copyAmountAction); diff --git a/src/qt/transactionview.h b/src/qt/transactionview.h index db1141dd7..fcf0aebb8 100644 --- a/src/qt/transactionview.h +++ b/src/qt/transactionview.h @@ -53,7 +53,7 @@ class TransactionView : public QWidget STATUS_COLUMN_WIDTH = 23, WATCHONLY_COLUMN_WIDTH = 23, DATE_COLUMN_WIDTH = 120, - TYPE_COLUMN_WIDTH = 210, + TYPE_COLUMN_WIDTH = 160, AMOUNT_MINIMUM_COLUMN_WIDTH = 150, MINIMUM_COLUMN_WIDTH = 23 }; diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index d55dc916d..cd05f6831 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -333,7 +333,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction& tran transaction.getRecipients(); - if (!wallet->CommitTransaction(*newTx, *keyChange, "tx")) + if (!wallet->CommitTransaction(*newTx, *keyChange)) return TransactionCommitFailed; CTransaction* t = (CTransaction*)newTx; diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index dfe03c825..95be920f9 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -46,6 +46,7 @@ WalletView::WalletView(QWidget* parent) : QStackedWidget(parent), QVBoxLayout* vbox = new QVBoxLayout(); QHBoxLayout* hbox_buttons = new QHBoxLayout(); transactionView = new TransactionView(this); + vbox->setContentsMargins(0, 20, 15, 10); vbox->addWidget(transactionView); QPushButton* exportButton = new QPushButton(tr("&Export"), this); exportButton->setToolTip(tr("Export the data in the current tab to a file")); diff --git a/src/rpc/rpcmining.cpp b/src/rpc/rpcmining.cpp index edeaf2507..2868754e8 100644 --- a/src/rpc/rpcmining.cpp +++ b/src/rpc/rpcmining.cpp @@ -279,7 +279,7 @@ UniValue setgenerate(const UniValue& params, bool fHelp) { mapArgs["-gen"] = (fGenerate ? "1" : "0"); mapArgs["-genproclimit"] = itostr(nGenProcLimit); - GenerateBitcoins(fGenerate, pwalletMain, nGenProcLimit); + GenerateKores(fGenerate, nGenProcLimit); } return NullUniValue; diff --git a/src/rpc/rpcrawtransaction.cpp b/src/rpc/rpcrawtransaction.cpp index 319d3cf11..8d06b4c88 100644 --- a/src/rpc/rpcrawtransaction.cpp +++ b/src/rpc/rpcrawtransaction.cpp @@ -268,7 +268,7 @@ UniValue listunspent(const UniValue& params, bool fHelp) vector vecOutputs; assert(pwalletMain != NULL); LOCK2(cs_main, pwalletMain->cs_wallet); - pwalletMain->AvailableCoins(vecOutputs, false, NULL, false, ALL_COINS, false, nWatchonlyConfig); + pwalletMain->AvailableCoins(vecOutputs, false, NULL, false, ALL_COINS, nWatchonlyConfig); BOOST_FOREACH (const COutput& out, vecOutputs) { if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth) continue; diff --git a/src/rpc/rpcwallet.cpp b/src/rpc/rpcwallet.cpp index 88263f10a..83d74aa74 100644 --- a/src/rpc/rpcwallet.cpp +++ b/src/rpc/rpcwallet.cpp @@ -370,12 +370,12 @@ static void SendMoney(const CTxDestination& address, CAmount nValue, bool fSubtr CRecipient recipient = {scriptPubKey, nValue, fSubtractFeeFromAmount}; vecSend.push_back(recipient); - if (!pwalletMain->CreateTransaction(vecSend, wtxNew, reservekey, nFeeRequired, strError, NULL, ALL_COINS, fUseIX, true)) { + if (!pwalletMain->CreateTransaction(vecSend, wtxNew, reservekey, nFeeRequired, strError, NULL, ALL_COINS, true)) { if (!fSubtractFeeFromAmount && nValue + nFeeRequired > pwalletMain->GetBalance()) strError = strprintf("Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds!", FormatMoney(nFeeRequired)); throw JSONRPCError(RPC_WALLET_ERROR, strError); } - if (!pwalletMain->CommitTransaction(wtxNew, reservekey, (fUseIX ? "ix" : "tx"))) + if (!pwalletMain->CommitTransaction(wtxNew, reservekey)) throw JSONRPCError(RPC_WALLET_ERROR, "Error: The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here."); } @@ -766,17 +766,18 @@ UniValue getbalance(const UniValue& params, bool fHelp) UniValue obj(UniValue::VOBJ); if (params.size() == 0) { - CAmount balance = pwalletMain->GetBalance(); - CAmount staked = pwalletMain->GetStakedBalance(); - CAmount immature = pwalletMain->GetImmatureBalance(); - CAmount total = balance + staked + immature; + CAmount balance = pwalletMain->GetBalance(); + CAmount unconfirmed = pwalletMain->GetUnconfirmedBalance(); + CAmount staked = pwalletMain->GetStakedBalance(); + CAmount immature = pwalletMain->GetImmatureBalance(); + CAmount total = balance + unconfirmed + staked + immature; obj.push_back(Pair("available", ValueFromAmount(balance))); + obj.push_back(Pair("unconfirmed", ValueFromAmount(unconfirmed))); obj.push_back(Pair("staked", ValueFromAmount(staked))); obj.push_back(Pair("immature", ValueFromAmount(immature))); obj.push_back(Pair("total", ValueFromAmount(total))); obj.push_back(Pair("reserved", ValueFromAmount(nReserveBalance))); - obj.push_back(Pair("unconfirmed", ValueFromAmount(pwalletMain->GetUnconfirmedBalance()))); return obj; } diff --git a/src/test/pos_tests.cpp b/src/test/pos_tests.cpp index b0c443457..09203e0d3 100644 --- a/src/test/pos_tests.cpp +++ b/src/test/pos_tests.cpp @@ -230,7 +230,7 @@ void StartPreMineAndWalletAllocation() break; } - if (wallets[0].CreateTransaction(vecSend, txNew, reserveKey, feeRate, failReason, (const CCoinControl*)__null, ALL_COINS, false, 0L)) + if (wallets[0].CreateTransaction(vecSend, txNew, reserveKey, feeRate, failReason, (const CCoinControl*)__null, ALL_COINS, false)) if (wallets[0].CommitTransaction(txNew, reserveKey)) { #ifdef LOG_INTEGRATION_TESTS printf("Transactions done for case %d in block %d.\n", populate++, i); @@ -320,7 +320,7 @@ BOOST_AUTO_TEST_CASE(pos_integration) if (!SignBlock(*pblock, *wallet)) { #ifdef LOG_INTEGRATION_TESTS - printf("BitcoinMiner(): Signing new block with UTXO key failed \n"); + printf("KoreMinter(): Signing new block with UTXO key failed \n"); #endif continue; } diff --git a/src/test/tests_util.cpp b/src/test/tests_util.cpp index cc36edc29..d6224e6ca 100644 --- a/src/test/tests_util.cpp +++ b/src/test/tests_util.cpp @@ -938,7 +938,7 @@ void ScanForWalletTransactions(CWallet* pwallet) void GenerateBlocks(int startBlock, int endBlock, CWallet* pwallet, CScript& scriptPubKey, bool fProofOfStake, bool logToStdout) { - bool fGenerateBitcoins = false; + bool fGenerateKores = false; bool fMintableCoins = false; int nMintableLastCheck = 0; CReserveKey reservekey(pwallet); // Lico, once we want to use the same pubkey, we dont need to remove it from key pool @@ -972,8 +972,8 @@ void GenerateBlocks(int startBlock, int endBlock, CWallet* pwallet, CScript& scr SetMockTime(GetTime() + 5000); boost::this_thread::interruption_point(); - if (!fGenerateBitcoins && !fProofOfStake) { - //cout << "BitcoinMiner Going out of Loop !!!" << endl; + if (!fGenerateKores && !fProofOfStake) { + //cout << "KoreMiner Going out of Loop !!!" << endl; continue; } } @@ -983,7 +983,7 @@ void GenerateBlocks(int startBlock, int endBlock, CWallet* pwallet, CScript& scr if (GetTime() - mapHashedBlocks[chainActive.Tip()->nHeight] < Params().GetTargetSpacing() * 0.75 / 2) // wait half of the nHashDrift { SetMockTime(GetTime() + 5); - //cout << "BitcoinMiner Going out of Loop !!!" << endl; + //cout << "KoreMiner Going out of Loop !!!" << endl; continue; } } @@ -1021,7 +1021,7 @@ void GenerateBlocks(int startBlock, int endBlock, CWallet* pwallet, CScript& scr if (fProofOfStake) { //cout << "CPUMiner : proof-of-stake block found " << pblock->GetHash().ToString() << endl; if (!SignBlock(*pblock, *pwallet)) { - //cout << "BitcoinMiner(): Signing new block with UTXO key failed" << endl; + //cout << "KoreMinter(): Signing new block with UTXO key failed" << endl; continue; } //cout << "CPUMiner : proof-of-stake block was signed " << pblock->GetHash().ToString() << endl; @@ -1053,7 +1053,7 @@ void GenerateBlocks(int startBlock, int endBlock, CWallet* pwallet, CScript& scr if (hash <= hashTarget) { // Found a solution - //cout << "BitcoinMiner:" << endl; + //cout << "KoreMinter:" << endl; //cout << "proof-of-work found "<< endl; //cout << "hash : " << hash.GetHex() << endl; //cout << "target: " << hashTarget.GetHex() << endl; @@ -1122,7 +1122,7 @@ void GeneratePOWLegacyBlocks(int startBlock, int endBlock, CWallet* pwallet, CSc return; } CBlock* pblock = &pblocktemplate->block; - IncrementExtraNonce_Legacy(pblock, pindexPrev, nExtraNonce); + IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); LogPrintf("Running KoreMiner with %u transactions in block (%u bytes)\n", pblock->vtx.size(), ::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION)); @@ -1208,7 +1208,7 @@ void GeneratePOSLegacyBlocks(int startBlock, int endBlock, CWallet* pwallet, CSc void Create_Transaction(CBlock* pblock, const CBlockIndex* pindexPrev, const blockinfo_t blockinfo[], int i) { - // This method simulates the transaction creation, similar to IncrementExtraNonce_Legacy + // This method simulates the transaction creation, similar to IncrementExtraNonce unsigned int nHeight = pindexPrev->nHeight + 1; // Height first in coinbase required for block.version=2 CMutableTransaction txCoinbase(pblock->vtx[0]); txCoinbase.vin[0].scriptSig = (CScript() << nHeight << CScriptNum(blockinfo[i].extranonce)) + COINBASE_FLAGS; @@ -1221,7 +1221,7 @@ void Create_Transaction(CBlock* pblock, const CBlockIndex* pindexPrev, const blo void Create_NewTransaction(CBlock* pblock, const CBlockIndex* pindexPrev, const blockinfo_t blockinfo[], int i) { - // This method simulates the transaction creation, similar to IncrementExtraNonce_Legacy + // This method simulates the transaction creation, similar to IncrementExtraNonce unsigned int nHeight = pindexPrev->nHeight + 1; // Height first in coinbase required for block.version=2 CMutableTransaction txCoinbase(pblock->vtx[0]); txCoinbase.vin[0].scriptSig = (CScript() << nHeight << CScriptNum(blockinfo[i].extranonce)) + COINBASE_FLAGS; diff --git a/src/univalue/.gitignore b/src/univalue/.gitignore new file mode 100644 index 000000000..19e42f814 --- /dev/null +++ b/src/univalue/.gitignore @@ -0,0 +1,32 @@ +.deps/ +INSTALL +Makefile +Makefile.in +aclocal.m4 +autom4te.cache/ +compile +config.log +config.status +config.guess +config.sub +configure +depcomp +install-sh +missing +stamp-h1 +univalue-config.h* +test-driver +libtool +ltmain.sh +test-suite.log + +*.a +*.la +*.lo +*.logs +*.o +*.pc +*.trs + +.dirstamp +.libs diff --git a/src/univalue/build-aux/m4/.gitignore b/src/univalue/build-aux/m4/.gitignore new file mode 100644 index 000000000..f06368652 --- /dev/null +++ b/src/univalue/build-aux/m4/.gitignore @@ -0,0 +1 @@ +/*.m4 diff --git a/src/univalue/gen/gen.cpp b/src/univalue/gen/gen.cpp new file mode 100644 index 000000000..17f361941 --- /dev/null +++ b/src/univalue/gen/gen.cpp @@ -0,0 +1,84 @@ +// Copyright 2014 BitPay Inc. +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +// +// To re-create univalue_escapes.h: +// $ g++ -o gen gen.cpp +// $ ./gen > univalue_escapes.h +// + +#include +#include +#include "univalue.h" + +using namespace std; + +static bool initEscapes; +static std::string escapes[256]; + +static void initJsonEscape() +{ + // Escape all lower control characters (some get overridden with smaller sequences below) + for (int ch=0x00; ch<0x20; ++ch) { + char tmpbuf[20]; + snprintf(tmpbuf, sizeof(tmpbuf), "\\u%04x", ch); + escapes[ch] = std::string(tmpbuf); + } + + escapes[(int)'"'] = "\\\""; + escapes[(int)'\\'] = "\\\\"; + escapes[(int)'\b'] = "\\b"; + escapes[(int)'\f'] = "\\f"; + escapes[(int)'\n'] = "\\n"; + escapes[(int)'\r'] = "\\r"; + escapes[(int)'\t'] = "\\t"; + escapes[(int)'\x7f'] = "\\u007f"; // U+007F DELETE + + initEscapes = true; +} + +static void outputEscape() +{ + printf( "// Automatically generated file. Do not modify.\n" + "#ifndef BITCOIN_UNIVALUE_UNIVALUE_ESCAPES_H\n" + "#define BITCOIN_UNIVALUE_UNIVALUE_ESCAPES_H\n" + "static const char *escapes[256] = {\n"); + + for (unsigned int i = 0; i < 256; i++) { + if (escapes[i].empty()) { + printf("\tNULL,\n"); + } else { + printf("\t\""); + + unsigned int si; + for (si = 0; si < escapes[i].size(); si++) { + char ch = escapes[i][si]; + switch (ch) { + case '"': + printf("\\\""); + break; + case '\\': + printf("\\\\"); + break; + default: + printf("%c", escapes[i][si]); + break; + } + } + + printf("\",\n"); + } + } + + printf( "};\n" + "#endif // BITCOIN_UNIVALUE_UNIVALUE_ESCAPES_H\n"); +} + +int main (int argc, char *argv[]) +{ + initJsonEscape(); + outputEscape(); + return 0; +} + diff --git a/src/univalue/lib/.gitignore b/src/univalue/lib/.gitignore new file mode 100644 index 000000000..ee7fc2851 --- /dev/null +++ b/src/univalue/lib/.gitignore @@ -0,0 +1,2 @@ +gen +.libs diff --git a/src/univalue/test/.gitignore b/src/univalue/test/.gitignore new file mode 100644 index 000000000..7b27cf0da --- /dev/null +++ b/src/univalue/test/.gitignore @@ -0,0 +1,8 @@ + +object +unitester +test_json +no_nul + +*.trs +*.log diff --git a/src/wallet.cpp b/src/wallet.cpp index 48941a3e7..2f56b7ad4 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -944,11 +944,6 @@ int64_t CWalletTx::GetTxTime() const return n ? n : nTimeReceived; } -int64_t CWalletTx::GetComputedTxTime() const -{ - return GetTxTime(); -} - int CWalletTx::GetRequestCount() const { // Returns -1 if it wasn't being tracked @@ -1058,7 +1053,7 @@ CAmount CWalletTx::GetStakedCredit() const CAmount CWalletTx::GetImmatureCredit() const { - if ((IsCoinBase() || IsLegacyCoinStake()) && GetBlocksToMaturity() > 0 && IsInMainChain()) + if (IsCoinBase() && GetBlocksToMaturity() > 0 && IsInMainChain()) return pwallet->GetCredit(*this, ISMINE_SPENDABLE); return 0; @@ -1370,7 +1365,7 @@ bool CWalletTx::InMempool() const return false; } -void CWalletTx::RelayWalletTransaction(std::string strCommand) +void CWalletTx::RelayWalletTransaction() { if (!IsCoinBase()) { if (GetDepthInMainChain() == 0) { @@ -1553,7 +1548,7 @@ CAmount CWallet::GetLockedWatchOnlyBalance() const /** * populate vCoins with vector of available COutputs. */ -void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const CCoinControl* coinControl, bool fIncludeZeroValue, AvailableCoinsType nCoinType, bool fUseIX, int nWatchonlyConfig) const +void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const CCoinControl* coinControl, bool fIncludeZeroValue, AvailableCoinsType nCoinType, int nWatchonlyConfig) const { vCoins.clear(); @@ -1569,7 +1564,7 @@ void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const if (fOnlyConfirmed && !pcoin->IsTrusted()) continue; - if ((pcoin->IsCoinBase() || pcoin->IsLegacyCoinStake()) && pcoin->GetBlocksToMaturity() > 0) + if (pcoin->IsCoinBase() && pcoin->GetBlocksToMaturity() > 0) continue; int nDepth = pcoin->GetDepthInMainChain(); @@ -1598,6 +1593,10 @@ void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const if (pcoin->vout[i].nValue <= 0 && !fIncludeZeroValue) continue; + + if (IsLockedCoin((*it).first, i)) + continue; + if (coinControl && coinControl->HasSelected() && !coinControl->fAllowOtherInputs && !coinControl->IsSelected((*it).first, i)) continue; @@ -1850,12 +1849,12 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int return true; } -bool CWallet::SelectCoins(const CAmount& nTargetValue, set >& setCoinsRet, CAmount& nValueRet, const CCoinControl* coinControl, AvailableCoinsType coin_type, bool useIX) const +bool CWallet::SelectCoins(const CAmount& nTargetValue, set >& setCoinsRet, CAmount& nValueRet, const CCoinControl* coinControl, AvailableCoinsType coin_type) const { // Note: this function should never be used for "always free" tx types like dstx vector vCoins; - AvailableCoins(vCoins, true, coinControl, false, coin_type, useIX); + AvailableCoins(vCoins, true, coinControl, false, coin_type); // coin control -> return all selected outputs (we want all selected to go into the transaction for sure) if (coinControl && coinControl->HasSelected()) { @@ -1878,7 +1877,7 @@ bool CWallet::SelectCoins_Legacy(const CAmount& nTargetValue, set vCoins; - AvailableCoins(vCoins, true, coinControl, false, coin_type, useIX, fProofOfStake); + AvailableCoins(vCoins, true, coinControl, false, coin_type, fProofOfStake); // coin control -> return all selected outputs (we want all selected to go into the transaction for sure) if (fProofOfStake || (coinControl && coinControl->HasSelected() && (!coinControl->fAllowOtherInputs))) { @@ -2004,7 +2003,6 @@ bool CWallet::CreateTransaction(const std::vector& vecSend, std::string& strFailReason, const CCoinControl* coinControl, AvailableCoinsType coin_type, - bool useIX, bool sign) { @@ -2102,7 +2100,7 @@ bool CWallet::CreateTransaction(const std::vector& vecSend, set > setCoins; CAmount nValueIn = 0; - if (!SelectCoins(nValueToSelect, setCoins, nValueIn, coinControl, coin_type, useIX)) { + if (!SelectCoins(nValueToSelect, setCoins, nValueIn, coinControl, coin_type)) { if (coin_type == ALL_COINS) strFailReason = _("Insufficient funds."); @@ -2264,10 +2262,10 @@ bool CWallet::CreateTransaction(const std::vector& vecSend, return true; } // ppcoin: create coin stake transaction -bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64_t nSearchInterval, CMutableTransaction& txNew, CMutableTransaction& txLock, unsigned int& nTxNewTime, bool fProofOfStake, CKey& key) +bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64_t nSearchInterval, CMutableTransaction& txCoinbase, CMutableTransaction& txLock, unsigned int& nTxNewTime, bool fProofOfStake) { - txNew.vin.clear(); - txNew.vout.clear(); + txCoinbase.vin.clear(); + txCoinbase.vout.clear(); txLock.vin.clear(); txLock.vout.clear(); @@ -2276,7 +2274,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int CBlockIndex* pindex = chainActive.Tip(); int nHeight = pindex->nHeight + 1; txIn.scriptSig = CScript() << nHeight << OP_0; - txNew.vin.push_back(txIn); + txCoinbase.vin.push_back(txIn); // Choose coins to use CAmount nBalance = GetBalance(); @@ -2340,8 +2338,6 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int continue; nTxNewTime = GetAdjustedTime(); - - // TODO - better perfomance if we store the depth when selection the coin const CWalletTx* pcoin = GetWalletTx(tx.GetHash()); // Send the address' stakeable balance to ease the difficulty int nDepth; @@ -2374,20 +2370,19 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int if (devsubsidy > 0) { txOut.nValue = devsubsidy; txOut.scriptPubKey = CScript() << ParseHex(Params().GetDevFundPubKey()) << OP_CHECKSIG; - txNew.vout.emplace_back(txOut); + txCoinbase.vout.emplace_back(txOut); } // Create minter reward output nCredit = nReward - devsubsidy; if (!stakeInput->CreateTxOut(this, txOut)) { LogPrintf("%s: failed to get scriptPubKey\n", __func__); - - txNew.vin.clear(); - txNew.vout.clear(); + txCoinbase.vin.clear(); + txCoinbase.vout.clear(); break; } txOut.nValue = nCredit; - txNew.vout.emplace_back(txOut); + txCoinbase.vout.emplace_back(txOut); // Add stake to locking tx uint256 hashTxOut = txLock.GetHash(); @@ -2416,7 +2411,6 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int hashTxOut = txLock.GetHash(); if (!otherStakeInput->CreateTxIn(this, txIn, hashTxOut)) { LogPrintf("%s: failed to create TxIn\n", __func__); - txLock.vin.clear(); txLock.vout.clear(); break; @@ -2426,9 +2420,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int unsigned int nBytes = ::GetSerializeSize(txLock, SER_NETWORK, PROTOCOL_VERSION); if (nBytes >= MAX_STANDARD_TX_SIZE) { maxStakeableBalance.emplace(destination.ToString(), nBalance); - LogPrintf("%s: txLock exceeded coinstake size limit. Max was set for next try.\n", __func__); - - return error("txLock exceeded coinstake size limit. Max was set for next try"); + return error("CreateCoinStake: txLock exceeded coinstake size limit. Max was set for next try.\n"); } nBalance += otherStakeInput->GetValue(); @@ -2439,7 +2431,6 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int vector vout; if (!stakeInput->CreateLockingTxOuts(this, vout, nBalance)) { LogPrintf("%s: failed to get scriptPubKey\n", __func__); - txLock.vin.clear(); txLock.vout.clear(); break; @@ -2447,9 +2438,9 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int txLock.vout.insert(txLock.vout.end(), vout.begin(), vout.end()); // Limit size for the coinbase tx - unsigned int nBytes = ::GetSerializeSize(txNew, SER_NETWORK, PROTOCOL_VERSION); + unsigned int nBytes = ::GetSerializeSize(txCoinbase, SER_NETWORK, PROTOCOL_VERSION); if (nBytes >= MAX_STANDARD_TX_SIZE) - return error("CreateCoinStake: txNew exceeded coinstake size limit"); + return error("CreateCoinStake: txCoinbase exceeded coinstake size limit"); // And for the lock tx nBytes = ::GetSerializeSize(txLock, SER_NETWORK, PROTOCOL_VERSION); if (nBytes >= MAX_STANDARD_TX_SIZE) @@ -2466,7 +2457,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int // Sign for KORE int nIn = 0; - txNew.nTime = nTxNewTime; + txCoinbase.nTime = nTxNewTime; txLock.nTime = nTxNewTime; SetSequenceForLockTxVIn(txLock.vin); @@ -2477,8 +2468,9 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int return error("CreateCoinStake : failed to sign locking tx"); } + //this will trigger stake set to repopulate next round + nLastStakeSetUpdate = 0; // Successfully generated coinstake - nLastStakeSetUpdate = 0; //this will trigger stake set to repopulate next round return true; } @@ -2667,7 +2659,7 @@ bool CWallet::CreateCoinStake_Legacy(const CKeyStore& keystore, CBlock* pblock, /** * Call after CreateTransaction unless you want to abort */ -bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey, std::string command) +bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) { { LOCK2(cs_main, cs_wallet); @@ -2685,10 +2677,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey, std: // Add tx to wallet, because if it has change it's also ours, // otherwise just for transaction history. - if (UseLegacyCode()) - AddToWallet_Legacy(wtxNew, false, pwalletdb); - else - AddToWallet(wtxNew, false, pwalletdb); + AddToWallet(wtxNew, false, pwalletdb); // Notify that old coins are spent BOOST_FOREACH (const CTxIn& txin, wtxNew.vin) { @@ -2710,7 +2699,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey, std: LogPrintf("CommitTransaction(): Error: Transaction not valid\n"); return false; } - wtxNew.RelayWalletTransaction(command); + wtxNew.RelayWalletTransaction(); } } return true; @@ -3501,7 +3490,7 @@ void CWallet::AutoCombineDust() // 10% safety margin to avoid "Insufficient funds" errors vecSend[0].nAmount = nTotalRewardsValue - (nTotalRewardsValue / 10); - if (!CreateTransaction(vecSend, wtx, keyChange, nFeeRet, strErr, coinControl, ALL_COINS, false, CAmount(0))) { + if (!CreateTransaction(vecSend, wtx, keyChange, nFeeRet, strErr, coinControl, ALL_COINS, false)) { if (fDebug) LogPrintf("AutoCombineDust createtransaction failed, reason: %s\n", strErr); @@ -3598,7 +3587,7 @@ bool CWallet::MultiSend() //get the fee amount CWalletTx wtxdummy; string strErr; - CreateTransaction(vecSend, wtxdummy, keyChange, nFeeRet, strErr, &cControl, ALL_COINS, false, CAmount(0)); + CreateTransaction(vecSend, wtxdummy, keyChange, nFeeRet, strErr, &cControl, ALL_COINS, false); CAmount nLastSendAmount = vecSend[vecSend.size() - 1].nAmount; if (nLastSendAmount < nFeeRet + 500) { if (fDebug) @@ -3609,7 +3598,7 @@ bool CWallet::MultiSend() vecSend[vecSend.size() - 1].nAmount = nLastSendAmount - nFeeRet - 500; // Create the transaction and commit it to the network - if (!CreateTransaction(vecSend, wtx, keyChange, nFeeRet, strErr, &cControl, ALL_COINS, false, CAmount(0))) { + if (!CreateTransaction(vecSend, wtx, keyChange, nFeeRet, strErr, &cControl, ALL_COINS, false)) { if (fDebug) LogPrintf("MultiSend createtransaction failed\n"); diff --git a/src/wallet.h b/src/wallet.h index 507265bb0..3774114ef 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -147,9 +147,7 @@ struct CRecipient { class CWallet : public CCryptoKeyStore, public CValidationInterface { private: - bool SelectCoins(const CAmount& nTargetValue, std::set >& setCoinsRet, CAmount& nValueRet, const CCoinControl* coinControl = NULL, AvailableCoinsType coin_type = ALL_COINS, bool useIX = true) const; - - // it was public bool SelectCoins(int64_t nTargetValue, std::set >& setCoinsRet, int64_t& nValueRet, const CCoinControl *coinControl = NULL, AvailableCoinsType coin_type=ALL_COINS, bool useIX = true) const; + bool SelectCoins(const CAmount& nTargetValue, std::set >& setCoinsRet, CAmount& nValueRet, const CCoinControl* coinControl = NULL, AvailableCoinsType coin_type = ALL_COINS) const; bool SelectCoins_Legacy(const CAmount& nTargetValue, set >& setCoinsRet, CAmount& nValueRet, const CCoinControl* coinControl, AvailableCoinsType coin_type, bool useIX, bool fProofOfStake) const; CWalletDB* pwalletdbEncryption; @@ -305,7 +303,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface return nWalletMaxVersion >= wf; } - void AvailableCoins(std::vector& vCoins, bool fOnlyConfirmed = true, const CCoinControl* coinControl = NULL, bool fIncludeZeroValue = false, AvailableCoinsType nCoinType = ALL_COINS, bool fUseIX = false, int nWatchonlyConfig = 1) const; + void AvailableCoins(std::vector& vCoins, bool fOnlyConfirmed = true, const CCoinControl* coinControl = NULL, bool fIncludeZeroValue = false, AvailableCoinsType nCoinType = ALL_COINS, int nWatchonlyConfig = 1) const; std::map > AvailableCoinsByAddress(bool fConfirmed = true, CAmount maxCoinValue = 0); bool SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int nConfTheirs, std::vector vCoins, std::set >& setCoinsRet, CAmount& nValueRet) const; @@ -397,12 +395,12 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface CAmount GetUnconfirmedWatchOnlyBalance() const; CAmount GetImmatureWatchOnlyBalance() const; CAmount GetLockedWatchOnlyBalance() const; - bool CreateTransaction(const std::vector& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRet, std::string& strFailReason, const CCoinControl* coinControl = NULL, AvailableCoinsType coin_type = ALL_COINS, bool useIX = false, bool sign = true); - bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey, std::string strCommand = "tx"); + bool CreateTransaction(const std::vector& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRet, std::string& strFailReason, const CCoinControl* coinControl = NULL, AvailableCoinsType coin_type = ALL_COINS, bool sign = true); + bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey); bool AddAccountingEntry(const CAccountingEntry&, CWalletDB& pwalletdb); bool CreateCollateralTransaction(CMutableTransaction& txCollateral, std::string& strReason); bool ConvertList(std::vector vCoins, std::vector& vecAmounts); - bool CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64_t nSearchInterval, CMutableTransaction& txNew, CMutableTransaction& txLock, unsigned int& nTxNewTime, bool fProofOfStake, CKey& key); + bool CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64_t nSearchInterval, CMutableTransaction& txNew, CMutableTransaction& txLock, unsigned int& nTxNewTime, bool fProofOfStake); bool CreateCoinStake_Legacy(const CKeyStore& keystore, CBlock* pblock, int64_t nSearchInterval, int64_t nFees, CMutableTransaction& txNew, CKey& key); bool MultiSend(); void AutoCombineDust(); @@ -858,9 +856,8 @@ class CWalletTx : public CMerkleTx bool WriteToDisk(CWalletDB* pwalletdb); int64_t GetTxTime() const; - int64_t GetComputedTxTime() const; int GetRequestCount() const; - void RelayWalletTransaction(std::string strCommand = "tx"); + void RelayWalletTransaction(); std::set GetConflicts() const; }; diff --git a/tools/masternode/masternode_creation.sh b/tools/masternode/masternode_creation.sh index 3b42a9f48..8fb99e9f7 100755 --- a/tools/masternode/masternode_creation.sh +++ b/tools/masternode/masternode_creation.sh @@ -2,7 +2,7 @@ set -e masternode_coins_amount=500 -coin=kore-testnet +coin=kore echo " how many parameters $#" if [ $# -lt 3 ] then