Bitcoin Forum
May 07, 2024, 06:42:10 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoin-Qt fee calculation. Explain this code for me?  (Read 1081 times)
DannyHamilton (OP)
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
May 16, 2013, 10:49:39 PM
 #1

Ok, I just did a pull from git, I'm looking at:
Code:
bool CWallet::CreateTransaction(const vector<pair<CScript, int64> >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet, std::string& strFailReason)
and I'm a bit confused.

I'm sure I must be overlooking something simple, but I just can't seem to see it.  Would someone here mind pointing out what I'm missing?

It is my understanding that the "fee per kilobyte" is only supposed to be enforced by the client when the total size of the transaction exceeds 10 kilobytes, is this right?

Code:
                int64 nPayFee = nTransactionFee * (1 + (int64)nBytes / 1000);
                bool fAllowFree = CTransaction::AllowFree(dPriority);
                int64 nMinFee = wtxNew.GetMinFee(1, fAllowFree, GMF_SEND);
                if (nFeeRet < max(nPayFee, nMinFee))
                {
                    nFeeRet = max(nPayFee, nMinFee);
                    continue;
                }

This code doesn't seem to have any sort of "if (int64)nBytes > 10240)" conditional?

It seems to set nPayFee to
Code:
nTransactionFee * (1 + (int64)nBytes / 1000)
regardless of the size of the transaction.

Then it sets:
Code:
nFeeRet = max(nPayFee, nMinFee);
which would seem to indicate that at a minimum the fee will always be nPayFee regardless of the size of the transaction.

Can someone please point out to me where in the code it tests for (int64)nBytes > 10240 ??
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
gmaxwell
Moderator
Legendary
*
expert
Offline Offline

Activity: 4158
Merit: 8411



View Profile WWW
May 16, 2013, 11:41:16 PM
 #2

It is my understanding that the "fee per kilobyte" is only supposed to be enforced by the client when the total size of the transaction exceeds 10 kilobytes, is this right?
The minimum anti-DOS fee per kb is only enforced for transactions which don't qualify as free (too small output, too large data, too low priority), but a _user configured_ fee per kilobyte applies to all transactions.
DannyHamilton (OP)
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
May 16, 2013, 11:55:17 PM
 #3

It is my understanding that the "fee per kilobyte" is only supposed to be enforced by the client when the total size of the transaction exceeds 10 kilobytes, is this right?
The minimum anti-DOS fee per kb is only enforced for transactions which don't qualify as free (too small output, too large data, too low priority), but a _user configured_ fee per kilobyte applies to all transactions.

Ah, ok.

So I have to look at GetMinFee to see the anti-DOS fee per kb.  Thanks. I'll check on it and open a new topic if I'm still confused.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!