Bitcoin ABC  0.26.3
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 <currencyunit.h>
10 #include <key_io.h> // For DecodeDestination
11 #include <util/system.h>
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 
27 static const CTxDestination &
28 GetMinerFundDestination(const bool useAxionDestination) {
29  static const std::string ecashMinerFundAxion =
30  "ecash:pqnqv9lt7e5vjyp0w88zf2af0l92l8rxdg2jj94l5j";
31  static const std::string bitcoinCashMinerFundAxion =
32  "bitcoincash:pqnqv9lt7e5vjyp0w88zf2af0l92l8rxdgnlxww9j9";
33  static CTxDestination destAxion = BuildDestination(
34  gArgs.GetBoolArg("-ecash", DEFAULT_ECASH) ? ecashMinerFundAxion
35  : bitcoinCashMinerFundAxion);
36 
37  static const std::string ecashMinerFund =
38  "ecash:prfhcnyqnl5cgrnmlfmms675w93ld7mvvqd0y8lz07";
39  static const std::string bitcoinCashMinerFund =
40  "bitcoincash:prfhcnyqnl5cgrnmlfmms675w93ld7mvvq5zsvycff";
41  static CTxDestination dest = BuildDestination(
42  gArgs.GetBoolArg("-ecash", DEFAULT_ECASH) ? ecashMinerFund
43  : bitcoinCashMinerFund);
44 
45  return useAxionDestination ? destAxion : dest;
46 }
47 
48 std::vector<CTxDestination>
50  const CBlockIndex *pindexPrev) {
51  if (!gArgs.GetBoolArg("-enableminerfund", params.enableMinerFund)) {
52  return {};
53  }
54 
55  if (!IsAxionEnabled(params, pindexPrev)) {
56  return {};
57  }
58 
59  return {GetMinerFundDestination(!IsGluonEnabled(params, pindexPrev))};
60 }
static bool IsGluonEnabled(const Consensus::Params &params, int32_t nHeight)
Definition: activation.cpp:91
static bool IsAxionEnabled(const Consensus::Params &params, int32_t nHeight)
Definition: activation.cpp:78
std::unique_ptr< CChainParams > CreateChainParams(const std::string &chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: system.cpp:603
static const std::string MAIN
BIP70 chain name strings (main, test or regtest)
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: blockindex.h:23
constexpr bool DEFAULT_ECASH
Definition: currencyunit.h:10
CTxDestination DecodeDestination(const std::string &addr, const CChainParams &params)
Definition: key_io.cpp:177
std::vector< CTxDestination > GetMinerFundWhitelist(const Consensus::Params &params, const CBlockIndex *pindexPrev)
Definition: minerfund.cpp:49
static const CTxDestination & GetMinerFundDestination(const bool useAxionDestination)
Definition: minerfund.cpp:28
static CTxDestination BuildDestination(const std::string &dest)
Definition: minerfund.cpp:22
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
boost::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:93
Definition: amount.h:19
Parameters that influence chain consensus.
Definition: params.h:76
bool enableMinerFund
Enable or disable the miner fund by default.
Definition: params.h:118
ArgsManager gArgs
Definition: system.cpp:77