From 7e3ce02d876705228ec95d728e63772babbcba60 Mon Sep 17 00:00:00 2001 From: Duke Date: Fri, 22 Aug 2025 06:16:25 -0400 Subject: [PATCH] Bring back sorting notes descending by value which was in find_unspent_notes() --- src/wallet/rpcwallet.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 482d2997b..859349052 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5286,6 +5286,13 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) // find all unspent and unlocked notes in this zaddr pwalletMain->GetFilteredNotes(saplingEntries, fromaddress); + // sort notes from largest to smallest, which means + // we will spend the largest first + std::sort(saplingEntries.begin(), saplingEntries.end(), + [](SaplingNoteEntry i, SaplingNoteEntry j) -> bool { + return i.note.value() > j.note.value(); + }); + CAmount total_value = 0; std::vector saplingNoteInputs;