diff --git a/BTCPayServer/Plugins/BoltcardBalance/Controllers/UIBoltcardBalanceController.cs b/BTCPayServer/Plugins/BoltcardBalance/Controllers/UIBoltcardBalanceController.cs index 254fc66fd..b9c63bba4 100644 --- a/BTCPayServer/Plugins/BoltcardBalance/Controllers/UIBoltcardBalanceController.cs +++ b/BTCPayServer/Plugins/BoltcardBalance/Controllers/UIBoltcardBalanceController.cs @@ -7,6 +7,7 @@ using BTCPayServer.Client.Models; using BTCPayServer.Controllers; using BTCPayServer.Data; using BTCPayServer.HostedServices; +using BTCPayServer.NTag424; using BTCPayServer.Plugins.BoltcardBalance.ViewModels; using BTCPayServer.Plugins.BoltcardFactory; using BTCPayServer.Services; @@ -57,10 +58,14 @@ namespace BTCPayServer.Plugins.BoltcardBalance.Controllers var registration = await _dbContextFactory.GetBoltcardRegistration(issuerKey, boltData, true); if (registration is null) 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] - public async Task GetBalanceView(string ppId, string p) + public async Task GetBalanceView(string ppId, string p, BoltcardKeys keys) { using var ctx = _dbContextFactory.CreateContext(); var pp = await ctx.PullPayments.FindAsync(ppId); @@ -105,6 +110,7 @@ namespace BTCPayServer.Plugins.BoltcardBalance.Controllers Status = PayoutState.Completed }); + vm.Keys = keys; return View($"{BoltcardBalancePlugin.ViewsDirectory}/BalanceView.cshtml", vm); } } diff --git a/BTCPayServer/Plugins/BoltcardBalance/ViewModels/BalanceViewModel.cs b/BTCPayServer/Plugins/BoltcardBalance/ViewModels/BalanceViewModel.cs index 72be4274b..072769aaf 100644 --- a/BTCPayServer/Plugins/BoltcardBalance/ViewModels/BalanceViewModel.cs +++ b/BTCPayServer/Plugins/BoltcardBalance/ViewModels/BalanceViewModel.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using BTCPayServer.Client.Models; +using BTCPayServer.NTag424; namespace BTCPayServer.Plugins.BoltcardBalance.ViewModels { @@ -19,5 +20,6 @@ namespace BTCPayServer.Plugins.BoltcardBalance.ViewModels public string LNUrlBech32 { get; set; } public string LNUrlPay { get; set; } + public BoltcardKeys? Keys { get; set; } } } diff --git a/BTCPayServer/Plugins/BoltcardBalance/Views/BalanceView.cshtml b/BTCPayServer/Plugins/BoltcardBalance/Views/BalanceView.cshtml index 72934706d..42090f792 100644 --- a/BTCPayServer/Plugins/BoltcardBalance/Views/BalanceView.cshtml +++ b/BTCPayServer/Plugins/BoltcardBalance/Views/BalanceView.cshtml @@ -1,73 +1,106 @@ @using BTCPayServer.Plugins.BoltcardBalance.ViewModels @using BTCPayServer.Services +@using Newtonsoft.Json.Linq +@using BTCPayServer.Components.QRCode +@using NBitcoin.DataEncoders @inject DisplayFormatter DisplayFormatter @model BalanceViewModel @{ - Layout = null; + Layout = null; }
-
- -
-
-
-
-
@DisplayFormatter.Currency(Model.AmountDue, Model.Currency)
-
-
-@*
+
+ +
+
+
+
+
@DisplayFormatter.Currency(Model.AmountDue, Model.Currency)
+
+
+ @*
*@ -
- -
- -
-
-
+
+ +
+ +
+
+
@if (Model.Transactions.Any()) { -
-
- - - - - - - - - @foreach (var tx in Model.Transactions) - { - - - - - } - -
DateAmount
@tx.Date.ToBrowserDate(ViewsRazor.DateDisplayFormat.Relative) - @DisplayFormatter.Currency(tx.Balance, Model.Currency, DisplayFormatter.CurrencyFormat.Code) -
-
-
+
+
+ + + + + + + + + @foreach (var tx in Model.Transactions) + { + + + + + } + +
DateAmount
@tx.Date.ToBrowserDate(ViewsRazor.DateDisplayFormat.Relative) + @DisplayFormatter.Currency(tx.Balance, Model.Currency, DisplayFormatter.CurrencyFormat.Code) +
+
+
+} + + +@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(); +
Wipe Bolt Card
+
+
+ @await Component.InvokeAsync("QRCode", new {data = wipeContent}) +
+
+
+ + +
+ +
+
} diff --git a/BTCPayServer/Plugins/BoltcardFactory/Views/UpdateBoltcardFactory.cshtml b/BTCPayServer/Plugins/BoltcardFactory/Views/UpdateBoltcardFactory.cshtml index a44491c50..512c5f005 100644 --- a/BTCPayServer/Plugins/BoltcardFactory/Views/UpdateBoltcardFactory.cshtml +++ b/BTCPayServer/Plugins/BoltcardFactory/Views/UpdateBoltcardFactory.cshtml @@ -16,7 +16,7 @@ } -
+