@@ -83,6 +83,32 @@ await walletRpcClient.SendCommandAsync<OpenWalletRequest, object>(
8383 return false ;
8484 }
8585 }
86+
87+ public async Task < bool > CloseWallet ( string cryptoCode )
88+ {
89+ cryptoCode = cryptoCode . ToUpperInvariant ( ) ;
90+ if ( ! WalletRpcClients . TryGetValue ( cryptoCode , out var walletRpcClient ) )
91+ {
92+ return false ;
93+ }
94+ try
95+ {
96+ await walletRpcClient . SendCommandAsync < JsonRpcClient . NoRequestModel , object > (
97+ "close_wallet" , JsonRpcClient . NoRequestModel . Instance ) ;
98+
99+ if ( _summaries . TryGetValue ( cryptoCode , out var summary ) )
100+ {
101+ summary . WalletAvailable = false ;
102+ _summaries . AddOrReplace ( cryptoCode , summary ) ;
103+ _eventAggregator . Publish ( new MoneroDaemonStateChange ( ) { Summary = summary , CryptoCode = cryptoCode } ) ;
104+ }
105+ return true ;
106+ }
107+ catch
108+ {
109+ return false ;
110+ }
111+ }
86112
87113 public async Task < ( bool Success , string ErrorMessage ) > CreateWalletFromKeys (
88114 string cryptoCode ,
@@ -276,17 +302,6 @@ public string[] GetWalletList(string cryptoCode)
276302 }
277303 }
278304
279- public async Task CloseWallet ( string cryptoCode )
280- {
281- if ( ! WalletRpcClients . TryGetValue ( cryptoCode . ToUpperInvariant ( ) , out var walletRpcClient ) )
282- {
283- throw new InvalidOperationException ( $ "Wallet RPC client not found for { cryptoCode } ") ;
284- }
285-
286- await walletRpcClient . SendCommandAsync < JsonRpcClient . NoRequestModel , object > (
287- "close_wallet" , JsonRpcClient . NoRequestModel . Instance ) ;
288- }
289-
290305 public void DeleteWallet ( )
291306 {
292307 if ( ! _moneroLikeConfiguration . MoneroLikeConfigurationItems . TryGetValue ( "XMR" , out var configItem ) )
0 commit comments