Skip to content

Commit

Permalink
Fix founders rewards and znode payment in testnet. Add Znode GUI.
Browse files Browse the repository at this point in the history
  • Loading branch information
aizensou committed Dec 6, 2017
1 parent 02bc303 commit 27aadcb
Show file tree
Hide file tree
Showing 34 changed files with 1,018 additions and 93 deletions.
4 changes: 4 additions & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ QT_FORMS_UI = \
qt/forms/coincontroldialog.ui \
qt/forms/editaddressdialog.ui \
qt/forms/helpmessagedialog.ui \
qt/forms/znodelist.ui \
qt/forms/intro.ui \
qt/forms/openuridialog.ui \
qt/forms/optionsdialog.ui \
Expand Down Expand Up @@ -132,6 +133,7 @@ QT_MOC_CPP = \
qt/moc_intro.cpp \
qt/moc_macdockiconhandler.cpp \
qt/moc_macnotificationhandler.cpp \
qt/moc_znodelist.cpp \
qt/moc_notificator.cpp \
qt/moc_openuridialog.cpp \
qt/moc_optionsdialog.cpp \
Expand Down Expand Up @@ -200,6 +202,7 @@ BITCOIN_QT_H = \
qt/intro.h \
qt/macdockiconhandler.h \
qt/macnotificationhandler.h \
qt/znodelist.h \
qt/networkstyle.h \
qt/notificator.h \
qt/openuridialog.h \
Expand Down Expand Up @@ -346,6 +349,7 @@ BITCOIN_QT_WALLET_CPP = \
qt/walletframe.cpp \
qt/walletmodel.cpp \
qt/walletmodeltransaction.cpp \
qt/znodelist.cpp \
qt/walletview.cpp

BITCOIN_QT_CPP = $(BITCOIN_QT_BASE_CPP)
Expand Down
4 changes: 3 additions & 1 deletion src/activeznode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ void CActiveZnode::ManageStateInitial() {
}

if (pwalletMain->GetBalance() < ZNODE_COIN_REQUIRED * COIN) {
LogPrintf("CActiveZnode::ManageStateInitial -- %s: Wallet balance is < 1000 DASH\n", GetStateString());
LogPrintf("CActiveZnode::ManageStateInitial -- %s: Wallet balance is < 1000 XZC\n", GetStateString());
return;
}

Expand Down Expand Up @@ -257,6 +257,8 @@ void CActiveZnode::ManageStateRemote() {
}
if (service != infoMn.addr) {
nState = ACTIVE_ZNODE_NOT_CAPABLE;
LogPrintf("service: %s\n", service.ToString());
LogPrintf("infoMn.addr: %s\n", infoMn.addr.ToString());
strNotCapableReason = "Broadcasted IP doesn't match our external address. Make sure you issued a new broadcast if IP of this znode changed recently.";
LogPrintf("CActiveZnode::ManageStateRemote -- %s: %s\n", GetStateString(), strNotCapableReason);
return;
Expand Down
2 changes: 1 addition & 1 deletion src/bitcoind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ bool AppInit(int argc, char* argv[])
return false;
}

