diff --git a/base_layer/core/src/transactions/key_manager/memory_db_key_manager.rs b/base_layer/core/src/transactions/key_manager/memory_db_key_manager.rs index 1518dfb546..1dd12d5f9e 100644 --- a/base_layer/core/src/transactions/key_manager/memory_db_key_manager.rs +++ b/base_layer/core/src/transactions/key_manager/memory_db_key_manager.rs @@ -65,6 +65,27 @@ pub fn create_memory_db_key_manager_with_range_proof_size( ) } +pub fn create_memory_db_key_manager_from_seed( + seed: CipherSeed, + rangeproof_size: usize, +) -> Result { + let connection = DbConnection::connect_url(&DbConnectionUrl::MemoryShared(random_string(8)))?; + let cipher = seed; + + let mut key = [0u8; size_of::()]; + OsRng.fill_bytes(&mut key); + let key_ga = Key::from_slice(&key); + let db_cipher = XChaCha20Poly1305::new(key_ga); + let factory = CryptoFactories::new(rangeproof_size); + + TransactionKeyManagerWrapper::>::new( + cipher, + KeyManagerDatabase::new(KeyManagerSqliteDatabase::init(connection, db_cipher)), + factory, + WalletType::default(), + ) +} + pub fn create_memory_db_key_manager() -> Result { create_memory_db_key_manager_with_range_proof_size(64) } diff --git a/base_layer/core/src/transactions/key_manager/mod.rs b/base_layer/core/src/transactions/key_manager/mod.rs index 37fe079630..157883564e 100644 --- a/base_layer/core/src/transactions/key_manager/mod.rs +++ b/base_layer/core/src/transactions/key_manager/mod.rs @@ -42,6 +42,7 @@ mod memory_db_key_manager; pub use inner::TransactionKeyManagerInner; pub use memory_db_key_manager::{ create_memory_db_key_manager, + create_memory_db_key_manager_from_seed, create_memory_db_key_manager_with_range_proof_size, MemoryDbKeyManager, };