Skip to content

Commit da65c20

Browse files
committed
fixup: for wallet dust combiner
1 parent 7957600 commit da65c20

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

divi/src/CoinControlSelectionAlgorithm.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#include <CoinControlSelectionAlgorithm.h>
22
#include <coincontrol.h>
3+
#include <wallet.h>
34
#include <WalletTx.h>
45

56
CoinControlSelectionAlgorithm::CoinControlSelectionAlgorithm(
6-
const CCoinControl* coinControl
7-
): coinControl_(coinControl)
7+
const CCoinControl* coinControl,
8+
const CWallet& wallet
9+
): coinControl_(coinControl), wallet_(wallet)
810
{
911
}
1012

@@ -20,7 +22,7 @@ std::set<COutput> CoinControlSelectionAlgorithm::SelectCoins(
2022
for(const COutput& out: vCoins)
2123
{
2224
if (!out.fSpendable ||
23-
(!coinControl_->fAllowOtherInputs && !coinControl_->IsSelected(out.tx->GetHash(),out.i)))
25+
(!coinControl_->fAllowOtherInputs && !coinControl_->IsSelected(wallet_.GetUtxoHash(*out.tx),out.i)))
2426
{
2527
continue;
2628
}
@@ -31,4 +33,4 @@ std::set<COutput> CoinControlSelectionAlgorithm::SelectCoins(
3133
}
3234
fees = totalInputs - transactionToSelectCoinsFor.GetValueOut();
3335
return setCoinsRet;
34-
}
36+
}

divi/src/CoinControlSelectionAlgorithm.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22
#define COIN_CONTROL_COIN_SELECTOR_H
33
#include <I_CoinSelectionAlgorithm.h>
44
class CCoinControl;
5+
class CWallet;
56
class CoinControlSelectionAlgorithm: public I_CoinSelectionAlgorithm
67
{
78
private:
89
const CCoinControl* coinControl_;
10+
const CWallet& wallet_;
911
public:
10-
CoinControlSelectionAlgorithm(
11-
const CCoinControl* coinControl);
12+
explicit CoinControlSelectionAlgorithm(
13+
const CCoinControl* coinControl,
14+
const CWallet& wallet);
1215
virtual std::set<COutput> SelectCoins(
1316
const CMutableTransaction& transactionToSelectCoinsFor,
1417
const std::vector<COutput>& vCoins,
1518
CAmount& fees) const;
1619
};
17-
#endif// COIN_CONTROL_COIN_SELECTOR_H
20+
#endif// COIN_CONTROL_COIN_SELECTOR_H

divi/src/walletdustcombiner.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void WalletDustCombiner::CombineDust(CAmount combineThreshold)
6969
if (out.Value() > combineThreshold * COIN)
7070
continue;
7171

72-
COutPoint outpt(out.tx->GetHash(), out.i);
72+
COutPoint outpt(wallet_.GetUtxoHash(*out.tx), out.i);
7373
coinControl->Select(outpt);
7474
coinsToCombine.push_back(out);
7575
nTotalRewardsValue += out.Value();
@@ -92,7 +92,7 @@ void WalletDustCombiner::CombineDust(CAmount combineThreshold)
9292
CWalletTx wtx;
9393
std::pair<std::string,bool> txCreationResult;
9494
{
95-
CoinControlSelectionAlgorithm coinSelectionAlgorithm(coinControl);
95+
CoinControlSelectionAlgorithm coinSelectionAlgorithm(coinControl, wallet_);
9696
txCreationResult = wallet_.SendMoney(vecSend, wtx, ALL_SPENDABLE_COINS,&coinSelectionAlgorithm);
9797
}
9898
delete coinControl;
@@ -115,4 +115,4 @@ void combineWalletDust(const Settings& settings)
115115
settings.GetArg("-combinethreshold",std::numeric_limits<int64_t>::max() ) );
116116
}
117117
}
118-
}
118+
}

0 commit comments

Comments
 (0)