Skip to content

Commit

Permalink
Merge pull request #281 from carsenk/v3.3.9.8
Browse files Browse the repository at this point in the history
v3.3.9.8 MANDATORY
  • Loading branch information
metaspartan committed Sep 7, 2020
2 parents 7976d9d + b988c00 commit dbd8571
Show file tree
Hide file tree
Showing 20 changed files with 198 additions and 59 deletions.
2 changes: 1 addition & 1 deletion denarius-qt.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TEMPLATE = app
TARGET = Denarius
VERSION = 3.3.9.7
VERSION = 3.3.9.8
INCLUDEPATH += src src/json src/qt src/qt/plugins/mrichtexteditor
DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE CURL_STATICLIB
CONFIG += no_include_pwd
Expand Down
2 changes: 1 addition & 1 deletion snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# https://github.com/carsenk/denarius
# By Carsen Klock
name: denarius
version: '3.3.9.7'
version: '3.3.9.8'
summary: Denarius
description: |
An open source hybrid cryptocurrency called Denarius, which features Fortuna Stakes (Masternodes), Staking, Mining, Multisig, and much more!
Expand Down
2 changes: 1 addition & 1 deletion src/activefortunastake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void CActiveFortunastake::ManageStatus()
// return;
//}

printf("CActiveFortunastake::ManageStatus() - Is capable master node!\n");
printf("CActiveFortunastake::ManageStatus() - Is a capable FortunaStake!\n");

status = FORTUNASTAKE_IS_CAPABLE;
notCapableReason = "";
Expand Down
3 changes: 2 additions & 1 deletion src/checkpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ namespace Checkpoints
( 1469647, uint256("0x000000000035f3c2c5e21ea1d4ccd83fe1b59d37659bb3302bd9edfab67da312") )
( 1701516, uint256("0x000000000021e83d2818325042fc528a63027de9ff7612bca0efcdda688c9672") )
( 2487883, uint256("0x00000000000c66f7f18969f44c28509c7a3948da5155d6f3d1c674d458a0948b") )
( 3692415, uint256("0x0000000028605ffbf22ef461ba8a867fc3beaabf34dacb6d1737209eb7f70ed5") )
//
;

