Bitcoin Forum
May 03, 2024, 09:20:20 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: 4615



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 ??
1714771220
Hero Member
*
Offline Offline

Posts: 1714771220

View Profile Personal Message (Offline)

Ignore
1714771220
Reply with quote  #2

1714771220
Report to moderator
1714771220
Hero Member
*
Offline Offline

Posts: 1714771220

View Profile Personal Message (Offline)

Ignore
1714771220
Reply with quote  #2

1714771220
Report to moderator
1714771220
Hero Member
*
Offline Offline

Posts: 1714771220

View Profile Personal Message (Offline)

Ignore
1714771220
Reply with quote  #2

1714771220
Report to moderator
There are several different types of Bitcoin clients. The most secure are full nodes like Bitcoin Core, which will follow the rules of the network no matter what miners do. Even if every miner decided to create 1000 bitcoins per block, full nodes would stick to the rules and reject those blocks.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714771220
Hero Member
*
Offline Offline

Posts: 1714771220

View Profile Personal Message (Offline)

Ignore
1714771220
Reply with quote  #2

1714771220
Report to moderator
gmaxwell
Moderator
Legendary
*
expert
Offline Offline

Activity: 4158
Merit: 8382



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: 4615



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!