Optionally allow ImportScripts to set script creation timestamp

Behavior changes:
* scripts imported in importmulti that are not explicilty scriptPubKeys will have timestamps set for them
This commit is contained in:
Andrew Chow
2019-06-27 21:17:42 -04:00
parent 94bf156f39
commit 78941da5ba
3 changed files with 13 additions and 5 deletions

View File

@@ -1661,7 +1661,7 @@ bool CWallet::DummySignTx(CMutableTransaction &txNew, const std::vector<CTxOut>
return true;
}
bool CWallet::ImportScripts(const std::set<CScript> scripts)
bool CWallet::ImportScripts(const std::set<CScript> scripts, int64_t timestamp)
{
WalletBatch batch(*database);
for (const auto& entry : scripts) {
@@ -1673,7 +1673,15 @@ bool CWallet::ImportScripts(const std::set<CScript> scripts)
if (!AddCScriptWithDB(batch, entry)) {
return false;
}
if (timestamp > 0) {
m_script_metadata[CScriptID(entry)].nCreateTime = timestamp;
}
}
if (timestamp > 0) {
UpdateTimeFirstKey(timestamp);
}
return true;
}