diff --git a/.gitignore b/.gitignore index 3538ce7f2cf6..0cee466e2a85 100644 --- a/.gitignore +++ b/.gitignore @@ -124,3 +124,7 @@ qa/pull-tester/test.*/* .project /doc/doxygen/ /nbproject/ + +.idea +CMakeLists.txt +cmake-build-debug diff --git a/src/chainparams.cpp b/src/chainparams.cpp index b79c12ac5a72..b52e753ab9f8 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -134,6 +134,7 @@ class CMainParams : public CChainParams nLastPOWBlock = 259200; nModifierUpdateBlock = 615800; nZerocoinStartHeight = 863787; + nZerocoinStartTime = 1508214600; // October 17, 2017 4:30:00 AM nBlockEnforceSerialRange = 895400; //Enforce serial range starting this block nBlockRecalculateAccumulators = 908000; //Trigger a recalculation of accumulators nBlockFirstFraudulent = 891737; //First block that bad serials emerged @@ -289,7 +290,7 @@ class CTestNetParams : public CMainParams strSporkKey = "04348C2F50F90267E64FACC65BFDC9D0EB147D090872FB97ABAE92E9A36E6CA60983E28E741F8E7277B11A7479B626AC115BA31463AC48178A5075C5A9319D4A38"; strObfuscationPoolDummyAddress = "y57cqfGRkekRyDRNeJiLtYVEbvhXrNbmox"; nStartMasternodePayments = 1420837558; //Fri, 09 Jan 2015 21:05:58 GMT - nBudget_Fee_Confirmations = 3; // Number of confirmations for the finalization fee. We have to make this very short + nBudget_Fee_Confirmations = 3; // Number of confirmations for the finalization fee. We have to make this very short // here because we only have a 8 block finalization window on testnet } const Checkpoints::CCheckpointData& Checkpoints() const diff --git a/src/chainparams.h b/src/chainparams.h index c440704f6c5a..bf46680b004c 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -115,6 +115,7 @@ class CChainParams int Zerocoin_Block_RecalculateAccumulators() const { return nBlockRecalculateAccumulators; } int Zerocoin_Block_FirstFraudulent() const { return nBlockFirstFraudulent; } int Zerocoin_Block_LastGoodCheckpoint() const { return nBlockLastGoodCheckpoint; } + int Zerocoin_StartTime() const { return nZerocoinStartTime; } protected: CChainParams() {} @@ -166,6 +167,8 @@ class CChainParams int nZerocoinHeaderVersion; int64_t nBudget_Fee_Confirmations; int nZerocoinStartHeight; + int nZerocoinStartTime; + int nBlockEnforceSerialRange; int nBlockRecalculateAccumulators; int nBlockFirstFraudulent; diff --git a/src/main.cpp b/src/main.cpp index d5c058072b96..9e5e6de01286 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1315,9 +1315,6 @@ std::list ZerocoinSpendListFromBlock(const CBlock bool CheckZerocoinMint(const uint256& txHash, const CTxOut& txout, CValidationState& state, bool fCheckOnly) { - if(!fCheckOnly && GetAdjustedTime() < GetSporkValue(SPORK_17_ENABLE_ZEROCOIN)) - return state.DoS(100, error("CheckZerocoinMint(): Zerocoin transactions are not allowed yet")); - PublicCoin pubCoin(Params().Zerocoin_Params()); if(!TxOutToPublicCoin(txout, pubCoin, state)) return state.DoS(100, error("CheckZerocoinMint(): TxOutToPublicCoin() failed")); @@ -1355,9 +1352,6 @@ bool IsZerocoinSpendUnknown(CoinSpend coinSpend, uint256 hashTx, CValidationStat bool CheckZerocoinSpend(const CTransaction tx, bool fVerifySignature, CValidationState& state) { - if(GetAdjustedTime() < GetSporkValue(SPORK_17_ENABLE_ZEROCOIN)) - return state.DoS(100, error("CheckZerocoinSpend(): Zerocoin transactions are not allowed yet")); - //max needed non-mint outputs should be 2 - one for redemption address and a possible 2nd for change if (tx.vout.size() > 2) { int outs = 0; @@ -1457,9 +1451,7 @@ bool CheckTransaction(const CTransaction& tx, bool fZerocoinActive, bool fReject REJECT_INVALID, "bad-txns-vout-empty"); // Size limits - unsigned int nMaxSize = MAX_BLOCK_SIZE_LEGACY; - if(GetAdjustedTime() > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN)) - nMaxSize = MAX_ZEROCOIN_TX_SIZE; + unsigned int nMaxSize = MAX_ZEROCOIN_TX_SIZE; if (::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION) > nMaxSize) return state.DoS(100, error("CheckTransaction() : size limits failed"), @@ -1604,11 +1596,11 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState& state, const CTransa if (pfMissingInputs) *pfMissingInputs = false; - //Temporarily disable zerocoin - if (tx.ContainsZerocoins()) - return state.DoS(10, error("AcceptToMemoryPool : Zerocoin transactions temporarily disabled")); + //Temporarily disable zerocoin for maintenance + if (GetAdjustedTime() > GetSporkValue(SPORK_16_ZEROCOIN_MAINTENANCE_MODE) && tx.ContainsZerocoins()) + return state.DoS(10, error("AcceptToMemoryPool : Zerocoin transactions are temporarily disabled for maintenance"), REJECT_INVALID, "bad-tx"); - if (!CheckTransaction(tx, GetAdjustedTime() > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN), true, state)) + if (!CheckTransaction(tx, chainActive.Height() >= Params().Zerocoin_StartHeight(), true, state)) return state.DoS(100, error("AcceptToMemoryPool: : CheckTransaction failed"), REJECT_INVALID, "bad-tx"); // Coinbase is only valid in a block, not as a loose transaction @@ -1739,7 +1731,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState& state, const CTransa // merely non-standard transaction. if (!tx.IsZerocoinSpend()) { unsigned int nSigOps = GetLegacySigOpCount(tx); - unsigned int nMaxSigOps = GetAdjustedTime() > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN) ? MAX_TX_SIGOPS_CURRENT : MAX_TX_SIGOPS_LEGACY; + unsigned int nMaxSigOps = MAX_TX_SIGOPS_CURRENT; nSigOps += GetP2SHSigOpCount(tx, view); if(nSigOps > nMaxSigOps) return state.DoS(0, @@ -1839,7 +1831,8 @@ bool AcceptableInputs(CTxMemPool& pool, CValidationState& state, const CTransact if (pfMissingInputs) *pfMissingInputs = false; - if (!CheckTransaction(tx, GetAdjustedTime() > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN), true, state)) + + if (!CheckTransaction(tx, chainActive.Height() >= Params().Zerocoin_StartHeight(), true, state)) return error("AcceptableInputs: : CheckTransaction failed"); // Coinbase is only valid in a block, not as a loose transaction @@ -1941,7 +1934,7 @@ bool AcceptableInputs(CTxMemPool& pool, CValidationState& state, const CTransact // MAX_BLOCK_SIGOPS; we still consider this an invalid rather than // merely non-standard transaction. unsigned int nSigOps = GetLegacySigOpCount(tx); - unsigned int nMaxSigOps = GetAdjustedTime() > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN) ? MAX_TX_SIGOPS_CURRENT : MAX_TX_SIGOPS_LEGACY; + unsigned int nMaxSigOps = MAX_TX_SIGOPS_CURRENT; nSigOps += GetP2SHSigOpCount(tx, view); if (nSigOps > nMaxSigOps) return state.DoS(0, @@ -3288,7 +3281,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin blockundo.vtxundo.reserve(block.vtx.size() - 1); CAmount nValueOut = 0; CAmount nValueIn = 0; - unsigned int nMaxBlockSigOps = block.nTime > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN) ? MAX_BLOCK_SIGOPS_CURRENT : MAX_BLOCK_SIGOPS_LEGACY; + unsigned int nMaxBlockSigOps = MAX_BLOCK_SIGOPS_CURRENT; for (unsigned int i = 0; i < block.vtx.size(); i++) { const CTransaction& tx = block.vtx[i]; @@ -3298,10 +3291,10 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return state.DoS(100, error("ConnectBlock() : too many sigops"), REJECT_INVALID, "bad-blk-sigops"); - //Temporarily shut off zerocoin transactions - if (pindex->nHeight >= Params().Zerocoin_Block_EnforceSerialRange() && tx.ContainsZerocoins()) - return state.DoS(100, error("ConnectBlock() : zerocoin transactions are disabled")); - + //Temporarily disable zerocoin transactions for maintenance + if (block.nTime > GetSporkValue(SPORK_16_ZEROCOIN_MAINTENANCE_MODE) && !IsInitialBlockDownload() && tx.ContainsZerocoins()) { + return state.DoS(100, error("ConnectBlock() : zerocoin transactions are currently in maintenance mode")); + } if (tx.IsZerocoinSpend()) { int nHeightTx = 0; if (IsTransactionInChain(tx.GetHash(), nHeightTx)) { @@ -4320,14 +4313,14 @@ bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool f return state.DoS(50, error("CheckBlockHeader() : proof of work failed"), REJECT_INVALID, "high-hash"); - // Version 4 header must be used when SPORK_17_ENABLE_ZEROCOIN is activated. And never before. - if (block.GetBlockTime() > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN)) { - if (block.nVersion < Params().Zerocoin_HeaderVersion()) - return state.DoS(50, error("CheckBlockHeader() : block version must be above 4 after SPORK_17"), + // Version 4 header must be used after Params().Zerocoin_StartHeight(). And never before. + if (block.GetBlockTime() > Params().Zerocoin_StartTime()) { + if(block.nVersion < Params().Zerocoin_HeaderVersion()) + return state.DoS(50, error("CheckBlockHeader() : block version must be above 4 after ZerocoinStartHeight"), REJECT_INVALID, "block-version"); } else { if (block.nVersion >= Params().Zerocoin_HeaderVersion()) - return state.DoS(50, error("CheckBlockHeader() : block version must be below 4 before SPORK_17"), + return state.DoS(50, error("CheckBlockHeader() : block version must be below 4 before ZerocoinStartHeight"), REJECT_INVALID, "block-version"); } @@ -4371,7 +4364,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo // because we receive the wrong transactions for it. // Size limits - unsigned int nMaxBlockSize = GetAdjustedTime() > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN) ? MAX_BLOCK_SIZE_CURRENT : MAX_BLOCK_SIZE_LEGACY; + unsigned int nMaxBlockSize = MAX_BLOCK_SIZE_CURRENT; if (block.vtx.empty() || block.vtx.size() > nMaxBlockSize || ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION) > nMaxBlockSize) return state.DoS(100, error("CheckBlock() : size limits failed"), REJECT_INVALID, "bad-blk-length"); @@ -4450,7 +4443,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo } // Check transactions - bool fZerocoinActive = block.nTime > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN); + bool fZerocoinActive = block.GetBlockTime() > Params().Zerocoin_StartTime(); vector vBlockSerials; for (const CTransaction& tx : block.vtx) { if (!CheckTransaction(tx, fZerocoinActive, chainActive.Height() + 1 >= Params().Zerocoin_Block_EnforceSerialRange(), state)) @@ -5927,7 +5920,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, // available. If not, ask the first peer connected for them. if (!pSporkDB->SporkExists(SPORK_14_NEW_PROTOCOL_ENFORCEMENT) && !pSporkDB->SporkExists(SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2) && - !pSporkDB->SporkExists(SPORK_17_ENABLE_ZEROCOIN)) { + !pSporkDB->SporkExists(SPORK_16_ZEROCOIN_MAINTENANCE_MODE)) { LogPrintf("Required sporks not found, asking peer to send them\n"); pfrom->PushMessage("getsporks"); } diff --git a/src/miner.cpp b/src/miner.cpp index 1e7b9165e61f..91972a11bead 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -108,7 +108,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet, pblock->nVersion = GetArg("-blockversion", pblock->nVersion); // Make sure to create the correct block version after zerocoin is enabled - bool fZerocoinActive = GetAdjustedTime() > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN); + bool fZerocoinActive = GetAdjustedTime() >= Params().Zerocoin_StartTime(); if (fZerocoinActive) pblock->nVersion = 4; else @@ -154,7 +154,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet, // 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 = pblock->nTime > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN) ? MAX_BLOCK_SIZE_CURRENT : MAX_BLOCK_SIZE_LEGACY; + unsigned int nBlockMaxSizeNetwork = MAX_BLOCK_SIZE_CURRENT; nBlockMaxSize = std::max((unsigned int)1000, std::min((nBlockMaxSizeNetwork - 1000), nBlockMaxSize)); // How much of the block should be dedicated to high-priority transactions, @@ -188,8 +188,12 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet, for (map::iterator mi = mempool.mapTx.begin(); mi != mempool.mapTx.end(); ++mi) { const CTransaction& tx = mi->second.GetTx(); - if (tx.IsCoinBase() || tx.IsCoinStake() || !IsFinalTx(tx, nHeight) || tx.ContainsZerocoins()) + if (tx.IsCoinBase() || tx.IsCoinStake() || !IsFinalTx(tx, nHeight)){ continue; + } + if(GetAdjustedTime() > GetSporkValue(SPORK_16_ZEROCOIN_MAINTENANCE_MODE) && tx.ContainsZerocoins()){ + continue; + } COrphan* porphan = NULL; double dPriority = 0; @@ -289,7 +293,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet, continue; // Legacy limits on sigOps: - unsigned int nMaxBlockSigOps = GetAdjustedTime() > GetSporkValue(SPORK_17_ENABLE_ZEROCOIN) ? MAX_BLOCK_SIGOPS_CURRENT : MAX_BLOCK_SIGOPS_LEGACY; + unsigned int nMaxBlockSigOps = MAX_BLOCK_SIGOPS_CURRENT; unsigned int nTxSigOps = GetLegacySigOpCount(tx); if (nBlockSigOps + nTxSigOps >= nMaxBlockSigOps) continue; diff --git a/src/qt/privacydialog.cpp b/src/qt/privacydialog.cpp index 0a816981378c..c02521279299 100644 --- a/src/qt/privacydialog.cpp +++ b/src/qt/privacydialog.cpp @@ -15,6 +15,7 @@ #include "walletmodel.h" #include "coincontrol.h" #include "zpivcontroldialog.h" +#include "spork.h" #include #include @@ -74,7 +75,7 @@ PrivacyDialog::PrivacyDialog(QWidget* parent) : QDialog(parent), else{ nSecurityLevel = settings.value("nSecurityLevel").toInt(); } - + if (!settings.contains("fMinimizeChange")){ fMinimizeChange = false; settings.setValue("fMinimizeChange", fMinimizeChange); @@ -90,6 +91,15 @@ PrivacyDialog::PrivacyDialog(QWidget* parent) : QDialog(parent), // Hide those placeholder elements needed for CoinControl interaction ui->WarningLabel->hide(); // Explanatory text visible in QT-Creator ui->dummyHideWidget->hide(); // Dummy widget with elements to hide + + //temporary disable for maintenance + if(GetAdjustedTime() > GetSporkValue(SPORK_16_ZEROCOIN_MAINTENANCE_MODE)) { + ui->pushButtonMintzPIV->setEnabled(false); + ui->pushButtonMintzPIV->setToolTip(tr("zPIV is currently disabled due to maintenance.")); + + ui->pushButtonSpendzPIV->setEnabled(false); + ui->pushButtonSpendzPIV->setToolTip(tr("zPIV is currently disabled due to maintenance.")); + } } PrivacyDialog::~PrivacyDialog() @@ -106,8 +116,8 @@ void PrivacyDialog::setModel(WalletModel* walletModel) setBalance(walletModel->getBalance(), walletModel->getUnconfirmedBalance(), walletModel->getImmatureBalance(), walletModel->getZerocoinBalance(), walletModel->getUnconfirmedZerocoinBalance(), walletModel->getImmatureZerocoinBalance(), walletModel->getWatchBalance(), walletModel->getWatchUnconfirmedBalance(), walletModel->getWatchImmatureBalance()); - - connect(walletModel, SIGNAL(balanceChanged(CAmount, CAmount, CAmount, CAmount, CAmount, CAmount, CAmount, CAmount, CAmount)), this, + + connect(walletModel, SIGNAL(balanceChanged(CAmount, CAmount, CAmount, CAmount, CAmount, CAmount, CAmount, CAmount, CAmount)), this, SLOT(setBalance(CAmount, CAmount, CAmount, CAmount, CAmount, CAmount, CAmount, CAmount, CAmount))); ui->securityLevel->setValue(nSecurityLevel); } @@ -136,10 +146,12 @@ void PrivacyDialog::on_pushButtonMintzPIV_clicked() if (!walletModel || !walletModel->getOptionsModel()) return; - - QMessageBox::information(this, tr("Mint Zerocoin"), tr("Zerocoin functionality is not enabled on the PIVX network."), QMessageBox::Ok, QMessageBox::Ok); - return; - + if(GetAdjustedTime() > GetSporkValue(SPORK_16_ZEROCOIN_MAINTENANCE_MODE)) { + QMessageBox::information(this, tr("Mint Zerocoin"), + tr("zPIV is currently undergoing maintenance."), QMessageBox::Ok, + QMessageBox::Ok); + return; + } // Reset message text ui->TEMintStatus->setPlainText(tr("Mint Status: Okay")); @@ -166,13 +178,13 @@ void PrivacyDialog::on_pushButtonMintzPIV_clicked() ui->TEMintStatus->setPlainText(tr("Minting ") + ui->labelMintAmountValue->text() + " zPIV..."); ui->TEMintStatus->repaint (); - + int64_t nTime = GetTimeMillis(); - + CWalletTx wtx; vector vMints; string strError = pwalletMain->MintZerocoin(nAmount, wtx, vMints, CoinControlDialog::coinControl); - + // Return if something went wrong during minting if (strError != ""){ ui->TEMintStatus->setPlainText(QString::fromStdString(strError)); @@ -182,12 +194,12 @@ void PrivacyDialog::on_pushButtonMintzPIV_clicked() double fDuration = (double)(GetTimeMillis() - nTime)/1000.0; // Minting successfully finished. Show some stats for entertainment. - QString strStatsHeader = tr("Successfully minted ") + ui->labelMintAmountValue->text() + tr(" zPIV in ") + + QString strStatsHeader = tr("Successfully minted ") + ui->labelMintAmountValue->text() + tr(" zPIV in ") + QString::number(fDuration) + tr(" sec. Used denominations:\n"); - + // Clear amount to avoid double spending when accidentally clicking twice ui->labelMintAmountValue->setText ("0"); - + QString strStats = ""; ui->TEMintStatus->setPlainText(strStatsHeader); @@ -196,11 +208,11 @@ void PrivacyDialog::on_pushButtonMintzPIV_clicked() strStats = strStats + QString::number(mint.GetDenomination()) + " "; ui->TEMintStatus->setPlainText(strStatsHeader + strStats); ui->TEMintStatus->repaint (); - + } // Available balance isn't always updated, so force it. - setBalance(walletModel->getBalance(), walletModel->getUnconfirmedBalance(), walletModel->getImmatureBalance(), + setBalance(walletModel->getBalance(), walletModel->getUnconfirmedBalance(), walletModel->getImmatureBalance(), walletModel->getZerocoinBalance(), walletModel->getUnconfirmedZerocoinBalance(), walletModel->getImmatureZerocoinBalance(), walletModel->getWatchBalance(), walletModel->getWatchUnconfirmedBalance(), walletModel->getWatchImmatureBalance()); coinControlUpdateLabels(); @@ -247,10 +259,11 @@ void PrivacyDialog::on_pushButtonSpendzPIV_clicked() if (!walletModel || !walletModel->getOptionsModel() || !pwalletMain) return; - - QMessageBox::information(this, tr("Spend Zerocoin"), tr("Zerocoin functionality is not enabled on the PIVX network."), QMessageBox::Ok, QMessageBox::Ok); - return; - + if(GetAdjustedTime() > GetSporkValue(SPORK_16_ZEROCOIN_MAINTENANCE_MODE)) { + QMessageBox::information(this, tr("Mint Zerocoin"), + tr("zPIV is currently undergoing maintenance."), QMessageBox::Ok, QMessageBox::Ok); + return; + } // Request unlock if wallet was locked or unlocked for mixing: WalletModel::EncryptionStatus encStatus = walletModel->getEncryptionStatus(); @@ -352,7 +365,7 @@ void PrivacyDialog::sendzPIV() // Add address info if available QString strAddressLabel = ""; if(!ui->payTo->text().isEmpty() && !ui->addAsLabel->text().isEmpty()){ - strAddressLabel = "
(" + ui->addAsLabel->text() + ") "; + strAddressLabel = "
(" + ui->addAsLabel->text() + ") "; } // General info @@ -378,7 +391,7 @@ void PrivacyDialog::sendzPIV() // Sending canceled return; } - + int64_t nTime = GetTimeMillis(); ui->TEMintStatus->setPlainText(tr("Spending Zerocoin.\nComputationally expensive, might need several minutes depending on the selected Security Level and your hardware. \nPlease be patient...")); ui->TEMintStatus->repaint(); @@ -395,7 +408,7 @@ void PrivacyDialog::sendzPIV() bool fSuccess = false; if(ui->payTo->text().isEmpty()){ // Spend to newly generated local address - fSuccess = pwalletMain->SpendZerocoin(nAmount, nSecurityLevel, wtxNew, receipt, vMintsSelected, fMintChange, fMinimizeChange); + fSuccess = pwalletMain->SpendZerocoin(nAmount, nSecurityLevel, wtxNew, receipt, vMintsSelected, fMintChange, fMinimizeChange); } else { // Spend to supplied destination address @@ -524,7 +537,7 @@ bool PrivacyDialog::updateLabel(const QString& address) return false; } -void PrivacyDialog::setBalance(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance, +void PrivacyDialog::setBalance(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance, const CAmount& zerocoinBalance, const CAmount& unconfirmedZerocoinBalance, const CAmount& immatureZerocoinBalance, const CAmount& watchOnlyBalance, const CAmount& watchUnconfBalance, const CAmount& watchImmatureBalance) { @@ -541,7 +554,7 @@ void PrivacyDialog::setBalance(const CAmount& balance, const CAmount& unconfirme CWalletDB walletdb(pwalletMain->strWalletFile); list listMints = walletdb.ListMintedCoins(true, false, true); - + std::map mapDenomBalances; std::map mapUnconfirmed; std::map mapImmature; @@ -600,11 +613,11 @@ void PrivacyDialog::setBalance(const CAmount& balance, const CAmount& unconfirme } strDenomStats = strUnconfirmed + QString::number(mapDenomBalances.at(denom)) + " x " + - QString::number(nCoins) + " = " + + QString::number(nCoins) + " = " + QString::number(nSumPerCoin) + " zPIV "; switch (nCoins) { - case libzerocoin::CoinDenomination::ZQ_ONE: + case libzerocoin::CoinDenomination::ZQ_ONE: ui->labelzDenom1Amount->setText(strDenomStats); break; case libzerocoin::CoinDenomination::ZQ_FIVE: diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 3bf4ba94379c..eeca2d3286cf 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -2321,23 +2321,23 @@ Value getzerocoinbalance(const Array& params, bool fHelp) } Value listmintedzerocoins(const Array& params, bool fHelp) { - + if (fHelp || params.size() != 0) throw runtime_error( "listmintedzerocoins\n" + HelpRequiringPassphrase()); - + if (pwalletMain->IsLocked()) throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first."); - + CWalletDB walletdb(pwalletMain->strWalletFile); list listPubCoin = walletdb.ListMintedCoins(true, false, true); - + Array jsonList; for (const CZerocoinMint& pubCoinItem : listPubCoin) { jsonList.push_back(pubCoinItem.GetValue().GetHex()); } - + return jsonList; } @@ -2354,7 +2354,7 @@ Value listzerocoinamounts(const Array& params, bool fHelp) CWalletDB walletdb(pwalletMain->strWalletFile); list listPubCoin = walletdb.ListMintedCoins(true, true, true); - + std::map spread; for (const auto& denom : libzerocoin::zerocoinDenomList) spread.insert(std::pair(denom, 0)); @@ -2405,7 +2405,8 @@ Value mintzerocoin(const Array& params, bool fHelp) int64_t nTime = GetTimeMillis(); - throw JSONRPCError(RPC_WALLET_ERROR, "Error: Zerocoin functionality is not enabled on the PIVX network."); + if(GetAdjustedTime() > GetSporkValue(SPORK_16_ZEROCOIN_MAINTENANCE_MODE)) + throw JSONRPCError(RPC_WALLET_ERROR, "zPIV is currently disabled due to maintenance."); if (pwalletMain->IsLocked()) throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first."); @@ -2430,7 +2431,7 @@ Value mintzerocoin(const Array& params, bool fHelp) m.push_back(Pair("time", GetTimeMillis() - nTime)); arrMints.push_back(m); } - + return arrMints; } @@ -2450,7 +2451,8 @@ Value spendzerocoin(const Array& params, bool fHelp) "an address is required" + HelpRequiringPassphrase()); - throw JSONRPCError(RPC_WALLET_ERROR, "Error: Zerocoin functionality is not enabled on the PIVX network."); + if(GetAdjustedTime() > GetSporkValue(SPORK_16_ZEROCOIN_MAINTENANCE_MODE)) + throw JSONRPCError(RPC_WALLET_ERROR, "zPIV is currently disabled due to maintenance."); int64_t nTimeStart = GetTimeMillis(); if (pwalletMain->IsLocked()) @@ -2802,4 +2804,4 @@ Value reconsiderzerocoins(const Array& params, bool fHelp) } return arrRet; -} \ No newline at end of file +} diff --git a/src/spork.cpp b/src/spork.cpp index 321cb12337ea..d9a3f8585460 100644 --- a/src/spork.cpp +++ b/src/spork.cpp @@ -128,7 +128,7 @@ int64_t GetSporkValue(int nSporkID) if (nSporkID == SPORK_13_ENABLE_SUPERBLOCKS) r = SPORK_13_ENABLE_SUPERBLOCKS_DEFAULT; if (nSporkID == SPORK_14_NEW_PROTOCOL_ENFORCEMENT) r = SPORK_14_NEW_PROTOCOL_ENFORCEMENT_DEFAULT; if (nSporkID == SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2) r = SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2_DEFAULT; - if (nSporkID == SPORK_17_ENABLE_ZEROCOIN) r = SPORK_17_ENABLE_ZEROCOIN_DEFAULT; + if (nSporkID == SPORK_16_ZEROCOIN_MAINTENANCE_MODE) r = SPORK_16_ZEROCOIN_MAINTENANCE_MODE_DEFAULT; if (r == -1) LogPrintf("GetSpork::Unknown Spork %d\n", nSporkID); } @@ -268,7 +268,7 @@ int CSporkManager::GetSporkIDByName(std::string strName) if (strName == "SPORK_13_ENABLE_SUPERBLOCKS") return SPORK_13_ENABLE_SUPERBLOCKS; if (strName == "SPORK_14_NEW_PROTOCOL_ENFORCEMENT") return SPORK_14_NEW_PROTOCOL_ENFORCEMENT; if (strName == "SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2") return SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2; - if (strName == "SPORK_17_ENABLE_ZEROCOIN") return SPORK_17_ENABLE_ZEROCOIN; + if (strName == "SPORK_16_ZEROCOIN_MAINTENANCE_MODE") return SPORK_16_ZEROCOIN_MAINTENANCE_MODE; return -1; } @@ -286,7 +286,7 @@ std::string CSporkManager::GetSporkNameByID(int id) if (id == SPORK_13_ENABLE_SUPERBLOCKS) return "SPORK_13_ENABLE_SUPERBLOCKS"; if (id == SPORK_14_NEW_PROTOCOL_ENFORCEMENT) return "SPORK_14_NEW_PROTOCOL_ENFORCEMENT"; if (id == SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2) return "SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2"; - if (id == SPORK_17_ENABLE_ZEROCOIN) return "SPORK_17_ENABLE_ZEROCOIN"; + if (id == SPORK_16_ZEROCOIN_MAINTENANCE_MODE) return "SPORK_16_ZEROCOIN_MAINTENANCE_MODE"; return "Unknown"; } diff --git a/src/spork.h b/src/spork.h index 71d9b3ab4149..6add73e7b8ed 100644 --- a/src/spork.h +++ b/src/spork.h @@ -27,7 +27,7 @@ using namespace boost; Sporks 11,12, and 16 to be removed with 1st zerocoin release */ #define SPORK_START 10001 -#define SPORK_END 10016 +#define SPORK_END 10015 #define SPORK_2_SWIFTTX 10001 #define SPORK_3_SWIFTTX_BLOCK_FILTERING 10002 @@ -41,8 +41,7 @@ using namespace boost; #define SPORK_13_ENABLE_SUPERBLOCKS 10012 #define SPORK_14_NEW_PROTOCOL_ENFORCEMENT 10013 #define SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2 10014 -//#define SPORK_16_MN_WINNER_MINIMUM_AGE 10015 -#define SPORK_17_ENABLE_ZEROCOIN 10016 +#define SPORK_16_ZEROCOIN_MAINTENANCE_MODE 10015 #define SPORK_2_SWIFTTX_DEFAULT 978307200 //2001-1-1 #define SPORK_3_SWIFTTX_BLOCK_FILTERING_DEFAULT 1424217600 //2015-2-18 @@ -55,7 +54,7 @@ using namespace boost; #define SPORK_13_ENABLE_SUPERBLOCKS_DEFAULT 4070908800 //OFF #define SPORK_14_NEW_PROTOCOL_ENFORCEMENT_DEFAULT 4070908800 //OFF #define SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2_DEFAULT 4070908800 //OFF -#define SPORK_17_ENABLE_ZEROCOIN_DEFAULT 4070908800 //OFF +#define SPORK_16_ZEROCOIN_MAINTENANCE_MODE_DEFAULT 4070908800 //OFF class CSporkMessage; class CSporkManager; diff --git a/src/wallet.cpp b/src/wallet.cpp index 75e6da17b590..a6c919407e16 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -3527,7 +3527,7 @@ bool CWallet::GetDestData(const CTxDestination& dest, const std::string& key, st void CWallet::AutoZeromint() { // Don't bother Autominting if Zerocoin Protocol isn't active - if (!IsSporkActive(SPORK_17_ENABLE_ZEROCOIN)) return; + if (GetAdjustedTime() > GetSporkValue(SPORK_16_ZEROCOIN_MAINTENANCE_MODE)) return; // Wait until blockchain + masternodes are fully synced and wallet is unlocked. if (!masternodeSync.IsSynced() || IsLocked()){