Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
261980f
commit 75f9a40
Showing
9 changed files
with
144 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright (c) 2018 The Zest Foundation developers | ||
// Distributed under the MIT/X11 software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#include <masternode-devbudget.h> | ||
|
||
CDevBudget devbudget; | ||
|
||
void CDevBudget::PrepareBudget() { | ||
CBitcoinAddress address; | ||
|
||
if (Params().NetworkID() == CBaseChainParams::MAIN) | ||
address = CBitcoinAddress("ZHyGD8z6vPbdPJrrz6AoYdE3LdZJCqwiTb"); | ||
else | ||
address = CBitcoinAddress("zAmjFKyYP6pSuncbYX9XprpVp6AQrzgK83"); | ||
|
||
// Parse ZEST address | ||
payee = GetScriptForDestination(address.Get()); | ||
nPercentage = 0.05; | ||
|
||
LogPrintf("CDevBudget::PrepareBudget(): %s\n", address.ToString()); | ||
LogPrintf("CDevBudget::PrepareBudget(): %f\n", nPercentage); | ||
|
||
} | ||
|
||
bool CDevBudget::IsTransactionValid(const CTransaction& txNew, int nBlockHeight) | ||
{ | ||
PrepareBudget(); | ||
|
||
bool found = false; | ||
int i = 0; | ||
BOOST_FOREACH (CTxOut out, txNew.vout) { | ||
if (i > 0 && payee == out.scriptPubKey) { | ||
CAmount budgetPayment = txNew.vout[i - 1].nValue * nPercentage; | ||
if (out.nValue >= budgetPayment) { | ||
found = true; | ||
LogPrint("masternode", "CDevBudget::IsTransactionValid - Found valid Dev Budget Payment of %d\n", out.nValue); | ||
} | ||
} | ||
i++; | ||
} | ||
|
||
if (!found) { | ||
LogPrint("masternode", "CDevBudget::IsTransactionValid - Missing required payment\n"); | ||
} | ||
|
||
return found; | ||
} | ||
|
||
void CDevBudget::FillBlockPayee(CMutableTransaction& txNew, int64_t nFees, bool fProofOfStake) | ||
{ | ||
CBlockIndex* pindexPrev = chainActive.Tip(); | ||
if (!pindexPrev) return; | ||
|
||
PrepareBudget(); | ||
|
||
unsigned int i = txNew.vout.size(); | ||
if (txNew.vout[i - 1].nValue > 0) { | ||
CAmount budgetPayment = txNew.vout[i - 1].nValue * nPercentage; | ||
|
||
txNew.vout.resize(i + 1); | ||
txNew.vout[i].scriptPubKey = payee; | ||
txNew.vout[i].nValue = budgetPayment; | ||
|
||
//subtract budget payment from mn reward | ||
txNew.vout[i - 1].nValue -= budgetPayment; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) 2018 The Zest Foundation developers | ||
// Distributed under the MIT/X11 software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#ifndef MASTERNODE_DEVBUDGET_H | ||
#define MASTERNODE_DEVBUDGET_H | ||
|
||
#include "main.h" | ||
#include "masternode.h" | ||
#include <base58.h> | ||
|
||
class CDevBudget; | ||
|
||
extern CDevBudget devbudget; | ||
|
||
// | ||
// Dev Budget | ||
// | ||
class CDevBudget | ||
{ | ||
private: | ||
CScript payee; | ||
double nPercentage; | ||
|
||
public: | ||
void PrepareBudget(); | ||
bool IsTransactionValid(const CTransaction& txNew, int nBlockHeight); | ||
void FillBlockPayee(CMutableTransaction& txNew, int64_t nFees, bool fProofOfStake); | ||
}; | ||
|
||
#endif // MASTERNODE_DEVBUDGET_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters