aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/misc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rpc/misc.cpp')
-rw-r--r--src/rpc/misc.cpp66
1 files changed, 12 insertions, 54 deletions
diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp
index a1e39be64e..f7d62a6326 100644
--- a/src/rpc/misc.cpp
+++ b/src/rpc/misc.cpp
@@ -33,57 +33,6 @@
#include <univalue.h>
-class DescribeAddressVisitor : public boost::static_visitor<UniValue>
-{
-public:
- explicit DescribeAddressVisitor() {}
-
- UniValue operator()(const CNoDestination &dest) const { return UniValue(UniValue::VOBJ); }
-
- UniValue operator()(const CKeyID &keyID) const {
- UniValue obj(UniValue::VOBJ);
- obj.pushKV("isscript", false);
- obj.pushKV("iswitness", false);
- return obj;
- }
-
- UniValue operator()(const CScriptID &scriptID) const {
- UniValue obj(UniValue::VOBJ);
- obj.pushKV("isscript", true);
- obj.pushKV("iswitness", false);
- return obj;
- }
-
- UniValue operator()(const WitnessV0KeyHash& id) const
- {
- UniValue obj(UniValue::VOBJ);
- obj.pushKV("isscript", false);
- obj.pushKV("iswitness", true);
- obj.pushKV("witness_version", 0);
- obj.pushKV("witness_program", HexStr(id.begin(), id.end()));
- return obj;
- }
-
- UniValue operator()(const WitnessV0ScriptHash& id) const
- {
- UniValue obj(UniValue::VOBJ);
- obj.pushKV("isscript", true);
- obj.pushKV("iswitness", true);
- obj.pushKV("witness_version", 0);
- obj.pushKV("witness_program", HexStr(id.begin(), id.end()));
- return obj;
- }
-
- UniValue operator()(const WitnessUnknown& id) const
- {
- UniValue obj(UniValue::VOBJ);
- obj.pushKV("iswitness", true);
- obj.pushKV("witness_version", (int)id.version);
- obj.pushKV("witness_program", HexStr(id.program, id.program + id.length));
- return obj;
- }
-};
-
#ifdef ENABLE_WALLET
class DescribeWalletAddressVisitor : public boost::static_visitor<UniValue>
{
@@ -182,6 +131,15 @@ public:
UniValue operator()(const WitnessUnknown& id) const { return UniValue(UniValue::VOBJ); }
};
+
+UniValue DescribeWalletAddress(CWallet* pwallet, const CTxDestination& dest)
+{
+ UniValue ret(UniValue::VOBJ);
+ UniValue detail = DescribeAddress(dest);
+ ret.pushKVs(detail);
+ ret.pushKVs(boost::apply_visitor(DescribeWalletAddressVisitor(pwallet), dest));
+ return ret;
+}
#endif
UniValue validateaddress(const JSONRPCRequest& request)
@@ -254,10 +212,8 @@ UniValue validateaddress(const JSONRPCRequest& request)
isminetype mine = pwallet ? IsMine(*pwallet, dest) : ISMINE_NO;
ret.pushKV("ismine", bool(mine & ISMINE_SPENDABLE));
ret.pushKV("iswatchonly", bool(mine & ISMINE_WATCH_ONLY));
- UniValue detail = boost::apply_visitor(DescribeAddressVisitor(), dest);
+ UniValue detail = DescribeWalletAddress(pwallet, dest);
ret.pushKVs(detail);
- UniValue wallet_detail = boost::apply_visitor(DescribeWalletAddressVisitor(pwallet), dest);
- ret.pushKVs(wallet_detail);
if (pwallet && pwallet->mapAddressBook.count(dest)) {
ret.pushKV("account", pwallet->mapAddressBook[dest].name);
}
@@ -284,6 +240,8 @@ UniValue validateaddress(const JSONRPCRequest& request)
}
}
}
+#else
+ ret.pushKvs = DescribeAddress(dest);
#endif
}
return ret;