@@ -2448,6 +2448,11 @@ bool CWallet::AvailableCoins(std::vector<COutput>* pCoins, // --> populates
24482448 for (unsigned int i = 0 ; i < pcoin->tx ->vout .size (); i++) {
24492449 const auto & output = pcoin->tx ->vout [i];
24502450
2451+ // Filter by value if needed
2452+ if (coinsFilter.nMaxOutValue > 0 && output.nValue > coinsFilter.nMaxOutValue ) {
2453+ continue ;
2454+ }
2455+
24512456 // Filter by specific destinations if needed
24522457 if (coinsFilter.onlyFilteredDest && !coinsFilter.onlyFilteredDest ->empty ()) {
24532458 CTxDestination address;
@@ -2486,26 +2491,27 @@ std::map<CTxDestination , std::vector<COutput> > CWallet::AvailableCoinsByAddres
24862491 coinFilter.fIncludeColdStaking = true ;
24872492 coinFilter.fOnlyConfirmed = fConfirmed ;
24882493 coinFilter.fIncludeColdStaking = fIncludeColdStaking ;
2494+ coinFilter.nMaxOutValue = maxCoinValue;
24892495 std::vector<COutput> vCoins;
2490- // include cold
24912496 AvailableCoins (&vCoins, nullptr , coinFilter);
24922497
24932498 std::map<CTxDestination, std::vector<COutput> > mapCoins;
2494- for (COutput& out : vCoins) {
2495- if (maxCoinValue > 0 && out.tx ->tx ->vout [out.i ].nValue > maxCoinValue)
2496- continue ;
2497-
2499+ for (const COutput& out : vCoins) {
24982500 CTxDestination address;
24992501 bool fColdStakeAddr = false ;
25002502 if (!ExtractDestination (out.tx ->tx ->vout [out.i ].scriptPubKey , address, fColdStakeAddr )) {
2503+ bool isP2CS = out.tx ->tx ->vout [out.i ].scriptPubKey .IsPayToColdStaking ();
2504+ if (isP2CS && !fIncludeColdStaking ) {
2505+ // It must never happen as the coin filtering process shouldn't had added the P2CS in the first place
2506+ assert (false );
2507+ }
25012508 // if this is a P2CS we don't have the owner key - check if we have the staking key
25022509 fColdStakeAddr = true ;
2503- if ( !out.tx ->tx ->vout [out.i ].scriptPubKey .IsPayToColdStaking () ||
2504- !ExtractDestination (out.tx ->tx ->vout [out.i ].scriptPubKey , address, fColdStakeAddr ) )
2510+ if (!isP2CS || !ExtractDestination (out.tx ->tx ->vout [out.i ].scriptPubKey , address, fColdStakeAddr ) )
25052511 continue ;
25062512 }
25072513
2508- mapCoins[address].push_back (out);
2514+ mapCoins[address].emplace_back (out);
25092515 }
25102516
25112517 return mapCoins;
@@ -3207,7 +3213,7 @@ std::string CWallet::CommitResult::ToString() const
32073213
32083214CWallet::CommitResult CWallet::CommitTransaction (CTransactionRef tx, CReserveKey& opReservekey, CConnman* connman)
32093215{
3210- return CommitTransaction (tx , &opReservekey, connman);
3216+ return CommitTransaction (std::move (tx) , &opReservekey, connman);
32113217}
32123218
32133219/* *
0 commit comments