Minor cleanups

This commit is contained in:
Jack Grigg
2018-09-03 01:28:31 +01:00
parent 1ec06e93b1
commit 7c02acc5b6
2 changed files with 19 additions and 17 deletions

View File

@@ -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."); 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; CAmount t_inputs_total = 0;
for (SendManyInputUTXO & t : t_inputs_) { for (SendManyInputUTXO & t : t_inputs_) {
t_inputs_total += std::get<2>(t); t_inputs_total += std::get<2>(t);
@@ -277,7 +280,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
if (isfromzaddr_ && (z_inputs_total < targetAmount)) { if (isfromzaddr_ && (z_inputs_total < targetAmount)) {
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, 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))); FormatMoney(z_inputs_total), FormatMoney(targetAmount)));
} }
@@ -598,7 +601,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
if (selectedUTXOCoinbase) { if (selectedUTXOCoinbase) {
assert(isSingleZaddrOutput); assert(isSingleZaddrOutput);
throw JSONRPCError(RPC_WALLET_ERROR, strprintf( 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 " "allow any change as there is currently no way to specify a change address "
"in z_sendmany.", FormatMoney(change))); "in z_sendmany.", FormatMoney(change)));
} else { } else {
@@ -1081,12 +1084,13 @@ bool AsyncRPCOperation_sendmany::find_unspent_notes() {
} }
// sort in descending order, so big notes appear first // sort in descending order, so big notes appear first
std::sort(z_sprout_inputs_.begin(), z_sprout_inputs_.end(), [](SendManyInputJSOP i, SendManyInputJSOP j) -> bool { std::sort(z_sprout_inputs_.begin(), z_sprout_inputs_.end(),
return ( std::get<2>(i) > std::get<2>(j)); [](SendManyInputJSOP i, SendManyInputJSOP j) -> bool {
}); return std::get<2>(i) > std::get<2>(j);
});
std::sort(z_sapling_inputs_.begin(), z_sapling_inputs_.end(), std::sort(z_sapling_inputs_.begin(), z_sapling_inputs_.end(),
[](SaplingNoteEntry i, SaplingNoteEntry j) -> bool { [](SaplingNoteEntry i, SaplingNoteEntry j) -> bool {
return ( i.note.value() > j.note.value()); return i.note.value() > j.note.value();
}); });
return true; return true;

View File

@@ -3672,17 +3672,15 @@ UniValue z_sendmany(const UniValue& params, bool fHelp)
// If we are sending from a shielded address, all recipient // If we are sending from a shielded address, all recipient
// shielded addresses must be of the same type. // shielded addresses must be of the same type.
if (!fromTaddr) { if (fromSprout && toSapling) {
if (fromSprout && toSapling) { throw JSONRPCError(
throw JSONRPCError( RPC_INVALID_PARAMETER,
RPC_INVALID_PARAMETER, "Cannot send from a Sprout address to a Sapling address using z_sendmany");
"Cannot send from a Sprout address to a Sapling address using z_sendmany"); }
} if (fromSapling && toSprout) {
if (fromSapling && toSprout) { throw JSONRPCError(
throw JSONRPCError( RPC_INVALID_PARAMETER,
RPC_INVALID_PARAMETER, "Cannot send from a Sapling address to a Sprout address using z_sendmany");
"Cannot send from a Sapling address to a Sprout address using z_sendmany");
}
} }
} else { } else {
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, unknown address format: ")+address ); throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, unknown address format: ")+address );