Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcdump.cpp
Show First 20 Lines • Show All 187 Lines • ▼ Show 20 Lines | bool fRescan = true; | ||||
CKey key = DecodeSecret(strSecret); | CKey key = DecodeSecret(strSecret); | ||||
if (!key.IsValid()) { | if (!key.IsValid()) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
"Invalid private key encoding"); | "Invalid private key encoding"); | ||||
} | } | ||||
CPubKey pubkey = key.GetPubKey(); | CPubKey pubkey = key.GetPubKey(); | ||||
assert(key.VerifyPubKey(pubkey)); | CHECK_NONFATAL(key.VerifyPubKey(pubkey)); | ||||
CKeyID vchAddress = pubkey.GetID(); | CKeyID vchAddress = pubkey.GetID(); | ||||
{ | { | ||||
pwallet->MarkDirty(); | pwallet->MarkDirty(); | ||||
// We don't know which corresponding address will be used; | // We don't know which corresponding address will be used; | ||||
// label all new addresses, and label existing addresses if a | // label all new addresses, and label existing addresses if a | ||||
// label was passed. | // label was passed. | ||||
for (const auto &dest : GetAllDestinationsForKey(pubkey)) { | for (const auto &dest : GetAllDestinationsForKey(pubkey)) { | ||||
▲ Show 20 Lines • Show All 558 Lines • ▼ Show 20 Lines | bool fGood = true; | ||||
std::max(50, std::min<int>(75, 100 * progress / total) + 50), | std::max(50, std::min<int>(75, 100 * progress / total) + 50), | ||||
false); | false); | ||||
const CKey &key = std::get<0>(key_tuple); | const CKey &key = std::get<0>(key_tuple); | ||||
int64_t time = std::get<1>(key_tuple); | int64_t time = std::get<1>(key_tuple); | ||||
bool has_label = std::get<2>(key_tuple); | bool has_label = std::get<2>(key_tuple); | ||||
std::string label = std::get<3>(key_tuple); | std::string label = std::get<3>(key_tuple); | ||||
CPubKey pubkey = key.GetPubKey(); | CPubKey pubkey = key.GetPubKey(); | ||||
assert(key.VerifyPubKey(pubkey)); | CHECK_NONFATAL(key.VerifyPubKey(pubkey)); | ||||
CKeyID keyid = pubkey.GetID(); | CKeyID keyid = pubkey.GetID(); | ||||
pwallet->WalletLogPrintf("Importing %s...\n", | pwallet->WalletLogPrintf("Importing %s...\n", | ||||
EncodeDestination(PKHash(keyid), config)); | EncodeDestination(PKHash(keyid), config)); | ||||
if (!pwallet->ImportPrivKeys({{keyid, key}}, time)) { | if (!pwallet->ImportPrivKeys({{keyid, key}}, time)) { | ||||
pwallet->WalletLogPrintf( | pwallet->WalletLogPrintf( | ||||
"Error importing key for %s\n", | "Error importing key for %s\n", | ||||
▲ Show 20 Lines • Show All 296 Lines • ▼ Show 20 Lines | switch (script_type) { | ||||
import_data.used_keys[id] = true; | import_data.used_keys[id] = true; | ||||
return ""; | return ""; | ||||
} | } | ||||
case TX_SCRIPTHASH: { | case TX_SCRIPTHASH: { | ||||
if (script_ctx == ScriptContext::P2SH) { | if (script_ctx == ScriptContext::P2SH) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
"Trying to nest P2SH inside another P2SH"); | "Trying to nest P2SH inside another P2SH"); | ||||
} | } | ||||
assert(script_ctx == ScriptContext::TOP); | CHECK_NONFATAL(script_ctx == ScriptContext::TOP); | ||||
CScriptID id = CScriptID(uint160(solverdata[0])); | CScriptID id = CScriptID(uint160(solverdata[0])); | ||||
// Remove redeemscript from import_data to check for superfluous | // Remove redeemscript from import_data to check for superfluous | ||||
// script later. | // script later. | ||||
auto subscript = std::move(import_data.redeemscript); | auto subscript = std::move(import_data.redeemscript); | ||||
if (!subscript) { | if (!subscript) { | ||||
return "missing redeemscript"; | return "missing redeemscript"; | ||||
} | } | ||||
if (CScriptID(*subscript) != id) { | if (CScriptID(*subscript) != id) { | ||||
▲ Show 20 Lines • Show All 751 Lines • Show Last 20 Lines |