Bitcoin ABC  0.22.13
P2P Digital Currency
minerfund.cpp
Go to the documentation of this file.
1 // Copyright (c) 2020 The Bitcoin developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <minerfund.h>
6 
7 #include <chainparams.h>
8 #include <consensus/activation.h>
9 #include <key_io.h> // For DecodeDestination
10 #include <util/system.h>
11 #include <validation.h> // For VersionBitsBlockState
12 
16 static constexpr int MINER_FUND_RATIO = 8;
17 
18 Amount GetMinerFundAmount(const Amount &coinbaseValue) {
19  return MINER_FUND_RATIO * coinbaseValue / 100;
20 }
21 
22 static CTxDestination BuildDestination(const std::string &dest) {
23  const auto mainNetParams = CreateChainParams(CBaseChainParams::MAIN);
24  return DecodeDestination(dest, *mainNetParams);
25 }
26 
28  static CTxDestination dest =
29  BuildDestination("pqnqv9lt7e5vjyp0w88zf2af0l92l8rxdgnlxww9j9");
30  return dest;
31 }
32 
33 std::vector<CTxDestination>
35  const CBlockIndex *pindexPrev) {
36  if (!gArgs.GetBoolArg("-enableminerfund", params.enableMinerFund)) {
37  return {};
38  }
39 
40  if (!IsAxionEnabled(params, pindexPrev)) {
41  return {};
42  }
43 
44  return {GetMinerFundDestination()};
45 }
bool IsAxionEnabled(const Consensus::Params &params, const CBlockIndex *pindexPrev)
Check if November 15th, 2020 protocol upgrade has activated.
Definition: activation.cpp:78
static CTxDestination BuildDestination(const std::string &dest)
Definition: minerfund.cpp:22
Definition: amount.h:17
static const CTxDestination & GetMinerFundDestination()
Definition: minerfund.cpp:27
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: system.cpp:498
static const std::string MAIN
BIP70 chain name strings (main, test or regtest)
bool enableMinerFund
Enable or disable the miner fund by default.
Definition: params.h:97
static constexpr int MINER_FUND_RATIO
Percentage of the block reward to be sent to the fund.
Definition: minerfund.cpp:16
Amount GetMinerFundAmount(const Amount &coinbaseValue)
Definition: minerfund.cpp:18
std::unique_ptr< CChainParams > CreateChainParams(const std::string &chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
CTxDestination DecodeDestination(const std::string &addr, const CChainParams &params)
Definition: key_io.cpp:177
Parameters that influence chain consensus.
Definition: params.h:59
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: blockindex.h:23
ArgsManager gArgs
Definition: system.cpp:76
boost::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:87
std::vector< CTxDestination > GetMinerFundWhitelist(const Consensus::Params &params, const CBlockIndex *pindexPrev)
Definition: minerfund.cpp:34