Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcdump.cpp
Show First 20 Lines • Show All 230 Lines • ▼ Show 20 Lines | UniValue abortrescan(const Config &config, const JSONRPCRequest &request) { | ||||
} | } | ||||
pwallet->AbortRescan(); | pwallet->AbortRescan(); | ||||
return true; | return true; | ||||
} | } | ||||
static void ImportAddress(CWallet *, const CTxDestination &dest, | static void ImportAddress(CWallet *, const CTxDestination &dest, | ||||
const std::string &strLabel); | const std::string &strLabel); | ||||
static void ImportScript(CWallet *const pwallet, const CScript &script, | static void ImportScript(CWallet *const pwallet, const CScript &script, | ||||
const std::string &strLabel, bool isRedeemScript) { | const std::string &strLabel, bool isRedeemScript) | ||||
EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) { | |||||
if (!isRedeemScript && ::IsMine(*pwallet, script) == ISMINE_SPENDABLE) { | if (!isRedeemScript && ::IsMine(*pwallet, script) == ISMINE_SPENDABLE) { | ||||
throw JSONRPCError(RPC_WALLET_ERROR, "The wallet already contains the " | throw JSONRPCError(RPC_WALLET_ERROR, "The wallet already contains the " | ||||
"private key for this address or " | "private key for this address or " | ||||
"script"); | "script"); | ||||
} | } | ||||
pwallet->MarkDirty(); | pwallet->MarkDirty(); | ||||
Show All 12 Lines | if (isRedeemScript) { | ||||
CTxDestination destination; | CTxDestination destination; | ||||
if (ExtractDestination(script, destination)) { | if (ExtractDestination(script, destination)) { | ||||
pwallet->SetAddressBook(destination, strLabel, "receive"); | pwallet->SetAddressBook(destination, strLabel, "receive"); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
static void ImportAddress(CWallet *const pwallet, const CTxDestination &dest, | static void ImportAddress(CWallet *const pwallet, const CTxDestination &dest, | ||||
const std::string &strLabel) { | const std::string &strLabel) | ||||
EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) { | |||||
CScript script = GetScriptForDestination(dest); | CScript script = GetScriptForDestination(dest); | ||||
ImportScript(pwallet, script, strLabel, false); | ImportScript(pwallet, script, strLabel, false); | ||||
// add to address book or update label | // add to address book or update label | ||||
if (IsValidDestination(dest)) { | if (IsValidDestination(dest)) { | ||||
pwallet->SetAddressBook(dest, strLabel, "receive"); | pwallet->SetAddressBook(dest, strLabel, "receive"); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 688 Lines • ▼ Show 20 Lines | UniValue dumpwallet(const Config &config, const JSONRPCRequest &request) { | ||||
UniValue reply(UniValue::VOBJ); | UniValue reply(UniValue::VOBJ); | ||||
reply.pushKV("filename", filepath.string()); | reply.pushKV("filename", filepath.string()); | ||||
return reply; | return reply; | ||||
} | } | ||||
static UniValue ProcessImport(CWallet *const pwallet, const UniValue &data, | static UniValue ProcessImport(CWallet *const pwallet, const UniValue &data, | ||||
const int64_t timestamp) { | const int64_t timestamp) | ||||
EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) { | |||||
try { | try { | ||||
bool success = false; | bool success = false; | ||||
// Required fields. | // Required fields. | ||||
const UniValue &scriptPubKey = data["scriptPubKey"]; | const UniValue &scriptPubKey = data["scriptPubKey"]; | ||||
// Should have script or JSON with "address". | // Should have script or JSON with "address". | ||||
if (!(scriptPubKey.getType() == UniValue::VOBJ && | if (!(scriptPubKey.getType() == UniValue::VOBJ && | ||||
▲ Show 20 Lines • Show All 550 Lines • Show Last 20 Lines |