mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-26 03:03:22 -03:00
wallet: birth time update during tx scanning
As the user could have imported a descriptor with a newer timestamp (by blindly setting 'timestamp=now'), the wallet needs to update the birth time when it detects a transaction older than the oldest descriptor timestamp.
This commit is contained in:
parent
b4306e3c8d
commit
75fbf444c1
1 changed files with 8 additions and 1 deletions
|
@ -1080,6 +1080,9 @@ CWalletTx* CWallet::AddToWallet(CTransactionRef tx, const TxState& state, const
|
||||||
wtx.m_it_wtxOrdered = wtxOrdered.insert(std::make_pair(wtx.nOrderPos, &wtx));
|
wtx.m_it_wtxOrdered = wtxOrdered.insert(std::make_pair(wtx.nOrderPos, &wtx));
|
||||||
wtx.nTimeSmart = ComputeTimeSmart(wtx, rescanning_old_block);
|
wtx.nTimeSmart = ComputeTimeSmart(wtx, rescanning_old_block);
|
||||||
AddToSpends(wtx, &batch);
|
AddToSpends(wtx, &batch);
|
||||||
|
|
||||||
|
// Update birth time when tx time is older than it.
|
||||||
|
MaybeUpdateBirthTime(wtx.GetTxTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fInsertedNew)
|
if (!fInsertedNew)
|
||||||
|
@ -1199,6 +1202,10 @@ bool CWallet::LoadToWallet(const uint256& hash, const UpdateWalletTxFn& fill_wtx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update birth time when tx time is older than it.
|
||||||
|
MaybeUpdateBirthTime(wtx.GetTxTime());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3087,7 +3094,7 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
|
||||||
int64_t time = spk_man->GetTimeFirstKey();
|
int64_t time = spk_man->GetTimeFirstKey();
|
||||||
if (!time_first_key || time < *time_first_key) time_first_key = time;
|
if (!time_first_key || time < *time_first_key) time_first_key = time;
|
||||||
}
|
}
|
||||||
if (time_first_key) walletInstance->m_birth_time = *time_first_key;
|
if (time_first_key) walletInstance->MaybeUpdateBirthTime(*time_first_key);
|
||||||
|
|
||||||
if (chain && !AttachChain(walletInstance, *chain, rescan_required, error, warnings)) {
|
if (chain && !AttachChain(walletInstance, *chain, rescan_required, error, warnings)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
Loading…
Add table
Reference in a new issue