Author

Topic: Does this code work for transaction fees? [NEWB] (Read 841 times)

sr. member
Activity: 366
Merit: 260
November 15, 2014, 03:31:59 PM
#2
Anyone? Should i post this in another section?
sr. member
Activity: 366
Merit: 260
I'm a newbie trying to modify wallet code of an altcoin, mimicking dogecoin's transaction fees, but it looks like they've made a lot of other changes in their code.

I think this is the only section i need to modify, along with the updated nMinRelayTxFee and nMinFee

.
.
.
yes? no?

Should this be in a different section?

Code:

/** Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) */
int64 CTransaction::nMinTxFee = 100000000;
/** Fees smaller than this (in satoshi) are considered zero fee (for relaying) */
int64 CTransaction::nMinRelayTxFee = 100000000;

int64 CTransaction::GetMinFee(unsigned int nBlockSize, bool fAllowFree,
                              enum GetMinFee_mode mode) const
{
    // Base fee is either nMinTxFee or nMinRelayTxFee
        int64 nBaseFee = (mode == GMF_RELAY) ? nMinRelayTxFee : nMinTxFee;

    unsigned int nBytes = ::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION);
    unsigned int nNewBlockSize = nBlockSize + nBytes;
    int64 nMinFee = (1 + (int64)nBytes / 1000) * nBaseFee;
   

    if (fAllowFree && mode != GMF_SEND)
    {
          // Free transaction area up to 10,000 bytes
         if (nBytes < 10000)
              nMinFee = 0;
    }

   
    // To limit dust spam, add nBaseFee for each output less than DUST_SOFT_LIMIT 11-14-14
    BOOST_FOREACH(const CTxOut& txout, vout)
        if (txout.nValue < DUST_SOFT_LIMIT)
nMinFee += nBaseFee;
       

    if (!MoneyRange(nMinFee))
        nMinFee = MAX_MONEY;
     
    return nMinFee;
}

Jump to: