From 2d608621d9853536175f63ad101798ba9b4954b1 Mon Sep 17 00:00:00 2001
From: Dennis Reimann
Date: Wed, 5 Aug 2020 11:20:34 +0200
Subject: [PATCH] Remove confirm option for seed from wallet settings
Closes #1813.
---
BTCPayServer.Tests/SeleniumTests.cs | 8 ++++++-
BTCPayServer/Controllers/WalletsController.cs | 1 +
BTCPayServer/Extensions.cs | 1 +
.../RecoverySeedBackupViewModel.cs | 3 ++-
.../Views/Home/RecoverySeedBackup.cshtml | 21 ++++++++++++-------
5 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/BTCPayServer.Tests/SeleniumTests.cs b/BTCPayServer.Tests/SeleniumTests.cs
index d214abb64..4145dba4f 100644
--- a/BTCPayServer.Tests/SeleniumTests.cs
+++ b/BTCPayServer.Tests/SeleniumTests.cs
@@ -664,6 +664,7 @@ namespace BTCPayServer.Tests
Assert.Equal(parsedBip21.Address.ToString(), s.Driver.FindElement(By.Id($"Outputs_0__DestinationAddress")).GetAttribute("value"));
s.GoToWallet(new WalletId(storeId.storeId, "BTC"), WalletsNavPages.Settings);
+ var walletUrl = s.Driver.Url;
s.Driver.FindElement(By.Id("SettingsMenu")).ForceClick();
s.Driver.FindElement(By.CssSelector("button[value=view-seed]")).Click();
@@ -671,7 +672,12 @@ namespace BTCPayServer.Tests
// Seed backup page
var recoveryPhrase = s.Driver.FindElements(By.Id("recovery-phrase")).First().GetAttribute("data-mnemonic");
Assert.Equal(mnemonic.ToString(), recoveryPhrase);
- Assert.Contains("The recovery phrase will also be stored on a server as a hot wallet.", s.Driver.PageSource);
+ Assert.Contains("The recovery phrase will also be stored on the server as a hot wallet.", s.Driver.PageSource);
+
+ // No confirmation, just a link to return to the wallet
+ Assert.Empty(s.Driver.FindElements(By.Id("confirm")));
+ s.Driver.FindElement(By.Id("proceed")).Click();
+ Assert.Equal(walletUrl, s.Driver.Url);
}
}
void SetTransactionOutput(SeleniumTester s, int index, BitcoinAddress dest, decimal amount, bool subtract = false)
diff --git a/BTCPayServer/Controllers/WalletsController.cs b/BTCPayServer/Controllers/WalletsController.cs
index 5d73f04c4..b165add39 100644
--- a/BTCPayServer/Controllers/WalletsController.cs
+++ b/BTCPayServer/Controllers/WalletsController.cs
@@ -1160,6 +1160,7 @@ namespace BTCPayServer.Controllers
CryptoCode = walletId.CryptoCode,
Mnemonic = seed,
IsStored = true,
+ RequireConfirm = false,
ReturnUrl = Url.Action(nameof(WalletSettings), new { walletId })
};
return this.RedirectToRecoverySeedBackup(recoveryVm);
diff --git a/BTCPayServer/Extensions.cs b/BTCPayServer/Extensions.cs
index eb4ad0f44..0eff102dc 100644
--- a/BTCPayServer/Extensions.cs
+++ b/BTCPayServer/Extensions.cs
@@ -445,6 +445,7 @@ namespace BTCPayServer
new KeyValuePair("mnemonic", vm.Mnemonic),
new KeyValuePair("passphrase", vm.Passphrase),
new KeyValuePair("isStored", vm.IsStored ? "true" : "false"),
+ new KeyValuePair("requireConfirm", vm.RequireConfirm ? "true" : "false"),
new KeyValuePair("returnUrl", vm.ReturnUrl)
}
};
diff --git a/BTCPayServer/Models/StoreViewModels/RecoverySeedBackupViewModel.cs b/BTCPayServer/Models/StoreViewModels/RecoverySeedBackupViewModel.cs
index 265d37f27..a00c7a20f 100644
--- a/BTCPayServer/Models/StoreViewModels/RecoverySeedBackupViewModel.cs
+++ b/BTCPayServer/Models/StoreViewModels/RecoverySeedBackupViewModel.cs
@@ -10,8 +10,9 @@ namespace BTCPayServer.Models.StoreViewModels
public string CryptoCode { get; set; }
public string Mnemonic { get; set; }
public string Passphrase { get; set; }
- public bool IsStored { get; set; }
public string ReturnUrl { get; set; }
+ public bool IsStored { get; set; }
+ public bool RequireConfirm { get; set; } = true;
public string[] Words
{
diff --git a/BTCPayServer/Views/Home/RecoverySeedBackup.cshtml b/BTCPayServer/Views/Home/RecoverySeedBackup.cshtml
index 519a3e53f..f9f12af33 100644
--- a/BTCPayServer/Views/Home/RecoverySeedBackup.cshtml
+++ b/BTCPayServer/Views/Home/RecoverySeedBackup.cshtml
@@ -46,7 +46,7 @@
Do not photograph it. Do not store it digitally.
- The recovery phrase will also be stored on a server as a hot wallet.
+ The recovery phrase will also be stored on the server as a hot wallet.
}
else
@@ -65,11 +65,18 @@
Please make sure to also write down your passphrase.
}
-
+ @if (Model.RequireConfirm)
+ {
+
+ }
+ else
+ {
+ Done
+ }