From 7d4ec2b6c470e9305593b943b710f8e4f7d64f50 Mon Sep 17 00:00:00 2001 From: ThatGuy Date: Wed, 7 Aug 2019 09:57:16 -0400 Subject: [PATCH] 1.0.0.1 (#3) --- .gitignore | 4 + src/activemasternode.cpp | 2 +- src/chainparams.cpp | 4 +- src/qt/coincontroldialog.cpp | 217 +++++++++++++++++++++++++++++- src/qt/coincontroldialog.h | 13 +- src/qt/forms/coincontroldialog.ui | 142 ++++++++++++++++--- src/rpcblockchain.cpp | 4 +- src/rpcmisc.cpp | 4 +- src/version.h | 4 +- src/wallet.cpp | 8 +- 10 files changed, 366 insertions(+), 36 deletions(-) diff --git a/.gitignore b/.gitignore index 4de7311..d5add35 100644 --- a/.gitignore +++ b/.gitignore @@ -155,3 +155,7 @@ config.status \.vs/Xavander-coin/v15/\.suo \.vs/Xavander-coin/v15/ipch/AutoPCH/f3069f7e1af0cae9/CLIENTVERSION\.ipch + +\.vs/Xavander-coin/v15/ipch/AutoPCH/fe03518b59430e57/RPCBLOCKCHAIN\.ipch + +\.vs/Xavander-coin/v15/ipch/AutoPCH/c3af879c1645467/CLIENTVERSION\.ipch diff --git a/src/activemasternode.cpp b/src/activemasternode.cpp index 2b5703a..d589d1f 100644 --- a/src/activemasternode.cpp +++ b/src/activemasternode.cpp @@ -472,7 +472,7 @@ vector CActiveMasternode::SelectCoinsMasternode() // Filter BOOST_FOREACH (const COutput& out, vCoins) { - if (out.tx->vout[out.i].nValue == Params().MasternodeCollateralAmt()*COIN) { //Was 5000 * COIN + if (out.tx->vout[out.i].nValue == Params().MasternodeCollateralAmt() * COIN) { //Was 5000 * COIN //if (out.tx->vout[out.i].nValue == 10000 * COIN){ filteredCoins.push_back(out); } diff --git a/src/chainparams.cpp b/src/chainparams.cpp index ea56d41..ed7fff3 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -202,8 +202,8 @@ class CMainParams : public CChainParams fHeadersFirstSyncingActive = false; nPoolMaxTransactions = 3; - nEnforceNewSporkKey = 1561931967; //!> Sporks signed after 06/30/2019 @ 9:59pm (UTC) - nRejectOldSporkKey = 1562716800; //!> Fully reject old spork key after 07/10/2019 @ 12:00am (UTC) + nEnforceNewSporkKey = 1564971936; //!> Sporks signed after 08/05/2019 @ 2:25am (UTC) + nRejectOldSporkKey = 1566691200; //!> Fully reject old spork key after 08/25/2019 @ 12:00am (UTC) strSporkKey = "0279d5e624dff289b3ef1f05d53a328a301f81db61d7da5e463fdd64c3dcda5c62"; strSporkKeyOld = "02085fb93df4c4bf6ac7b88452963d66b7a52b65ed801fdc58909d651fb2035e51"; strObfuscationPoolDummyAddress = "XCNAsFGy8k7amqRG26ikKyfVDwK8585Z6b"; diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index 4b98406..3a0d62a 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -127,6 +127,27 @@ CoinControlDialog::CoinControlDialog(QWidget* parent, bool fMultisigEnabled) : Q // Toggle lock state connect(ui->pushButtonToggleLock, SIGNAL(clicked()), this, SLOT(buttonToggleLockClicked())); + //selection of first 50 inputs on button pressed + connect(ui->select_50, SIGNAL(clicked()), this, SLOT(select_50())); + + //selection of first 100 inputs on button pressed + connect(ui->select_100, SIGNAL(clicked()), this, SLOT(select_100())); + + //selection of first 250 inputs on button pressed + connect(ui->select_250, SIGNAL(clicked()), this, SLOT(select_250())); + + //Make "advanced" features visible if check (advance check box) + connect(ui->advanced, SIGNAL(clicked(bool)), this, SLOT(toggled(bool))); + + //selection of all inputs greater than what the user inputs into "num_box" + connect(ui->GreaterThan, SIGNAL(clicked()), this, SLOT(greater())); + + //selection of all inputs less than what the user inputs into "num_box" + connect(ui->LessThan, SIGNAL(clicked()), this, SLOT(Less())); + + //selection of all inputs equal to what the user inputs into "num_box" + connect(ui->EqualTo, SIGNAL(clicked()), this, SLOT(Equal())); + // change coin control first column label due Qt4 bug. // see https://github.com/bitcoin/bitcoin/issues/5716 ui->treeWidget->headerItem()->setText(COLUMN_CHECKBOX, QString()); @@ -143,6 +164,14 @@ CoinControlDialog::CoinControlDialog(QWidget* parent, bool fMultisigEnabled) : Q ui->treeWidget->setColumnHidden(COLUMN_AMOUNT_INT64, true); // store amount int64 in this column, but dont show it ui->treeWidget->setColumnHidden(COLUMN_PRIORITY_INT64, true); // store priority int64 in this column, but dont show it ui->treeWidget->setColumnHidden(COLUMN_DATE_INT64, true); // store date int64 in this column, but dont show it + ui->num_box->setRange(1, 9999); // set the range + ui->select_50->setVisible(false); // set the advanced features to hidden + ui->select_100->setVisible(false); + ui->select_250->setVisible(false); + ui->GreaterThan->setVisible(false); + ui->LessThan->setVisible(false); + ui->EqualTo->setVisible(false); + ui->num_box->setVisible(false); // default view is sorted by amount desc sortView(COLUMN_AMOUNT_INT64, Qt::DescendingOrder); @@ -196,7 +225,7 @@ void CoinControlDialog::buttonBoxClicked(QAbstractButton* button) // (un)select all void CoinControlDialog::buttonSelectAllClicked() { - Qt::CheckState state = Qt::Checked; + Qt::CheckState state = Qt::Checked; for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) { if (ui->treeWidget->topLevelItem(i)->checkState(COLUMN_CHECKBOX) != Qt::Unchecked) { state = Qt::Unchecked; @@ -214,6 +243,164 @@ void CoinControlDialog::buttonSelectAllClicked() updateDialogLabels(); } +void CoinControlDialog::HideInputAutoSelection() //set the advanced features to hidden +{ + ui->select_50->setVisible(false); + ui->select_100->setVisible(false); + ui->select_250->setVisible(false); + ui->GreaterThan->setVisible(false); + ui->LessThan->setVisible(false); + ui->EqualTo->setVisible(false); + ui->num_box->setVisible(false); +} + +void CoinControlDialog::ShowInputAutoSelection() // set the advanced features to shown +{ + ui->select_50->setVisible(true); + ui->select_100->setVisible(true); + ui->select_250->setVisible(true); + ui->GreaterThan->setVisible(true); + ui->LessThan->setVisible(true); + ui->EqualTo->setVisible(true); + ui->num_box->setVisible(true); +} + + +void CoinControlDialog::greater()// select all inputs grater than "amount" +{ + int val = ui->num_box->value(); + Qt::CheckState state = Qt::Checked; + ui->treeWidget->setEnabled(true); + for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) { + QTreeWidgetItem* item = ui->treeWidget->topLevelItem(i); + double value = item->text(COLUMN_AMOUNT).toDouble(); + if (value > val) { + if (ui->treeWidget->topLevelItem(i)->checkState(COLUMN_CHECKBOX) != state) + ui->treeWidget->topLevelItem(i)->setCheckState(COLUMN_CHECKBOX, state); + ui->treeWidget->setEnabled(true); + if (state == Qt::Unchecked) + coinControl->UnSelectAll(); + ui->treeWidget->setEnabled(true); + CoinControlDialog::updateLabels(model, this); + updateDialogLabels(); + } + } +} + +void CoinControlDialog::Less()//select all inputs Less than "amount" +{ + int val = ui->num_box->value(); + Qt::CheckState state = Qt::Checked; + ui->treeWidget->setEnabled(true); + for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) { + QTreeWidgetItem* item = ui->treeWidget->topLevelItem(i); + double value = item->text(COLUMN_AMOUNT).toDouble(); + if (value < val) { + if (ui->treeWidget->topLevelItem(i)->checkState(COLUMN_CHECKBOX) != state) + ui->treeWidget->topLevelItem(i)->setCheckState(COLUMN_CHECKBOX, state); + ui->treeWidget->setEnabled(true); + if (state == Qt::Unchecked) + coinControl->UnSelectAll(); + ui->treeWidget->setEnabled(true); + CoinControlDialog::updateLabels(model, this); + updateDialogLabels(); + } + } +} + + +void CoinControlDialog::Equal() // select all inputs equal to "amount" +{ + double round; + double val = ui->num_box->value(); + Qt::CheckState state = Qt::Checked; + ui->treeWidget->setEnabled(true); + for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) { + QTreeWidgetItem* item = ui->treeWidget->topLevelItem(i); + double value = item->text(COLUMN_AMOUNT).toDouble(); + int log = 0; + adjusted: + if (val > value){round = val - value; log++;}//since we can't compare "value" and "val" directly we minus the 2 and get the difference + if (val < value){round = value - val; log++;} + if (log == 0) { val = val +0.001; log++; goto adjusted; } // in the event that the input and "val" are equal add a small amount and go through the sorting process again + if (round < 0.01) { // if are input and "val" are within 0.01 of each other + if (ui->treeWidget->topLevelItem(i)->checkState(COLUMN_CHECKBOX) != state) + ui->treeWidget->topLevelItem(i)->setCheckState(COLUMN_CHECKBOX, state); + ui->treeWidget->setEnabled(true); + if (state == Qt::Unchecked) + coinControl->UnSelectAll(); + CoinControlDialog::updateLabels(model, this); + updateDialogLabels(); + } + } +} + +void CoinControlDialog::select_50() //select the first 50 inputs +{ + if (ui->treeWidget->topLevelItemCount() > 49){ //check we have more then 50 inputs + Qt::CheckState state = Qt::Checked; + ui->treeWidget->setEnabled(false); + for (int i = 0; i < 50; i++) + if (ui->treeWidget->topLevelItem(i)->checkState(COLUMN_CHECKBOX) != state) + ui->treeWidget->topLevelItem(i)->setCheckState(COLUMN_CHECKBOX, state); + ui->treeWidget->setEnabled(true); + if (state == Qt::Unchecked) + coinControl->UnSelectAll(); // just to be sure + CoinControlDialog::updateLabels(model, this); + updateDialogLabels(); + }else{ //if we have less then 50 inputs give the user dialogue to inform them of this issue + QMessageBox msgBox; + msgBox.setObjectName("lockMessageBox"); + msgBox.setStyleSheet(GUIUtil::loadStyleSheet()); + msgBox.setText(tr("Please have at least 50 inputs to use this function.")); + msgBox.exec(); + } +} + +void CoinControlDialog::select_100() //select the first 100 inputs +{ + if (ui->treeWidget->topLevelItemCount() > 99){ //check we have more then 100 inputs + Qt::CheckState state = Qt::Checked; + ui->treeWidget->setEnabled(false); + for (int i = 0; i < 100; i++) + if (ui->treeWidget->topLevelItem(i)->checkState(COLUMN_CHECKBOX) != state) + ui->treeWidget->topLevelItem(i)->setCheckState(COLUMN_CHECKBOX, state); + ui->treeWidget->setEnabled(true); + if (state == Qt::Unchecked) + coinControl->UnSelectAll(); // just to be sure + CoinControlDialog::updateLabels(model, this); + updateDialogLabels(); + }else{ //if we have less then 100 inputs give the user dialogue to inform them of this issue + QMessageBox msgBox; + msgBox.setObjectName("lockMessageBox"); + msgBox.setStyleSheet(GUIUtil::loadStyleSheet()); + msgBox.setText(tr("Please have at least 100 inputs to use this function.")); + msgBox.exec(); + } +} + +void CoinControlDialog::select_250() //select the first 250 inputs +{ + if (ui->treeWidget->topLevelItemCount() > 249){ //check we have more then 250 inputs + Qt::CheckState state = Qt::Checked; + ui->treeWidget->setEnabled(false); + for (int i = 0; i < 250; i++) + if (ui->treeWidget->topLevelItem(i)->checkState(COLUMN_CHECKBOX) != state) + ui->treeWidget->topLevelItem(i)->setCheckState(COLUMN_CHECKBOX, state); + ui->treeWidget->setEnabled(true); + if (state == Qt::Unchecked) + coinControl->UnSelectAll(); // just to be sure + CoinControlDialog::updateLabels(model, this); + updateDialogLabels(); + }else{ //if we have less then 250 inputs give the user dialogue to inform them of this issue + QMessageBox msgBox; + msgBox.setObjectName("lockMessageBox"); + msgBox.setStyleSheet(GUIUtil::loadStyleSheet()); + msgBox.setText(tr("Please have at least 250 inputs to use this function.")); + msgBox.exec(); + } +} + // Toggle lock state void CoinControlDialog::buttonToggleLockClicked() { @@ -414,6 +601,7 @@ void CoinControlDialog::headerSectionClicked(int logicalIndex) // toggle tree mode void CoinControlDialog::radioTreeMode(bool checked) { +HideInputAutoSelection(); if (checked && model) updateView(); } @@ -421,10 +609,35 @@ void CoinControlDialog::radioTreeMode(bool checked) // toggle list mode void CoinControlDialog::radioListMode(bool checked) { + if (ui->advanced->checkState()){ + ShowInputAutoSelection(); + }else{ + HideInputAutoSelection(); + } if (checked && model) updateView(); } +//toggle advaced features +void CoinControlDialog::toggled(bool checked) +{ + if (ui->radioListMode->isChecked()){ + if (ui->advanced->checkState()){ + ShowInputAutoSelection(); + }else{ + HideInputAutoSelection(); + } + if (checked && model) + updateView(); + }else{ // if not in lsit mode + QMessageBox msgBox; + msgBox.setObjectName("lockMessageBox"); + msgBox.setStyleSheet(GUIUtil::loadStyleSheet()); + msgBox.setText(tr("Please switch to \"List mode\" to use this function.")); + msgBox.exec(); + } +} + // checkbox clicked by user void CoinControlDialog::viewItemChanged(QTreeWidgetItem* item, int column) { @@ -903,4 +1116,4 @@ void CoinControlDialog::updateView() // sort view sortView(sortColumn, sortOrder); ui->treeWidget->setEnabled(true); -} +} \ No newline at end of file diff --git a/src/qt/coincontroldialog.h b/src/qt/coincontroldialog.h index 163aa8c..6bf7f1e 100644 --- a/src/qt/coincontroldialog.h +++ b/src/qt/coincontroldialog.h @@ -15,7 +15,6 @@ #include #include #include - class WalletModel; class MultisigDialog; @@ -52,7 +51,6 @@ class CoinControlDialog : public QDialog int sortColumn; Qt::SortOrder sortOrder; bool fMultisigEnabled; - QMenu* contextMenu; QTreeWidgetItem* contextMenuItem; QAction* copyTransactionHashAction; @@ -119,12 +117,21 @@ private slots: void clipboardChange(); void radioTreeMode(bool); void radioListMode(bool); + void toggled(bool); void viewItemChanged(QTreeWidgetItem*, int); void headerSectionClicked(int); void buttonBoxClicked(QAbstractButton*); void buttonSelectAllClicked(); + void HideInputAutoSelection(); + void ShowInputAutoSelection(); + void greater(); + void Less(); + void Equal(); + void select_50(); + void select_100(); + void select_250(); void buttonToggleLockClicked(); void updateLabelLocked(); }; -#endif // BITCOIN_QT_COINCONTROLDIALOG_H +#endif // BITCOIN_QT_COINCONTROLDIALOG_H \ No newline at end of file diff --git a/src/qt/forms/coincontroldialog.ui b/src/qt/forms/coincontroldialog.ui index fc6d4cd..9f0b0bf 100644 --- a/src/qt/forms/coincontroldialog.ui +++ b/src/qt/forms/coincontroldialog.ui @@ -6,7 +6,7 @@ 0 0 - 954 + 1035 500 @@ -348,12 +348,12 @@ - + 14 - + 0 @@ -361,15 +361,12 @@ - (un)select all - - - false + Tree mode - + 0 @@ -377,15 +374,28 @@ - toggle lock state + List mode - - false + + true - + + + + 70 + 17 + + + + advanced + + + + + 0 @@ -393,12 +403,15 @@ - Tree mode + (un)select all + + + false - + 0 @@ -406,10 +419,10 @@ - List mode + toggle lock status - - true + + false @@ -438,6 +451,99 @@ + + + + + + + 115 + 23 + + + + 50 + + + + + + + + 115 + 23 + + + + 100 + + + + + + + + 114 + 23 + + + + 250 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Greater Than + + + + + + + Less Than + + + + + + + Equal to + + + + + + + + 96 + 20 + + + + + + + + + + + + @@ -552,4 +658,4 @@ - + \ No newline at end of file diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 564f767..2788769 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -96,7 +96,7 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDe zXAVANDERObj.push_back(Pair(to_string(denom), ValueFromAmount(blockindex->mapZerocoinSupply.at(denom) * (denom*COIN)))); } zXAVANDERObj.emplace_back(Pair("total", ValueFromAmount(blockindex->GetZerocoinSupply()))); - result.emplace_back(Pair("zXAVANDERsupply", zXAVANDERObj)); + result.emplace_back(Pair("zXCZMsupply", zXAVANDERObj)); return result; } @@ -279,7 +279,7 @@ Value getblock(const Array& params, bool fHelp) " \"previousblockhash\" : \"hash\", (string) The hash of the previous block\n" " \"nextblockhash\" : \"hash\" (string) The hash of the next block\n" " \"moneysupply\" : \"supply\" (numeric) The money supply when this block was added to the blockchain\n" - " \"zXAVANDERsupply\" :\n" + " \"zXCZMsupply\" :\n" " {\n" " \"1\" : n, (numeric) supply of 1 zXAVANDER denomination\n" " \"5\" : n, (numeric) supply of 5 zXAVANDER denomination\n" diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 5f2b3ae..7ce860f 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -66,7 +66,7 @@ Value getinfo(const Array& params, bool fHelp) " \"difficulty\": xxxxxx, (numeric) the current difficulty\n" " \"testnet\": true|false, (boolean) if the server is using testnet or not\n" " \"moneysupply\" : \"supply\" (numeric) The money supply when this block was added to the blockchain\n" - " \"zXAVANDERsupply\" :\n" + " \"zXCZMsupply\" :\n" " {\n" " \"1\" : n, (numeric) supply of 1 zXAVANDER denomination\n" " \"5\" : n, (numeric) supply of 5 zXAVANDER denomination\n" @@ -114,7 +114,7 @@ Value getinfo(const Array& params, bool fHelp) zXAVANDERObj.push_back(Pair(to_string(denom), ValueFromAmount(chainActive.Tip()->mapZerocoinSupply.at(denom) * (denom*COIN)))); } zXAVANDERObj.emplace_back(Pair("total", ValueFromAmount(chainActive.Tip()->GetZerocoinSupply()))); - obj.emplace_back(Pair("zXAVANDERsupply", zXAVANDERObj)); + obj.emplace_back(Pair("zXCZMsupply", zXAVANDERObj)); #ifdef ENABLE_WALLET if (pwalletMain) { diff --git a/src/version.h b/src/version.h index 791c932..f39508b 100644 --- a/src/version.h +++ b/src/version.h @@ -12,7 +12,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 70003; +static const int PROTOCOL_VERSION = 70004; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; @@ -22,7 +22,7 @@ static const int GETHEADERS_VERSION = 70000; //! disconnect from peers older than this proto version static const int MIN_PEER_PROTO_VERSION_BEFORE_ENFORCEMENT = 70002; -static const int MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT = 70003; +static const int MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT = 70004; //! nTime field added to CAddress, starting with this version; //! if possible, avoid requesting addresses nodes older than this diff --git a/src/wallet.cpp b/src/wallet.cpp index c957ead..7b263b6 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1625,15 +1625,15 @@ void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const if (nCoinType == ONLY_DENOMINATED) { found = IsDenominatedAmount(pcoin->vout[i].nValue); } else if (nCoinType == ONLY_NOT10000IFMN) { - found = !(fMasterNode && pcoin->vout[i].nValue == Params().MasternodeCollateralAmt()*COIN); + found = !(fMasterNode && pcoin->vout[i].nValue == Params().MasternodeCollateralAmt() * COIN); //found = !(fMasterNode && pcoin->vout[i].nValue == 10000 * COIN); } else if (nCoinType == ONLY_NONDENOMINATED_NOT10000IFMN) { if (IsCollateralAmount(pcoin->vout[i].nValue)) continue; // do not use collateral amounts found = !IsDenominatedAmount(pcoin->vout[i].nValue); - if (found && fMasterNode) found = pcoin->vout[i].nValue != Params().MasternodeCollateralAmt()*COIN; // do not use Hot MN funds + if (found && fMasterNode) found = pcoin->vout[i].nValue != Params().MasternodeCollateralAmt() * COIN; // do not use Hot MN funds //if (found && fMasterNode) found = pcoin->vout[i].nValue != 10000 * COIN; // do not use Hot MN funds } else if (nCoinType == ONLY_10000) { - found = pcoin->vout[i].nValue == Params().MasternodeCollateralAmt()*COIN; + found = pcoin->vout[i].nValue == Params().MasternodeCollateralAmt() * COIN; //found = pcoin->vout[i].nValue == 10000 * COIN; } else { found = true; @@ -2099,7 +2099,7 @@ bool CWallet::SelectCoinsDark(CAmount nValueMin, CAmount nValueMax, std::vector< if (out.tx->vout[out.i].nValue < CENT) continue; //do not allow collaterals to be selected if (IsCollateralAmount(out.tx->vout[out.i].nValue)) continue; - if (fMasterNode && wtx.vout[i].nValue == Params().MasternodeCollateralAmt()*COIN) continue; + if (fMasterNode && out.tx->vout[out.i].nValue == Params().MasternodeCollateralAmt() * COIN) continue; //if (fMasterNode && out.tx->vout[out.i].nValue == 10000 * COIN) continue; //masternode input if (nValueRet + out.tx->vout[out.i].nValue <= nValueMax) {