diff --git a/BTCPayServer.Tests/docker-compose.altcoins.yml b/BTCPayServer.Tests/docker-compose.altcoins.yml index 41a418133..fd4cbe798 100644 --- a/BTCPayServer.Tests/docker-compose.altcoins.yml +++ b/BTCPayServer.Tests/docker-compose.altcoins.yml @@ -310,6 +310,7 @@ services: - "tor_datadir:/home/tor/.tor" - "torrcdir:/usr/local/etc/tor" - "tor_servicesdir:/var/lib/tor/hidden_services" + monerod: image: btcpayserver/monero:0.18.3.3 restart: unless-stopped @@ -319,6 +320,7 @@ services: - "monero_data:/home/monero/.bitmonero" ports: - "18081:18081" + monero_wallet: image: btcpayserver/monero:0.18.3.3 restart: unless-stopped @@ -330,6 +332,7 @@ services: - "./monero_wallet:/wallet" depends_on: - monerod + litecoind: restart: unless-stopped image: btcpayserver/litecoin:0.18.1 diff --git a/BTCPayServer/Plugins/Altcoins/Monero/RPC/Models/OpenWallerErrorResponse.cs b/BTCPayServer/Plugins/Altcoins/Monero/RPC/Models/OpenWallerErrorResponse.cs new file mode 100644 index 000000000..90c4e6e22 --- /dev/null +++ b/BTCPayServer/Plugins/Altcoins/Monero/RPC/Models/OpenWallerErrorResponse.cs @@ -0,0 +1,10 @@ +using Newtonsoft.Json; + +namespace BTCPayServer.Services.Altcoins.Monero.RPC.Models +{ + public partial class OpenWalletErrorResponse + { + [JsonProperty("code")] public int Code { get; set; } + [JsonProperty("message")] public string Message { get; set; } + } +} diff --git a/BTCPayServer/Plugins/Altcoins/Monero/RPC/Models/OpenWalletRequest.cs b/BTCPayServer/Plugins/Altcoins/Monero/RPC/Models/OpenWalletRequest.cs new file mode 100644 index 000000000..3da005827 --- /dev/null +++ b/BTCPayServer/Plugins/Altcoins/Monero/RPC/Models/OpenWalletRequest.cs @@ -0,0 +1,10 @@ +using Newtonsoft.Json; + +namespace BTCPayServer.Services.Altcoins.Monero.RPC.Models +{ + public partial class OpenWalletRequest + { + [JsonProperty("filename")] public string Filename { get; set; } + [JsonProperty("password")] public string Password { get; set; } + } +} diff --git a/BTCPayServer/Plugins/Altcoins/Monero/RPC/Models/OpenWalletResponse.cs b/BTCPayServer/Plugins/Altcoins/Monero/RPC/Models/OpenWalletResponse.cs new file mode 100644 index 000000000..75c2a3a86 --- /dev/null +++ b/BTCPayServer/Plugins/Altcoins/Monero/RPC/Models/OpenWalletResponse.cs @@ -0,0 +1,12 @@ +using Newtonsoft.Json; + +namespace BTCPayServer.Services.Altcoins.Monero.RPC.Models +{ + public partial class OpenWalletResponse + { + [JsonProperty("id")] public string Id { get; set; } + [JsonProperty("jsonrpc")] public string Jsonrpc { get; set; } + [JsonProperty("result")] public object Result { get; set; } + [JsonProperty("error")] public OpenWalletErrorResponse Error { get; set; } + } +} diff --git a/BTCPayServer/Properties/launchSettings.json b/BTCPayServer/Properties/launchSettings.json index 6c0d3e5cf..7e23a1c84 100644 --- a/BTCPayServer/Properties/launchSettings.json +++ b/BTCPayServer/Properties/launchSettings.json @@ -70,6 +70,47 @@ }, "applicationUrl": "https://localhost:14142/" }, + "Altcoins": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "BTCPAY_EXPERIMENTALV2_CONFIRM": "true", + "BTCPAY_NETWORK": "regtest", + "BTCPAY_LAUNCHSETTINGS": "true", + "BTCPAY_PORT": "14142", + "BTCPAY_HttpsUseDefaultCertificate": "true", + "BTCPAY_VERBOSE": "true", + "BTCPAY_LTCEXPLORERURL": "http://127.0.0.1:32838/", + "BTCPAY_LBTCEXPLORERURL": "http://127.0.0.1:32838/", + "BTCPAY_BTCLIGHTNING": "type=clightning;server=tcp://127.0.0.1:30993/", + "BTCPAY_BTCEXTERNALLNDREST": "type=lnd-rest;server=http://lnd:lnd@127.0.0.1:35531/;allowinsecure=true", + "BTCPAY_BTCEXTERNALLNDSEEDBACKUP": "../BTCPayServer.Tests/TestData/LndSeedBackup/walletunlock.json", + "BTCPAY_BTCEXTERNALSPARK": "server=/spark/btc/;cookiefile=fake", + "BTCPAY_BTCEXTERNALCHARGE": "server=https://127.0.0.1:53280/mycharge/btc/;cookiefilepath=fake", + "BTCPAY_BTCEXTERNALRTL": "server=/rtl/api/authenticate/cookie;cookiefile=fake", + "BTCPAY_BTCEXTERNALTHUNDERHUB": "server=/thub/sso;cookiefile=fake", + "BTCPAY_BTCEXTERNALTORQ": "server=/torq/cookie-login;cookiefile=fake", + "BTCPAY_EXTERNALSERVICES": "totoservice:totolink;Lightning Terminal:/lit/;", + "BTCPAY_EXTERNALCONFIGURATOR": "passwordfile=testpwd;server=/configurator", + "BTCPAY_BTCEXPLORERURL": "http://127.0.0.1:32838/", + "BTCPAY_ALLOW-ADMIN-REGISTRATION": "true", + "BTCPAY_DISABLE-REGISTRATION": "false", + "ASPNETCORE_ENVIRONMENT": "Development", + "BTCPAY_CHAINS": "btc,ltc,lbtc,xmr", + "BTCPAY_POSTGRES": "User ID=postgres;Include Error Detail=true;Host=127.0.0.1;Port=39372;Database=btcpayserver", + "BTCPAY_DEBUGLOG": "debug.log", + "BTCPAY_TORRCFILE": "../BTCPayServer.Tests/TestData/Tor/torrc", + "BTCPAY_SOCKSENDPOINT": "localhost:9050", + "BTCPAY_DOCKERDEPLOYMENT": "true", + "BTCPAY_RECOMMENDED-PLUGINS": "", + "BTCPAY_CHEATMODE": "true", + "BTCPAY_EXPLORERPOSTGRES": "User ID=postgres;Include Error Detail=true;Host=127.0.0.1;Port=39372;Database=nbxplorer", + "BTCPAY_XMR_DAEMON_URI": "http://127.0.0.1:18081", + "BTCPAY_XMR_WALLET_DAEMON_URI": "http://127.0.0.1:18082", + "BTCPAY_XMR_WALLET_DAEMON_WALLETDIR": "/path/to/monero_wallet" + }, + "applicationUrl": "https://localhost:14142/" + }, "Altcoins-HTTPS": { "commandName": "Project", "launchBrowser": true, @@ -95,7 +136,7 @@ "BTCPAY_ALLOW-ADMIN-REGISTRATION": "true", "BTCPAY_DISABLE-REGISTRATION": "false", "ASPNETCORE_ENVIRONMENT": "Development", - "BTCPAY_CHAINS": "btc,ltc,lbtc", + "BTCPAY_CHAINS": "btc,ltc,lbtc,xmr", "BTCPAY_POSTGRES": "User ID=postgres;Include Error Detail=true;Host=127.0.0.1;Port=39372;Database=btcpayserver", "BTCPAY_SSHCONNECTION": "root@127.0.0.1:21622", "BTCPAY_SSHPASSWORD": "opD3i2282D", @@ -105,7 +146,10 @@ "BTCPAY_DOCKERDEPLOYMENT": "true", "BTCPAY_RECOMMENDED-PLUGINS": "", "BTCPAY_CHEATMODE": "true", - "BTCPAY_EXPLORERPOSTGRES": "User ID=postgres;Include Error Detail=true;Host=127.0.0.1;Port=39372;Database=nbxplorer" + "BTCPAY_EXPLORERPOSTGRES": "User ID=postgres;Include Error Detail=true;Host=127.0.0.1;Port=39372;Database=nbxplorer", + "BTCPAY_XMR_DAEMON_URI": "http://127.0.0.1:18081", + "BTCPAY_XMR_WALLET_DAEMON_URI": "http://127.0.0.1:18082", + "BTCPAY_XMR_WALLET_DAEMON_WALLETDIR": "/path/to/monero_wallet" }, "applicationUrl": "https://localhost:14142/" } diff --git a/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs b/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs index 2da1d3275..d0ebf7bfe 100644 --- a/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs +++ b/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs @@ -249,10 +249,28 @@ namespace BTCPayServer.Services.Altcoins.Monero.UI } } + try + { + var response = await _MoneroRpcProvider.WalletRpcClients[cryptoCode].SendCommandAsync("open_wallet", new OpenWalletRequest + { + Filename = "wallet", + Password = viewModel.WalletPassword + }); + if (response?.Error != null) + { + throw new Exception(response.Error.Message); + } + } + catch (Exception ex) + { + ModelState.AddModelError(nameof(viewModel.AccountIndex), $"Could not open the wallet: {ex.Message}"); + return View(viewModel); + } + return RedirectToAction(nameof(GetStoreMoneroLikePaymentMethod), new { cryptoCode, - StatusMessage = "View-only wallet files uploaded. If they are valid the wallet will soon become available." + StatusMessage = "View-only wallet files uploaded. The wallet will soon become available." }); } diff --git a/BTCPayServer/Views/UIMoneroLikeStore/GetStoreMoneroLikePaymentMethods.cshtml b/BTCPayServer/Views/UIMoneroLikeStore/GetStoreMoneroLikePaymentMethods.cshtml index 3cebbe6d8..83aa22407 100644 --- a/BTCPayServer/Views/UIMoneroLikeStore/GetStoreMoneroLikePaymentMethods.cshtml +++ b/BTCPayServer/Views/UIMoneroLikeStore/GetStoreMoneroLikePaymentMethods.cshtml @@ -3,7 +3,6 @@ @model BTCPayServer.Services.Altcoins.Monero.UI.UIMoneroLikeStoreController.MoneroLikePaymentMethodListViewModel @{ - Layout = "../Shared/_NavLayout.cshtml"; ViewData.SetActivePage("Monero Settings", "Monero Settings", "Monero Settings"); ViewData["NavPartialName"] = "../UIStores/_Nav"; }