diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.cpp b/src/wallet/asyncrpcoperation_mergetoaddress.cpp index 6a16dd4fa..80968e01c 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.cpp +++ b/src/wallet/asyncrpcoperation_mergetoaddress.cpp @@ -82,8 +82,10 @@ AsyncRPCOperation_mergetoaddress::AsyncRPCOperation_mergetoaddress( auto address = DecodePaymentAddress(std::get<0>(recipient)); if (IsValidPaymentAddress(address)) { isToZaddr_ = true; - // TODO: Add Sapling support. For now, ensure we can later convert freely. - assert(boost::get(&address) != nullptr); + // TODO: Add Sapling support. For now, return an error to the user. + if (boost::get(&address) == nullptr) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Currently, only Sprout zaddrs are supported"); + } toPaymentAddress_ = address; } else { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid recipient address"); @@ -328,8 +330,10 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() // Copy zinputs to more flexible containers std::deque zInputsDeque; for (auto o : noteInputs_) { - // TODO: Add Sapling support. For now, ensure we can later convert freely. - assert(boost::get(&std::get<3>(o)) != nullptr); + // TODO: Add Sapling support. For now, return an error to the user. + if (boost::get(&std::get<3>(o)) == nullptr) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Currently, only Sprout zaddrs are supported"); + } zInputsDeque.push_back(o); } diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 81e2969d5..d507a3b1b 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -724,8 +724,10 @@ UniValue z_importviewingkey(const UniValue& params, bool fHelp) if (!IsValidViewingKey(viewingkey)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid viewing key"); } - // TODO: Add Sapling support. For now, ensure we can freely convert. - assert(boost::get(&viewingkey) != nullptr); + // TODO: Add Sapling support. For now, return an error to the user. + if (boost::get(&viewingkey) == nullptr) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Currently, only Sprout viewing keys are supported"); + } auto vkey = boost::get(viewingkey); auto addr = vkey.address(); @@ -824,8 +826,10 @@ UniValue z_exportviewingkey(const UniValue& params, bool fHelp) if (!IsValidPaymentAddress(address)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid zaddr"); } - // TODO: Add Sapling support. For now, ensure we can freely convert. - assert(boost::get(&address) != nullptr); + // TODO: Add Sapling support. For now, return an error to the user. + if (boost::get(&address) == nullptr) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Currently, only Sprout zaddrs are supported"); + } auto addr = boost::get(address); libzcash::SproutViewingKey vk;