// parse masternode.conf
// parse znode.conf
std::string strErr;
if(!znodeConfig.read(strErr)) {
fprintf(stderr,"Error reading znode configuration file: %s\n", strErr.c_str());
Expand Down
2 changes: 1 addition & 1 deletion src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define CLIENT_VERSION_MAJOR 0
#define CLIENT_VERSION_MINOR 13
#define CLIENT_VERSION_REVISION 4
#define CLIENT_VERSION_BUILD 0
#define CLIENT_VERSION_BUILD 1

//! Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE true
Expand Down
2 changes: 1 addition & 1 deletion src/darksend.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class CDarksendBroadcastTx
class CDarkSendSigner
{
public:
/// Is the input associated with this public key? (and there is 1000 DASH - checking if valid znode)
/// Is the input associated with this public key? (and there is 1000 XZC - checking if valid znode)
bool IsVinAssociatedWithPubkey(const CTxIn& vin, const CPubKey& pubkey);
/// Set the private/public key values, returns true if successful
bool GetKeysFromSecret(std::string strSecret, CKey& keyRet, CPubKey& pubkeyRet);
Expand Down
6 changes: 2 additions & 4 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1360,8 +1360,7 @@ bool AppInit2(boost::thread_group &threadGroup, CScheduler &scheduler) {
}

if (mapArgs.count("-externalip")) {
BOOST_FOREACH(
const std::string &strAddr, mapMultiArgs["-externalip"]) {
BOOST_FOREACH(const std::string &strAddr, mapMultiArgs["-externalip"]) {
CService addrLocal;
if (Lookup(strAddr.c_str(), addrLocal, GetListenPort(), fNameLookup) && addrLocal.IsValid())
AddLocal(addrLocal, LOCAL_MANUAL);
Expand Down Expand Up @@ -1709,8 +1708,7 @@ bool AppInit2(boost::thread_group &threadGroup, CScheduler &scheduler) {
LogPrintf("Locking Znodes:\n");
uint256 mnTxHash;
int outputIndex;
BOOST_FOREACH(CZnodeConfig::CZnodeEntry
mne, znodeConfig.getEntries()) {
BOOST_FOREACH(CZnodeConfig::CZnodeEntry mne, znodeConfig.getEntries()) {
mnTxHash.SetHex(mne.getTxHash());
outputIndex = boost::lexical_cast<unsigned int>(mne.getOutputIndex());
COutPoint outpoint = COutPoint(mnTxHash, outputIndex);
Expand Down
28 changes: 13 additions & 15 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ CAmount maxTxFee = DEFAULT_TRANSACTION_MAXFEE;
CTxMemPool mempool(::minRelayTxFee);
FeeFilterRounder filterRounder(::minRelayTxFee);

// Dash masternode
// Dash znode

This comment has been minimized.

Copy link
@KuroGuo

KuroGuo Dec 6, 2017

Contributor

Zcoin znode

map <uint256, int64_t> mapRejectedBlocks GUARDED_BY(cs_main);

// Settings
Expand Down Expand Up @@ -1367,21 +1367,20 @@ bool CheckTransaction(const CTransaction &tx, CValidationState &state, uint256 h
if (tx.vin[0].scriptSig.size() < 2 || tx.vin[0].scriptSig.size() > 100)
return state.DoS(100, false, REJECT_INVALID, "bad-cb-length");
// Check for founders inputs
if ((nHeight > ZC_CHECK_BUG_FIXED_AT_BLOCK) && (nHeight < 210000)) {
if (((nHeight > ZC_CHECK_BUG_FIXED_AT_BLOCK) && (nHeight < 210000)) || (fTestNet && nHeight >= 7200)) {
bool found_1 = false;
bool found_2 = false;
bool found_3 = false;
bool found_4 = false;
bool found_5 = false;
int total_payment_tx = 0;
bool found_znode_payment = true; // no more than 1 output for payment

CScript FOUNDER_1_SCRIPT;
CScript FOUNDER_2_SCRIPT;
CScript FOUNDER_3_SCRIPT;
CScript FOUNDER_4_SCRIPT;
CScript FOUNDER_5_SCRIPT;
if (!fTestNet || nHeight < Params().GetConsensus().nZnodePaymentsStartBlock) {
if (nHeight < Params().GetConsensus().nZnodePaymentsStartBlock) {
if (!fTestNet && GetAdjustedTime() > nStartRewardTime) {
FOUNDER_1_SCRIPT = GetScriptForDestination(CBitcoinAddress("aCAgTPgtYcA4EysU4UKC86EQd5cTtHtCcr").Get());
if (nHeight < 14000) {
Expand Down Expand Up @@ -1422,7 +1421,7 @@ bool CheckTransaction(const CTransaction &tx, CValidationState &state, uint256 h
found_5 = true;
}
}
} else if (!fTestNet || nHeight >= Params().GetConsensus().nZnodePaymentsStartBlock) {
} else {

if (!fTestNet && GetAdjustedTime() > nStartRewardTime) {
FOUNDER_1_SCRIPT = GetScriptForDestination(CBitcoinAddress("aCAgTPgtYcA4EysU4UKC86EQd5cTtHtCcr").Get());
Expand Down Expand Up @@ -1580,8 +1579,7 @@ bool CheckTransaction(const CTransaction &tx, CValidationState &state, uint256 h
if (tx.IsZerocoinSpend()) {
// Check vOut
// Only one loop, we checked on the format before enter this case
BOOST_FOREACH(
const CTxOut &txout, tx.vout)
BOOST_FOREACH(const CTxOut &txout, tx.vout)
{
CZerocoinEntry pubCoinTx;
list <CZerocoinEntry> listPubCoin;
Expand All @@ -1601,7 +1599,7 @@ bool CheckTransaction(const CTransaction &tx, CValidationState &state, uint256 h
if (!CheckSpendZcoinTransaction(tx, pubCoinTx, listPubCoin, libzerocoin::ZQ_GOLDWASSER, state,
hashTx, isVerifyDB, nHeight, isCheckWallet)) {
return state.DoS(100,
error("CTr[ansaction::CheckTransaction() : COIN SPEND TX IN ZQ_GOLDWASSER DID NOT VERIFY!"));
error("CTransaction::CheckTransaction() : COIN SPEND TX IN ZQ_GOLDWASSER DID NOT VERIFY!"));
};
} else if (txout.nValue == libzerocoin::ZQ_RACKOFF * COIN) {
if (!CheckSpendZcoinTransaction(tx, pubCoinTx, listPubCoin, libzerocoin::ZQ_RACKOFF, state,
Expand Down Expand Up @@ -3112,7 +3110,7 @@ bool ConnectBlock(const CBlock &block, CValidationState &state, CBlockIndex *pin
block.vtx[0].GetValueOut(), blockReward),
REJECT_INVALID, "bad-cb-amount");

// ZNODE : MODIFIED TO CHECK MASTERNODE PAYMENTS AND SUPERBLOCKS
// ZNODE : MODIFIED TO CHECK ZNODE PAYMENTS AND SUPERBLOCKS
// It's possible that we simply don't have enough data and this could fail
// (i.e. block itself could be a correct one and we need to store it),
// that's why this is in ConnectBlock. Could be the other way around however -
Expand All @@ -3126,7 +3124,7 @@ bool ConnectBlock(const CBlock &block, CValidationState &state, CBlockIndex *pin

if (!IsBlockPayeeValid(block.vtx[0], pindex->nHeight, blockReward)) {
mapRejectedBlocks.insert(make_pair(block.GetHash(), GetTime()));
return state.DoS(0, error("ConnectBlock(): couldn't find masternode or superblock payments"),
return state.DoS(0, error("ConnectBlock(): couldn't find znode or superblock payments"),
REJECT_INVALID, "bad-cb-payee");
}
// END ZNODE
Expand Down Expand Up @@ -4510,14 +4508,14 @@ bool CheckBlock(const CBlock &block, CValidationState &state, const Consensus::P
instantsend.Relay(hashLocked);
LOCK(cs_main);
mapRejectedBlocks.insert(make_pair(block.GetHash(), GetTime()));
return state.DoS(0, error("CheckBlock(DASH): transaction %s conflicts with transaction lock %s",
return state.DoS(0, error("CheckBlock(XZC): transaction %s conflicts with transaction lock %s",
tx.GetHash().ToString(), hashLocked.ToString()),
REJECT_INVALID, "conflict-tx-lock");
}
}
}
} else {
LogPrintf("CheckBlock(DASH): spork is off, skipping transaction locking checks\n");
LogPrintf("CheckBlock(XZC): spork is off, skipping transaction locking checks\n");
}

// Check transactions
Expand Down Expand Up @@ -6830,13 +6828,13 @@ bool static ProcessMessage(CNode *pfrom, string strCommand, CDataStream &vRecv,

CZnode *pmn = mnodeman.Find(dstx.vin);
if (pmn == NULL) {
LogPrint("privatesend", "DSTX -- Can't find masternode %s to verify %s\n",
LogPrint("privatesend", "DSTX -- Can't find znode %s to verify %s\n",
dstx.vin.prevout.ToStringShort(), hashTx.ToString());
return false;
}

if (!pmn->fAllowMixingTx) {
LogPrint("privatesend", "DSTX -- Masternode %s is sending too many transactions %s\n",
LogPrint("privatesend", "DSTX -- Znode %s is sending too many transactions %s\n",
dstx.vin.prevout.ToStringShort(), hashTx.ToString());
return true;
// TODO: Not an error? Could it be that someone is relaying old DSTXes
Expand All @@ -6848,7 +6846,7 @@ bool static ProcessMessage(CNode *pfrom, string strCommand, CDataStream &vRecv,
return false;
}

LogPrintf("DSTX -- Got Masternode transaction %s\n", hashTx.ToString());
LogPrintf("DSTX -- Got Znode transaction %s\n", hashTx.ToString());
mempool.PrioritiseTransaction(hashTx, hashTx.ToString(), 1000, 0.1 * COIN);
pmn->fAllowMixingTx = false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ CBlockTemplate* BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn)
}
}
CAmount blockReward = nFees + GetBlockSubsidy(nHeight, chainparams.GetConsensus());
// Update coinbase transaction with additional info about masternode and governance payments,
// Update coinbase transaction with additional info about znode and governance payments,
// get some info back to pass to getblocktemplate
if (nHeight >= chainparams.GetConsensus().nZnodePaymentsStartBlock) {
CAmount znodePayment = GetZnodePayment(nHeight, blockReward);
Expand Down
2 changes: 1 addition & 1 deletion src/primitives/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class CBlock : public CBlockHeader
std::vector<CTransaction> vtx;

// memory only
mutable CTxOut txoutZnode; // masternode payment
mutable CTxOut txoutZnode; // znode payment
mutable std::vector<CTxOut> voutSuperblock; // superblock payment
mutable bool fChecked;

Expand Down
2 changes: 1 addition & 1 deletion src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ int main(int argc, char *argv[])
std::string strErr;
if(!znodeConfig.read(strErr)) {
QMessageBox::critical(0, QObject::tr("Zcoin Core"),
QObject::tr("Error reading masternode configuration file: %1").arg(strErr.c_str()));
QObject::tr("Error reading znode configuration file: %1").arg(strErr.c_str()));
return EXIT_FAILURE;
}

Expand Down
1 change: 1 addition & 0 deletions src/qt/bitcoin.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<file alias="history">res/icons/history.png</file>
<file alias="qrcode">res/icons/qrcode.png</file>
<file alias="zerocoin">res/icons/zerocoin.png</file>
<file alias="znodes">res/icons/znodes.png</file>
<file alias="overview">res/icons/overview.png</file>
<file alias="export">res/icons/export.png</file>
<file alias="synced">res/icons/synced.png</file>
Expand Down
57 changes: 55 additions & 2 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
#include "ui_interface.h"
#include "util.h"

#include "znode-sync.h"
#include "znodelist.h"

#include <iostream>

#include <QAction>
Expand Down Expand Up @@ -97,6 +100,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *platformStyle, const NetworkStyle *n
signMessageAction(0),
verifyMessageAction(0),
aboutAction(0),
znodeAction(0),
receiveCoinsAction(0),
receiveCoinsMenuAction(0),
optionsAction(0),
Expand Down Expand Up @@ -310,8 +314,20 @@ void BitcoinGUI::createActions()


#ifdef ENABLE_WALLET
// These showNormalIfMinimized are needed because Send Coins and Receive Coins
// can be triggered from the tray menu, and need to show the GUI to be useful.
// These showNormalIfMinimized are needed because Send Coins and Receive Coins
// can be triggered from the tray menu, and need to show the GUI to be useful.
znodeAction = new QAction(platformStyle->SingleColorIcon(":/icons/znodes"), tr("&Znodes"), this);
znodeAction->setStatusTip(tr("Browse znodes"));
znodeAction->setToolTip(znodeAction->statusTip());
znodeAction->setCheckable(true);
#ifdef Q_OS_MAC
znodeAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_5));
#else
znodeAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5));
#endif
tabGroup->addAction(znodeAction);
connect(znodeAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(znodeAction, SIGNAL(triggered()), this, SLOT(gotoZnodePage()));
connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage()));
connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
Expand Down Expand Up @@ -460,6 +476,7 @@ void BitcoinGUI::createToolBars()
toolbar->addAction(receiveCoinsAction);
toolbar->addAction(historyAction);
toolbar->addAction(zerocoinAction);
toolbar->addAction(znodeAction);
overviewAction->setChecked(true);
}
}
Expand Down Expand Up @@ -558,6 +575,7 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled)
receiveCoinsMenuAction->setEnabled(enabled);
historyAction->setEnabled(enabled);
zerocoinAction->setEnabled(enabled);
znodeAction->setEnabled(enabled);
encryptWalletAction->setEnabled(enabled);
backupWalletAction->setEnabled(enabled);
changePassphraseAction->setEnabled(enabled);
Expand Down Expand Up @@ -688,6 +706,13 @@ void BitcoinGUI::gotoHistoryPage()
if (walletFrame) walletFrame->gotoHistoryPage();
}

void BitcoinGUI::gotoZnodePage()
{
QSettings settings;
znodeAction->setChecked(true);
if (walletFrame) walletFrame->gotoZnodePage();
}

void BitcoinGUI::gotoReceiveCoinsPage()
{
receiveCoinsAction->setChecked(true);
Expand Down Expand Up @@ -835,6 +860,34 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
if(walletFrame)
walletFrame->showOutOfSyncWarning(true);
#endif // ENABLE_WALLET
}

if(!znodeSync.IsBlockchainSynced())
{
QString timeBehindText = GUIUtil::formatNiceTimeOffset(secs);

progressBarLabel->setVisible(true);
progressBar->setFormat(tr("%1 behind").arg(timeBehindText));
progressBar->setMaximum(1000000000);
progressBar->setValue(nVerificationProgress * 1000000000.0 + 0.5);
progressBar->setVisible(true);

tooltip = tr("Catching up...") + QString("<br>") + tooltip;
if(count != prevBlocks)
{
labelBlocksIcon->setPixmap(platformStyle->SingleColorIcon(QString(
":/movies/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0')))
.pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
spinnerFrame = (spinnerFrame + 1) % SPINNER_FRAMES;
}
prevBlocks = count;

#ifdef ENABLE_WALLET
if(walletFrame)
{
walletFrame->showOutOfSyncWarning(true);
}
#endif // ENABLE_WALLET

tooltip += QString("<br>");
tooltip += tr("Last received block was generated %1 ago.").arg(timeBehindText);
Expand Down
3 changes: 3 additions & 0 deletions src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class BitcoinGUI : public QMainWindow
QAction *openAction;
QAction *showHelpMessageAction;
QAction *zerocoinAction;
QAction *znodeAction;
QAction *zerocoinMenuAction;

QSystemTrayIcon *trayIcon;
Expand Down Expand Up @@ -183,6 +184,8 @@ private Q_SLOTS:
void gotoOverviewPage();
/** Switch to history (transactions) page */
void gotoHistoryPage();
/** Switch to znode page */
void gotoZnodePage();
/** Switch to receive coins page */
void gotoReceiveCoinsPage();
/** Switch to send coins page */
Expand Down
Loading

0 comments on commit 27aadcb

Please sign in to comment.