Address suggestions from code review on #5637

This commit is contained in:
Kris Nuttycombe 2022-03-10 08:51:18 -07:00
parent f5b23b3336
commit 5d17e53c5c
2 changed files with 20 additions and 6 deletions

View File

@ -334,7 +334,7 @@ impl Wallet {
/// Add note data for those notes that are decryptable with one of this wallet's
/// incoming viewing keys to the wallet, and return a map from each decrypted
/// action's index to the incoming vieing key that successfully decrypted that
/// action's index to the incoming viewing key that successfully decrypted that
/// action.
pub fn add_notes_from_bundle(
&mut self,
@ -369,9 +369,20 @@ impl Wallet {
involvement
}
/// Add note data to the wallet by attempting to
/// incoming viewing keys to the wallet, and return a map from incoming viewing
/// key to the vector of action indices that that key decrypts.
/// Restore note and potential spend data from a bundle using the provided
/// metadata.
///
/// - `tx_height`: if the transaction containing the bundle has been mined,
/// this should contain the block height it was mined at
/// - `txid`: The ID for the transaction from which the provided bundle was
/// extracted.
/// - `bundle`: the bundle to decrypt notes from
/// - `hints`: a map from action index to the incoming viewing key that decrypts
/// that action. If the IVK does not decrypt the action, or if it is not
/// associated with a FVK in this wallet, `load_bundle` will return an error.
/// - `potential_spend_idxs`: a list of action indices that were previously
/// detected as spending our notes. If an index is out of range, `load_bundle`
/// will return an error.
pub fn load_bundle(
&mut self,
tx_height: Option<BlockHeight>,

View File

@ -849,6 +849,7 @@ bool CWallet::LoadUnifiedAddressMetadata(const ZcashdUnifiedAddressMetadata &add
bool CWallet::LoadCaches()
{
AssertLockHeld(cs_wallet);
AssertLockHeld(cs_main);
auto seed = GetMnemonicSeed();
@ -2428,7 +2429,7 @@ void CWallet::DecrementNoteWitnesses(const Consensus::Params& consensus, const C
// pindex->nHeight is the height of the block being removed, so we rewind
// to the previous block height
uint32_t blocksRewound{0};
if (!orchardWallet.Rewind(pindex->nHeight - 1, blocksRewound)) {
if (!orchardWallet.Rewind(pindex->nHeight - 1, blocksRewound) || blocksRewound != 1) {
LogPrintf(
"DecrementNoteWitnesses: Orchard wallet rewind unsuccessful at height %d; rewound %d",
pindex->nHeight - 1, blocksRewound);
@ -4104,7 +4105,9 @@ int CWallet::ScanForWalletTransactions(
CWalletTx wtx = mapWallet[hash];
if (!wtx.mapSaplingNoteData.empty() || !wtx.orchardTxMeta.empty()) {
if (!walletdb.WriteTx(wtx)) {
LogPrintf("Rescanning... WriteToDisk failed to update Sapling note data for: %s\n", hash.ToString());
LogPrintf(
"Rescanning... WriteToDisk failed to update Sapling/Orchard note data for tx: %s\n",
hash.ToString());
}
}
}