src/masternode-payments.cpp
/**
*   FillBlockPayee
*
*   Fill Masternode ONLY payment block
*/
FillBlockPayee
Fill Masternode ONLY payment block
FillBlockPayee Fill Masternode ONLY payment block
void CMasternodePayments::FillBlockPayee(CMutableTransaction& txNew, int nBlockHeight,  CAmount &blockReward, CAmount &fees, CTxOut& txoutMasternodeRet) const
{
    txoutMasternodeRet = CTxOut();
	const CAmount &nHalfFee = fees / 2;
    CScript payee;
	int nStartHeightBlock = 0;
    if(!GetBlockPayee(nBlockHeight, payee, nStartHeightBlock)) {
        int nCount = 0;
        masternode_info_t mnInfo;
        if(!mnodeman.GetNextMasternodeInQueueForPayment(nBlockHeight, true, nCount, mnInfo)) {
            LogPrintf("CMasternodePayments::FillBlockPayee -- Failed to detect masternode to pay\n");
            return;
        }
        payee = GetScriptForDestination(mnInfo.pubKeyCollateralAddress.GetID());
		nStartHeightBlock = 0;
    }
    CAmount nTotalReward;
    CAmount nMasternodeReward = GetBlockSubsidy(nBlockHeight, Params().GetConsensus(), nTotalReward, false, true, nStartHeightBlock);
    blockReward = nTotalReward - nMasternodeReward;
	txNew.vout[0].nValue = blockReward;
	if (nBlockHeight >= Params().GetConsensus().nShareFeeBlock)
		txNew.vout[0].nValue += nHalfFee;
    txoutMasternodeRet = CTxOut(nMasternodeReward, payee);
	if (nBlockHeight >= Params().GetConsensus().nShareFeeBlock)
		txoutMasternodeRet.nValue += nHalfFee;
    txNew.vout.push_back(txoutMasternodeRet);
    CTxDestination address1;
    ExtractDestination(payee, address1);
    CMartkistAddress address2(address1);
    LogPrintf("CMasternodePayments::FillBlockPayee -- Masternode payment %lld to %s\n", nMasternodeReward, address2.ToString());
}
void CMasternodePayments :: FillBlockPayee ( CMutableTransaction & txNew , int nBlockHeight , CAmount & blockReward , CAmount & fees , CTxOut & txoutMasternodeRet ) const { txoutMasternodeRet = CTxOut ( ) ; const CAmount & nHalfFee = fees / 2 ; CScript payee ; int nStartHeightBlock = 0 ; if ( ! GetBlockPayee ( nBlockHeight , payee , nStartHeightBlock ) ) { int nCount = 0 ; masternode_info_t mnInfo ; if ( ! mnodeman . GetNextMasternodeInQueueForPayment ( nBlockHeight , true , nCount , mnInfo ) ) { LogPrintf ( " \n " ) ; return ; } payee = GetScriptForDestination ( mnInfo . pubKeyCollateralAddress . GetID ( ) ) ; nStartHeightBlock = 0 ; } CAmount nTotalReward ; CAmount nMasternodeReward = GetBlockSubsidy ( nBlockHeight , Params ( ) . GetConsensus ( ) , nTotalReward , false , true , nStartHeightBlock ) ; blockReward = nTotalReward - nMasternodeReward ; txNew . vout [ 0 ] . nValue = blockReward ; if ( nBlockHeight >= Params ( ) . GetConsensus ( ) . nShareFeeBlock ) txNew . vout [ 0 ] . nValue += nHalfFee ; txoutMasternodeRet = CTxOut ( nMasternodeReward , payee ) ; if ( nBlockHeight >= Params ( ) . GetConsensus ( ) . nShareFeeBlock ) txoutMasternodeRet . nValue += nHalfFee ; txNew . vout . push_back ( txoutMasternodeRet ) ; CTxDestination address1 ; ExtractDestination ( payee , address1 ) ; CMartkistAddress address2 ( address1 ) ; LogPrintf ( " \n " , nMasternodeReward , address2 . ToString ( ) ) ; }
FillBlockPayee
Fill Masternode ONLY payment block
FillBlockPayee Fill Masternode ONLY payment block
// make sure it's not filled yet // no masternode detected... // ...and we can't calculate it on our own // fill payee with locally calculated winner and hope for the best