| 
					
				 | 
			
			
				@@ -21,7 +21,7 @@ use tracing::instrument; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 use super::error::Error; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 use crate::migrations::migrate_00_to_01; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-use crate::wallet::migrations::{migrate_01_to_02, migrate_02_to_03}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use crate::wallet::migrations::{migrate_01_to_02, migrate_02_to_03, migrate_03_to_04}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 mod migrations; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -46,7 +46,7 @@ const TRANSACTIONS_TABLE: TableDefinition<&[u8], &str> = TableDefinition::new("t 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const KEYSET_U32_MAPPING: TableDefinition<u32, &str> = TableDefinition::new("keyset_u32_mapping"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-const DATABASE_VERSION: u32 = 3; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+const DATABASE_VERSION: u32 = 4; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /// Wallet Redb Database 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #[derive(Debug, Clone)] 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -96,6 +96,10 @@ impl WalletRedbDatabase { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 current_file_version = migrate_02_to_03(Arc::clone(&db))?; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if current_file_version == 3 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                current_file_version = migrate_03_to_04(Arc::clone(&db))?; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             if current_file_version != DATABASE_VERSION { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 tracing::warn!( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     "Database upgrade did not complete at {} current is {}", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -786,7 +790,7 @@ impl WalletDatabase for WalletRedbDatabase { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     #[instrument(skip(self), fields(keyset_id = %keyset_id))] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    async fn get_keyset_counter(&self, keyset_id: &Id) -> Result<Option<u32>, Self::Err> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    async fn get_keyset_counter(&self, keyset_id: &Id) -> Result<u32, Self::Err> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let read_txn = self.db.begin_read().map_err(Error::from)?; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let table = read_txn.open_table(KEYSET_COUNTER).map_err(Error::from)?; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -794,7 +798,7 @@ impl WalletDatabase for WalletRedbDatabase { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             .get(keyset_id.to_string().as_str()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             .map_err(Error::from)?; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Ok(counter.map(|c| c.value())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Ok(counter.map_or(0, |c| c.value())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     #[instrument(skip(self))] 
			 |