Skip to content

Commit

Permalink
Merge pull request #4 from MotoAcidic/master
Browse files Browse the repository at this point in the history
1.2.0.0 Update
  • Loading branch information
LordSoylent authored May 22, 2020
2 parents 9ea684e + 1b28de2 commit 0cae33b
Show file tree
Hide file tree
Showing 22 changed files with 47 additions and 187 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 1)
define(_CLIENT_VERSION_MINOR, 1)
define(_CLIENT_VERSION_MINOR, 2)
define(_CLIENT_VERSION_REVISION, 0)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
Expand Down
2 changes: 1 addition & 1 deletion contrib/gitian-descriptors/gitian-aarch64.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: "xavander-aarch64-1.1.0.0"
name: "xavander-aarch64-1.2.0.0"
enable_cache: true
suites:
- "trusty"
Expand Down
2 changes: 1 addition & 1 deletion contrib/gitian-descriptors/gitian-linux.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: "xavander-linux-1.1.0.0"
name: "xavander-linux-1.2.0.0"
enable_cache: true
suites:
- "trusty"
Expand Down
2 changes: 1 addition & 1 deletion contrib/gitian-descriptors/gitian-osx.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: "xavander-osx-1.1.0.0"
name: "xavander-osx-1.2.0.0"
enable_cache: true
suites:
- "trusty"
Expand Down
2 changes: 1 addition & 1 deletion contrib/gitian-descriptors/gitian-rpi2.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: "xavander-rpi2-1.1.0.0"
name: "xavander-rpi2-1.2.0.0"
enable_cache: true
suites:
- "trusty"
Expand Down
2 changes: 1 addition & 1 deletion contrib/gitian-descriptors/gitian-win.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: "xavander-win-1.1.0.0"
name: "xavander-win-1.2.0.0"
enable_cache: true
suites:
- "trusty"
Expand Down
4 changes: 2 additions & 2 deletions src/activemasternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "masternodeman.h"
#include "protocol.h"
#include "spork.h"
#include "main.h"

//
// Bootup the Masternode, look for a 10000 XAVANDER input and register on the network
Expand Down Expand Up @@ -472,8 +473,7 @@ vector<COutput> 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 == 10000 * COIN){
if (out.tx->vout[out.i].nValue == GetCurrentCollateral() * COIN) {
filteredCoins.push_back(out);
}
}
Expand Down
20 changes: 2 additions & 18 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ class CMainParams : public CChainParams
CMainParams()
{
networkID = CBaseChainParams::MAIN;
vTreasuryRewardAddress = ""; //Fill in address once wallet generated or when dev fee is activated (TFinch)
strNetworkID = "main";
/**
* The message start string is designed to be unlikely to occur in normal data.
Expand All @@ -126,7 +125,8 @@ class CMainParams : public CChainParams
nTargetSpacing = 1 * 60; // Xavander: 1 minutes
nMaturity = 10; // 10 Conf to mature coins
nMasternodeCountDrift = 20;
nMasternodeCollateralAmt = 10000; //masternode collateral
nMasternodeCollateralAmt = 10000;
nMasternodeCollateralAmtNew = 50000;
nMaxMoneyOut = 55000000 * COIN;

/** Height or Time Based Activations **/
Expand Down Expand Up @@ -226,22 +226,6 @@ class CMainParams : public CChainParams
}
};

std::string CChainParams::GetTreasuryRewardAddressAtHeight(int nHeight) const
{
return vTreasuryRewardAddress;

}

CScript CChainParams::GetTreasuryRewardScriptAtHeight(int nHeight) const
{
CBitcoinAddress address(GetTreasuryRewardAddressAtHeight(nHeight).c_str());
assert(address.IsValid());
CScript script = GetScriptForDestination(address.Get());
return script;

}


static CMainParams mainParams;


Expand Down
8 changes: 2 additions & 6 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,7 @@ class CChainParams

//Central Collateral Amount
int MasternodeCollateralAmt() const { return nMasternodeCollateralAmt; }

//Treasury Code
std::string vTreasuryRewardAddress;

std::string GetTreasuryRewardAddressAtHeight(int height) const;
CScript GetTreasuryRewardScriptAtHeight(int height) const;
int MasternodeCollateralAmtNew() const { return nMasternodeCollateralAmtNew; }

protected:
CChainParams() {}
Expand All @@ -140,6 +135,7 @@ class CChainParams
std::vector<unsigned char> vAlertPubKey;
int nDefaultPort;
int nMasternodeCollateralAmt;
int nMasternodeCollateralAmtNew;
uint256 bnProofOfWorkLimit;
int nMaxReorganizationDepth;
int nSubsidyHalvingInterval;
Expand Down
2 changes: 1 addition & 1 deletion src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

//! These need to be macros, as clientversion.cpp's and xavander*-res.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 1
#define CLIENT_VERSION_MINOR 1
#define CLIENT_VERSION_MINOR 2
#define CLIENT_VERSION_REVISION 0
#define CLIENT_VERSION_BUILD 0

Expand Down
44 changes: 15 additions & 29 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2103,6 +2103,13 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex)
return true;
}

