mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-12 19:02:01 +01:00
add qr wipe option
This commit is contained in:
parent
4adfcb2de4
commit
b46bf8c910
4 changed files with 31 additions and 3 deletions
|
@ -9,11 +9,14 @@ using BTCPayServer.Controllers.Greenfield;
|
||||||
using BTCPayServer.Data;
|
using BTCPayServer.Data;
|
||||||
using BTCPayServer.HostedServices;
|
using BTCPayServer.HostedServices;
|
||||||
using BTCPayServer.Models;
|
using BTCPayServer.Models;
|
||||||
|
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;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using NBitcoin.DataEncoders;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace BTCPayServer.Plugins.BoltcardBalance.Controllers
|
namespace BTCPayServer.Plugins.BoltcardBalance.Controllers
|
||||||
{
|
{
|
||||||
|
@ -59,12 +62,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);
|
return await GetBalanceView(registration, p, issuerKey);
|
||||||
}
|
}
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public async Task<IActionResult> GetBalanceView(string ppId, string p)
|
public async Task<IActionResult> GetBalanceView(BoltcardDataExtensions.BoltcardRegistration registration, string p, IssuerKey issuerKey)
|
||||||
{
|
{
|
||||||
using var ctx = _dbContextFactory.CreateContext();
|
var ppId = registration.PullPaymentId;
|
||||||
|
var boltCardKeys = issuerKey.CreatePullPaymentCardKey(registration.UId, registration.Version, ppId).DeriveBoltcardKeys(issuerKey);
|
||||||
|
await using var ctx = _dbContextFactory.CreateContext();
|
||||||
var pp = await ctx.PullPayments.FindAsync(ppId);
|
var pp = await ctx.PullPayments.FindAsync(ppId);
|
||||||
if (pp is null)
|
if (pp is null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
@ -91,6 +96,17 @@ namespace BTCPayServer.Plugins.BoltcardBalance.Controllers
|
||||||
LNUrlBech32 = bech32LNUrl.AbsoluteUri,
|
LNUrlBech32 = bech32LNUrl.AbsoluteUri,
|
||||||
LNUrlPay = Url.Action(nameof(UIBoltcardController.GetPayRequest), "UIBoltcard", new { p }, "lnurlp"),
|
LNUrlPay = Url.Action(nameof(UIBoltcardController.GetPayRequest), "UIBoltcard", new { p }, "lnurlp"),
|
||||||
BoltcardKeysResetLink = $"boltcard://reset?url={GetBoltcardDeeplinkUrl(pp.Id, OnExistingBehavior.KeepVersion)}",
|
BoltcardKeysResetLink = $"boltcard://reset?url={GetBoltcardDeeplinkUrl(pp.Id, OnExistingBehavior.KeepVersion)}",
|
||||||
|
WipeData = JObject.FromObject(new
|
||||||
|
{
|
||||||
|
version = registration.Version,
|
||||||
|
action = "wipe",
|
||||||
|
K0 = Encoders.Hex.EncodeData(boltCardKeys.AppMasterKey.ToBytes()).ToUpperInvariant(),
|
||||||
|
K1 = Encoders.Hex.EncodeData(boltCardKeys.EncryptionKey.ToBytes()).ToUpperInvariant(),
|
||||||
|
K2 = Encoders.Hex.EncodeData(boltCardKeys.AuthenticationKey.ToBytes()).ToUpperInvariant(),
|
||||||
|
K3 = Encoders.Hex.EncodeData(boltCardKeys.K3.ToBytes()).ToUpperInvariant(),
|
||||||
|
K4 = Encoders.Hex.EncodeData(boltCardKeys.K4.ToBytes()).ToUpperInvariant(),
|
||||||
|
|
||||||
|
}).ToString(Newtonsoft.Json.Formatting.None),
|
||||||
PullPaymentLink = Url.Action(nameof(UIPullPaymentController.ViewPullPayment), "UIPullPayment", new { pullPaymentId = pp.Id }, Request.Scheme, Request.Host.ToString())
|
PullPaymentLink = Url.Action(nameof(UIPullPaymentController.ViewPullPayment), "UIPullPayment", new { pullPaymentId = pp.Id }, Request.Scheme, Request.Host.ToString())
|
||||||
};
|
};
|
||||||
foreach (var payout in payouts)
|
foreach (var payout in payouts)
|
||||||
|
|
|
@ -21,5 +21,6 @@ namespace BTCPayServer.Plugins.BoltcardBalance.ViewModels
|
||||||
public string PullPaymentLink { get; set; }
|
public string PullPaymentLink { get; set; }
|
||||||
public string LNUrlPay { get; set; }
|
public string LNUrlPay { get; set; }
|
||||||
|
|
||||||
|
public string WipeData{ get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,11 @@
|
||||||
<div class="boltcard-reset boltcard-details mt-3 mt-sm-0 w-100 text-center">
|
<div class="boltcard-reset boltcard-details mt-3 mt-sm-0 w-100 text-center">
|
||||||
<a class="btn btn-outline-danger" href="@Model.BoltcardKeysResetLink">Reset Boltcard</a>
|
<a class="btn btn-outline-danger" href="@Model.BoltcardKeysResetLink">Reset Boltcard</a>
|
||||||
<p class="text-secondary mt-2">Requires installing the <a href="https://play.google.com/store/apps/details?id=com.lightningnfcapp&hl=en&gl=US">Bolt Card Creator app</a></p>
|
<p class="text-secondary mt-2">Requires installing the <a href="https://play.google.com/store/apps/details?id=com.lightningnfcapp&hl=en&gl=US">Bolt Card Creator app</a></p>
|
||||||
|
<button type="button" class="btn btn-link" id="show-wipe-qr">Show QR instead</button>
|
||||||
|
<div id="wipe-qr" class="d-none">
|
||||||
|
|
||||||
|
<vc:qr-code data="@Model.WipeData" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -216,6 +216,12 @@
|
||||||
document.querySelector(".boltcard-reset").classList.add("d-none");
|
document.querySelector(".boltcard-reset").classList.add("d-none");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
delegate('click', "#show-wipe-qr", ()=>{
|
||||||
|
document.getElementById("wipe-qr").classList.remove("d-none");
|
||||||
|
document.getElementById("show-wipe-qr").classList.add("d-none");
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
handleError(e);
|
handleError(e);
|
||||||
|
|
Loading…
Add table
Reference in a new issue