diff --git a/BTCPayServer/Controllers/StoresController.BTCLike.cs b/BTCPayServer/Controllers/StoresController.BTCLike.cs index 4d7bd8c1a..b347f2326 100644 --- a/BTCPayServer/Controllers/StoresController.BTCLike.cs +++ b/BTCPayServer/Controllers/StoresController.BTCLike.cs @@ -5,6 +5,7 @@ using System.Globalization; using System.IO; using System.Linq; using System.Net.WebSockets; +using System.Reflection.Metadata.Ecma335; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -54,7 +55,9 @@ namespace BTCPayServer.Controllers vm.Config = derivation.ToJson(); } vm.Enabled = !store.GetStoreBlob().IsExcluded(new PaymentMethodId(vm.CryptoCode, PaymentTypes.BTCLike)); - vm.CanUseHotWallet = await CanUseHotWallet(); + var hotWallet = await CanUseHotWallet(); + vm.CanUseHotWallet = hotWallet.HotWallet; + vm.CanUseRPCImport = hotWallet.RPCImport; return View(vm); } @@ -332,8 +335,8 @@ namespace BTCPayServer.Controllers GenerateWalletRequest request) { Logs.Events.LogInformation($"GenerateNBXWallet called {storeId}, {cryptoCode}"); - - if (!await CanUseHotWallet()) + var hotWallet = await CanUseHotWallet(); + if (!hotWallet.HotWallet || (!hotWallet.RPCImport && request.ImportKeysToRPC)) { return NotFound(); } @@ -395,13 +398,14 @@ namespace BTCPayServer.Controllers return result; } - private async Task CanUseHotWallet() + private async Task<(bool HotWallet, bool RPCImport)> CanUseHotWallet() { var isAdmin = (await _authorizationService.AuthorizeAsync(User, Policies.CanModifyServerSettings)).Succeeded; if (isAdmin) - return true; + return (true, true); var policies = await _settingsRepository.GetSettingAsync(); - return policies?.AllowHotWalletForAll is true; + var hotWallet = policies?.AllowHotWalletForAll is true; + return (hotWallet, hotWallet && policies?.AllowHotWalletRPCImportForAll is true); } private async Task ReadAllText(IFormFile file) diff --git a/BTCPayServer/Models/StoreViewModels/DerivationSchemeViewModel.cs b/BTCPayServer/Models/StoreViewModels/DerivationSchemeViewModel.cs index b447d44d8..bd8bc1847 100644 --- a/BTCPayServer/Models/StoreViewModels/DerivationSchemeViewModel.cs +++ b/BTCPayServer/Models/StoreViewModels/DerivationSchemeViewModel.cs @@ -11,6 +11,7 @@ namespace BTCPayServer.Models.StoreViewModels { public class DerivationSchemeViewModel { + public DerivationSchemeViewModel() { } @@ -42,6 +43,7 @@ namespace BTCPayServer.Models.StoreViewModels public string AccountKey { get; set; } public BTCPayNetwork Network { get; set; } public bool CanUseHotWallet { get; set; } + public bool CanUseRPCImport { get; set; } public RootedKeyPath GetAccountKeypath() { diff --git a/BTCPayServer/Services/PoliciesSettings.cs b/BTCPayServer/Services/PoliciesSettings.cs index 9dddeca6e..cfd112790 100644 --- a/BTCPayServer/Services/PoliciesSettings.cs +++ b/BTCPayServer/Services/PoliciesSettings.cs @@ -25,6 +25,8 @@ namespace BTCPayServer.Services public bool AllowLightningInternalNodeForAll { get; set; } [Display(Name = "Allow non-admins to create hot wallets for their stores")] public bool AllowHotWalletForAll { get; set; } + [Display(Name = "Allow non-admins to import their hot wallets to the node wallet")] + public bool AllowHotWalletRPCImportForAll { get; set; } [Display(Name = "Display app on website root")] public string RootAppId { get; set; } diff --git a/BTCPayServer/Views/Server/Policies.cshtml b/BTCPayServer/Views/Server/Policies.cshtml index 972d6db01..f28c0e2d8 100644 --- a/BTCPayServer/Views/Server/Policies.cshtml +++ b/BTCPayServer/Views/Server/Policies.cshtml @@ -37,6 +37,11 @@ +
+ + + +
diff --git a/BTCPayServer/Views/Stores/AddDerivationSchemes_HardwareWalletDialogs.cshtml b/BTCPayServer/Views/Stores/AddDerivationSchemes_HardwareWalletDialogs.cshtml index 02895a111..8d47923ee 100644 --- a/BTCPayServer/Views/Stores/AddDerivationSchemes_HardwareWalletDialogs.cshtml +++ b/BTCPayServer/Views/Stores/AddDerivationSchemes_HardwareWalletDialogs.cshtml @@ -2,6 +2,8 @@ @model DerivationSchemeViewModel @if (Model.CanUseHotWallet) { + ViewData.Add(nameof(Model.CanUseRPCImport), Model.CanUseRPCImport); + } -
- - - - - If checked, each address generated will be imported into the node wallet so that you can view your balance through your node. When this is enabled alongside Is hot wallet, you're also able to use the node wallet to spend (this works pretty well in conjunction with apps such as FullyNoded). - -
+ @if (ViewData["CanUseRPCImport"] is true) + { +
+ + + + + If checked, each address generated will be imported into the node wallet so that you can view your balance through your node. When this is enabled alongside Is hot wallet, you're also able to use the node wallet to spend (this works pretty well in conjunction with apps such as FullyNoded). + +
+ }