mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-12 10:30:47 +01:00
wipe option on balance page
This commit is contained in:
parent
27150bcd4e
commit
2c2b6b8890
5 changed files with 98 additions and 57 deletions
|
@ -7,6 +7,7 @@ using BTCPayServer.Client.Models;
|
||||||
using BTCPayServer.Controllers;
|
using BTCPayServer.Controllers;
|
||||||
using BTCPayServer.Data;
|
using BTCPayServer.Data;
|
||||||
using BTCPayServer.HostedServices;
|
using BTCPayServer.HostedServices;
|
||||||
|
using BTCPayServer.NTag424;
|
||||||
using BTCPayServer.Plugins.BoltcardBalance.ViewModels;
|
using BTCPayServer.Plugins.BoltcardBalance.ViewModels;
|
||||||
using BTCPayServer.Plugins.BoltcardFactory;
|
using BTCPayServer.Plugins.BoltcardFactory;
|
||||||
using BTCPayServer.Services;
|
using BTCPayServer.Services;
|
||||||
|
@ -57,10 +58,14 @@ namespace BTCPayServer.Plugins.BoltcardBalance.Controllers
|
||||||
var registration = await _dbContextFactory.GetBoltcardRegistration(issuerKey, boltData, true);
|
var registration = await _dbContextFactory.GetBoltcardRegistration(issuerKey, boltData, true);
|
||||||
if (registration is null)
|
if (registration is null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
return await GetBalanceView(registration.PullPaymentId, p);
|
|
||||||
|
var keys = issuerKey.CreatePullPaymentCardKey(registration.UId, registration.Version, registration.PullPaymentId).DeriveBoltcardKeys(issuerKey);
|
||||||
|
|
||||||
|
var result = await GetBalanceView(registration.PullPaymentId, p, keys);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public async Task<IActionResult> GetBalanceView(string ppId, string p)
|
public async Task<IActionResult> GetBalanceView(string ppId, string p, BoltcardKeys keys)
|
||||||
{
|
{
|
||||||
using var ctx = _dbContextFactory.CreateContext();
|
using var ctx = _dbContextFactory.CreateContext();
|
||||||
var pp = await ctx.PullPayments.FindAsync(ppId);
|
var pp = await ctx.PullPayments.FindAsync(ppId);
|
||||||
|
@ -105,6 +110,7 @@ namespace BTCPayServer.Plugins.BoltcardBalance.Controllers
|
||||||
Status = PayoutState.Completed
|
Status = PayoutState.Completed
|
||||||
});
|
});
|
||||||
|
|
||||||
|
vm.Keys = keys;
|
||||||
return View($"{BoltcardBalancePlugin.ViewsDirectory}/BalanceView.cshtml", vm);
|
return View($"{BoltcardBalancePlugin.ViewsDirectory}/BalanceView.cshtml", vm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using BTCPayServer.Client.Models;
|
using BTCPayServer.Client.Models;
|
||||||
|
using BTCPayServer.NTag424;
|
||||||
|
|
||||||
namespace BTCPayServer.Plugins.BoltcardBalance.ViewModels
|
namespace BTCPayServer.Plugins.BoltcardBalance.ViewModels
|
||||||
{
|
{
|
||||||
|
@ -19,5 +20,6 @@ namespace BTCPayServer.Plugins.BoltcardBalance.ViewModels
|
||||||
public string LNUrlBech32 { get; set; }
|
public string LNUrlBech32 { get; set; }
|
||||||
public string LNUrlPay { get; set; }
|
public string LNUrlPay { get; set; }
|
||||||
|
|
||||||
|
public BoltcardKeys? Keys { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
@using BTCPayServer.Plugins.BoltcardBalance.ViewModels
|
@using BTCPayServer.Plugins.BoltcardBalance.ViewModels
|
||||||
@using BTCPayServer.Services
|
@using BTCPayServer.Services
|
||||||
|
@using Newtonsoft.Json.Linq
|
||||||
|
@using BTCPayServer.Components.QRCode
|
||||||
|
@using NBitcoin.DataEncoders
|
||||||
@inject DisplayFormatter DisplayFormatter
|
@inject DisplayFormatter DisplayFormatter
|
||||||
|
|
||||||
@model BalanceViewModel
|
@model BalanceViewModel
|
||||||
|
@ -71,3 +74,33 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@if (Model.Keys is not null && Model.AmountDue <= 0)
|
||||||
|
{
|
||||||
|
var wipeContent = JObject.FromObject(new
|
||||||
|
{
|
||||||
|
version = 1,
|
||||||
|
action = "wipe",
|
||||||
|
K0 = Encoders.Hex.EncodeData(Model.Keys.AppMasterKey.ToBytes()).ToUpperInvariant(),
|
||||||
|
K1 = Encoders.Hex.EncodeData(Model.Keys.EncryptionKey.ToBytes()).ToUpperInvariant(),
|
||||||
|
K2 = Encoders.Hex.EncodeData(Model.Keys.AuthenticationKey.ToBytes()).ToUpperInvariant(),
|
||||||
|
K3 = Encoders.Hex.EncodeData(Model.Keys.K3.ToBytes()).ToUpperInvariant(),
|
||||||
|
K4 = Encoders.Hex.EncodeData(Model.Keys.K4.ToBytes()).ToUpperInvariant(),
|
||||||
|
}).ToString();
|
||||||
|
<h5 class="mb-3 mt-5">Wipe Bolt Card</h5>
|
||||||
|
<div class="payment-box mx-0">
|
||||||
|
<div class="qr-container" data-clipboard="@wipeContent">
|
||||||
|
@await Component.InvokeAsync("QRCode", new {data = wipeContent})
|
||||||
|
</div>
|
||||||
|
<div class="input-group mt-3">
|
||||||
|
<div class="form-floating">
|
||||||
|
<input id="Bolt-Wipe-Json" class="form-control-plaintext" readonly="readonly" value="@wipeContent">
|
||||||
|
<label for="Bolt-Wipe-Json">Bolt Card Wipe JSON</label>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="btn btn-link" data-clipboard-target="#Bolt-Wipe-Json">
|
||||||
|
@await Component.InvokeAsync("Icon", new {symbol = "copy"})
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<script src="~/vendor/summernote/summernote-bs5.js" asp-append-version="true"></script>
|
<script src="~/vendor/summernote/summernote-bs5.js" asp-append-version="true"></script>
|
||||||
}
|
}
|
||||||
|
|
||||||
<form method="post" asp-route-appId="@Context.GetRouteValue("appId")" asp-action="UpdateBoltcardFactory">
|
<form method="post" asp-route-appId="@Context.GetRouteValue("appId")" asp-controller="UIBoltcardFactory" asp-action="UpdateBoltcardFactory">
|
||||||
<div class="sticky-header d-flex align-items-center justify-content-between">
|
<div class="sticky-header d-flex align-items-center justify-content-between">
|
||||||
<h2 class="mb-0">@ViewData["Title"]</h2>
|
<h2 class="mb-0">@ViewData["Title"]</h2>
|
||||||
<div class="d-flex gap-3 mt-3 mt-sm-0">
|
<div class="d-flex gap-3 mt-3 mt-sm-0">
|
||||||
|
|
|
@ -201,7 +201,7 @@ namespace BTCPayServer.Plugins.BoltcardTopUp.Controllers
|
||||||
await ctx.Payouts.AddAsync(payout);
|
await ctx.Payouts.AddAsync(payout);
|
||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
_boltcardBalanceController.ViewData["NoCancelWizard"] = true;
|
_boltcardBalanceController.ViewData["NoCancelWizard"] = true;
|
||||||
return await _boltcardBalanceController.GetBalanceView(registration.PullPaymentId, p);
|
return await _boltcardBalanceController.GetBalanceView(registration.PullPaymentId, p, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue