src/privatesend.cpp
// check to make sure the collateral provided by the client is valid
check to make sure the collateral provided by the client is valid
check to make sure the collateral provided by the client is valid
bool CPrivateSend::IsCollateralValid(const CTransaction& txCollateral)
{
    if(txCollateral.vout.empty()) return false;
    if(txCollateral.nLockTime != 0) return false;
    CAmount nValueIn = 0;
    CAmount nValueOut = 0;
    for (const auto& txout : txCollateral.vout) {
        nValueOut += txout.nValue;
        bool fAllowData = true;
        if(!txout.scriptPubKey.IsPayToPublicKeyHash() && !(fAllowData && txout.scriptPubKey.IsUnspendable())) {
            LogPrintf ("CPrivateSend::IsCollateralValid -- Invalid Script, txCollateral=%s", txCollateral.ToString());
            return false;
        }
    }
    for (const auto& txin : txCollateral.vin) {
        Coin coin;
        if(!GetUTXOCoin(txin.prevout, coin)) {
            LogPrint("privatesend", "CPrivateSend::IsCollateralValid -- Unknown inputs in collateral transaction, txCollateral=%s", txCollateral.ToString());
            return false;
        }
        nValueIn += coin.out.nValue;
    }
    if(nValueIn - nValueOut < GetCollateralAmount()) {
        LogPrint("privatesend", "CPrivateSend::IsCollateralValid -- did not include enough fees in transaction: fees: %d, txCollateral=%s", nValueOut - nValueIn, txCollateral.ToString());
        return false;
    }
    LogPrint("privatesend", "CPrivateSend::IsCollateralValid -- %s", txCollateral.ToString());
    {
        LOCK(cs_main);
        CValidationState validationState;
        if(!AcceptToMemoryPool(mempool, validationState, MakeTransactionRef(txCollateral), false, NULL, NULL, false, maxTxFee, true)) {
            LogPrint("privatesend", "CPrivateSend::IsCollateralValid -- didn't pass AcceptToMemoryPool()\n");
            return false;
        }
    }
    return true;
}
bool CPrivateSend :: IsCollateralValid ( const CTransaction & txCollateral ) { if ( txCollateral . vout . empty ( ) ) return false ; if ( txCollateral . nLockTime != 0 ) return false ; CAmount nValueIn = 0 ; CAmount nValueOut = 0 ; for ( const auto & txout : txCollateral . vout ) { nValueOut += txout . nValue ; bool fAllowData = true ; if ( ! txout . scriptPubKey . IsPayToPublicKeyHash ( ) && ! ( fAllowData && txout . scriptPubKey . IsUnspendable ( ) ) ) { LogPrintf ( " " , txCollateral . ToString ( ) ) ; return false ; } } for ( const auto & txin : txCollateral . vin ) { Coin coin ; if ( ! GetUTXOCoin ( txin . prevout , coin ) ) { LogPrint ( " " , " " , txCollateral . ToString ( ) ) ; return false ; } nValueIn += coin . out . nValue ; } if ( nValueIn - nValueOut < GetCollateralAmount ( ) ) { LogPrint ( " " , " " , nValueOut - nValueIn , txCollateral . ToString ( ) ) ; return false ; } LogPrint ( " " , " " , txCollateral . ToString ( ) ) ; { LOCK ( cs_main ) ; CValidationState validationState ; if ( ! AcceptToMemoryPool ( mempool , validationState , MakeTransactionRef ( txCollateral ) , false , NULL , NULL , false , maxTxFee , true ) ) { LogPrint ( " " , " \n " ) ; return false ; } } return true ; }
check to make sure the collateral provided by the client is valid
check to make sure the collateral provided by the client is valid
//collateral transactions are required to pay out a small fee to the miners