From 06a96e8b7758b441b2e13d3b7f0fe20cd7e434f4 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Wed, 18 Oct 2017 10:40:59 +0900 Subject: [PATCH 1/9] README, prevent a nullreferenceexception --- BTCPayServer.Tests/README.md | 6 ++++++ BTCPayServer/Views/Stores/CreateToken.cshtml | 2 ++ 2 files changed, 8 insertions(+) diff --git a/BTCPayServer.Tests/README.md b/BTCPayServer.Tests/README.md index 652c0bca4..14ebab334 100644 --- a/BTCPayServer.Tests/README.md +++ b/BTCPayServer.Tests/README.md @@ -19,6 +19,12 @@ Once you want to stop docker-compose down ``` +If you want to stop, and remove all existing data + +``` +docker-compose down -v +``` + You can run the tests inside a container by running ``` diff --git a/BTCPayServer/Views/Stores/CreateToken.cshtml b/BTCPayServer/Views/Stores/CreateToken.cshtml index f18be63fe..46ec03af4 100644 --- a/BTCPayServer/Views/Stores/CreateToken.cshtml +++ b/BTCPayServer/Views/Stores/CreateToken.cshtml @@ -3,6 +3,8 @@ Layout = "../Shared/_NavLayout.cshtml"; ViewData["Title"] = "Create a new token"; ViewData.AddActivePage(StoreNavPages.Tokens); + ViewBag.HidePublicKey = ViewBag.HidePublicKey ?? false; + ViewBag.ShowStores = ViewBag.ShowStores ?? false; }

@ViewData["Title"]

From 94e9ab7f672e84e0a5d57525a304f861bd7077bc Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Wed, 18 Oct 2017 18:43:52 +0900 Subject: [PATCH 2/9] In server-initiated situation, the server can set the label --- BTCPayServer.Tests/UnitTest1.cs | 2 +- BTCPayServer/Controllers/AccessTokenController.cs | 6 ++++++ BTCPayServer/Controllers/StoresController.cs | 2 +- BTCPayServer/Models/StoreViewModels/TokensViewModel.cs | 2 +- BTCPayServer/Views/Stores/CreateToken.cshtml | 4 ++++ 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index a629012fc..fe3bbcac2 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -118,7 +118,7 @@ namespace BTCPayServer.Tests var acc = tester.NewAccount(); acc.Register(); acc.CreateStore(); - + var controller = tester.PayTester.GetController(acc.UserId); var token = (RedirectToActionResult)controller.CreateToken(acc.StoreId, new Models.StoreViewModels.CreateTokenViewModel() { diff --git a/BTCPayServer/Controllers/AccessTokenController.cs b/BTCPayServer/Controllers/AccessTokenController.cs index 4e8601d92..b72c90a4c 100644 --- a/BTCPayServer/Controllers/AccessTokenController.cs +++ b/BTCPayServer/Controllers/AccessTokenController.cs @@ -58,6 +58,12 @@ namespace BTCPayServer.Controllers pairingEntity = await _TokenRepository.GetPairingAsync(request.PairingCode); pairingEntity.SIN = sin; + if(string.IsNullOrEmpty(pairingEntity.Label) && !string.IsNullOrEmpty(request.Label)) + { + pairingEntity.Label = request.Label; + await _TokenRepository.UpdatePairingCode(pairingEntity); + } + var result = await _TokenRepository.PairWithSINAsync(request.PairingCode, sin); if(result != PairingResult.Complete && result != PairingResult.Partial) throw new BitpayHttpException(400, $"Error while pairing ({result})"); diff --git a/BTCPayServer/Controllers/StoresController.cs b/BTCPayServer/Controllers/StoresController.cs index 8827b83de..31d15eb08 100644 --- a/BTCPayServer/Controllers/StoresController.cs +++ b/BTCPayServer/Controllers/StoresController.cs @@ -230,7 +230,7 @@ namespace BTCPayServer.Controllers { return View(model); } - + model.Label = model.Label ?? String.Empty; if(storeId == null) // Permissions are not checked by Policy if the storeId is not passed by url { storeId = model.StoreId; diff --git a/BTCPayServer/Models/StoreViewModels/TokensViewModel.cs b/BTCPayServer/Models/StoreViewModels/TokensViewModel.cs index 8788d1ad2..f5dd739dc 100644 --- a/BTCPayServer/Models/StoreViewModels/TokensViewModel.cs +++ b/BTCPayServer/Models/StoreViewModels/TokensViewModel.cs @@ -15,7 +15,7 @@ namespace BTCPayServer.Models.StoreViewModels { get; set; } - [Required] + public string Label { get; set; diff --git a/BTCPayServer/Views/Stores/CreateToken.cshtml b/BTCPayServer/Views/Stores/CreateToken.cshtml index 46ec03af4..93a7ec8c1 100644 --- a/BTCPayServer/Views/Stores/CreateToken.cshtml +++ b/BTCPayServer/Views/Stores/CreateToken.cshtml @@ -14,6 +14,10 @@
+ @if(ViewBag.HidePublicKey) + { + optional + }
From ff719fbe2d280ae2984c875840711bba8a9784ac Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Wed, 18 Oct 2017 18:45:00 +0900 Subject: [PATCH 3/9] bump --- BTCPayServer/BTCPayServer.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index f450ee4c3..d18d7ed6a 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -2,7 +2,7 @@ Exe netcoreapp2.0 - 1.0.0.15 + 1.0.0.16 From 1a060a6c7bb0e41a2ee0b5a56edbd1d744737f6f Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Thu, 19 Oct 2017 01:33:55 +0900 Subject: [PATCH 4/9] Fix checkout page --- BTCPayServer/Controllers/InvoiceController.UI.cs | 1 + BTCPayServer/Models/InvoicingModels/PaymentModel.cs | 5 ++++- BTCPayServer/Views/Invoice/Checkout.cshtml | 1 + BTCPayServer/wwwroot/js/core.js | 4 ++-- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/BTCPayServer/Controllers/InvoiceController.UI.cs b/BTCPayServer/Controllers/InvoiceController.UI.cs index 7eae4a662..832b09ac5 100644 --- a/BTCPayServer/Controllers/InvoiceController.UI.cs +++ b/BTCPayServer/Controllers/InvoiceController.UI.cs @@ -112,6 +112,7 @@ namespace BTCPayServer.Controllers var model = new PaymentModel() { + ServerUrl = HttpContext.Request.GetAbsoluteRoot(), OrderId = invoice.OrderId, InvoiceId = invoice.Id, BTCAddress = invoice.DepositAddress.ToString(), diff --git a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs index 1f19e91c9..f10f39e12 100644 --- a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs +++ b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs @@ -11,7 +11,10 @@ namespace BTCPayServer.Models.InvoicingModels { get; set; } - + public string ServerUrl + { + get; set; + } public string OrderId { get; set; diff --git a/BTCPayServer/Views/Invoice/Checkout.cshtml b/BTCPayServer/Views/Invoice/Checkout.cshtml index 9a68d39a6..42b58c733 100644 --- a/BTCPayServer/Views/Invoice/Checkout.cshtml +++ b/BTCPayServer/Views/Invoice/Checkout.cshtml @@ -27,6 +27,7 @@ crossorigin="anonymous">