Skip to content

Commit

Permalink
optimizeutxoset fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
backpacker69 authored and lateminer committed Jan 7, 2024
1 parent daebfc0 commit cc3571e
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/wallet/rpc/spend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,18 +392,15 @@ RPCHelpMan optimizeutxoset()
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Blackcoin address: ") + request.params[3].get_str());
}

auto available_coins = AvailableCoins(*pwallet, &coin_control);
std::vector<COutput> coins = available_coins.All();
for (const COutput& out : coins) {
ExtractDestination(out.txout.scriptPubKey, tmpAddress);
if (tmpAddress == fromAddress) {
if (tmpAddress == dest && out.txout.nValue == amount)
continue;
std::vector<COutput> vAvailableCoins = AvailableCoins(*pwallet, &coin_control).All();
for (const COutput& out : vAvailableCoins) {
const CScript& scriptPubKey = out.txout.scriptPubKey;
bool fValidAddress = ExtractDestination(scriptPubKey, tmpAddress);
if (fValidAddress && (tmpAddress == fromAddress)) {
coin_control.Select(out.outpoint);
availableCoins += out.txout.nValue;
}
}

coin_control.m_allow_other_inputs = false;
} else {
const auto bal = GetBalance(*pwallet);
Expand Down

0 comments on commit cc3571e

Please sign in to comment.