Skip to content

Commit 6b41197

Browse files
committed
bitcoin_functional working
1 parent d1ccd89 commit 6b41197

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

src/wallet/coinselection.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ bool KnapsackSolver(const CAmountMap& mapTargetValue, std::vector<OutputGroup>&
232232
}
233233

234234
// Get output groups that only contain this asset.
235+
// We consider that groups will almost always be of one asset entirely.
235236
for (OutputGroup g : groups) {
236237
bool add = true;
237238
for (CInputCoin c : g.m_outputs) {
@@ -253,8 +254,7 @@ bool KnapsackSolver(const CAmountMap& mapTargetValue, std::vector<OutputGroup>&
253254
}
254255

255256
CAmount outValue;
256-
bool ret = KnapsackSolver(it->second, asset_groups, asset_coinsret, outValue);
257-
if (!ret) {
257+
if (!KnapsackSolver(it->second, asset_groups, asset_coinsret, outValue)) {
258258
return false;
259259
}
260260
mapValueRet[it->first] = outValue;

src/wallet/rpcwallet.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,9 @@ UniValue AmountMapToUniv(const CAmountMap& balance, std::string strasset)
120120
asset = policyAsset;
121121
}
122122

123-
// The code below circumvents the const constraint that prevents the line below.
124-
//return ValueFromAmount(balance[asset]);
125-
for(std::map<CAsset, CAmount>::const_iterator it = balance.begin(); it != balance.end(); ++it) {
126-
if (it->first == asset) {
127-
return ValueFromAmount(it->second);
128-
}
123+
std::map<CAsset, CAmount>::const_iterator it = balance.find(asset);
124+
if (it != balance.end()) {
125+
return ValueFromAmount(it->second);
129126
}
130127
return ValueFromAmount(0);
131128
}

src/wallet/wallet.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2449,7 +2449,7 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm
24492449
if (pcoin->tx->vout.size() <= outpoint.n)
24502450
return false;
24512451
// Just to calculate the marginal byte size
2452-
mapValueFromPresetInputs[pcoin->GetOutputAsset(outpoint.n)] += pcoin->tx->vout[outpoint.n].nValue.GetAmount();
2452+
mapValueFromPresetInputs[pcoin->GetOutputAsset(outpoint.n)] += pcoin->GetOutputValueOut(outpoint.n);
24532453
setPresetCoins.insert(CInputCoin(pcoin->tx, outpoint.n));
24542454
} else
24552455
return false; // TODO: Allow non-wallet inputs
@@ -2478,8 +2478,7 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm
24782478
size_t max_descendants = (size_t)std::max<int64_t>(1, gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT));
24792479
bool fRejectLongChains = gArgs.GetBoolArg("-walletrejectlongchains", DEFAULT_WALLET_REJECT_LONG_CHAINS);
24802480

2481-
CAmountMap mapTargetMinusPreset = mapTargetValue;
2482-
mapTargetMinusPreset -= mapValueFromPresetInputs;
2481+
CAmountMap mapTargetMinusPreset = mapTargetValue - mapValueFromPresetInputs;
24832482

24842483
bool res = mapTargetValue <= mapValueFromPresetInputs ||
24852484
SelectCoinsMinConf(mapTargetMinusPreset, CoinEligibilityFilter(1, 6, 0), groups, setCoinsRet, mapValueRet, coin_selection_params, bnb_used) ||

0 commit comments

Comments
 (0)