Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcdump.cpp
Show First 20 Lines • Show All 686 Lines • ▼ Show 20 Lines | UniValue dumpwallet(const Config &config, const JSONRPCRequest &request) { | ||||
std::ofstream file; | std::ofstream file; | ||||
file.open(request.params[0].get_str().c_str()); | file.open(request.params[0].get_str().c_str()); | ||||
if (!file.is_open()) { | if (!file.is_open()) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, | throw JSONRPCError(RPC_INVALID_PARAMETER, | ||||
"Cannot open wallet dump file"); | "Cannot open wallet dump file"); | ||||
} | } | ||||
std::map<CTxDestination, int64_t> mapKeyBirth; | std::map<CTxDestination, int64_t> mapKeyBirth; | ||||
std::set<CKeyID> setKeyPool; | const std::map<CKeyID, int64_t> &mapKeyPool = pwallet->GetAllReserveKeys(); | ||||
pwallet->GetKeyBirthTimes(mapKeyBirth); | pwallet->GetKeyBirthTimes(mapKeyBirth); | ||||
pwallet->GetAllReserveKeys(setKeyPool); | |||||
// sort time/key pairs | // sort time/key pairs | ||||
std::vector<std::pair<int64_t, CKeyID>> vKeyBirth; | std::vector<std::pair<int64_t, CKeyID>> vKeyBirth; | ||||
for (const auto &entry : mapKeyBirth) { | for (const auto &entry : mapKeyBirth) { | ||||
if (const CKeyID *keyID = boost::get<CKeyID>(&entry.first)) { | if (const CKeyID *keyID = boost::get<CKeyID>(&entry.first)) { | ||||
// set and test | // set and test | ||||
vKeyBirth.push_back(std::make_pair(entry.second, *keyID)); | vKeyBirth.push_back(std::make_pair(entry.second, *keyID)); | ||||
} | } | ||||
Show All 37 Lines | for (std::vector<std::pair<int64_t, CKeyID>>::const_iterator it = | ||||
file << strprintf("%s %s ", CBitcoinSecret(key).ToString(), | file << strprintf("%s %s ", CBitcoinSecret(key).ToString(), | ||||
strTime); | strTime); | ||||
if (pwallet->mapAddressBook.count(keyid)) { | if (pwallet->mapAddressBook.count(keyid)) { | ||||
file << strprintf( | file << strprintf( | ||||
"label=%s", | "label=%s", | ||||
EncodeDumpString(pwallet->mapAddressBook[keyid].name)); | EncodeDumpString(pwallet->mapAddressBook[keyid].name)); | ||||
} else if (keyid == masterKeyID) { | } else if (keyid == masterKeyID) { | ||||
file << "hdmaster=1"; | file << "hdmaster=1"; | ||||
} else if (setKeyPool.count(keyid)) { | } else if (mapKeyPool.count(keyid)) { | ||||
file << "reserve=1"; | file << "reserve=1"; | ||||
} else if (pwallet->mapKeyMetadata[keyid].hdKeypath == "m") { | } else if (pwallet->mapKeyMetadata[keyid].hdKeypath == "m") { | ||||
file << "inactivehdmaster=1"; | file << "inactivehdmaster=1"; | ||||
} else { | } else { | ||||
file << "change=1"; | file << "change=1"; | ||||
} | } | ||||
file << strprintf( | file << strprintf( | ||||
" # addr=%s%s\n", strAddr, | " # addr=%s%s\n", strAddr, | ||||
▲ Show 20 Lines • Show All 572 Lines • Show Last 20 Lines |