diff --git a/src/miner.cpp b/src/miner.cpp index 387e891a53..1d1e8a3f7f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -150,7 +150,7 @@ bool TrySignClaim( // This is in anonymous namespace because it is only to be used by miner code here in this file. bool CreateMRCRewards(CBlock &blocknew, std::map>& mrc_map, - std::map& mrc_tx_map, uint32_t& claim_contract_version, + std::map& mrc_tx_map, CAmount& reward, uint32_t& claim_contract_version, GRC::Claim& claim, CWallet* pwallet) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { // For convenience @@ -160,7 +160,7 @@ bool CreateMRCRewards(CBlock &blocknew, std::map 0) { // TODO: Make foundation address a defaulted but protocol overridable parameter. @@ -287,7 +290,7 @@ bool CreateMRCRewards(CBlock &blocknew, std::map( @@ -1439,7 +1442,8 @@ void StakeMiner(CWallet *pwallet) // * Add MRC outputs to coinstake. This has to be done before the coinstake splitting/sidestaking, because // Some of the MRC fees go to the miner as part of the reward, and this affects the SplitCoinStakeOutput calculation. - if (!CreateMRCRewards(StakeBlock, mrc_map, mrc_tx_map, claim_contract_version, claim, pwallet)) continue; + // Note that nReward here now includes the mrc fees to the staker. + if (!CreateMRCRewards(StakeBlock, mrc_map, mrc_tx_map, nReward, claim_contract_version, claim, pwallet)) continue; g_timer.GetTimes(function + "CreateMRC", "miner"); @@ -1467,6 +1471,28 @@ void StakeMiner(CWallet *pwallet) g_miner_status.IncrementBlocksCreated(); + if (LogInstance().WillLogCategory(BCLog::LogFlags::VERBOSE)) { + COutPoint stake_prevout = StakeBlock.vtx[1].vin[0].prevout; + CTransaction stake_input; + ReadTxFromDisk(stake_input, stake_prevout); + + LogPrintf("INFO: %s: stake input = %s", + __func__, + FormatMoney(stake_input.vout[stake_prevout.n].nValue)); + + for (unsigned int i = 1; i < StakeBlock.vtx[1].vout.size(); ++i) { + CTxDestination destination; + + ExtractDestination(StakeBlock.vtx[1].vout[i].scriptPubKey, destination); + + LogPrintf("INFO: %s: stake output[%u] = %s, destination = %s", + __func__, + i, + FormatMoney(StakeBlock.vtx[1].vout[i].nValue), + CBitcoinAddress(destination).ToString()); + } + } + // * delegate to ProcessBlock if (!ProcessBlock(nullptr, &StakeBlock, true)) { error("%s: Block vehemently rejected", __func__); diff --git a/src/miner.h b/src/miner.h index c713a8de89..6e439c099a 100644 --- a/src/miner.h +++ b/src/miner.h @@ -31,6 +31,7 @@ bool GetStakeSplitStatusAndParams(int64_t& nMinStakeSplitValue, double& dEfficie bool CreateMRCRewards(CBlock &blocknew, std::map>& mrc_map, std::map& mrc_tx_map, + CAmount& reward, uint32_t& claim_contract_version, GRC::Claim& claim, CWallet* pwallet) EXCLUSIVE_LOCKS_REQUIRED(cs_main); diff --git a/src/test/gridcoin/mrc_tests.cpp b/src/test/gridcoin/mrc_tests.cpp index 779d957b3f..f80c5c4495 100644 --- a/src/test/gridcoin/mrc_tests.cpp +++ b/src/test/gridcoin/mrc_tests.cpp @@ -264,7 +264,7 @@ BOOST_AUTO_TEST_CASE(it_creates_valid_mrc_claims) BOOST_CHECK(CreateGridcoinReward(block, pindex->pprev, reward, claim)); - BOOST_CHECK(CreateMRCRewards(block, mrc_map, mrc_tx_map, claim_contract_version, claim, wallet)); + BOOST_CHECK(CreateMRCRewards(block, mrc_map, mrc_tx_map, reward, claim_contract_version, claim, wallet)); // TODO(div72): Separate this test into pieces and actually have it do // some useful testing by testing the validation logic against it.