Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcdump.cpp
Show First 20 Lines • Show All 667 Lines • ▼ Show 20 Lines | bool fGood = true; | ||||
EnsureWalletIsUnlocked(pwallet); | EnsureWalletIsUnlocked(pwallet); | ||||
fsbridge::ifstream file; | fsbridge::ifstream file; | ||||
file.open(request.params[0].get_str(), std::ios::in | std::ios::ate); | file.open(request.params[0].get_str(), std::ios::in | std::ios::ate); | ||||
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"); | ||||
} | } | ||||
Optional<int> tip_height = locked_chain->getHeight(); | CHECK_NONFATAL(pwallet->chain().findBlock( | ||||
nTimeBegin = tip_height ? locked_chain->getBlockTime(*tip_height) : 0; | pwallet->GetLastBlockHash(), FoundBlock().time(nTimeBegin))); | ||||
int64_t nFilesize = std::max<int64_t>(1, file.tellg()); | int64_t nFilesize = std::max<int64_t>(1, file.tellg()); | ||||
file.seekg(0, file.beg); | file.seekg(0, file.beg); | ||||
// Use uiInterface.ShowProgress instead of pwallet.ShowProgress because | // Use uiInterface.ShowProgress instead of pwallet.ShowProgress because | ||||
// pwallet.ShowProgress has a cancel button tied to AbortRescan which we | // pwallet.ShowProgress has a cancel button tied to AbortRescan which we | ||||
// don't want for this progress bar showing the import progress. | // don't want for this progress bar showing the import progress. | ||||
// uiInterface.ShowProgress does not have a cancel button. | // uiInterface.ShowProgress does not have a cancel button. | ||||
▲ Show 20 Lines • Show All 253 Lines • ▼ Show 20 Lines | for (const auto &entry : mapKeyBirth) { | ||||
vKeyBirth.push_back(std::make_pair(entry.second, entry.first)); | vKeyBirth.push_back(std::make_pair(entry.second, entry.first)); | ||||
} | } | ||||
mapKeyBirth.clear(); | mapKeyBirth.clear(); | ||||
std::sort(vKeyBirth.begin(), vKeyBirth.end()); | std::sort(vKeyBirth.begin(), vKeyBirth.end()); | ||||
// produce output | // produce output | ||||
file << strprintf("# Wallet dump created by Bitcoin %s\n", CLIENT_BUILD); | file << strprintf("# Wallet dump created by Bitcoin %s\n", CLIENT_BUILD); | ||||
file << strprintf("# * Created on %s\n", FormatISO8601DateTime(GetTime())); | file << strprintf("# * Created on %s\n", FormatISO8601DateTime(GetTime())); | ||||
const Optional<int> tip_height = locked_chain->getHeight(); | |||||
file << strprintf("# * Best block at time of backup was %i (%s),\n", | file << strprintf("# * Best block at time of backup was %i (%s),\n", | ||||
tip_height.value_or(-1), | pwallet->GetLastBlockHeight(), | ||||
tip_height | pwallet->GetLastBlockHash().ToString()); | ||||
? locked_chain->getBlockHash(*tip_height).ToString() | int64_t block_time = 0; | ||||
: "(missing block hash)"); | CHECK_NONFATAL(pwallet->chain().findBlock(pwallet->GetLastBlockHash(), | ||||
file << strprintf("# mined on %s\n", | FoundBlock().time(block_time))); | ||||
tip_height ? FormatISO8601DateTime( | file << strprintf("# mined on %s\n", FormatISO8601DateTime(block_time)); | ||||
locked_chain->getBlockTime(*tip_height)) | |||||
: "(missing block time)"); | |||||
file << "\n"; | file << "\n"; | ||||
// add the base58check encoded extended master if the wallet uses HD | // add the base58check encoded extended master if the wallet uses HD | ||||
CKeyID seed_id = spk_man.GetHDChain().seed_id; | CKeyID seed_id = spk_man.GetHDChain().seed_id; | ||||
if (!seed_id.IsNull()) { | if (!seed_id.IsNull()) { | ||||
CKey seed; | CKey seed; | ||||
if (spk_man.GetKey(seed_id, seed)) { | if (spk_man.GetKey(seed_id, seed)) { | ||||
CExtKey masterKey; | CExtKey masterKey; | ||||
▲ Show 20 Lines • Show All 879 Lines • Show Last 20 Lines |