Skip to content

Commit

Permalink
Merge PIVX-Project#700: [Wallet] Avoid autocombine getting stuck
Browse files Browse the repository at this point in the history
e846993 [Wallet] Avoid autocombine getting stuck (warrows)

Tree-SHA512: 1c9f7e4fc590bc73eb331d45bb79aa87a7c36e02ff8225f24cb3578b46bf674f1614f45ab4bf241190157eb471586e54aeb01f724da737dc9eee4b641729650e
  • Loading branch information
Mrs-X committed Aug 29, 2018
2 parents 29fab59 + e846993 commit a2d7170
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/wallet.cpp
Expand Up @@ -4090,6 +4090,7 @@ void CWallet::AutoCombineDust()
//coins are sectioned by address. This combination code only wants to combine inputs that belong to the same address
for (map<CBitcoinAddress, vector<COutput> >::iterator it = mapCoinsByAddress.begin(); it != mapCoinsByAddress.end(); it++) {
vector<COutput> vCoins, vRewardCoins;
bool maxSize = false;
vCoins = it->second;

// We don't want the tx to be refused for being too large
Expand Down Expand Up @@ -4117,8 +4118,10 @@ void CWallet::AutoCombineDust()

// Around 180 bytes per input. We use 190 to be certain
txSizeEstimate += 190;
if (txSizeEstimate >= MAX_STANDARD_TX_SIZE - 200)
if (txSizeEstimate >= MAX_STANDARD_TX_SIZE - 200) {
maxSize = true;
break;
}
}

//if no inputs found then return
Expand Down Expand Up @@ -4156,7 +4159,7 @@ void CWallet::AutoCombineDust()
}

//we don't combine below the threshold unless the fees are 0 to avoid paying fees over fees over fees
if (nTotalRewardsValue < nAutoCombineThreshold * COIN && nFeeRet > 0)
if (!maxSize && nTotalRewardsValue < nAutoCombineThreshold * COIN && nFeeRet > 0)
continue;

if (!CommitTransaction(wtx, keyChange)) {
Expand Down

0 comments on commit a2d7170

Please sign in to comment.