@@ -112,6 +112,22 @@ pub(crate) fn prepare_home_dir(home_path: Option<PathBuf>) -> Result<PathBuf, Er
112112 Ok ( dir)
113113}
114114
115+ /// Prepare wallet database directory.
116+ #[ allow( dead_code) ]
117+ pub ( crate ) fn prepare_wallet_db_dir (
118+ home_path : & Path ,
119+ wallet_name : & str ,
120+ ) -> Result < std:: path:: PathBuf , Error > {
121+ let mut dir = home_path. to_owned ( ) ;
122+ dir. push ( wallet_name) ;
123+
124+ if !dir. exists ( ) {
125+ std:: fs:: create_dir ( & dir) . map_err ( |e| Error :: Generic ( e. to_string ( ) ) ) ?;
126+ }
127+
128+ Ok ( dir)
129+ }
130+
115131pub fn is_mnemonic ( s : & str ) -> bool {
116132 let word_count = s. split_whitespace ( ) . count ( ) ;
117133 ( 12 ..=24 ) . contains ( & word_count) && s. chars ( ) . all ( |c| c. is_alphanumeric ( ) || c. is_whitespace ( ) )
@@ -138,19 +154,12 @@ pub async fn trace_logger(
138154 }
139155}
140156
141- /// Prepare wallet database directory and config .
142- pub fn prepare_wallet_db_dir_and_config (
143- home_path : & Path ,
157+ /// Prepare wallet database directory.
158+ pub fn load_wallet_config (
159+ home_dir : & Path ,
144160 wallet_name : & str ,
145- ) -> Result < ( std:: path:: PathBuf , WalletOpts , Network ) , Error > {
146- let mut dir = home_path. to_owned ( ) ;
147- dir. push ( wallet_name) ;
148-
149- if !dir. exists ( ) {
150- std:: fs:: create_dir ( & dir) . map_err ( |e| Error :: Generic ( e. to_string ( ) ) ) ?;
151- }
152-
153- let config = WalletConfig :: load ( home_path) ?. ok_or ( Error :: Generic ( format ! (
161+ ) -> Result < ( WalletOpts , Network ) , Error > {
162+ let config = WalletConfig :: load ( home_dir) ?. ok_or ( Error :: Generic ( format ! (
154163 "No config found for wallet {wallet_name}" ,
155164 ) ) ) ?;
156165
@@ -165,7 +174,7 @@ pub fn prepare_wallet_db_dir_and_config(
165174 let network = Network :: from_str ( & wallet_config. network )
166175 . map_err ( |_| Error :: Generic ( "Invalid network in config" . to_string ( ) ) ) ?;
167176
168- Ok ( ( dir , wallet_opts, network) )
177+ Ok ( ( wallet_opts, network) )
169178}
170179
171180#[ cfg( feature = "silent-payments" ) ]
0 commit comments