Bitcoin ABC  0.24.7
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 #include <validation.h> // For VersionBitsBlockState
13 
17 static constexpr int MINER_FUND_RATIO = 8;
18 
19 Amount GetMinerFundAmount(const Amount &coinbaseValue) {
20  return MINER_FUND_RATIO * coinbaseValue / 100;
21 }
22 
23 static CTxDestination BuildDestination(const std::string &dest) {
24  const auto mainNetParams = CreateChainParams(CBaseChainParams::MAIN);
25  return DecodeDestination(dest, *mainNetParams);
26 }
27 
29  static const std::string ecashMinerFund =
30  "ecash:pqnqv9lt7e5vjyp0w88zf2af0l92l8rxdg2jj94l5j";
31  static const std::string bitcoinCashMinerFund =
32  "bitcoincash:pqnqv9lt7e5vjyp0w88zf2af0l92l8rxdgnlxww9j9";
33  static CTxDestination dest = BuildDestination(
34  gArgs.GetBoolArg("-ecash", DEFAULT_ECASH) ? ecashMinerFund
35  : bitcoinCashMinerFund);
36  return dest;
37 }
38 
39 std::vector<CTxDestination>
41  const CBlockIndex *pindexPrev) {
42  if (!gArgs.GetBoolArg("-enableminerfund", params.enableMinerFund)) {
43  return {};
44  }
45 
46  if (!IsAxionEnabled(params, pindexPrev)) {
47  return {};
48  }
49 
50  return {GetMinerFundDestination()};
51 }
ArgsManager::GetBoolArg
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Definition: system.cpp:517
MINER_FUND_RATIO
static constexpr int MINER_FUND_RATIO
Percentage of the block reward to be sent to the fund.
Definition: minerfund.cpp:17
key_io.h
chainparams.h
validation.h
GetMinerFundDestination
static const CTxDestination & GetMinerFundDestination()
Definition: minerfund.cpp:28
Consensus::Params
Parameters that influence chain consensus.
Definition: params.h:59
activation.h
CreateChainParams
std::unique_ptr< CChainParams > CreateChainParams(const std::string &chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
Definition: chainparams.cpp:513
Amount
Definition: amount.h:19
CBaseChainParams::MAIN
static const std::string MAIN
BIP70 chain name strings (main, test or regtest)
Definition: chainparamsbase.h:21
IsAxionEnabled
bool IsAxionEnabled(const Consensus::Params &params, const CBlockIndex *pindexPrev)
Check if November 15th, 2020 protocol upgrade has activated.
Definition: activation.cpp:78
system.h
currencyunit.h
gArgs
ArgsManager gArgs
Definition: system.cpp:75
GetMinerFundAmount
Amount GetMinerFundAmount(const Amount &coinbaseValue)
Definition: minerfund.cpp:19
DEFAULT_ECASH
constexpr bool DEFAULT_ECASH
Definition: currencyunit.h:10
minerfund.h
GetMinerFundWhitelist
std::vector< CTxDestination > GetMinerFundWhitelist(const Consensus::Params &params, const CBlockIndex *pindexPrev)
Definition: minerfund.cpp:40
CBlockIndex
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: blockindex.h:23
DecodeDestination
CTxDestination DecodeDestination(const std::string &addr, const CChainParams &params)
Definition: key_io.cpp:177
Consensus::Params::enableMinerFund
bool enableMinerFund
Enable or disable the miner fund by default.
Definition: params.h:101
BuildDestination
static CTxDestination BuildDestination(const std::string &dest)
Definition: minerfund.cpp:23
CTxDestination
boost::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:132