static const CCheckpointData data = {
&mapCheckpoints,
1570646530, // * UNIX timestamp of last checkpoint block above ^^
1599322010, // * UNIX timestamp of last checkpoint block above ^^
5033897, // * total number of transactions between genesis and last checkpoint
// (the tx=... number in the SetBestChain debug.log lines)
5000.0 // * estimated number of transactions per day after checkpoint
Expand Down
2 changes: 1 addition & 1 deletion src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define CLIENT_VERSION_MAJOR 3
#define CLIENT_VERSION_MINOR 3
#define CLIENT_VERSION_REVISION 9
#define CLIENT_VERSION_BUILD 7
#define CLIENT_VERSION_BUILD 8

// Converts the parameter X to a string after macro replacement on X has been performed.
// Don't merge these into one macro!
Expand Down
4 changes: 3 additions & 1 deletion src/denariusrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ static const CRPCCommand vRPCCommands[] =
{ "sendalert", &sendalert, false, false},
{ "gettxout", &gettxout, true, false },
{ "importaddress", &importaddress, false, false },
{ "burn", &burn, false, false },

{ "getnewstealthaddress", &getnewstealthaddress, false, false},
{ "liststealthaddresses", &liststealthaddresses, false, false},
Expand Down Expand Up @@ -1333,6 +1334,7 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector<std::stri
//
if (strMethod == "stop" && n > 0) ConvertTo<bool>(params[0]);
if (strMethod == "sendtoaddress" && n > 1) ConvertTo<double>(params[1]);
if (strMethod == "burn" && n > 0) ConvertTo<double>(params[0]);
if (strMethod == "settxfee" && n > 0) ConvertTo<double>(params[0]);
if (strMethod == "getreceivedbyaddress" && n > 1) ConvertTo<int64_t>(params[1]);
if (strMethod == "getreceivedbyaccount" && n > 1) ConvertTo<int64_t>(params[1]);
Expand All @@ -1345,7 +1347,7 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector<std::stri
if (strMethod == "getbalance" && n > 1) ConvertTo<int64_t>(params[1]);
if (strMethod == "getbalance" && n > 2) ConvertTo<bool>(params[2]);
if (strMethod == "getblock" && n > 1) ConvertTo<bool>(params[1]);
if (strMethod == "getblockheader" && n > 1) ConvertTo<bool>(params[1]);
if (strMethod == "getblockheader" && n > 1) ConvertTo<bool>(params[1]);
if (strMethod == "getblock_old" && n > 1) ConvertTo<bool>(params[1]);
if (strMethod == "getblockbynumber" && n > 0) ConvertTo<int64_t>(params[0]);
if (strMethod == "getblockbynumber" && n > 1) ConvertTo<bool>(params[1]);
Expand Down
1 change: 1 addition & 0 deletions src/denariusrpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ extern json_spirit::Value getblockbynumber(const json_spirit::Array& params, boo
extern json_spirit::Value getcheckpoint(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value gettxout(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value importaddress(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value burn(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value proofofdata(const json_spirit::Array& params, bool fHelp); // in rpcblockchain.cpp

extern json_spirit::Value jupiterversion(const json_spirit::Array& params, bool fHelp); // in rpcjupiter.cpp Denarius Jupiter
Expand Down
4 changes: 2 additions & 2 deletions src/fortuna.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ CActiveFortunastake activeFortunastake;
int RequestedFortunaStakeList = 0;

//MIN_MN_PROTO_VERSION
int MIN_MN_PROTO_VERSION = 33900; // D v3.3.9.2 - Proto - 33900
int MIN_MN_PROTO_VERSION = 33933; // D v3.3.9.8 - Proto - 33933

/* *** BEGIN FORTUNA MAGIC **********
Copyright 2014, Darkcoin Developers
eduffield - evan@darkcoin.io
Copyright 2018-2019, Denarius Developers
Copyright 2018-2020, Denarius Developers
carsenk - admin@denarius.io
enkayz - enkayz@denarius.io
*/
Expand Down
2 changes: 1 addition & 1 deletion src/fortuna.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class CFortunaSession
class CForTunaPool
{
public:
static const int PROTOCOL_VERSION = 33900; //33900, D v3.3.9.2
static const int PROTOCOL_VERSION = 33933; //33933, D v3.3.9.8

// clients entries
std::vector<CForTunaEntry> myEntries;
Expand Down
55 changes: 53 additions & 2 deletions src/fortunastake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ std::map<int64_t, uint256> mapCacheBlockHashes;
CMedianFilter<unsigned int> mnMedianCount(10, 0);
unsigned int mnCount = 0;
int64_t nAverageFSIncome;
int64_t nAveragePayCount;

// manage the fortunastake connections
void ProcessFortunastakeConnections(){
Expand Down Expand Up @@ -618,6 +619,9 @@ int GetFortunastakeRank(CFortunaStake &tmn, CBlockIndex* pindex, int minProtocol

bool CheckFSPayment(CBlockIndex* pindex, int64_t value, CFortunaStake &mn) {
if (mn.nBlockLastPaid == 0) return true; // if we didn't find a payment for this MN, let it through regardless of rate

//if (mn.nBlockLastPaid - vFortunastakes.count()) return false;

// find height
// calculate average payment across all FS
// check if value is > 25% higher
Expand All @@ -627,11 +631,29 @@ bool CheckFSPayment(CBlockIndex* pindex, int64_t value, CFortunaStake &mn) {
if (value > max) {
return false;
}

CScript pubScript;
pubScript = GetScriptForDestination(mn.pubkey.GetID());
CTxDestination address1;
ExtractDestination(pubScript, address1);
CBitcoinAddress address2(address1);

// calculate pay count average across FS
// check if pay count is > 50% higher than the avg
nAveragePayCount = avgCount(vecFortunastakeScoresList);
if (nAveragePayCount < 1) return true; // if the pay count is less than 1 just let it through
int64_t maxed = nAveragePayCount * 12 / 8;
if (mn.payCount > maxed) {
printf("CheckFSPayment() Current payCount of %s FS is %d - payCount Overall Average %d\n", address2.ToString().c_str(), mn.payCount, nAveragePayCount);
return false;
}

return true;
}

bool CheckPoSFSPayment(CBlockIndex* pindex, int64_t value, CFortunaStake &mn) {
if (mn.nBlockLastPaid == 0) return true; // if we didn't find a payment for this MN, let it through regardless of rate

// find height
// calculate average payment across all FS
// check if value is > 25% higher
Expand All @@ -643,6 +665,22 @@ bool CheckPoSFSPayment(CBlockIndex* pindex, int64_t value, CFortunaStake &mn) {
return false;
}
*/
CScript pubScript;
pubScript = GetScriptForDestination(mn.pubkey.GetID());
CTxDestination address1;
ExtractDestination(pubScript, address1);
CBitcoinAddress address2(address1);

// calculate pay count average across FS
// check if pay count is > 50% higher than the avg
nAveragePayCount = avgCount(vecFortunastakeScoresList);
if (nAveragePayCount < 1) return true; // if the pay count is less than 1 just let it through
int64_t maxed = nAveragePayCount * 12 / 8;
if (mn.payCount > maxed) {
printf("CheckPoSFSPayment() Current payCount of %s is %d - payCount Overall Average %d\n", address2.ToString().c_str(), mn.payCount, nAveragePayCount);
return false;
}

return true;
}

Expand All @@ -660,6 +698,19 @@ int64_t avg2(std::vector<CFortunaStake> const& v) {
return mean;
}

int64_t avgCount(std::vector<CFortunaStake> const& v) {
int n = 0;
int64_t mean = 0;
for (int i = 0; i < v.size(); i++) {
int64_t x = v[i].payCount;
int64_t delta = x - mean;
//TODO: implement in mandatory update, will reduce average & lead to rejections
if (v[i].payCount < 1) { continue; } // don't consider payees below 1 payment (pos only / new payees)
mean += delta/++n;
}
return mean;
}

int GetFortunastakeByRank(int findRank, int64_t nBlockHeight, int minProtocol)
{
if (IsInitialBlockDownload()) return 0;
Expand Down Expand Up @@ -998,7 +1049,7 @@ void CFortunaStake::UpdateLastPaidBlock(const CBlockIndex *pindex, int nMaxBlock
// TODO HERE: Scan the block for fortunastake payment amount
BOOST_FOREACH(CTxOut txout, block.vtx[1].vout)
if(mnpayee == txout.scriptPubKey) {
nBlockLastPaid = BlockReading->nHeight;\
nBlockLastPaid = BlockReading->nHeight;
int lastPay = pindexBest->nHeight - nBlockLastPaid;
int value = txout.nValue;
// TODO HERE: Check the nValue for the fortunastake payment amount
Expand All @@ -1019,7 +1070,7 @@ void CFortunaStake::UpdateLastPaidBlock(const CBlockIndex *pindex, int nMaxBlock
}

//
// Deterministically calculate a given "score" for a fortunastake depending on how close it's hash is to
// Deterministically calculate a given "score" for a fortunastake with tribus depending on how close it's hash is to
// the proof of work for that block. The further away they are the better, the furthest will win the election
// and get paid this block
//
Expand Down
3 changes: 2 additions & 1 deletion src/fortunastake.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2017-2018 The Denarius developers
// Copyright (c) 2017-2020 The Denarius developers
// Copyright (c) 2009-2012 The Darkcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
Expand Down Expand Up @@ -264,6 +264,7 @@ int GetCurrentFortunaStake(int mod=1, int64_t nBlockHeight=0, int minProtocol=CF
bool CheckFSPayment(CBlockIndex* pindex, int64_t value, CFortunaStake &mn);
bool CheckPoSFSPayment(CBlockIndex* pindex, int64_t value, CFortunaStake &mn);
int64_t avg2(std::vector<CFortunaStake> const& v);
int64_t avgCount(std::vector<CFortunaStake> const& v);
int GetFortunastakeByVin(CTxIn& vin);
int GetFortunastakeRank(CFortunaStake& tmn, CBlockIndex* pindex, int minProtocol=CFortunaStake::minProtoVersion);
int GetFortunastakeByRank(int findRank, int64_t nBlockHeight=0, int minProtocol=CFortunaStake::minProtoVersion);
Expand Down
3 changes: 2 additions & 1 deletion src/kernel.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2012-2013 The Peercoin developers
// Copyright (c) 2017-2018 The Denarius developers
// Copyright (c) 2017-2020 The Denarius developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

Expand All @@ -20,6 +20,7 @@ static std::map<int, unsigned int> mapStakeModifierCheckpoints =
( 1000000, 0x0164bdb4 )
( 1701527, 0xb64daf99 )
( 2487918, 0x518704f3 )
( 3692427, 0x20a869c0 )
//( 640106, 0x491697be ) Example of bad modifier checkpoint, must have proof-of-stake flag
;

Expand Down
21 changes: 14 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1723,7 +1723,7 @@ bool IsInitialBlockDownload()
GetFortunastakeRanks(pindexBest);
}
return state;

}

void static InvalidChainFound(CBlockIndex* pindexNew)
Expand Down Expand Up @@ -2438,6 +2438,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck)
int64_t nFees = 0;
int64_t nValueIn = 0;
int64_t nValueOut = 0;
int64_t nAmountBurned = 0;
int64_t nStakeReward = 0;
unsigned int nSigOps = 0;
BOOST_FOREACH(CTransaction& tx, vtx)
Expand Down Expand Up @@ -2505,6 +2506,10 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck)

nValueIn += nTxValueIn;
nValueOut += nTxValueOut;
for (const CTxOut& out : tx.vout) {
if(out.scriptPubKey.IsUnspendable())
nAmountBurned += out.nValue;
}
if (!tx.IsCoinStake())
nFees += nTxValueIn - nTxValueOut;
if (tx.IsCoinStake())
Expand Down Expand Up @@ -2658,11 +2663,11 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck)
if (!CheckPoSFSPayment(pindex, vtx[1].vout[i].nValue, mn)) // CheckPoSFSPayment()
{
if (pindexBest->nHeight >= MN_ENFORCEMENT_ACTIVE_HEIGHT) { //Update PoS FS Payments to not go out of sync
printf("CheckBlock-POS() : Out-of-cycle fortunastake payment detected, rejecting block.");
//printf("CheckBlock-POS() : Out-of-cycle fortunastake payment detected, rejecting block.");
printf("CheckBlock-POS() : Out-of-cycle FortunaStake payment detected, rejecting block. rank:%d value:%s avg:%s payRate:%s payCount:%d\n",mn.nRank,FormatMoney(mn.payValue).c_str(),FormatMoney(nAverageFSIncome).c_str(),FormatMoney(mn.payRate).c_str(), mn.payCount);
} else {
printf("CheckBlock-POS(): This fortunastake payment is too aggressive and will be accepted after block %d\n", MN_ENFORCEMENT_ACTIVE_HEIGHT);
}
//break;
} else {
if (fDebug) printf("CheckBlock-POS() : Payment meets rate requirement: payee has earnt %s against average %s\n",FormatMoney(mn.payValue).c_str(),FormatMoney(nAverageFSIncome).c_str());
}
Expand Down Expand Up @@ -2784,9 +2789,9 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck)
{
if (pindexBest->nHeight >= MN_ENFORCEMENT_ACTIVE_HEIGHT)
{
return error("CheckBlock-POW() : Fortunastake overpayment detected, rejecting block. rank:%d value:%s avg:%s payRate:%s",mn.nRank,FormatMoney(mn.payValue).c_str(),FormatMoney(nAverageFSIncome).c_str(),FormatMoney(mn.payRate).c_str());
printf("CheckBlock-POW() : Fortunastake overpayment detected, rejecting block. rank:%d value:%s avg:%s payRate:%s payCount:%d\n",mn.nRank,FormatMoney(mn.payValue).c_str(),FormatMoney(nAverageFSIncome).c_str(),FormatMoney(mn.payRate).c_str(), mn.payCount);
} else {
if (fDebug) printf("WARNING: This fortunastake payment is too aggressive and will not be accepted after block %d\n", MN_ENFORCEMENT_ACTIVE_HEIGHT);
printf("WARNING: This fortunastake payment is too aggressive and will not be accepted after block %d\n", MN_ENFORCEMENT_ACTIVE_HEIGHT);
}
} else {
if (fDebug) printf("CheckBlock-POW() : Payment meets rate requirement: payee has earnt %s against average %s\n",FormatMoney(mn.payValue).c_str(),FormatMoney(nAverageFSIncome).c_str());
Expand Down Expand Up @@ -2876,6 +2881,8 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck)
// ppcoin: track money supply and mint amount info
pindex->nMint = nValueOut - nValueIn + nFees;
pindex->nMoneySupply = (pindex->pprev? pindex->pprev->nMoneySupply : 0) + nValueOut - nValueIn;
pindex->nMoneySupply -= nAmountBurned;
assert(pindex->nMoneySupply >= 0);
if (!txdb.WriteBlockIndex(CDiskBlockIndex(pindex)))
return error("Connect() : WriteBlockIndex for pindex failed");

Expand Down Expand Up @@ -3702,7 +3709,7 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock)

//After block 1.5m, The Minimum FortunaStake Protocol Version is 31005
if(nBestHeight >= 1500000) {
MIN_MN_PROTO_VERSION = 33900;
MIN_MN_PROTO_VERSION = 33933;
}

// ppcoin: if responsible for sync-checkpoint send it
Expand Down Expand Up @@ -5400,4 +5407,4 @@ int64_t GetFortunastakePayment(int nHeight, int64_t blockValue)
int64_t ret = static_cast<int64_t>(blockValue * 1/3); //33%

return ret;
}
}
9 changes: 5 additions & 4 deletions src/qt/marketbrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ QString bitcoing;
QString dnrnewsfeed;
QString dnrmarket;
QString dollarg;
QString eurog;
int mode=1;
int o = 0;

Expand Down Expand Up @@ -84,15 +85,15 @@ void MarketBrowser::parseNetworkResponse(QNetworkReply *finished )
emit networkError( finished->error() );
return;
}

if (what == kBaseUrl) // Denarius Price
{

// QNetworkReply is a QIODevice. So we read from it just like it was a file
QString denarius = finished->readAll();
denarius2 = (denarius.toDouble());
denarius = QString::number(denarius2, 'f', 2);

if(denarius > denariusp)
{
ui->denarius->setText("<font color=\"yellow\">$" + denarius + "</font>");
Expand Down Expand Up @@ -132,7 +133,7 @@ if (what == kBaseUrl2) // Denarius Market Cap
QString dnrmc = finished->readAll();
dnrmc2 = (dnrmc.toDouble());
dnrmc = QString::number(dnrmc2, 'f', 2);

if(dnrmc > dnrmcp)
{
ui->dnrmc->setText("<font color=\"yellow\">$" + dnrmc + "</font>");
Expand All @@ -153,7 +154,7 @@ if (what == kBaseUrl3) // Denarius BTC Price
QString dnrbtc = finished->readAll();
dnrbtc2 = (dnrbtc.toDouble());
dnrbtc = QString::number(dnrbtc2, 'f', 8);

if(dnrbtc > dnrbtcp)
{
ui->dnrbtc->setText("<font color=\"yellow\">" + dnrbtc + " BTC</font>");
Expand Down
3 changes: 2 additions & 1 deletion src/qt/marketbrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

extern QString bitcoing;
extern QString dollarg;
extern QString eurog;
extern QString dnrmarket;
extern QString dnrnewsfeed;

Expand All @@ -29,7 +30,7 @@ class MarketBrowser : public QWidget
public:
explicit MarketBrowser(QWidget *parent = 0);
~MarketBrowser();

void setModel(ClientModel *model);

private:
Expand Down
Loading

3 comments on commit dbd8571

@crackfoo
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will there be an OSX wallet?

@metaspartan
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will there be an OSX wallet?

Yes, we may revert some code and then release it today!

@crackfoo
Copy link

@crackfoo crackfoo commented on dbd8571 Sep 8, 2020 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.