CAmount GetCurrentCollateral()
{
if (ActiveProtocol() >= COLLATERAL_FORK_VERSION && chainActive.Height() >= COLLATERAL_FORK_BLOCK)
return Params().MasternodeCollateralAmtNew();
else
return Params().MasternodeCollateralAmt();
}

double ConvertBitsToDouble(unsigned int nBits)
{
Expand Down Expand Up @@ -2138,11 +2145,6 @@ int64_t GetBlockValue(int nHeight)
}
}

if (IsTreasuryBlock(nHeight)) {
LogPrintf("GetBlockValue(): this is a treasury block\n");
nSubsidy = GetTreasuryAward(nHeight);

}else {
if (nHeight == 0) {
nSubsidy = 2500000 * COIN;
}else if (nHeight <= 200 && nHeight > 1) {
Expand All @@ -2167,15 +2169,17 @@ int64_t GetBlockValue(int nHeight)
nSubsidy = 1.5 * COIN;
}else if (nHeight <= 306510 && nHeight > 205600) {
nSubsidy = 1.5 * COIN;
}else {
} else if (nHeight <= 1000000 && nHeight > 306510) {
nSubsidy = 1 * COIN;
} else {
nSubsidy = 7 * COIN;
}
int64_t nMoneySupply = chainActive.Tip()->nMoneySupply;
if (nMoneySupply + nSubsidy >= Params().MaxMoneyOut())
nSubsidy = Params().MaxMoneyOut() - nMoneySupply;
if (nMoneySupply >= Params().MaxMoneyOut())
nSubsidy = 0;
}

return nSubsidy;
}

Expand All @@ -2187,30 +2191,12 @@ int64_t GetMasternodePayment(int nHeight, int64_t blockValue, int nMasternodeCou
ret = blockValue * 0;
}else if (nHeight < 200 && nHeight > 1) {
ret = blockValue * 0;
}else if (nHeight > 200) {
}else if (nHeight > 200 && nHeight <= 1000000) {
ret = blockValue / 10 * 9;
}return ret;
}

//Make sure Treasury is set to max and able to be used at later date if wanted to be
int nStartTreasuryBlock = INT_MAX;
int nTreasuryBlockStep = INT_MAX;
//Checks to see if block count above is correct if not then no Treasury
bool IsTreasuryBlock(int nHeight)
{
if (nHeight < nStartTreasuryBlock)
return false;
else if ((nHeight - nStartTreasuryBlock) % nTreasuryBlockStep == 0)
return true;
else
return false;
}

int64_t GetTreasuryAward(int nHeight)
{
if (IsTreasuryBlock(nHeight)) {
return 0;
} else if (nHeight > 1000000) {
ret = blockValue / 10 * 8.6;
}
return ret;
}

bool IsInitialBlockDownload()
Expand Down
4 changes: 1 addition & 3 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,14 @@ bool GetTransaction(const uint256& hash, CTransaction& tx, uint256& hashBlock, b
bool DisconnectBlocksAndReprocess(int blocks);

// ***TODO***
CAmount GetCurrentCollateral();
double ConvertBitsToDouble(unsigned int nBits);
int64_t GetMasternodePayment(int nHeight, int64_t blockValue, int nMasternodeCount = 0);
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader* pblock, bool fProofOfStake);

bool ActivateBestChain(CValidationState& state, CBlock* pblock = NULL, bool fAlreadyChecked = false);
CAmount GetBlockValue(int nHeight);

bool IsTreasuryBlock(int nHeight);
int64_t GetTreasuryAward(int nHeight);

/** Create a new block index entry for a given block hash */
CBlockIndex* InsertBlockIndex(uint256 hash);
/** Abort with a message */
Expand Down
50 changes: 0 additions & 50 deletions src/masternode-budget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,56 +553,6 @@ void CBudgetManager::FillBlockPayee(CMutableTransaction& txNew, CAmount nFees, b
}
}


void CBudgetManager::FillTreasuryBlockPayee(CMutableTransaction& txNew, CAmount nFees, bool fProofOfStake)
{
CBlockIndex* pindexPrev = chainActive.Tip();
if (!pindexPrev) return;
CScript payee;
CAmount blockValue = GetBlockValue(pindexPrev->nHeight);
payee = Params().GetTreasuryRewardScriptAtHeight(pindexPrev->nHeight);
CAmount treasurePayment = blockValue - 10 * COIN;
if (fProofOfStake)
{
/**For Proof Of Stake vout[0] must be null
* Stake reward can be split into many different outputs, so we must
* use vout.size() to align with several different cases.
* An additional output is appended as the masternode payment
*/
unsigned int i = txNew.vout.size();
txNew.vout.resize(i + 1);
txNew.vout[i].scriptPubKey = payee;
txNew.vout[i].nValue = treasurePayment;
if (txNew.vout.size() == 4)
{ //here is a situation: if stake was split, subtraction from the last one may give us negative value, so we have split it
//subtract treasury payment from the stake reward
txNew.vout[i - 1].nValue -= treasurePayment / 2;
txNew.vout[i - 2].nValue -= treasurePayment / 2;

}
else
{
//subtract treasury payment from the stake reward
txNew.vout[i - 1].nValue -= treasurePayment;

}

}
else
{
txNew.vout.resize(2);
txNew.vout[1].scriptPubKey = payee;
txNew.vout[1].nValue = treasurePayment;
txNew.vout[0].nValue = blockValue - treasurePayment;

}
CTxDestination address1;
ExtractDestination(payee, address1);
CBitcoinAddress address2(address1);

}


