Skip to content

Commit

Permalink
Merge remote-tracking branch 'fork/master' into seed_nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
mxaddict committed Nov 18, 2019
2 parents d5404f2 + b8ed018 commit 51f7ed7
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 52 deletions.
2 changes: 1 addition & 1 deletion doc/release-notes/release-notes-4.7.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ When the wallet starts and detects it is still catching up to the latest block a
- Added a lock (Crashed the wallet when voting from details dialog) <[Pull Request 577](https://github.com/navcoin/navcoin-core/pull/577)> <[Commit f2b924e](https://github.com/navcoin/navcoin-core/commit/f2b924ef59cf2ae19fa8106ca3b71c5e7cd0a2c3)>
- Updated a lock on LoadWallet to fix a crash on wallet rescan <[Pull Request 582](https://github.com/navcoin/navcoin-core/pull/582)> <[Commit 06109e8](https://github.com/navcoin/navcoin-core/commit/06109e8356ebf741a7c9701adde1a20d234e5c1c)>
- Coldstaking pool fee <[Pull Request 523](https://github.com/navcoin/navcoin-core/pull/523)> <[Commit f449aec](https://github.com/navcoin/navcoin-core/commit/f449aeca138273151ded55b2ec14f9c97ca3f3dd)>
- OSX pink menu bug <[Pull Request 589](https://github.com/navcoin/navcoin-core/pull/589)> <[Commit e087919](https://github.com/navcoin/navcoin-core/commit/e0879195bdf5373e5b1fcf4e970af0a8815660f6)>
- OSX pink menu bug <[Pull Request 589](https://github.com/navcoin/navcoin-core/pull/589)> <[Commit e087919](https://github.com/navcoin/navcoin-core/commit/e0879195bdf5373e5b1fcf4e970af0a8815660f6)>
32 changes: 32 additions & 0 deletions doc/release-notes/release-notes-4.7.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# NavCoin v4.7.1 Release Notes

## Fix CFund DB read after nullified entry

<[Pull Request 608](https://github.com/navcoin/navcoin-core/pull/608)>
<[Commit 07d49bf2](https://github.com/navcoin/navcoin-core/commit/e688c6ed6a1da2734aa89b41ae16051807d49bf2)>

This patch fixes a bug where a cfund database entry that was previously deleted is still persisting, preventing future writes of the entry. This can happen in a scenario where a proposal is included in a block which is invalidated (because of a reorganization) which is then included in a new block as part of the new longest chain.

This fix is the main purpose of the 4.7.1 patch release, while preparing this bugfix there were several other PR's merged which are also included in this release.

## Merged PRs

* [`Pull Request 509`](https://github.com/navcoin/navcoin-core/pull/509) [`Commit 40eac7ab`](https://github.com/navcoin/navcoin-core/commit/58e38079d7d854a6b02ebb228f06244140eac7ab) Updated some NULL -> nullptr
* [`Pull Request 525`](https://github.com/navcoin/navcoin-core/pull/525) [`Commit 8ed8cf87`](https://github.com/navcoin/navcoin-core/commit/2e6aa1b3e598d3a443343c480bdbf6b88ed8cf87) Replaced all BOOST_FOREACH calls with new for() syntax (c++11)
* [`Pull Request 527`](https://github.com/navcoin/navcoin-core/pull/527) [`Commit b2921285`](https://github.com/navcoin/navcoin-core/commit/74def82624ff9bb4598762186598d2bab2921285) Updated the custom 'change' address to be a persistent setting #527
* [`Pull Request 546`](https://github.com/navcoin/navcoin-core/pull/546) [`Commit e1870814`](https://github.com/navcoin/navcoin-core/commit/083e790aed0120dd271a648d87948e5ae1870814) Added new -allindex option
* [`Pull Request 554`](https://github.com/navcoin/navcoin-core/pull/554) [`Commit 82523147`](https://github.com/navcoin/navcoin-core/commit/0a8c872a60169de4f6b57b83dab9b39382523147) Replaced Q_FOREACH with for() from c++11 standard
* [`Pull Request 560`](https://github.com/navcoin/navcoin-core/pull/560) [`Commit 762c3ffd`](https://github.com/navcoin/navcoin-core/commit/64f8cd453f4bdda04f4a718cb026d8a8762c3ffd) Set pindexDelete to nullptr on intialize
* [`Pull Request 561`](https://github.com/navcoin/navcoin-core/pull/561) [`Commit 130ddf4a`](https://github.com/navcoin/navcoin-core/commit/70276dba0515a133a47c081041092efa130ddf4a) Fixed some gitignore permissions and added new file to main gitignore
* [`Pull Request 566`](https://github.com/navcoin/navcoin-core/pull/566) [`Commit 6de5f909`](https://github.com/navcoin/navcoin-core/commit/556250920fef9dc3eddd28996329ba316de5f909) Updated includes syntax based on discussion on #503
* [`Pull Request 578`](https://github.com/navcoin/navcoin-core/pull/578) [`Commit c464383b`](https://github.com/navcoin/navcoin-core/commit/da5377e89a25cfa54a52768393630134c464383b) Sort available coins for staking by coin age descending
* [`Pull Request 587`](https://github.com/navcoin/navcoin-core/pull/587) [`Commit ff6f543e`](https://github.com/navcoin/navcoin-core/commit/49f74084cf9eed8d8e7c46707d836b82ff6f543e) Add support for raw script addresses
* [`Pull Request 603`](https://github.com/navcoin/navcoin-core/pull/603) [`Commit f755e298`](https://github.com/navcoin/navcoin-core/commit/6fe0683ba99ce912da4d9181094ab4baf755e298) Updated depends to use winssl for windows and darwinssl for osx
* [`Pull Request 605`](https://github.com/navcoin/navcoin-core/pull/605) [`Commit 5e0af830`](https://github.com/navcoin/navcoin-core/commit/0b8cb5dd81186fcd54860fe7c25f2cac5e0af830) Staking reward setup GUI
* [`Pull Request 611`](https://github.com/navcoin/navcoin-core/pull/611) [`Commit 30401b32`](https://github.com/navcoin/navcoin-core/commit/f7b1c6304200052418c66e8f242ddf8c30401b32) Fixed error.log loading in Debug Window (Windows)
* [`Pull Request 612`](https://github.com/navcoin/navcoin-core/pull/612) [`Commit d5cfa467`](https://github.com/navcoin/navcoin-core/commit/902970adfdd5ce0e54e54bfa7545edfad5cfa467) Fix random RPC tests failing
* [`Pull Request 614`](https://github.com/navcoin/navcoin-core/pull/614) [`Commit 80323b33`](https://github.com/navcoin/navcoin-core/commit/856d57a8f944ed3382d7001a3e9a1bfd80323b33) Patch for staking redirect gui
* [`Pull Request 615`](https://github.com/navcoin/navcoin-core/pull/615) [`Commit 9e84d40a`](https://github.com/navcoin/navcoin-core/commit/662163ad8f73081d2d6145938571ca809e84d40a) Bump version number

For additional information about new features, check [https://navcoin.org/en/notices/](https://navcoin.org/en/notices/)

4 changes: 4 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class CMainParams : public CChainParams {
consensus.nStaticReward = 2 * COIN;
consensus.nHeightv451Fork = 2722100;
consensus.nHeightv452Fork = 2882875;
consensus.fDaoClientActivated = false;

/** Coinbase transaction outputs can only be spent after this number of new blocks (network rule) */
consensus.nCoinbaseMaturity = 50;
Expand Down Expand Up @@ -328,6 +329,7 @@ class CTestNetParams : public CChainParams {
consensus.nStaticReward = 2 * COIN;
consensus.nHeightv451Fork = 100000;
consensus.nHeightv452Fork = 100000;
consensus.fDaoClientActivated = true;

/** Coinbase transaction outputs can only be spent after this number of new blocks (network rule) */
consensus.nCoinbaseMaturity = 50;
Expand Down Expand Up @@ -509,6 +511,7 @@ class CDevNetParams : public CChainParams {
consensus.nStaticReward = 2 * COIN;
consensus.nHeightv451Fork = 1000;
consensus.nHeightv452Fork = 1000;
consensus.fDaoClientActivated = true;

/** Coinbase transaction outputs can only be spent after this number of new blocks (network rule) */
consensus.nCoinbaseMaturity = 5;
Expand Down Expand Up @@ -700,6 +703,7 @@ class CRegTestParams : public CChainParams {
consensus.nStaticReward = 2 * COIN;
consensus.nHeightv451Fork = 1000;
consensus.nHeightv452Fork = 1000;
consensus.fDaoClientActivated = true;

/** Coinbase transaction outputs can only be spent after this number of new blocks (network rule) */
consensus.nCoinbaseMaturity = 50;
Expand Down
2 changes: 2 additions & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ struct Params {
int nHeightv451Fork;
int nHeightv452Fork;

bool fDaoClientActivated;

/** Coinbase transaction outputs can only be spent after this number of new blocks (network rule) */
int nCoinbaseMaturity;

Expand Down
2 changes: 2 additions & 0 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ CBlockTemplate* BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn, bo
coinbaseTx.vout[0].scriptPubKey = scriptPubKeyIn;
coinbaseTx.vout[0].nValue = GetBlockSubsidy(nHeight, chainparams.GetConsensus());
}

coinbaseTx.vin[0].scriptSig = CScript() << nHeight << OP_0;

if(IsCommunityFundEnabled(pindexPrev, chainparams.GetConsensus()))
{
std::map<uint256, bool> votes;
Expand Down
15 changes: 12 additions & 3 deletions src/qt/communityfundcreatepaymentrequestdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <QMessageBox>
#include <string>

#include <qt/navcoinunits.h>

#include <base58.h>
#include <consensus/cfund.h>
#include <qt/guiconstants.h>
Expand Down Expand Up @@ -192,11 +194,18 @@ void CommunityFundCreatePaymentRequestDialog::click_pushButtonSubmitPaymentReque
// Validate requested amount
if (nReqAmount <= 0 || nReqAmount > proposal.GetAvailable(*pcoinsTip, true)) {
QMessageBox msgBox(this);
std::string str = "Cannot create a Payment Request for the requested amount\n";
msgBox.setText(tr(str.c_str()));
QString str = tr("Requested amount must be greater than 0 NAV (Zero)\n");
if (nReqAmount > proposal.GetAvailable(*pcoinsTip, true)) {
str = tr("Requested amount %1 is more than avaible coins in the proposal (%2)\n")
.arg(
NavCoinUnits::formatWithUnit(NavCoinUnits::NAV, nReqAmount),
NavCoinUnits::formatWithUnit(NavCoinUnits::NAV, proposal.GetAvailable(*pcoinsTip, true))
);
}
msgBox.setText(str);
msgBox.addButton(tr("Ok"), QMessageBox::AcceptRole);
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle("Invalid Amount");
msgBox.setWindowTitle(tr("Invalid Amount"));
msgBox.exec();
return;
}
Expand Down
22 changes: 22 additions & 0 deletions src/qt/communityfundpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,17 @@ void CommunityFundPage::click_radioButtonExpired()

void CommunityFundPage::click_pushButtonCreateProposal()
{
if (!Params().GetConsensus().fDaoClientActivated)
{
QMessageBox msgBox(this);
QString str = tr("This function is temporarily disabled");
msgBox.setText(str);
msgBox.addButton(tr("Ok"), QMessageBox::AcceptRole);
msgBox.setIcon(QMessageBox::Information);
msgBox.setWindowTitle(str);
msgBox.exec();
return;
}
CommunityFundCreateProposalDialog dlg(this);
dlg.setModel(walletModel);
dlg.exec();
Expand All @@ -400,6 +411,17 @@ void CommunityFundPage::click_pushButtonCreateProposal()

void CommunityFundPage::click_pushButtonCreatePaymentRequest()
{
if (!Params().GetConsensus().fDaoClientActivated)
{
QMessageBox msgBox(this);
QString str = tr("This function is temporarily disabled");
msgBox.setText(str);
msgBox.addButton(tr("Ok"), QMessageBox::AcceptRole);
msgBox.setIcon(QMessageBox::Information);
msgBox.setWindowTitle(str);
msgBox.exec();
return;
}
CommunityFundCreatePaymentRequestDialog dlg(this);
dlg.setModel(walletModel);
dlg.exec();
Expand Down
1 change: 1 addition & 0 deletions src/qt/communityfundpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <consensus/cfund.h>
#include <wallet/wallet.h>

#include <QMessageBox>
#include <QWidget>
#include <QPushButton>
#include <QListView>
Expand Down
132 changes: 84 additions & 48 deletions src/qt/sendcoinsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ SendCoinsDialog::SendCoinsDialog(const PlatformStyle *platformStyle, QWidget *pa
ui->labelCoinControlLowOutput->addAction(clipboardLowOutputAction);
ui->labelCoinControlChange->addAction(clipboardChangeAction);

// init transaction fee section
// init settings values
QSettings settings;
if (!settings.contains("fFeeSectionMinimized"))
settings.setValue("fFeeSectionMinimized", true);
Expand All @@ -110,6 +110,10 @@ SendCoinsDialog::SendCoinsDialog(const PlatformStyle *platformStyle, QWidget *pa
settings.setValue("fPayOnlyMinFee", false);
if (!settings.contains("fAnonSend"))
settings.setValue("fAnonSend", false);
if (!settings.contains("sCustomChangeAddress"))
settings.setValue("sCustomChangeAddress", "");
if (!settings.contains("fUseCustomChangeAddress"))
settings.setValue("fUseCustomChangeAddress", false);
ui->groupFee->setId(ui->radioSmartFee, 0);
ui->groupFee->setId(ui->radioCustomFee, 1);
ui->groupFee->button((int)std::max(0, std::min(1, settings.value("nFeeRadio").toInt())))->setChecked(true);
Expand All @@ -119,6 +123,8 @@ SendCoinsDialog::SendCoinsDialog(const PlatformStyle *platformStyle, QWidget *pa
ui->sliderSmartFee->setValue(settings.value("nSmartFeeSliderPosition").toInt());
ui->customFee->setValue(settings.value("nTransactionFee").toLongLong());
ui->checkBoxMinimumFee->setChecked(settings.value("fPayOnlyMinFee").toBool());
ui->checkBoxCoinControlChange->setChecked(settings.value("fUseCustomChangeAddress").toBool());
ui->lineEditCoinControlChange->setText(settings.value("sCustomChangeAddress").toString());
minimizeFeeSection(settings.value("fFeeSectionMinimized").toBool());
ui->anonsendCheckbox->setChecked(settings.value("fAnonSend").toBool());

Expand Down Expand Up @@ -199,6 +205,11 @@ void SendCoinsDialog::setModel(WalletModel *model)
updateMinFeeLabel();
updateSmartFeeLabel();
updateGlobalFeeVariables();

// Toggle the checkbox for change address
// Which in turn uses model and model->getOptionsModel()
// via coinControlChangeEdited
coinControlChangeChecked(ui->checkBoxCoinControlChange->isChecked() ? Qt::Checked : Qt::Unchecked);
}
}

Expand Down Expand Up @@ -945,74 +956,99 @@ void SendCoinsDialog::coinControlButtonClicked()
// Coin Control: checkbox custom change address
void SendCoinsDialog::coinControlChangeChecked(int state)
{
QSettings settings;

if (state == Qt::Unchecked)
{
CoinControlDialog::coinControl->destChange = CNoDestination();
ui->labelCoinControlChangeLabel->clear();

// Clear the setting
settings.setValue("fUseCustomChangeAddress", false);
}
else
{
// use this to re-validate an already entered address
coinControlChangeEdited(ui->lineEditCoinControlChange->text());

// Save the setting
settings.setValue("fUseCustomChangeAddress", true);
}

ui->lineEditCoinControlChange->setEnabled((state == Qt::Checked));
}

// Coin Control: custom change address changed
void SendCoinsDialog::coinControlChangeEdited(const QString& text)
{
if (model && model->getAddressTableModel())
// Check for address table and model
if (!model || !model->getAddressTableModel())
return;

// We need access to settings
QSettings settings;

// Clear the setting
settings.setValue("sCustomChangeAddress", "");

// Default to no change address until verified
CoinControlDialog::coinControl->destChange = CNoDestination();
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}");

CNavCoinAddress addr = CNavCoinAddress(text.toStdString());

if (text.isEmpty()) // Nothing entered
{
// Default to no change address until verified
CoinControlDialog::coinControl->destChange = CNoDestination();
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}");
ui->labelCoinControlChangeLabel->setText("");

CNavCoinAddress addr = CNavCoinAddress(text.toStdString());
// Give up!
return;
}

if (text.isEmpty()) // Nothing entered
{
ui->labelCoinControlChangeLabel->setText("");
}
else if (!addr.IsValid()) // Invalid address
{
ui->labelCoinControlChangeLabel->setText(tr("Warning: Invalid NavCoin address"));
}
else // Valid address
{
bool fHaveKey = false;
if(addr.IsColdStakingAddress(Params()))
{
CKeyID stakingId, spendingId;
addr.GetStakingKeyID(stakingId);
addr.GetSpendingKeyID(spendingId);
if(model->havePrivKey(stakingId) || model->havePrivKey(spendingId))
fHaveKey = true;
}
else
{
CKeyID keyid;
addr.GetKeyID(keyid);
if(model->havePrivKey(keyid))
fHaveKey = true;
}
if (!addr.IsValid()) // Invalid address
{
ui->labelCoinControlChangeLabel->setText(tr("Warning: Invalid NavCoin address"));

if (!fHaveKey) // Unknown change address
{
ui->labelCoinControlChangeLabel->setText(tr("Warning: Unknown change address"));
}
else // Known change address
{
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}");
// Give up!
return;
}

// Query label
QString associatedLabel = model->getAddressTableModel()->labelForAddress(text);
if (!associatedLabel.isEmpty())
ui->labelCoinControlChangeLabel->setText(associatedLabel);
else
ui->labelCoinControlChangeLabel->setText(tr("(no label)"));
// Save the setting
settings.setValue("sCustomChangeAddress", text);

CoinControlDialog::coinControl->destChange = addr.Get();
}
}
bool fHaveKey = false;
if(addr.IsColdStakingAddress(Params()))
{
CKeyID stakingId, spendingId;
addr.GetStakingKeyID(stakingId);
addr.GetSpendingKeyID(spendingId);
if(model->havePrivKey(stakingId) || model->havePrivKey(spendingId))
fHaveKey = true;
}
else
{
CKeyID keyid;
addr.GetKeyID(keyid);
if(model->havePrivKey(keyid))
fHaveKey = true;
}

if (!fHaveKey) // Unknown change address
{
ui->labelCoinControlChangeLabel->setText(tr("Warning: Unknown change address"));
}
else // Known change address
{
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}");

// Query label
QString associatedLabel = model->getAddressTableModel()->labelForAddress(text);
if (!associatedLabel.isEmpty())
ui->labelCoinControlChangeLabel->setText(associatedLabel);
else
ui->labelCoinControlChangeLabel->setText(tr("(no label)"));

CoinControlDialog::coinControl->destChange = addr.Get();
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,9 @@ UniValue createproposal(const UniValue& params, bool fHelp)
+ HelpExampleCli("createproposal", "\"NQFqqMUD55ZV3PJEJZtaKCsQmjLT6JkjvJ\" 12000 3600 \"Promotional stickers for everyone\" 100")
);

if (!Params().GetConsensus().fDaoClientActivated)
throw JSONRPCError(RPC_WALLET_ERROR, "This command is temporarily disabled");

LOCK2(cs_main, pwalletMain->cs_wallet);

CNavCoinAddress address("NQFqqMUD55ZV3PJEJZtaKCsQmjLT6JkjvJ"); // Dummy address
Expand Down Expand Up @@ -691,6 +694,9 @@ UniValue createpaymentrequest(const UniValue& params, bool fHelp)
+ HelpExampleCli("createpaymentrequest", "\"196a4c2115d3c1c1dce1156eb2404ad77f3c5e9f668882c60cb98d638313dbd3\" 1000 \"Invoice March 2017\"")
);

if (!Params().GetConsensus().fDaoClientActivated)
throw JSONRPCError(RPC_WALLET_ERROR, "This command is temporarily disabled");

LOCK2(cs_main, pwalletMain->cs_wallet);

CFund::CProposal proposal;
Expand Down

0 comments on commit 51f7ed7

Please sign in to comment.