From 3818468932cb7278edeb963abaab29384aa031ee Mon Sep 17 00:00:00 2001 From: Andrew Camilleri Date: Thu, 1 Jun 2023 14:18:28 +0200 Subject: [PATCH] Pluginify on chain wallet setup (#4999) * Pluginify on chain wallet setup This PR fixes a few logical points in the wallet setup flow to allow more extensive plugin flexibility; It also fixes an issue when building plugins that requires an Altcoin config profile. Here is an example showcasing the Liquid+ plugin using this to enforce that it is a hot wallet (a requirement it has) and that import to RPC is always set, and a new option that is used to configure the wallet further https://i.imgur.com/pDPQ73v.gif * Update BTCPayServer/Controllers/UIStoresController.Onchain.cs * update nbx --- BTCPayServer.Client/BTCPayServer.Client.csproj | 2 ++ BTCPayServer.Common/BTCPayServer.Common.csproj | 2 +- BTCPayServer/Controllers/UIStoresController.Onchain.cs | 5 +++-- BTCPayServer/Models/StoreViewModels/WalletSetupRequest.cs | 1 + BTCPayServer/Views/UIStores/_GenerateWalletForm.cshtml | 8 +++++++- BTCPayServer/Views/UIStores/_LayoutWalletSetup.cshtml | 2 ++ 6 files changed, 16 insertions(+), 4 deletions(-) diff --git a/BTCPayServer.Client/BTCPayServer.Client.csproj b/BTCPayServer.Client/BTCPayServer.Client.csproj index f3086d462..e40c27e0e 100644 --- a/BTCPayServer.Client/BTCPayServer.Client.csproj +++ b/BTCPayServer.Client/BTCPayServer.Client.csproj @@ -12,6 +12,8 @@ MIT https://github.com/btcpayserver/btcpayserver git + Debug;Release;Altcoins-Debug;Altcoins-Release + AnyCPU 1.7.2 diff --git a/BTCPayServer.Common/BTCPayServer.Common.csproj b/BTCPayServer.Common/BTCPayServer.Common.csproj index 9535980ce..131983c22 100644 --- a/BTCPayServer.Common/BTCPayServer.Common.csproj +++ b/BTCPayServer.Common/BTCPayServer.Common.csproj @@ -4,7 +4,7 @@ - + diff --git a/BTCPayServer/Controllers/UIStoresController.Onchain.cs b/BTCPayServer/Controllers/UIStoresController.Onchain.cs index 8b2d8f1f8..85b94650d 100644 --- a/BTCPayServer/Controllers/UIStoresController.Onchain.cs +++ b/BTCPayServer/Controllers/UIStoresController.Onchain.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.ObjectModel; using System.IO; using System.Linq; using System.Text; @@ -250,7 +251,7 @@ namespace BTCPayServer.Controllers CryptoCode = cryptoCode, Method = method, SetupRequest = request, - Confirmation = string.IsNullOrEmpty(request.ExistingMnemonic), + Confirmation = !isImport, Network = network, Source = isImport ? "SeedImported" : "NBXplorerGenerated", IsHotWallet = isImport ? request.SavePrivateKeys : method == WalletSetupMethod.HotWallet, @@ -311,7 +312,7 @@ namespace BTCPayServer.Controllers var result = await UpdateWallet(vm); - if (!ModelState.IsValid || !(result is RedirectToActionResult)) + if (!ModelState.IsValid || result is not RedirectToActionResult) return result; if (!isImport) diff --git a/BTCPayServer/Models/StoreViewModels/WalletSetupRequest.cs b/BTCPayServer/Models/StoreViewModels/WalletSetupRequest.cs index 9d043f1ed..d6a31f571 100644 --- a/BTCPayServer/Models/StoreViewModels/WalletSetupRequest.cs +++ b/BTCPayServer/Models/StoreViewModels/WalletSetupRequest.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using NBXplorer.Models; namespace BTCPayServer.Models.StoreViewModels diff --git a/BTCPayServer/Views/UIStores/_GenerateWalletForm.cshtml b/BTCPayServer/Views/UIStores/_GenerateWalletForm.cshtml index 55d4b6c3e..9a03af5ad 100644 --- a/BTCPayServer/Views/UIStores/_GenerateWalletForm.cshtml +++ b/BTCPayServer/Views/UIStores/_GenerateWalletForm.cshtml @@ -140,7 +140,13 @@ - + @if (Model.AdditionalOptions is not null) + { + @foreach (var dictKeys in Model.AdditionalOptions) + { + + } + } diff --git a/BTCPayServer/Views/UIStores/_LayoutWalletSetup.cshtml b/BTCPayServer/Views/UIStores/_LayoutWalletSetup.cshtml index 725211cd3..686454c0e 100644 --- a/BTCPayServer/Views/UIStores/_LayoutWalletSetup.cshtml +++ b/BTCPayServer/Views/UIStores/_LayoutWalletSetup.cshtml @@ -19,3 +19,5 @@ } @RenderBody() + +