fix z_listunspent includeWatchonly logic
This commit is contained in:
@@ -2535,14 +2535,14 @@ UniValue z_listunspent(const UniValue& params, bool fHelp)
|
|||||||
}
|
}
|
||||||
string address = o.get_str();
|
string address = o.get_str();
|
||||||
auto zaddr = DecodePaymentAddress(address);
|
auto zaddr = DecodePaymentAddress(address);
|
||||||
if (IsValidPaymentAddress(zaddr)) {
|
if (!IsValidPaymentAddress(zaddr)) {
|
||||||
auto hasSpendingKey = boost::apply_visitor(HaveSpendingKeyForPaymentAddress(pwalletMain), zaddr);
|
|
||||||
if (hasSpendingKey) {
|
|
||||||
zaddrs.insert(zaddr);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, address is not a valid zaddr: ") + address);
|
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, address is not a valid zaddr: ") + address);
|
||||||
}
|
}
|
||||||
|
auto hasSpendingKey = boost::apply_visitor(HaveSpendingKeyForPaymentAddress(pwalletMain), zaddr);
|
||||||
|
if (!fIncludeWatchonly && !hasSpendingKey) {
|
||||||
|
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, spending key for address does not belong to wallet: ") + address);
|
||||||
|
}
|
||||||
|
zaddrs.insert(zaddr);
|
||||||
|
|
||||||
if (setAddress.count(address)) {
|
if (setAddress.count(address)) {
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ") + address);
|
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ") + address);
|
||||||
|
|||||||
Reference in New Issue
Block a user