Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcdump.cpp
Show First 20 Lines • Show All 1,714 Lines • ▼ Show 20 Lines | UniValue importmulti(const Config &config, const JSONRPCRequest &mainRequest) { | ||||
int64_t nLowestTimestamp = 0; | int64_t nLowestTimestamp = 0; | ||||
UniValue response(UniValue::VARR); | UniValue response(UniValue::VARR); | ||||
{ | { | ||||
auto locked_chain = pwallet->chain().lock(); | auto locked_chain = pwallet->chain().lock(); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
EnsureWalletIsUnlocked(pwallet); | EnsureWalletIsUnlocked(pwallet); | ||||
// Verify all timestamps are present before importing any keys. | // Verify all timestamps are present before importing any keys. | ||||
const Optional<int> tip_height = locked_chain->getHeight(); | CHECK_NONFATAL(pwallet->chain().findBlock( | ||||
now = | pwallet->GetLastBlockHash(), | ||||
tip_height ? locked_chain->getBlockMedianTimePast(*tip_height) : 0; | FoundBlock().time(nLowestTimestamp).mtpTime(now))); | ||||
for (const UniValue &data : requests.getValues()) { | for (const UniValue &data : requests.getValues()) { | ||||
GetImportTimestamp(data, now); | GetImportTimestamp(data, now); | ||||
} | } | ||||
const int64_t minimumTimestamp = 1; | const int64_t minimumTimestamp = 1; | ||||
if (fRescan && tip_height) { | |||||
nLowestTimestamp = locked_chain->getBlockTime(*tip_height); | |||||
} else { | |||||
fRescan = false; | |||||
} | |||||
for (const UniValue &data : requests.getValues()) { | for (const UniValue &data : requests.getValues()) { | ||||
const int64_t timestamp = | const int64_t timestamp = | ||||
std::max(GetImportTimestamp(data, now), minimumTimestamp); | std::max(GetImportTimestamp(data, now), minimumTimestamp); | ||||
const UniValue result = ProcessImport(pwallet, data, timestamp); | const UniValue result = ProcessImport(pwallet, data, timestamp); | ||||
response.push_back(result); | response.push_back(result); | ||||
if (!fRescan) { | if (!fRescan) { | ||||
continue; | continue; | ||||
▲ Show 20 Lines • Show All 95 Lines • Show Last 20 Lines |