Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcdump.cpp
Show First 20 Lines • Show All 591 Lines • ▼ Show 20 Lines | while (file.good()) { | ||||
if (!vchSecret.SetString(vstr[0])) { | if (!vchSecret.SetString(vstr[0])) { | ||||
continue; | continue; | ||||
} | } | ||||
CKey key = vchSecret.GetKey(); | CKey key = vchSecret.GetKey(); | ||||
CPubKey pubkey = key.GetPubKey(); | CPubKey pubkey = key.GetPubKey(); | ||||
assert(key.VerifyPubKey(pubkey)); | assert(key.VerifyPubKey(pubkey)); | ||||
CKeyID keyid = pubkey.GetID(); | CKeyID keyid = pubkey.GetID(); | ||||
if (pwallet->HaveKey(keyid)) { | if (pwallet->HaveKey(keyid)) { | ||||
LogPrintf("Skipping import of %s (key already present)\n", | LogPrint(BCLog::WALLET, | ||||
"Skipping import of %s (key already present)\n", | |||||
EncodeDestination(keyid)); | EncodeDestination(keyid)); | ||||
continue; | continue; | ||||
} | } | ||||
int64_t nTime = DecodeDumpTime(vstr[1]); | int64_t nTime = DecodeDumpTime(vstr[1]); | ||||
std::string strLabel; | std::string strLabel; | ||||
bool fLabel = true; | bool fLabel = true; | ||||
for (unsigned int nStr = 2; nStr < vstr.size(); nStr++) { | for (unsigned int nStr = 2; nStr < vstr.size(); nStr++) { | ||||
if (boost::algorithm::starts_with(vstr[nStr], "#")) { | if (boost::algorithm::starts_with(vstr[nStr], "#")) { | ||||
break; | break; | ||||
} | } | ||||
if (vstr[nStr] == "change=1") { | if (vstr[nStr] == "change=1") { | ||||
fLabel = false; | fLabel = false; | ||||
} | } | ||||
if (vstr[nStr] == "reserve=1") { | if (vstr[nStr] == "reserve=1") { | ||||
fLabel = false; | fLabel = false; | ||||
} | } | ||||
if (boost::algorithm::starts_with(vstr[nStr], "label=")) { | if (boost::algorithm::starts_with(vstr[nStr], "label=")) { | ||||
strLabel = DecodeDumpString(vstr[nStr].substr(6)); | strLabel = DecodeDumpString(vstr[nStr].substr(6)); | ||||
fLabel = true; | fLabel = true; | ||||
} | } | ||||
} | } | ||||
LogPrintf("Importing %s...\n", EncodeDestination(keyid)); | LogPrint(BCLog::WALLET, "Importing %s...\n", EncodeDestination(keyid)); | ||||
if (!pwallet->AddKeyPubKey(key, pubkey)) { | if (!pwallet->AddKeyPubKey(key, pubkey)) { | ||||
fGood = false; | fGood = false; | ||||
continue; | continue; | ||||
} | } | ||||
pwallet->mapKeyMetadata[keyid].nCreateTime = nTime; | pwallet->mapKeyMetadata[keyid].nCreateTime = nTime; | ||||
if (fLabel) { | if (fLabel) { | ||||
pwallet->SetAddressBook(keyid, strLabel, "receive"); | pwallet->SetAddressBook(keyid, strLabel, "receive"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 769 Lines • Show Last 20 Lines |