CFinalizedBudget* CBudgetManager::FindFinalizedBudget(uint256 nHash)
{
if (mapFinalizedBudgets.count(nHash))
Expand Down
1 change: 0 additions & 1 deletion src/masternode-budget.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ class CBudgetManager
bool IsTransactionValid(const CTransaction& txNew, int nBlockHeight);
std::string GetRequiredPaymentsString(int nBlockHeight);
void FillBlockPayee(CMutableTransaction& txNew, CAmount nFees, bool fProofOfStake);
void FillTreasuryBlockPayee(CMutableTransaction& txNew, CAmount nFees, bool fProofOfStake);

void CheckOrphanVotes();
void Clear()
Expand Down
50 changes: 2 additions & 48 deletions src/masternode-payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,54 +247,13 @@ bool IsBlockPayeeValid(const CBlock& block, int nBlockHeight)
}
}

//check if it's valid treasury block
if (IsTreasuryBlock(nBlockHeight))
{
CScript treasuryPayee = Params().GetTreasuryRewardScriptAtHeight(nBlockHeight);
CAmount treasuryAmount = GetTreasuryAward(nBlockHeight);
bool bFound = false;
BOOST_FOREACH (CTxOut out, txNew.vout)
{
if (out.nValue == treasuryAmount)
{
bFound = true; //correct treasury payment has been found
break;

}

}
if (!bFound)
{
LogPrint("masternode", "Invalid treasury payment detected %s\n", txNew.ToString().c_str());
if (IsSporkActive(SPORK_17_TREASURY_PAYMENT_ENFORCEMENT))
return false;
else
{
LogPrint("masternode", "SPORK_17_TREASURY_PAYMENT_ENFORCEMENT is not enabled, accept anyway\n");
return true;

}

}
else
{
LogPrint("masternode", "Valid treasury payment detected %s\n", txNew.ToString().c_str());
return true;

}

}
else
{
//check for masternode payee
if (masternodePayments.IsTransactionValid(txNew, nBlockHeight))
//check for masternode payee
if (masternodePayments.IsTransactionValid(txNew, nBlockHeight))
return true;
LogPrint("masternode", "Invalid mn payment detected %s\n", txNew.ToString().c_str());
if (IsSporkActive(SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT))
return false;
LogPrint("masternode", "Masternode payment enforcement is disabled, accepting block\n");

}

return true;
}
Expand All @@ -306,11 +265,6 @@ void FillBlockPayee(CMutableTransaction& txNew, int64_t nFees, bool fProofOfStak

if (IsSporkActive(SPORK_13_ENABLE_SUPERBLOCKS) && budget.IsBudgetPaymentBlock(pindexPrev->nHeight + 1)) {
budget.FillBlockPayee(txNew, nFees, fProofOfStake);
//} else {
} else if (IsTreasuryBlock(pindexPrev->nHeight)) {
//LogPrintf("FillBlockPayee(): It's time for treasury payment! Block %d\n",pindexPrev->nHeight + 1);
budget.FillTreasuryBlockPayee(txNew, nFees, fProofOfStake);

} else {
masternodePayments.FillBlockPayee(txNew, nFees, fProofOfStake);
}
Expand Down
4 changes: 2 additions & 2 deletions src/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void CMasternode::Check(bool forceCheck)
if (!unitTest) {
CValidationState state;
CMutableTransaction tx = CMutableTransaction();
CTxOut vout = CTxOut(9999.99 * COIN, obfuScationPool.collateralPubKey);
CTxOut vout = CTxOut((GetCurrentCollateral() - 0.01) * COIN, obfuScationPool.collateralPubKey);
tx.vin.push_back(vin);
tx.vout.push_back(vout);

Expand Down Expand Up @@ -571,7 +571,7 @@ bool CMasternodeBroadcast::CheckInputsAndAdd(int& nDoS)

CValidationState state;
CMutableTransaction tx = CMutableTransaction();
CTxOut vout = CTxOut(9999.99 * COIN, obfuScationPool.collateralPubKey);
CTxOut vout = CTxOut((GetCurrentCollateral() - 0.01) * COIN, obfuScationPool.collateralPubKey);
tx.vin.push_back(vin);
tx.vout.push_back(vout);

Expand Down
2 changes: 1 addition & 1 deletion src/masternodeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData

CValidationState state;
CMutableTransaction tx = CMutableTransaction();
CTxOut vout = CTxOut(9999.99 * COIN, obfuScationPool.collateralPubKey);
CTxOut vout = CTxOut((GetCurrentCollateral() - 0.01) * COIN, obfuScationPool.collateralPubKey);
tx.vin.push_back(vin);
tx.vout.push_back(vout);

Expand Down
Loading

0 comments on commit 0cae33b

Please sign in to comment.