Skip to content

Commit c14f84f

Browse files
rebase
1 parent 47c5858 commit c14f84f

2 files changed

Lines changed: 27 additions & 11 deletions

File tree

BTCPayServer.Plugins.IntegrationTests/Monero/MoneroPluginIntegrationTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Diagnostics;
12
using BTCPayServer.Plugins.Monero.Services;
23
using BTCPayServer.Rating;
34
using BTCPayServer.Services.Rates;

Plugins/Monero/Services/MoneroRPCProvider.cs

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)