Better error message when sending to both sprout and sapling

Co-authored-by mdr0id <marshall@z.cash>
This commit is contained in:
Eirik Ogilvie-Wigley
2018-10-12 14:12:21 -06:00
parent 807fb7497f
commit 0917c84d9a
2 changed files with 27 additions and 0 deletions

View File

@@ -3687,6 +3687,9 @@ UniValue z_sendmany(const UniValue& params, bool fHelp)
std::vector<SendManyRecipient> zaddrRecipients;
CAmount nTotalOut = 0;
bool containsSproutOutput = false;
bool containsSaplingOutput = false;
for (const UniValue& o : outputs.getValues()) {
if (!o.isObject())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected object");
@@ -3710,6 +3713,16 @@ UniValue z_sendmany(const UniValue& params, bool fHelp)
bool toSprout = !toSapling;
noSproutAddrs = noSproutAddrs && toSapling;
containsSproutOutput |= toSprout;
containsSaplingOutput |= toSapling;
// Sending to both Sprout and Sapling is currently unsupported using z_sendmany
if (containsSproutOutput && containsSaplingOutput) {
throw JSONRPCError(
RPC_INVALID_PARAMETER,
"Cannot send to both Sprout and Sapling addresses using z_sendmany");
}
// If we are sending from a shielded address, all recipient
// shielded addresses must be of the same type.
if (fromSprout && toSapling) {