Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcdump.cpp
Show First 20 Lines • Show All 651 Lines • ▼ Show 20 Lines | bool fGood = true; | ||||
file.open(request.params[0].get_str().c_str(), | file.open(request.params[0].get_str().c_str(), | ||||
std::ios::in | std::ios::ate); | 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"); | ||||
} | } | ||||
nTimeBegin = chainActive.Tip()->GetBlockTime(); | nTimeBegin = chainActive.Tip()->GetBlockTime(); | ||||
int64_t nFilesize = std::max((int64_t)1, (int64_t)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 progress dialog in GUI | // show progress dialog in GUI | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | bool fGood = true; | ||||
RPC_WALLET_ERROR, | RPC_WALLET_ERROR, | ||||
"Importing wallets is disabled when private keys are disabled"); | "Importing wallets is disabled when private keys are disabled"); | ||||
} | } | ||||
double total = double(keys.size() + scripts.size()); | double total = double(keys.size() + scripts.size()); | ||||
double progress = 0; | double progress = 0; | ||||
for (const auto &key_tuple : keys) { | for (const auto &key_tuple : keys) { | ||||
uiInterface.ShowProgress( | uiInterface.ShowProgress( | ||||
"", | "", | ||||
std::max(50, std::min<int>(75, (progress / total) * 100) + 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)); | assert(key.VerifyPubKey(pubkey)); | ||||
Show All 15 Lines | bool fGood = true; | ||||
pwallet->SetAddressBook(keyid, label, "receive"); | pwallet->SetAddressBook(keyid, label, "receive"); | ||||
} | } | ||||
nTimeBegin = std::min(nTimeBegin, time); | nTimeBegin = std::min(nTimeBegin, time); | ||||
progress++; | progress++; | ||||
} | } | ||||
for (const auto &script_pair : scripts) { | for (const auto &script_pair : scripts) { | ||||
uiInterface.ShowProgress( | uiInterface.ShowProgress( | ||||
"", | "", | ||||
std::max(50, std::min<int>(75, (progress / total) * 100) + 50), | std::max(50, std::min<int>(75, 100 * progress / total) + 50), | ||||
false); | false); | ||||
const CScript &script = script_pair.first; | const CScript &script = script_pair.first; | ||||
int64_t time = script_pair.second; | int64_t time = script_pair.second; | ||||
CScriptID id(script); | CScriptID id(script); | ||||
if (pwallet->HaveCScript(id)) { | if (pwallet->HaveCScript(id)) { | ||||
pwallet->WalletLogPrintf( | pwallet->WalletLogPrintf( | ||||
"Skipping import of %s (script already present)\n", | "Skipping import of %s (script already present)\n", | ||||
HexStr(script)); | HexStr(script)); | ||||
▲ Show 20 Lines • Show All 803 Lines • Show Last 20 Lines |