From 08a5cfa80bcb0bbaa9b03f8ed5acff6ad7db2b4b Mon Sep 17 00:00:00 2001 From: Kevin Gorham Date: Fri, 30 Apr 2021 21:55:18 -0400 Subject: [PATCH] Add clear function for the accounts table. --- zcash_client_sqlite/src/wallet/init.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/zcash_client_sqlite/src/wallet/init.rs b/zcash_client_sqlite/src/wallet/init.rs index 96e436300..f724a9c9f 100644 --- a/zcash_client_sqlite/src/wallet/init.rs +++ b/zcash_client_sqlite/src/wallet/init.rs @@ -209,6 +209,17 @@ pub fn init_accounts_table( Ok(()) } +pub fn clear_accounts_table( + wdb: &WalletDb

, +) -> Result<(), SqliteClientError> { + wdb.conn.execute("PRAGMA foreign_keys = OFF;", NO_PARAMS)?; + wdb.conn.execute( "DELETE FROM accounts;", NO_PARAMS, )?; + wdb.conn.execute("PRAGMA foreign_keys = ON;", NO_PARAMS)?; + + Ok(()) +} + + /// Initialises the data database with the given block. /// /// This enables a newly-created database to be immediately-usable, without needing to