-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1st Commit of 5% block reward code to AVN foundation wallet
- Loading branch information
1 parent
70b4838
commit e7f4373
Showing
10 changed files
with
146 additions
and
10 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
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,56 @@ | ||
#include "founder_payment.h" | ||
|
||
#include "util.h" | ||
#include "chainparams.h" | ||
#include <boost/foreach.hpp> | ||
#include "base58.h" | ||
|
||
CAmount FounderPayment::getFounderPaymentAmount(int blockHeight, CAmount blockReward) { | ||
if (blockHeight <= startBlock){ | ||
return 0; | ||
} | ||
for(int i = 0; i < rewardStructures.size(); i++) { | ||
FounderRewardStructure rewardStructure = rewardStructures[i]; | ||
if(rewardStructure.blockHeight == INT_MAX || blockHeight <= rewardStructure.blockHeight) { | ||
return blockReward * rewardStructure.rewardPercentage / 100; | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
void FounderPayment::FillFounderPayment(CMutableTransaction& txNew, int nBlockHeight, CAmount blockReward, CTxOut& txoutFounderRet) { | ||
// make sure it's not filled yet | ||
CAmount founderPayment = getFounderPaymentAmount(nBlockHeight, blockReward); | ||
// if(founderPayment == 0) { | ||
// LogPrintf("FounderPayment::FillFounderPayment -- Founder payment has not started\n"); | ||
// return; | ||
// | ||
// } | ||
txoutFounderRet = CTxOut(); | ||
CScript payee; | ||
// fill payee with the foundFounderRewardStrcutureFounderRewardStrcutureer address | ||
CBitcoinAddress cbAddress(founderAddress); | ||
payee = GetScriptForDestination(cbAddress.Get()); | ||
// GET FOUNDER PAYMENT VARIABLES SETUP | ||
|
||
// split reward between miner ... | ||
txNew.vout[0].nValue -= founderPayment; | ||
txoutFounderRet = CTxOut(founderPayment, payee); | ||
txNew.vout.push_back(txoutFounderRet); | ||
LogPrintf("FounderPayment::FillFounderPayment -- Founder payment %lld to %s\n", founderPayment, founderAddress.c_str()); | ||
} | ||
|
||
bool FounderPayment::IsBlockPayeeValid(const CTransaction& txNew, const int height, const CAmount blockReward) { | ||
CScript payee; | ||
// fill payee with the founder address | ||
payee = GetScriptForDestination(CBitcoinAddress(founderAddress).Get()); | ||
const CAmount founderReward = getFounderPaymentAmount(height, blockReward); | ||
//std::cout << "founderReward = " << founderReward << endl; | ||
BOOST_FOREACH(const CTxOut& out, txNew.vout) { | ||
if(out.scriptPubKey == payee && out.nValue >= founderReward) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} |
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,36 @@ | ||
#ifndef SRC_FOUNDER_PAYMENT_H_ | ||
#define SRC_FOUNDER_PAYMENT_H_ | ||
#include <string> | ||
#include "amount.h" | ||
#include "primitives/transaction.h" | ||
#include "script/standard.h" | ||
#include <limits.h> | ||
using namespace std; | ||
|
||
static const string DEFAULT_FOUNDER_ADDRESS = "RDs4A4sDHp4otDHQQuFSaPDYEg2xx3hbdN"; | ||
struct FounderRewardStructure { | ||
int blockHeight; | ||
int rewardPercentage; | ||
}; | ||
|
||
class FounderPayment { | ||
public: | ||
FounderPayment(vector<FounderRewardStructure> rewardStructures = {}, int startBlock = 0, const string &address = DEFAULT_FOUNDER_ADDRESS) { | ||
this->founderAddress = address; | ||
this->startBlock = startBlock; | ||
this->rewardStructures = rewardStructures; | ||
} | ||
~FounderPayment(){}; | ||
CAmount getFounderPaymentAmount(int blockHeight, CAmount blockReward); | ||
void FillFounderPayment(CMutableTransaction& txNew, int nBlockHeight, CAmount blockReward, CTxOut& txoutFounderRet); | ||
bool IsBlockPayeeValid(const CTransaction& txNew, const int height, const CAmount blockReward); | ||
int getStartBlock() {return this->startBlock;} | ||
private: | ||
string founderAddress; | ||
int startBlock; | ||
vector<FounderRewardStructure> rewardStructures; | ||
}; | ||
|
||
|
||
|
||
#endif /* SRC_FOUNDER_PAYMENT_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