88using BTCPayServer . Plugins . Monero . RPC ;
99using BTCPayServer . Plugins . Monero . RPC . Models ;
1010
11+ using Monero . Common ;
12+
1113using NBitcoin ;
1214
1315namespace BTCPayServer . Plugins . Monero . Services
@@ -16,12 +18,9 @@ public class MoneroRPCProvider
1618 {
1719 private readonly MoneroLikeConfiguration _moneroLikeConfiguration ;
1820 private readonly EventAggregator _eventAggregator ;
19- public ImmutableDictionary < string , JsonRpcClient > DaemonRpcClients ;
20- public ImmutableDictionary < string , JsonRpcClient > WalletRpcClients ;
21-
22- private readonly ConcurrentDictionary < string , MoneroLikeSummary > _summaries = new ( ) ;
23-
24- public ConcurrentDictionary < string , MoneroLikeSummary > Summaries => _summaries ;
21+ public ImmutableDictionary < string , MoneroRpcConnection > DaemonRpcClients ;
22+ public ImmutableDictionary < string , MoneroRpcConnection > WalletRpcClients ;
23+ public ConcurrentDictionary < string , MoneroLikeSummary > Summaries { get ; } = new ( ) ;
2524
2625 public MoneroRPCProvider ( MoneroLikeConfiguration moneroLikeConfiguration ,
2726 EventAggregator eventAggregator ,
@@ -31,19 +30,19 @@ public MoneroRPCProvider(MoneroLikeConfiguration moneroLikeConfiguration,
3130 _eventAggregator = eventAggregator ;
3231 DaemonRpcClients =
3332 _moneroLikeConfiguration . MoneroLikeConfigurationItems . ToImmutableDictionary ( pair => pair . Key ,
34- pair => new JsonRpcClient ( pair . Value . DaemonRpcUri , pair . Value . Username , pair . Value . Password ,
33+ pair => new MoneroRpcConnection ( pair . Value . DaemonRpcUri , pair . Value . Username , pair . Value . Password ,
3534 httpClientFactory . CreateClient ( $ "{ pair . Key } client") ) ) ;
3635 WalletRpcClients =
3736 _moneroLikeConfiguration . MoneroLikeConfigurationItems . ToImmutableDictionary ( pair => pair . Key ,
38- pair => new JsonRpcClient ( pair . Value . InternalWalletRpcUri , "" , "" ,
37+ pair => new MoneroRpcConnection ( pair . Value . InternalWalletRpcUri , "" , "" ,
3938 httpClientFactory . CreateClient ( $ "{ pair . Key } client") ) ) ;
4039 }
4140
4241 public bool IsConfigured ( string cryptoCode ) => WalletRpcClients . ContainsKey ( cryptoCode ) && DaemonRpcClients . ContainsKey ( cryptoCode ) ;
4342 public bool IsAvailable ( string cryptoCode )
4443 {
4544 cryptoCode = cryptoCode . ToUpperInvariant ( ) ;
46- return _summaries . ContainsKey ( cryptoCode ) && IsAvailable ( _summaries [ cryptoCode ] ) ;
45+ return Summaries . ContainsKey ( cryptoCode ) && IsAvailable ( Summaries [ cryptoCode ] ) ;
4746 }
4847
4948 private bool IsAvailable ( MoneroLikeSummary summary )
@@ -90,9 +89,9 @@ public async Task<MoneroLikeSummary> UpdateSummary(string cryptoCode)
9089 summary . WalletAvailable = false ;
9190 }
9291
93- var changed = ! _summaries . ContainsKey ( cryptoCode ) || IsAvailable ( cryptoCode ) != IsAvailable ( summary ) ;
92+ var changed = ! Summaries . ContainsKey ( cryptoCode ) || IsAvailable ( cryptoCode ) != IsAvailable ( summary ) ;
9493
95- _summaries . AddOrReplace ( cryptoCode , summary ) ;
94+ Summaries . AddOrReplace ( cryptoCode , summary ) ;
9695 if ( changed )
9796 {
9897 _eventAggregator . Publish ( new MoneroDaemonStateChange ( ) { Summary = summary , CryptoCode = cryptoCode } ) ;
0 commit comments