Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcdump.cpp
Show First 20 Lines • Show All 321 Lines • ▼ Show 20 Lines | UniValue importaddress(const Config &config, const JSONRPCRequest &request) { | ||||
if (!request.params[3].isNull()) { | if (!request.params[3].isNull()) { | ||||
fP2SH = request.params[3].get_bool(); | fP2SH = request.params[3].get_bool(); | ||||
} | } | ||||
{ | { | ||||
auto locked_chain = pwallet->chain().lock(); | auto locked_chain = pwallet->chain().lock(); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
CTxDestination dest = DecodeDestination(request.params[0].get_str(), | CTxDestination dest = | ||||
config.GetChainParams()); | DecodeDestination(request.params[0].get_str(), wallet->chainParams); | ||||
if (IsValidDestination(dest)) { | if (IsValidDestination(dest)) { | ||||
if (fP2SH) { | if (fP2SH) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
"Cannot use the p2sh flag with an address - " | "Cannot use the p2sh flag with an address - " | ||||
"use a script instead"); | "use a script instead"); | ||||
} | } | ||||
pwallet->MarkDirty(); | pwallet->MarkDirty(); | ||||
▲ Show 20 Lines • Show All 501 Lines • ▼ Show 20 Lines | UniValue dumpprivkey(const Config &config, const JSONRPCRequest &request) { | ||||
LegacyScriptPubKeyMan &spk_man = EnsureLegacyScriptPubKeyMan(*wallet); | LegacyScriptPubKeyMan &spk_man = EnsureLegacyScriptPubKeyMan(*wallet); | ||||
auto locked_chain = pwallet->chain().lock(); | auto locked_chain = pwallet->chain().lock(); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
EnsureWalletIsUnlocked(pwallet); | EnsureWalletIsUnlocked(pwallet); | ||||
std::string strAddress = request.params[0].get_str(); | std::string strAddress = request.params[0].get_str(); | ||||
CTxDestination dest = | CTxDestination dest = DecodeDestination(strAddress, wallet->chainParams); | ||||
DecodeDestination(strAddress, config.GetChainParams()); | |||||
if (!IsValidDestination(dest)) { | if (!IsValidDestination(dest)) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
"Invalid Bitcoin address"); | "Invalid Bitcoin address"); | ||||
} | } | ||||
auto keyid = GetKeyForDestination(spk_man, dest); | auto keyid = GetKeyForDestination(spk_man, dest); | ||||
if (keyid.IsNull()) { | if (keyid.IsNull()) { | ||||
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to a key"); | throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to a key"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 984 Lines • Show Last 20 Lines |