fix(store): drop payments on /wipe; document non-forensic
All checks were successful
ci / test (pull_request) Successful in 3m1s

/wipe now deletes payments as well as chat, checkpoints WAL, and
enables sqlite secure_delete (flash still not crypto-shred).
This commit is contained in:
Sirius DevOps 2026-09-10 20:22:31 -04:00
commit 45c105de8a
No known key found for this signature in database
5 changed files with 70 additions and 12 deletions

View file

@ -4,9 +4,9 @@ use std::path::{Path, PathBuf};
use std::time::{SystemTime, UNIX_EPOCH};
use ed25519_dalek::SigningKey;
use rand::RngCore;
use rand::rngs::OsRng;
use rusqlite::{Connection, OptionalExtension, params};
use rand::RngCore;
use rusqlite::{params, Connection, OptionalExtension};
use x25519_dalek::{PublicKey as X25519Public, StaticSecret};
pub type Result<T> = std::result::Result<T, Error>;
@ -123,6 +123,9 @@ impl Store {
if !journal.eq_ignore_ascii_case("wal") {
return Err(Error(format!("journal_mode WAL failed: {journal}")));
}
// Overwrite freed pages on DELETE. Flash wear-leveling can still keep copies;
// this is not a forensic / SSD crypto-shred.
conn.pragma_update(None, "secure_delete", "ON")?;
conn.execute_batch(
"
PRAGMA foreign_keys = ON;
@ -748,14 +751,17 @@ impl Store {
Ok(out)
}
/// Overwrite message bodies, delete rows, VACUUM. Identity + friends stay.
/// Drop chat + payments history. Identity + friends stay.
/// Not a forensic erase: SSD wear-leveling can keep copies.
pub fn wipe_messages(&self) -> Result<()> {
self.conn.execute(
"UPDATE messages SET plaintext = zeroblob(length(plaintext))",
[],
)?;
self.conn.execute("DELETE FROM messages", [])?;
self.conn.execute("DELETE FROM payments", [])?;
self.conn.execute_batch("VACUUM")?;
self.conn.execute_batch("PRAGMA wal_checkpoint(TRUNCATE)")?;
Ok(())
}

View file

@ -318,8 +318,9 @@ pub fn parse_slash(raw: &str) -> Option<WipeKind> {
pub fn wipe_screen_text(kind: WipeKind) -> &'static str {
match kind {
WipeKind::Messages => {
"Wipe message log?\n\
"Wipe chat and payments history?\n\
Identity key and friends stay.\n\
Not a forensic erase.\n\
Type WIPE to confirm Esc to cancel"
}
WipeKind::All => {