mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Fix statusMessage handling for the Receive wallet page
This commit is contained in:
@@ -307,7 +307,7 @@ namespace BTCPayServer.Controllers
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("{walletId}/receive")]
|
[Route("{walletId}/receive")]
|
||||||
public IActionResult WalletReceive([ModelBinder(typeof(WalletIdModelBinder))]
|
public IActionResult WalletReceive([ModelBinder(typeof(WalletIdModelBinder))]
|
||||||
WalletId walletId, string statusMessage = null)
|
WalletId walletId)
|
||||||
{
|
{
|
||||||
if (walletId?.StoreId == null)
|
if (walletId?.StoreId == null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
@@ -319,11 +319,6 @@ namespace BTCPayServer.Controllers
|
|||||||
return NotFound();
|
return NotFound();
|
||||||
|
|
||||||
var address = _WalletReceiveStateService.Get(walletId)?.Address;
|
var address = _WalletReceiveStateService.Get(walletId)?.Address;
|
||||||
if (!string.IsNullOrEmpty(statusMessage))
|
|
||||||
{
|
|
||||||
TempData[WellKnownTempData.SuccessMessage] = statusMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
return View(new WalletReceiveViewModel()
|
return View(new WalletReceiveViewModel()
|
||||||
{
|
{
|
||||||
CryptoCode = walletId.CryptoCode,
|
CryptoCode = walletId.CryptoCode,
|
||||||
@@ -345,7 +340,6 @@ namespace BTCPayServer.Controllers
|
|||||||
var network = this.NetworkProvider.GetNetwork<BTCPayNetwork>(walletId?.CryptoCode);
|
var network = this.NetworkProvider.GetNetwork<BTCPayNetwork>(walletId?.CryptoCode);
|
||||||
if (network == null)
|
if (network == null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
var statusMessage = string.Empty;
|
|
||||||
var wallet = _walletProvider.GetWallet(network);
|
var wallet = _walletProvider.GetWallet(network);
|
||||||
switch (command)
|
switch (command)
|
||||||
{
|
{
|
||||||
@@ -358,12 +352,12 @@ namespace BTCPayServer.Controllers
|
|||||||
var address = cachedAddress.ScriptPubKey.GetDestinationAddress(network.NBitcoinNetwork);
|
var address = cachedAddress.ScriptPubKey.GetDestinationAddress(network.NBitcoinNetwork);
|
||||||
ExplorerClientProvider.GetExplorerClient(network)
|
ExplorerClientProvider.GetExplorerClient(network)
|
||||||
.CancelReservation(cachedAddress.DerivationStrategy, new[] {cachedAddress.KeyPath});
|
.CancelReservation(cachedAddress.DerivationStrategy, new[] {cachedAddress.KeyPath});
|
||||||
statusMessage = new StatusMessageModel()
|
this.TempData.SetStatusMessageModel(new StatusMessageModel()
|
||||||
{
|
{
|
||||||
AllowDismiss =true,
|
AllowDismiss = true,
|
||||||
Message = $"Address {address} was unreserved.",
|
Message = $"Address {address} was unreserved.",
|
||||||
Severity = StatusMessageModel.StatusSeverity.Success,
|
Severity = StatusMessageModel.StatusSeverity.Success,
|
||||||
}.ToString();
|
});
|
||||||
_WalletReceiveStateService.Remove(walletId);
|
_WalletReceiveStateService.Remove(walletId);
|
||||||
break;
|
break;
|
||||||
case "generate-new-address":
|
case "generate-new-address":
|
||||||
@@ -371,7 +365,7 @@ namespace BTCPayServer.Controllers
|
|||||||
_WalletReceiveStateService.Set(walletId, reserve);
|
_WalletReceiveStateService.Set(walletId, reserve);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return RedirectToAction(nameof(WalletReceive), new {walletId, statusMessage});
|
return RedirectToAction(nameof(WalletReceive), new {walletId});
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
|||||||
@@ -5,13 +5,20 @@
|
|||||||
ViewData["Title"] = "Manage wallet";
|
ViewData["Title"] = "Manage wallet";
|
||||||
ViewData.SetActivePageAndTitle(WalletsNavPages.Receive);
|
ViewData.SetActivePageAndTitle(WalletsNavPages.Receive);
|
||||||
}
|
}
|
||||||
|
@if (TempData.HasStatusMessage())
|
||||||
|
{
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 text-center">
|
||||||
|
<partial name="_StatusMessage" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
<div class="row no-gutters">
|
<div class="row no-gutters">
|
||||||
<div class="col-lg-6 mx-auto my-auto ">
|
<div class="col-lg-6 mx-auto my-auto ">
|
||||||
<form method="post" asp-action="WalletReceive" class="card text-center">
|
<form method="post" asp-action="WalletReceive" class="card text-center">
|
||||||
@if (string.IsNullOrEmpty(Model.Address))
|
@if (string.IsNullOrEmpty(Model.Address))
|
||||||
{
|
{
|
||||||
|
|
||||||
<h2 class="card-title">Receive @Model.CryptoCode</h2>
|
<h2 class="card-title">Receive @Model.CryptoCode</h2>
|
||||||
<button class="btn btn-lg btn-primary m-2" type="submit" name="command" value="generate-new-address">Generate @Model.CryptoCode address</button>
|
<button class="btn btn-lg btn-primary m-2" type="submit" name="command" value="generate-new-address">Generate @Model.CryptoCode address</button>
|
||||||
}
|
}
|
||||||
@@ -21,14 +28,14 @@
|
|||||||
<noscript>
|
<noscript>
|
||||||
<div class="card-body m-sm-0 p-sm-0">
|
<div class="card-body m-sm-0 p-sm-0">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text" class="form-control " readonly="readonly" asp-for="Address" id="address"/>
|
<input type="text" class="form-control " readonly="readonly" asp-for="Address" id="address" />
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<span class="input-group-text fa fa-copy"> </span>
|
<span class="input-group-text fa fa-copy"> </span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="submit" name="command" value="unreserve-current-address" class="btn btn-link">Unreserve this address</button>
|
<button type="submit" name="command" value="unreserve-current-address" class="btn btn-link">Unreserve this address</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</noscript>
|
</noscript>
|
||||||
<div class="only-for-js card-body m-sm-0 p-sm-0" id="app">
|
<div class="only-for-js card-body m-sm-0 p-sm-0" id="app">
|
||||||
@@ -38,17 +45,17 @@
|
|||||||
</qrcode>
|
</qrcode>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group copy" data-clipboard-target="#vue-address">
|
<div class="input-group copy" data-clipboard-target="#vue-address">
|
||||||
<input type="text" class=" form-control " readonly="readonly" :value="srvModel.address" id="vue-address"/>
|
<input type="text" class=" form-control " readonly="readonly" :value="srvModel.address" id="vue-address" />
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<span class="input-group-text fa fa-copy"> </span>
|
<span class="input-group-text fa fa-copy"> </span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="submit" name="command" value="unreserve-current-address" class="btn btn-link">Unreserve this address</button>
|
<button type="submit" name="command" value="unreserve-current-address" class="btn btn-link">Unreserve this address</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -56,7 +63,7 @@
|
|||||||
@section HeadScripts
|
@section HeadScripts
|
||||||
|
|
||||||
{
|
{
|
||||||
<script src="~/bundles/lightning-node-info-bundle.min.js" type="text/javascript"></script>
|
<script src="~/bundles/lightning-node-info-bundle.min.js" type="text/javascript"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var srvModel = @Safe.Json(Model);
|
var srvModel = @Safe.Json(Model);
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
@@ -92,30 +99,31 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
.qr-icon {
|
.qr-icon {
|
||||||
height: 64px;
|
height: 64px;
|
||||||
width: 64px;
|
width: 64px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.qr-container {
|
||||||
|
position: relative;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.qr-container svg {
|
||||||
|
width: 256px;
|
||||||
|
height: 256px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.qr-container {
|
.copy {
|
||||||
position: relative;
|
cursor: copy;
|
||||||
text-align: center;
|
}
|
||||||
}
|
</style>
|
||||||
|
|
||||||
.qr-container svg {
|
|
||||||
width: 256px;
|
|
||||||
height: 256px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.copy {
|
|
||||||
cursor: copy;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user