Skip to content

Commit 10426c7

Browse files
committed
[Wallet] Increase fee margin to up to 10% of autocombine send
1 parent 4c01ba6 commit 10426c7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/wallet.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4003,6 +4003,8 @@ void CWallet::AutoCombineDust()
40034003
CCoinControl* coinControl = new CCoinControl();
40044004
CAmount nTotalRewardsValue = 0;
40054005
BOOST_FOREACH (const COutput& out, vCoins) {
4006+
if (!out.fSpendable)
4007+
continue;
40064008
//no coins should get this far if they dont have proper maturity, this is double checking
40074009
if (out.tx->IsCoinStake() && out.tx->GetDepthInMainChain() < COINBASE_MATURITY + 1)
40084010
continue;
@@ -4040,10 +4042,8 @@ void CWallet::AutoCombineDust()
40404042
string strErr;
40414043
CAmount nFeeRet = 0;
40424044

4043-
//get the fee amount
4044-
CWalletTx wtxdummy;
4045-
CreateTransaction(vecSend, wtxdummy, keyChange, nFeeRet, strErr, coinControl, ALL_COINS, false, CAmount(0));
4046-
vecSend[0].second = nTotalRewardsValue - nFeeRet - 500;
4045+
// 10% safety margin to avoid "Insufficient funds" errors
4046+
vecSend[0].second = nTotalRewardsValue - (nTotalRewardsValue / 10);
40474047

40484048
if (!CreateTransaction(vecSend, wtx, keyChange, nFeeRet, strErr, coinControl, ALL_COINS, false, CAmount(0))) {
40494049
LogPrintf("AutoCombineDust createtransaction failed, reason: %s\n", strErr);

0 commit comments

Comments
 (0)