Skip to content

Commit

Permalink
Merge branch 'UCR-master' of https://github.com/decenomy/DSW
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphire-pt committed Mar 13, 2021
2 parents b5b9197 + b79f364 commit d306b53
Show file tree
Hide file tree
Showing 35 changed files with 337 additions and 233 deletions.
1 change: 1 addition & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ RES_ICONS = \
qt/res/icons/ic-transaction-sent.svg \
qt/res/icons/ic-transaction-staked.svg \
qt/pivx/res/img/bg-dashboard-banner.png \
qt/pivx/res/img/bg-dashboard-banner-dark.png \
qt/pivx/res/img/bg-multi-number-dark.svg \
qt/pivx/res/img/ic-check-locked.svg \
qt/pivx/res/img/ic-check-console.svg \
Expand Down
2 changes: 1 addition & 1 deletion src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ class CTestNetParams : public CMainParams
vFixedSeeds.clear();
vSeeds.clear();
// nodes with support for servicebits filtering should be at the top
vSeeds.push_back(CDNSSeedData("tseeder", "tseeder.__decenomy.net__", true));
vSeeds.push_back(CDNSSeedData("tseeder", "tseeder.ucrcoin.net", true));

base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1, 139); // Testnet Ultra Clear addresses start with 'x' or 'y'
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1, 19); // Testnet Ultra Clear script addresses start with '8' or '9'
Expand Down
4 changes: 0 additions & 4 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
#ifndef BITCOIN_CHAINPARAMS_H
#define BITCOIN_CHAINPARAMS_H

#define __PORT_MAINNET__ 9999
#define __PORT_TESTNET__ 19999
#define __PORT_REGTEST__ 29999

#include "chainparamsbase.h"
#include "checkpoints.h"
#include "consensus/params.h"
Expand Down
294 changes: 147 additions & 147 deletions src/chainparamsseeds.h

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/masternode-payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,8 @@ void CMasternodePayments::ProcessMessageMasternodePayments(CNode* pfrom, std::st
}

