Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcdump.cpp
Show First 20 Lines • Show All 1,133 Lines • ▼ Show 20 Lines | switch (script_type) { | ||||
case TX_NULL_DATA: | case TX_NULL_DATA: | ||||
return "unspendable script"; | return "unspendable script"; | ||||
case TX_NONSTANDARD: | case TX_NONSTANDARD: | ||||
default: | default: | ||||
return "unrecognized script"; | return "unrecognized script"; | ||||
} | } | ||||
} | } | ||||
static UniValue ProcessImportLegacy(ImportData &import_data, | |||||
std::map<CKeyID, CPubKey> &pubkey_map, | |||||
std::map<CKeyID, CKey> &privkey_map, | |||||
std::set<CScript> &script_pub_keys, | |||||
bool &have_solving_data, | |||||
const UniValue &data) { | |||||
UniValue warnings(UniValue::VARR); | |||||
return warnings; | |||||
} | |||||
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) { | EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) { | ||||
UniValue warnings(UniValue::VARR); | UniValue warnings(UniValue::VARR); | ||||
UniValue result(UniValue::VOBJ); | UniValue result(UniValue::VOBJ); | ||||
try { | try { | ||||
const bool internal = | const bool internal = | ||||
data.exists("internal") ? data["internal"].get_bool() : false; | data.exists("internal") ? data["internal"].get_bool() : false; | ||||
// Internal addresses should not have a label | // Internal addresses should not have a label | ||||
if (internal && data.exists("label")) { | if (internal && data.exists("label")) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | throw JSONRPCError(RPC_INVALID_PARAMETER, | ||||
"Internal addresses should not have a label"); | "Internal addresses should not have a label"); | ||||
} | } | ||||
const std::string &label = | const std::string &label = | ||||
data.exists("label") ? data["label"].get_str() : ""; | data.exists("label") ? data["label"].get_str() : ""; | ||||
ImportData import_data; | ImportData import_data; | ||||
std::map<CKeyID, CPubKey> pubkey_map; | std::map<CKeyID, CPubKey> pubkey_map; | ||||
std::map<CKeyID, CKey> privkey_map; | std::map<CKeyID, CKey> privkey_map; | ||||
std::set<CScript> script_pub_keys; | std::set<CScript> script_pub_keys; | ||||
bool have_solving_data; | bool have_solving_data; | ||||
warnings = | |||||
ProcessImportLegacy(import_data, pubkey_map, privkey_map, | |||||
script_pub_keys, have_solving_data, data); | |||||
// First ensure scriptPubKey has either a script or JSON with "address" | // First ensure scriptPubKey has either a script or JSON with "address" | ||||
// string | // string | ||||
const UniValue &scriptPubKey = data["scriptPubKey"]; | const UniValue &scriptPubKey = data["scriptPubKey"]; | ||||
bool isScript = scriptPubKey.getType() == UniValue::VSTR; | bool isScript = scriptPubKey.getType() == UniValue::VSTR; | ||||
if (!isScript && !(scriptPubKey.getType() == UniValue::VOBJ && | if (!isScript && !(scriptPubKey.getType() == UniValue::VOBJ && | ||||
scriptPubKey.exists("address"))) { | scriptPubKey.exists("address"))) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | throw JSONRPCError(RPC_INVALID_PARAMETER, | ||||
"scriptPubKey must be string with script or " | "scriptPubKey must be string with script or " | ||||
▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | try { | ||||
// Check that all required keys for solvability are provided. | // Check that all required keys for solvability are provided. | ||||
if (error.empty()) { | if (error.empty()) { | ||||
for (const auto &require_key : import_data.used_keys) { | for (const auto &require_key : import_data.used_keys) { | ||||
if (!require_key.second) { | if (!require_key.second) { | ||||
// Not a required key | // Not a required key | ||||
continue; | continue; | ||||
} | } | ||||
if (pubkey_map.count(require_key.first) == 0 && | if (pubkey_map.count(require_key.first) == 0 && | ||||
privkey_map.count(require_key.first) == 0) { | privkey_map.count(require_key.first) == 0) { | ||||
error = "some required keys are missing"; | error = "some required keys are missing"; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if (!error.empty()) { | if (!error.empty()) { | ||||
▲ Show 20 Lines • Show All 425 Lines • Show Last 20 Lines |