Skip to content

Commit 8dfd8c6

Browse files
cozzlaanwj
authored andcommitted
pass nBytes as parameter to GetMinFee(..)
1 parent 6ad44f5 commit 8dfd8c6

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

src/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -599,12 +599,11 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state)
599599
return true;
600600
}
601601

602-
int64_t GetMinFee(const CTransaction& tx, bool fAllowFree, enum GetMinFee_mode mode)
602+
int64_t GetMinFee(const CTransaction& tx, unsigned int nBytes, bool fAllowFree, enum GetMinFee_mode mode)
603603
{
604604
// Base fee is either nMinTxFee or nMinRelayTxFee
605605
int64_t nBaseFee = (mode == GMF_RELAY) ? tx.nMinRelayTxFee : tx.nMinTxFee;
606606

607-
unsigned int nBytes = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
608607
int64_t nMinFee = (1 + (int64_t)nBytes / 1000) * nBaseFee;
609608

610609
if (fAllowFree)
@@ -740,7 +739,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
740739
unsigned int nSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
741740

742741
// Don't accept it if it can't get into a block
743-
int64_t txMinFee = GetMinFee(tx, true, GMF_RELAY);
742+
int64_t txMinFee = GetMinFee(tx, nSize, true, GMF_RELAY);
744743
if (fLimitFree && nFees < txMinFee)
745744
return state.DoS(0, error("AcceptToMemoryPool : not enough fees %s, %"PRId64" < %"PRId64,
746745
hash.ToString().c_str(), nFees, txMinFee),

src/main.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ enum GetMinFee_mode
258258
GMF_SEND,
259259
};
260260

261-
int64_t GetMinFee(const CTransaction& tx, bool fAllowFree, enum GetMinFee_mode mode);
261+
int64_t GetMinFee(const CTransaction& tx, unsigned int nBytes, bool fAllowFree, enum GetMinFee_mode mode);
262262

263263
//
264264
// Check transaction inputs, and make sure any

src/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,7 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
13341334
// Check that enough fee is included
13351335
int64_t nPayFee = nTransactionFee * (1 + (int64_t)nBytes / 1000);
13361336
bool fAllowFree = AllowFree(dPriority);
1337-
int64_t nMinFee = GetMinFee(wtxNew, fAllowFree, GMF_SEND);
1337+
int64_t nMinFee = GetMinFee(wtxNew, nBytes, fAllowFree, GMF_SEND);
13381338
if (nFeeRet < max(nPayFee, nMinFee))
13391339
{
13401340
nFeeRet = max(nPayFee, nMinFee);

0 commit comments

Comments
 (0)