// reject old signature version
if (winner.nMessVersion != MessageVersion::MESS_VER_HASH) {
if (Params().GetConsensus().NetworkUpgradeActive(chainActive.Tip()->nHeight, Consensus::UPGRADE_V4_0) &&
winner.nMessVersion != MessageVersion::MESS_VER_HASH) {
LogPrint(BCLog::MASTERNODE, "mnw - rejecting old message version %d\n", winner.nMessVersion);
return;
}
Expand Down
121 changes: 91 additions & 30 deletions src/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,58 @@ bool CMasternode::IsInputAssociatedWithPubkey() const

CAmount CMasternode::GetMasternodeNodeCollateral(int nHeight)
{
if (nHeight <= 100000) {
if (nHeight <= 1000 && nHeight > Params().LAST_POW_BLOCK()) {
return 10 * COIN;
} else if (nHeight <= 2000 && nHeight > 1000) {
return 50 * COIN;
} else if (nHeight <= 10000 && nHeight > 2000) {
return 100 * COIN;
} else if (nHeight <= 20000 && nHeight > 10000) {
return 500 * COIN;
} else if (nHeight <= 30000 && nHeight > 20000) {
return 750 * COIN;
} else if (nHeight <= 40000 && nHeight > 30000) {
return 250 * COIN;
} else if (nHeight <= 50000 && nHeight > 40000) {
return 375 * COIN;
} else if (nHeight <= 60000 && nHeight > 50000) {
return 750 * COIN;
} else if (nHeight <= 70000 && nHeight > 60000) {
return 1125 * COIN;
} else if (nHeight <= 80000 && nHeight > 70000) {
return 1750 * COIN;
} else if (nHeight <= 100000 && nHeight > 80000) {
return 2500 * COIN;
} else if (nHeight <= 120000 && nHeight > 100000) {
return 3500 * COIN;
} else if (nHeight <= 145000 && nHeight > 120000) {
return 5000 * COIN;
} else if (nHeight <= 170000 && nHeight > 145000) {
return 6500 * COIN;
} else if (nHeight <= 200000 && nHeight > 170000) {
return 8000 * COIN;
} else if (nHeight <= 230000 && nHeight > 200000) {
return 10000 * COIN;
} else if (nHeight <= 265000 && nHeight > 230000) {
return 12000 * COIN;
} else if (nHeight <= 300000 && nHeight > 265000) {
return 15000 * COIN;
} else if (nHeight <= 200000 && nHeight > 100000) {
return 17500 * COIN;
} else if (nHeight > 200000) {
} else if (nHeight <= 350000 && nHeight > 300000) {
return 20000 * COIN;
} else if (nHeight <= 400000 && nHeight > 350000) {
return 35000 * COIN;
} else if (nHeight <= Params().UltraClearStart() && nHeight > 400000) {
return 50000 * COIN;
} else if (nHeight <= 700000 && nHeight > Params().UltraClearStart()) {
return 60000 * COIN;
} else if (nHeight <= 800000 && nHeight > 700000) {
return 70000 * COIN;
} else if (nHeight <= 900000 && nHeight > 800000) {
return 80000 * COIN;
} else if (nHeight <= 1000000 && nHeight > 900000) {
return 90000 * COIN;
}
return 0;
return 100000 * COIN;
}

CAmount CMasternode::GetBlockValue(int nHeight)
Expand Down Expand Up @@ -418,11 +462,6 @@ CAmount CMasternode::GetMasternodePayment(int nHeight)
{
int64_t ret = 0;

if (Params().NetworkID() == CBaseChainParams::TESTNET) {
if (nHeight < 200)
return 0;
}

if (nHeight <= Params().LAST_POW_BLOCK()) {
return 0;
} else if (nHeight <=12000 && nHeight > Params().LAST_POW_BLOCK()){
Expand All @@ -434,6 +473,8 @@ CAmount CMasternode::GetMasternodePayment(int nHeight)
if(nHeight > Params().UltraClearStart()) {
ret = GetBlockValue(nHeight) - (5 * COIN);
}

return ret;
}

CMasternodeBroadcast::CMasternodeBroadcast() :
Expand Down Expand Up @@ -535,20 +576,40 @@ bool CMasternodeBroadcast::Create(CTxIn txin, CService service, CKey keyCollater

bool CMasternodeBroadcast::Sign(const CKey& key, const CPubKey& pubKey)
{
sigTime = GetAdjustedTime();

std::string strError = "";
nMessVersion = MessageVersion::MESS_VER_HASH;
const std::string strMessage = GetSignatureHash().GetHex();
std::string strMessage;

if (!CMessageSigner::SignMessage(strMessage, vchSig, key)) {
return error("%s : SignMessage() (nMessVersion=%d) failed", __func__, nMessVersion);
}
if(Params().GetConsensus().NetworkUpgradeActive(chainActive.Height(), Consensus::UPGRADE_V3_4)) {
nMessVersion = MessageVersion::MESS_VER_HASH;
strMessage = GetSignatureHash().GetHex();

if (!CMessageSigner::VerifyMessage(pubKey, vchSig, strMessage, strError)) {
return error("%s : VerifyMessage() (nMessVersion=%d) failed, error: %s\n",
__func__, nMessVersion, strError);
}
if (!CMessageSigner::SignMessage(strMessage, vchSig, key)) {
return error("%s : SignMessage() (nMessVersion=%d) failed", __func__, nMessVersion);
}

return true;
if (!CMessageSigner::VerifyMessage(pubKey, vchSig, strMessage, strError)) {
return error("%s : VerifyMessage() (nMessVersion=%d) failed, error: %s\n",
__func__, nMessVersion, strError);
}

return true;
} else {
nMessVersion = MessageVersion::MESS_VER_STRMESS;
strMessage = GetOldStrMessage();

CHashWriter ss(SER_GETHASH, 0);
ss << strMessageMagic;
ss << strMessage;

if (!key.SignCompact(ss.GetHash(), vchSig)) {
return error("%s : VerifyMessage() (nMessVersion=%d) failed, error: Signing failed.\n",
__func__, nMessVersion);
}

return true;
}
}

bool CMasternodeBroadcast::Sign(const std::string strSignKey)
Expand Down Expand Up @@ -577,16 +638,16 @@ std::string CMasternodeBroadcast::GetOldStrMessage() const
bool CMasternodeBroadcast::CheckSignature() const
{
std::string strError = "";
const std::string strMessage = (
nMessVersion == MessageVersion::MESS_VER_HASH ?
GetSignatureHash().GetHex() :
GetStrMessage()
);

if(!CMessageSigner::VerifyMessage(pubKeyCollateralAddress, vchSig, strMessage, strError) &&
!CMessageSigner::VerifyMessage(pubKeyCollateralAddress, vchSig, GetOldStrMessage(), strError)) {
std::string strMessage = (nMessVersion == MessageVersion::MESS_VER_HASH ?
GetSignatureHash().GetHex() :
GetStrMessage());
std::string oldStrMessage = (nMessVersion == MessageVersion::MESS_VER_HASH ?
GetSignatureHash().GetHex() :
GetOldStrMessage());

if (!CMessageSigner::VerifyMessage(pubKeyCollateralAddress, vchSig, oldStrMessage, strError) &&
!CMessageSigner::VerifyMessage(pubKeyCollateralAddress, vchSig, strMessage, strError))
return error("%s : VerifyMessage (nMessVersion=%d) failed: %s", __func__, nMessVersion, strError);
}

return true;
}
Expand Down Expand Up @@ -832,7 +893,7 @@ std::string CMasternodePing::GetStrMessage() const
{
int64_t salt = sporkManager.GetSporkValue(SPORK_103_PING_MESSAGE_SALT);

if (salt == 4070908800ULL) {
if (salt != 0) {
return vin.ToString() + blockHash.ToString() + std::to_string(sigTime) + std::to_string(salt);
} else {
return vin.ToString() + blockHash.ToString() + std::to_string(sigTime);
Expand Down
28 changes: 21 additions & 7 deletions src/messagesigner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,30 @@ bool CHashSigner::VerifyHash(const uint256& hash, const CKeyID& keyID, const std

bool CSignedMessage::Sign(const CKey& key, const CPubKey& pubKey)
{
nMessVersion = MessageVersion::MESS_VER_HASH;
std::string strError = "";
uint256 hash = GetSignatureHash();

if(!CHashSigner::SignHash(hash, key, vchSig)) {
return error("%s : SignHash() failed", __func__);
}
if (Params().GetConsensus().NetworkUpgradeActive(chainActive.Height(), Consensus::UPGRADE_V3_4)) {
nMessVersion = MessageVersion::MESS_VER_HASH;
uint256 hash = GetSignatureHash();

if (!CHashSigner::SignHash(hash, key, vchSig)) {
return error("%s : SignHash() failed", __func__);
}

if (!CHashSigner::VerifyHash(hash, pubKey, vchSig, strError)) {
return error("%s : VerifyHash() failed, error: %s", __func__, strError);
}
} else {
nMessVersion = MessageVersion::MESS_VER_STRMESS;
std::string strMessage = GetStrMessage();

if (!CMessageSigner::SignMessage(strMessage, vchSig, key)) {
return error("%s : SignMessage() failed", __func__);
}

if (!CHashSigner::VerifyHash(hash, pubKey, vchSig, strError)) {
return error("%s : VerifyHash() failed, error: %s", __func__, strError);
if (!CMessageSigner::VerifyMessage(pubKey, vchSig, strMessage, strError)) {
return error("%s : VerifyMessage() failed, error: %s\n", __func__, strError);
}
}

return true;
Expand Down
16 changes: 16 additions & 0 deletions src/qt/pivx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,22 @@ int main(int argc, char* argv[])
QFontDatabase::addApplicationFont(":/font/Nunito-SemiBold.ttf");
QFontDatabase::addApplicationFont(":/font/Nunito-SemiBoldItalic.ttf");

QFontDatabase::addApplicationFont(":/font/Montserrat-Black.ttf");
QFontDatabase::addApplicationFont(":/font/Montserrat-BlackItalic.ttf");
QFontDatabase::addApplicationFont(":/font/Montserrat-Bold.ttf");
QFontDatabase::addApplicationFont(":/font/Montserrat-BoldItalic.ttf");
QFontDatabase::addApplicationFont(":/font/Montserrat-ExtraBold.ttf");
QFontDatabase::addApplicationFont(":/font/Montserrat-ExtraBoldItalic.ttf");
QFontDatabase::addApplicationFont(":/font/Montserrat-ExtraLight.ttf");
QFontDatabase::addApplicationFont(":/font/Montserrat-ExtraLightItalic.ttf");
QFontDatabase::addApplicationFont(":/font/Montserrat-Italic.ttf");
QFontDatabase::addApplicationFont(":/font/Montserrat-Light.ttf");
QFontDatabase::addApplicationFont(":/font/Montserrat-LightItalic.ttf");
QFontDatabase::addApplicationFont(":/font/Montserrat-Regular.ttf");
QFontDatabase::addApplicationFont(":/font/Montserrat-SemiBold.ttf");
QFontDatabase::addApplicationFont(":/font/Montserrat-SemiBoldItalic.ttf");
QFontDatabase::addApplicationFont(":/font/Montserrat-Thin.ttf");
QFontDatabase::addApplicationFont(":/font/Montserrat-ThinItalic.ttf");

// Register meta types used for QMetaObject::invokeMethod
qRegisterMetaType<bool*>();
Expand Down
17 changes: 17 additions & 0 deletions src/qt/pivx.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@
<file alias="bg-welcome-container-2x">pivx/res/img/[email protected]</file>
<file alias="bg-welcome-container-3x">pivx/res/img/[email protected]</file>
<file alias="bg-dashboard-banner">pivx/res/img/bg-dashboard-banner.png</file>
<file alias="bg-dashboard-banner-dark">pivx/res/img/bg-dashboard-banner-dark.png</file>
<file alias="ic-check-box-dark-active">pivx/res/img/ic-check-box-dark-active.svg</file>
<file alias="ic-check-box-indeterminate">pivx/res/img/ic-check-box-indeterminate.svg</file>
<file alias="ic-check-liliac-indeterminate">pivx/res/img/ic-check-liliac-indeterminate.svg</file>
Expand Down Expand Up @@ -240,5 +241,21 @@
<file alias="Nunito-Regular.ttf">pivx/res/font/Nunito-Regular.ttf</file>
<file alias="Nunito-SemiBold.ttf">pivx/res/font/Nunito-SemiBold.ttf</file>
<file alias="Nunito-SemiBoldItalic.ttf">pivx/res/font/Nunito-SemiBoldItalic.ttf</file>
<file alias="Montserrat-Black.ttf">pivx/res/font/Montserrat-Black.ttf</file>
<file alias="Montserrat-BlackItalic.ttf">pivx/res/font/Montserrat-BlackItalic.ttf</file>
<file alias="Montserrat-Bold.ttf">pivx/res/font/Montserrat-Bold.ttf</file>
<file alias="Montserrat-BoldItalic.ttf">pivx/res/font/Montserrat-BoldItalic.ttf</file>
<file alias="Montserrat-ExtraBold.ttf">pivx/res/font/Montserrat-ExtraBold.ttf</file>
<file alias="Montserrat-ExtraBoldItalic.ttf">pivx/res/font/Montserrat-ExtraBoldItalic.ttf</file>
<file alias="Montserrat-ExtraLight.ttf">pivx/res/font/Montserrat-ExtraLight.ttf</file>
<file alias="Montserrat-ExtraLightItalic.ttf">pivx/res/font/Montserrat-ExtraLightItalic.ttf</file>
<file alias="Montserrat-Italic.ttf">pivx/res/font/Montserrat-Italic.ttf</file>
<file alias="Montserrat-Light.ttf">pivx/res/font/Montserrat-Light.ttf</file>
<file alias="Montserrat-LightItalic.ttf">pivx/res/font/Montserrat-LightItalic.ttf</file>
<file alias="Montserrat-Regular.ttf">pivx/res/font/Montserrat-Regular.ttf</file>
<file alias="Montserrat-SemiBold.ttf">pivx/res/font/Montserrat-SemiBold.ttf</file>
<file alias="Montserrat-SemiBoldItalic.ttf">pivx/res/font/Montserrat-SemiBoldItalic.ttf</file>
<file alias="Montserrat-Thin.ttf">pivx/res/font/Montserrat-Thin.ttf</file>
<file alias="Montserrat-ThinItalic.ttf">pivx/res/font/Montserrat-ThinItalic.ttf</file>
</qresource>
</RCC>
7 changes: 5 additions & 2 deletions src/qt/pivx/dashboardwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ DashboardWidget::DashboardWidget(PIVXGUI* parent) :
setCssSubtitleScreen(ui->labelSubtitle);

// Staking Information
ui->labelMessage->setText(tr("Amount of UCR earned via Staking & Masternodes"));
setCssSubtitleScreen(ui->labelMessage);
setCssProperty(ui->labelSquarePiv, "square-chart-piv");
setCssProperty(ui->labelPiv, "text-chart-piv");
Expand Down Expand Up @@ -575,6 +576,7 @@ const QMap<int, QMap<QString, qint64>> DashboardWidget::getAmountBy()
} else if (isMN) {
amountBy[time]["piv"] = 0;
amountBy[time]["mn"] = amount;
hasMNRewards = true;
}
}
}
Expand Down Expand Up @@ -614,7 +616,8 @@ bool DashboardWidget::loadChartData(bool withMonthNames)

chartData->xLabels << ((withMonthNames) ? monthsNames[num - 1] : QString::number(num));

chartData->valuesPiv.append(piv);
chartData->valuesPiv.append(piv);
chartData->valuesMNRewards.append(mnrewards);

int max = std::max(piv, mnrewards);
if (max > chartData->maxValue) {
Expand Down Expand Up @@ -690,7 +693,7 @@ void DashboardWidget::onChartRefreshed()

// Total
nDisplayUnit = walletModel->getOptionsModel()->getDisplayUnit();
if (chartData->totalPiv > 0 || chartData->totalMNRewards) {
if (chartData->totalPiv > 0 || chartData->totalMNRewards > 0) {
setCssProperty(ui->labelAmountPiv, "text-stake-piv");
setCssProperty(ui->labelAmountMNRewards, "text-stake-mnrewards");
} else {
Expand Down
48 changes: 24 additions & 24 deletions src/qt/pivx/forms/dashboardwidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -560,31 +560,31 @@
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5" stretch="0,0">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="labelAmountPiv">
<property name="text">
<string notr="true">0 UCR</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelAmountMNRewards">
<property name="text">
<string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<layout class="QHBoxLayout" name="horizontalLayout_5" stretch="0,0">
<property name="spacing">
<number>0</number>
</property>
</widget>
</item>
</layout>
<item>
<widget class="QLabel" name="labelAmountPiv">
<property name="text">
<string notr="true">0 UCR</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelAmountMNRewards">
<property name="text">
<string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_6">
Expand Down
Loading

0 comments on commit d306b53

Please sign in to comment.