Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete Unconfirmed outputs as part of wallet check_repair #2261

Merged
merged 2 commits into from
Dec 30, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion wallet/src/libwallet/internal/restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ where
accidental_spend_outs.push((s.0.clone(), deffo.clone()));
}
if s.0.status == OutputStatus::Locked {
locked_outs.push((s.0.clone(), deffo));
locked_outs.push((s.0.clone(), deffo.clone()));
}
}
None => missing_outs.push(deffo),
Expand Down Expand Up @@ -287,6 +287,7 @@ where
restore_missing_output(wallet, m, &mut found_parents)?;
}

// Unlock locked outputs
for m in locked_outs.into_iter() {
let mut o = m.0;
warn!(
Expand All @@ -301,6 +302,24 @@ where
batch.commit()?;
}

let unconfirmed_outs: Vec<&(OutputData, pedersen::Commitment)> = wallet_outputs
.iter()
.filter(|o| o.0.status == OutputStatus::Unconfirmed)
.collect();
// Delete unconfirmed outputs
for m in unconfirmed_outs.into_iter() {
let o = m.0.clone();
warn!(
"Unconfirmed output for {} with ID {} ({:?}) not in UTXO set. \
Deleting and cancelling associated transaction log entries.",
o.value, o.key_id, m.1,
);
cancel_tx_log_entry(wallet, &o)?;
let mut batch = wallet.batch()?;
batch.delete(&o.key_id)?;
batch.commit()?;
}

Ok(())
}

Expand Down