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 = | CTxDestination dest = DecodeDestination(request.params[0].get_str(), | ||||
DecodeDestination(request.params[0].get_str(), wallet->chainParams); | 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 = DecodeDestination(strAddress, wallet->chainParams); | CTxDestination dest = DecodeDestination(strAddress, wallet->chainParams()); | ||||
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 278 Lines • ▼ Show 20 Lines | if (data.exists("range")) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_INVALID_PARAMETER, | RPC_INVALID_PARAMETER, | ||||
"Range should not be specified for a non-descriptor import"); | "Range should not be specified for a non-descriptor import"); | ||||
} | } | ||||
// Generate the script and destination for the scriptPubKey provided | // Generate the script and destination for the scriptPubKey provided | ||||
CScript script; | CScript script; | ||||
if (!isScript) { | if (!isScript) { | ||||
CTxDestination dest = DecodeDestination(output, pwallet->chainParams); | CTxDestination dest = DecodeDestination(output, pwallet->chainParams()); | ||||
if (!IsValidDestination(dest)) { | if (!IsValidDestination(dest)) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
"Invalid address \"" + output + "\""); | "Invalid address \"" + output + "\""); | ||||
} | } | ||||
script = GetScriptForDestination(dest); | script = GetScriptForDestination(dest); | ||||
} else { | } else { | ||||
if (!IsHex(output)) { | if (!IsHex(output)) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
▲ Show 20 Lines • Show All 689 Lines • Show Last 20 Lines |