From 7c02acc5b64e8ef51517331682603d1ed9fe342c Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 3 Sep 2018 01:28:31 +0100 Subject: [PATCH] Minor cleanups --- src/wallet/asyncrpcoperation_sendmany.cpp | 16 ++++++++++------ src/wallet/rpcwallet.cpp | 20 +++++++++----------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index 780b30ea1..d37614dbe 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -240,6 +240,9 @@ bool AsyncRPCOperation_sendmany::main_impl() { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds, no unspent notes found for zaddr from address."); } + // At least one of z_sprout_inputs_ and z_sapling_inputs_ must be empty by design + assert(z_sprout_inputs_.empty() || z_sapling_inputs_.empty()); + CAmount t_inputs_total = 0; for (SendManyInputUTXO & t : t_inputs_) { t_inputs_total += std::get<2>(t); @@ -277,7 +280,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { if (isfromzaddr_ && (z_inputs_total < targetAmount)) { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, - strprintf("Insufficient protected funds, have %s, need %s", + strprintf("Insufficient shielded funds, have %s, need %s", FormatMoney(z_inputs_total), FormatMoney(targetAmount))); } @@ -598,7 +601,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { if (selectedUTXOCoinbase) { assert(isSingleZaddrOutput); throw JSONRPCError(RPC_WALLET_ERROR, strprintf( - "Change %s not allowed. When protecting coinbase funds, the wallet does not " + "Change %s not allowed. When shielding coinbase funds, the wallet does not " "allow any change as there is currently no way to specify a change address " "in z_sendmany.", FormatMoney(change))); } else { @@ -1081,12 +1084,13 @@ bool AsyncRPCOperation_sendmany::find_unspent_notes() { } // sort in descending order, so big notes appear first - std::sort(z_sprout_inputs_.begin(), z_sprout_inputs_.end(), [](SendManyInputJSOP i, SendManyInputJSOP j) -> bool { - return ( std::get<2>(i) > std::get<2>(j)); - }); + std::sort(z_sprout_inputs_.begin(), z_sprout_inputs_.end(), + [](SendManyInputJSOP i, SendManyInputJSOP j) -> bool { + return std::get<2>(i) > std::get<2>(j); + }); std::sort(z_sapling_inputs_.begin(), z_sapling_inputs_.end(), [](SaplingNoteEntry i, SaplingNoteEntry j) -> bool { - return ( i.note.value() > j.note.value()); + return i.note.value() > j.note.value(); }); return true; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 89719aa2d..c090a8234 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3672,17 +3672,15 @@ UniValue z_sendmany(const UniValue& params, bool fHelp) // If we are sending from a shielded address, all recipient // shielded addresses must be of the same type. - if (!fromTaddr) { - if (fromSprout && toSapling) { - throw JSONRPCError( - RPC_INVALID_PARAMETER, - "Cannot send from a Sprout address to a Sapling address using z_sendmany"); - } - if (fromSapling && toSprout) { - throw JSONRPCError( - RPC_INVALID_PARAMETER, - "Cannot send from a Sapling address to a Sprout address using z_sendmany"); - } + if (fromSprout && toSapling) { + throw JSONRPCError( + RPC_INVALID_PARAMETER, + "Cannot send from a Sprout address to a Sapling address using z_sendmany"); + } + if (fromSapling && toSprout) { + throw JSONRPCError( + RPC_INVALID_PARAMETER, + "Cannot send from a Sapling address to a Sprout address using z_sendmany"); } } else { throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, unknown address format: ")+address );