Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/misc.cpp
Show All 16 Lines | |||||
#include "util.h" | #include "util.h" | ||||
#include "utilstrencodings.h" | #include "utilstrencodings.h" | ||||
#include "validation.h" | #include "validation.h" | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
#include "wallet/rpcwallet.h" | #include "wallet/rpcwallet.h" | ||||
#include "wallet/wallet.h" | #include "wallet/wallet.h" | ||||
#include "wallet/walletdb.h" | #include "wallet/walletdb.h" | ||||
#endif | #endif | ||||
#include "cashaddrenc.h" | |||||
#include "warnings.h" | #include "warnings.h" | ||||
#include <univalue.h> | #include <univalue.h> | ||||
#include <cstdint> | #include <cstdint> | ||||
#ifdef HAVE_MALLOC_INFO | #ifdef HAVE_MALLOC_INFO | ||||
#include <malloc.h> | #include <malloc.h> | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 196 Lines • ▼ Show 20 Lines | |||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
CWallet *const pwallet = GetWalletForJSONRPCRequest(request); | CWallet *const pwallet = GetWalletForJSONRPCRequest(request); | ||||
LOCK2(cs_main, pwallet ? &pwallet->cs_wallet : nullptr); | LOCK2(cs_main, pwallet ? &pwallet->cs_wallet : nullptr); | ||||
#else | #else | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
#endif | #endif | ||||
const CChainParams ¶ms = config.GetChainParams(); | |||||
CTxDestination dest = | CTxDestination dest = | ||||
DecodeDestination(request.params[0].get_str(), config.GetChainParams()); | DecodeDestination(request.params[0].get_str(), params); | ||||
bool isValid = IsValidDestination(dest); | bool isValid = IsValidDestination(dest); | ||||
UniValue ret(UniValue::VOBJ); | UniValue ret(UniValue::VOBJ); | ||||
ret.pushKV("isvalid", isValid); | ret.pushKV("isvalid", isValid); | ||||
if (isValid) { | if (isValid) { | ||||
std::string currentAddress = EncodeDestination(dest); | std::string currentAddress = EncodeDestination(dest); | ||||
ret.pushKV("address", currentAddress); | ret.pushKV("address", currentAddress); | ||||
ret.pushKV("address_cashaddr", EncodeCashAddr(dest, params)); | |||||
ret.pushKV("address_legacy", EncodeLegacyAddr(dest, params)); | |||||
CScript scriptPubKey = GetScriptForDestination(dest); | CScript scriptPubKey = GetScriptForDestination(dest); | ||||
ret.pushKV("scriptPubKey", | ret.pushKV("scriptPubKey", | ||||
HexStr(scriptPubKey.begin(), scriptPubKey.end())); | HexStr(scriptPubKey.begin(), scriptPubKey.end())); | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
isminetype mine = pwallet ? IsMine(*pwallet, dest) : ISMINE_NO; | isminetype mine = pwallet ? IsMine(*pwallet, dest) : ISMINE_NO; | ||||
ret.pushKV("ismine", (mine & ISMINE_SPENDABLE) ? true : false); | ret.pushKV("ismine", (mine & ISMINE_SPENDABLE) ? true : false); | ||||
▲ Show 20 Lines • Show All 450 Lines • Show Last 20 Lines |